修复(履约绑定): 收敛活动别名中的瞬时历史角色

This commit is contained in:
yml
2026-11-26 01:03:22 +08:00
parent 4198f7ab39
commit 204cbd5d82
10 changed files with 574 additions and 47 deletions
@@ -11,6 +11,7 @@ from fastapi import HTTPException
from sqlalchemy.orm import Session
from ...models import (
DouyuTask,
PlatformCommodityMapping,
PlatformFulfillmentTask,
)
@@ -47,6 +48,8 @@ _AUTO_SYNC_LAST_ATTEMPT = float("-inf")
def _apply_customer_profile(
task: PlatformFulfillmentTask,
snapshot: dict[str, Any],
*,
db: Session | None = None,
) -> None:
"""order_site contractVersion=3 快照里的客户资料和主页截图。"""
keys = {
@@ -108,6 +111,15 @@ def _apply_customer_profile(
default=None,
)
)
if db is not None and task.bind_task_id and task.customer_role_name:
bind_task = db.get(DouyuTask, int(task.bind_task_id))
if bind_task is not None and bind_task.task_type in {
"get_bind_qr",
"confirm_bind",
}:
result = dict(bind_task.result or {})
result["expected_role_name"] = task.customer_role_name
bind_task.result = result
def _upsert_order_snapshot(
@@ -227,7 +239,7 @@ def _upsert_order_snapshot(
task.required_points,
task.issue_code,
)
_apply_customer_profile(task, snapshot)
_apply_customer_profile(task, snapshot, db=db)
terminal = (
terminal_order
or _snapshot_value(
@@ -583,7 +595,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)
_apply_customer_profile(task, row, db=db)
task.updated_at = _now()
if task.account_id is None and task.execution_status in {
"pending_mapping",