feat(履约绑定): 支持工作台修改客户资料、扫码不匹配时间线及确认后斗鱼复核

This commit is contained in:
yml
2026-11-26 16:23:30 +08:00
parent ed91fb7549
commit 917c11f203
14 changed files with 1293 additions and 19 deletions
+71 -2
View File
@@ -1078,6 +1078,24 @@ class BindMixin:
def finish_timeout() -> None:
self._merge_latest_expected_role(db, task, result)
latest_expected = str(result.get("expected_role_name") or "").strip()
last_mismatch = result.get("last_mismatched_role")
mismatched_role = (
str(last_mismatch.get("role_name") or "").strip()
if isinstance(last_mismatch, dict)
else ""
)
if mismatched_role and latest_expected:
timeout_message = (
f"绑定二维码已过期:期间扫到「{mismatched_role}」,"
f"与填写角色「{latest_expected}」不一致"
)
elif mismatched_role:
timeout_message = (
f"绑定二维码已过期:期间扫到「{mismatched_role}」,未匹配到目标角色"
)
else:
timeout_message = "绑定二维码已过期,未识别到新扫码角色"
result.update(
{
"bind_polling": False,
@@ -1094,7 +1112,7 @@ class BindMixin:
db,
task,
"failed",
"绑定二维码已过期,未识别到新扫码角色",
timeout_message[:512],
result,
)
@@ -1370,6 +1388,57 @@ class BindMixin:
result["current_role_name"] = snapshot["role_name"]
result["current_area_name"] = snapshot["area_name"]
result["current_plat_name"] = snapshot["plat_name"]
new_mismatch_observed = False
if expected_role_name:
candidate_by_alias = {
str(item.get("act_alias") or item.get("alias") or "").strip(): item
for item in candidates
if isinstance(item, dict)
}
recorded_keys = [
str(v)
for v in (result.get("recorded_mismatched_roles") or [])
if str(v or "").strip()
]
mismatched_roles = [
dict(item)
for item in (result.get("mismatched_roles") or [])
if isinstance(item, dict)
]
for decision in candidate_decisions:
if str(decision.get("reason") or "") != "expected_role_mismatch":
continue
if bool(decision.get("is_bound_act")):
continue
scanned_name = str(decision.get("role_name") or "").strip()
if not scanned_name:
continue
alias = str(decision.get("alias") or "").strip()
cand = candidate_by_alias.get(alias) or {}
cand_snap = self._bind_snapshot(cand) if cand else {}
area_name = str(cand_snap.get("area_name") or cand.get("area_name") or "").strip()
plat_name = str(cand_snap.get("plat_name") or cand.get("plat_name") or "").strip()
dedupe_key = f"{alias}|{scanned_name.casefold()}|{area_name}|{plat_name}"
if dedupe_key in recorded_keys:
continue
recorded_keys.append(dedupe_key)
entry = {
"act_alias": alias,
"role_name": scanned_name,
"area_name": area_name,
"plat_name": plat_name,
"expected_role_name": expected_role_name,
"observed_at": now.isoformat(),
}
mismatched_roles.append(entry)
result["last_mismatched_role"] = entry
new_mismatch_observed = True
if recorded_keys:
result["recorded_mismatched_roles"] = recorded_keys[-20:]
if mismatched_roles:
result["mismatched_roles"] = mismatched_roles[-10:]
result.update(
{
"bind_info": bind_info,
@@ -1413,7 +1482,7 @@ class BindMixin:
"running",
f"等待扫码绑定 ({summary})",
result,
sync_platform=False,
sync_platform=bool(task.platform_task_id and new_mismatch_observed),
)
def _execute_get_bind_qr(