feat: 重构订单和物流信息展示格式
主要改动: - 订单列表:使用 order_list 格式,展示 5 个订单(全部状态) - 订单详情:使用 order_detail 格式,优化价格和时间显示 - 物流信息:使用 logistics 格式,根据 track id 动态生成步骤 - 商品图片:从 orderProduct.imageUrl 字段获取 - 时间格式:统一为 YYYY-MM-DD HH:MM:SS - 多语言支持:amountLabel、orderTime 支持中英文 - 配置管理:新增 FRONTEND_URL 环境变量 - API 集成:改进 Mall API tracks 数据解析 - 认证优化:account_id 从 webhook 动态获取 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,39 @@ logger = get_logger(__name__)
|
||||
class TokenManager:
|
||||
"""管理用户 JWT token"""
|
||||
|
||||
@staticmethod
|
||||
def extract_token_from_sender(sender: Optional[dict]) -> Optional[str]:
|
||||
"""从 sender 对象中提取 JWT token
|
||||
|
||||
支持从以下位置提取 token(按优先级排序):
|
||||
1. sender.jwt_token(根级别)
|
||||
2. sender.mall_token(根级别)
|
||||
3. sender.custom_attributes.jwt_token
|
||||
4. sender.custom_attributes.mall_token
|
||||
5. sender.custom_attributes.access_token
|
||||
6. sender.custom_attributes.auth_token
|
||||
7. sender.custom_attributes.token
|
||||
|
||||
Args:
|
||||
sender: Chatwoot sender 对象(来自 conversation.meta.sender)
|
||||
|
||||
Returns:
|
||||
JWT token 字符串,如果未找到则返回 None
|
||||
"""
|
||||
if not sender:
|
||||
logger.debug("No sender provided")
|
||||
return None
|
||||
|
||||
# 1. 优先从根级别获取 token
|
||||
root_token = sender.get("jwt_token") or sender.get("mall_token")
|
||||
if root_token:
|
||||
logger.debug("JWT token found at sender root level")
|
||||
logger.debug(f"Token prefix: {root_token[:20]}...")
|
||||
return root_token
|
||||
|
||||
# 2. 从 custom_attributes 中获取 token
|
||||
return TokenManager.extract_token_from_contact(sender)
|
||||
|
||||
@staticmethod
|
||||
def extract_token_from_contact(contact: Optional[dict]) -> Optional[str]:
|
||||
"""从 Chatwoot contact 中提取 JWT token
|
||||
|
||||
Reference in New Issue
Block a user