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
@@ -42,6 +42,72 @@ _AUTO_SYNC_LOCK = threading.Lock()
_AUTO_SYNC_LAST_ATTEMPT = float("-inf")
def _apply_customer_profile(
task: PlatformFulfillmentTask,
snapshot: dict[str, Any],
) -> None:
"""order_site contractVersion=3 快照里的客户资料和主页截图。"""
keys = {
"customerRoleName",
"customer_role_name",
"homeImages",
"home_images",
}
if not keys.intersection(snapshot):
return
task.customer_role_name = str(
_snapshot_value(snapshot, "customerRoleName", "customer_role_name")
or ""
)[:128]
task.customer_platform = str(
_snapshot_value(snapshot, "customerPlatform", "customer_platform")
or ""
)[:16]
task.customer_system = str(
_snapshot_value(snapshot, "customerSystem", "customer_system")
or ""
)[:16]
raw_images = _snapshot_value(
snapshot,
"homeImages",
"home_images",
default=[],
)
images: list[dict[str, str]] = []
if isinstance(raw_images, list):
for item in raw_images[:5]:
if isinstance(item, str):
url = item.strip()
if url:
images.append({"url": url[:2048], "thumbnailUrl": url[:2048], "objectKey": ""})
continue
if not isinstance(item, dict):
continue
url = str(item.get("url") or "").strip()
if not url:
continue
images.append(
{
"url": url[:2048],
"thumbnailUrl": str(
item.get("thumbnailUrl") or item.get("thumbnail_url") or url
)[:2048],
"objectKey": str(
item.get("objectKey") or item.get("object_key") or ""
)[:512],
}
)
task.customer_home_images = images or None
task.customer_profile_updated_at = _parse_snapshot_datetime(
_snapshot_value(
snapshot,
"customerProfileUpdatedAt",
"customer_profile_updated_at",
default=None,
)
)
def _upsert_order_snapshot(
db: Session,
snapshot: dict[str, Any],
@@ -150,6 +216,7 @@ def _upsert_order_snapshot(
task.required_points,
task.issue_code,
)
_apply_customer_profile(task, snapshot)
if task.execution_status in {"completed", "cancelled"}:
task.source_snapshot_json = _jsonable(snapshot)
return task, created, False
@@ -481,6 +548,7 @@ def _sync_pending_tasks(
task.target_platform = TARGET_PLATFORM
task.scope = SCOPE_ELITE
task.source_snapshot_json = _jsonable(row)
_apply_customer_profile(task, row)
task.updated_at = _now()
if task.account_id is None and task.execution_status in {
"pending_mapping",