feat(fulfillment): 接收并展示 order_site 客户主页截图

- 履约任务新增客户角色/平台/系统/主页截图/更新时间字段
- 迁移 0131
- order_site contractVersion=3 快照自动落客户资料
- 增加客户资料 integration 写入接口
- 工作台详情展示客户资料、平台角色比对和截图
- 补充客户资料保存/快照解析测试与对接文档
This commit is contained in:
yml
2026-11-24 21:25:14 +08:00
parent 06a226f51f
commit 6ec8248068
14 changed files with 531 additions and 2 deletions
@@ -506,6 +506,7 @@ def _task_out(
if include_qr and bind_task is not None
else None
),
"customerProfile": _customer_profile_out(task, account, binding),
"exchangeTaskId": exchange_task_id,
"exchangeResultImage": (
{
@@ -690,6 +691,58 @@ def _customer_binding_queue_state(
return "preparing", 1000
def _customer_profile_out(
task: PlatformFulfillmentTask,
account: Account | None,
binding,
) -> dict[str, Any] | None:
"""客户资料 + 与平台当前/确认角色的绑定比对。"""
role = str(task.customer_role_name or "").strip()
images = list(task.customer_home_images or [])
if not role and not images:
return None
platform_role = str(binding.effective_role_name or "").strip()
if not platform_role and account is not None:
platform_role = str(account.game_name or "").strip()
role_matched: bool | None = None
if role and platform_role:
role_matched = role == platform_role
channel_matched: bool | None = None
customer_channel = " ".join(
[
"微信" if task.customer_platform == "wechat" else ("QQ" if task.customer_platform == "qq" else ""),
"苹果" if task.customer_system == "ios" else ("安卓" if task.customer_system == "android" else ""),
]
).strip()
account_channel = str(
binding.effective_channel
or (account.game_channel if account is not None else "")
or ""
)
if customer_channel and account_channel:
channel_matched = all(part in account_channel for part in customer_channel.split())
if role and not platform_role:
message = "客户已填角色,平台还未识别绑定角色"
elif role_matched is True and channel_matched is not False:
message = "客户资料与平台角色一致"
elif role_matched is False or channel_matched is False:
message = "客户资料与平台角色不一致,请核对绑定"
else:
message = "客户资料已收到,等待平台识别角色"
return {
"roleName": role,
"platform": str(task.customer_platform or ""),
"system": str(task.customer_system or ""),
"homeImages": images,
"updatedAt": _jsonable(task.customer_profile_updated_at),
"platformRoleName": platform_role,
"platformChannel": account_channel,
"roleMatched": role_matched,
"channelMatched": channel_matched,
"message": message,
}
def customer_binding_out(db: Session, task_id: int) -> dict[str, Any]:
"""面向前端客户页的安全绑定快照,不包含账号、CK、积分和租约。"""
task = _load_task(db, task_id)
@@ -754,6 +807,7 @@ def customer_binding_out(db: Session, task_id: int) -> dict[str, Any]:
"queueLane": bind_task.queue_lane if bind_task else "",
"accepted": False,
"stateVersion": int(task.state_version or 0),
"customerProfile": _customer_profile_out(task, account, binding),
"completedAt": _jsonable(task.completed_at),
"updatedAt": _jsonable(task.updated_at),
}