修复(履约绑定): 修复候选快照丢失与全链路绑定校验一致性
This commit is contained in:
@@ -20,7 +20,10 @@ from typing import Any
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ...models import Account, DouyuTask, PlatformFulfillmentTask
|
||||
from ..account_binding import pending_binding_role_from_result
|
||||
from ..account_binding import (
|
||||
hydrate_bind_candidates_from_result,
|
||||
pending_binding_role_from_result,
|
||||
)
|
||||
from .role_lock import AccountLock, RoleLock, find_account_lock, find_role_lock
|
||||
|
||||
|
||||
@@ -133,26 +136,39 @@ def build_binding_evidence(
|
||||
]
|
||||
candidates = [
|
||||
_candidate(raw)
|
||||
for raw in (result.get("bind_candidates") or [])
|
||||
if isinstance(raw, dict)
|
||||
for raw in hydrate_bind_candidates_from_result(result)
|
||||
]
|
||||
candidates = [item for item in candidates if item["alias"]]
|
||||
decision = result.get("bind_decision")
|
||||
decision = decision if isinstance(decision, dict) else {}
|
||||
if not action_aliases:
|
||||
action_aliases = [
|
||||
item["alias"] for item in candidates if item["actionableAlias"]
|
||||
]
|
||||
selected_info = result.get("bind_info") or result.get("before_bind_info")
|
||||
selected_info_candidate = _candidate_from_info(selected_info, action_aliases)
|
||||
if not candidates and selected_info_candidate is not None:
|
||||
candidates = [selected_info_candidate]
|
||||
|
||||
selected_alias = _text(
|
||||
result.get("act_alias")
|
||||
or (selected_info or {}).get("act_alias")
|
||||
or (candidates[0]["alias"] if candidates else "")
|
||||
)
|
||||
decision = result.get("bind_decision")
|
||||
decision = decision if isinstance(decision, dict) else {}
|
||||
if (
|
||||
not action_aliases
|
||||
and selected_alias
|
||||
and bool(decision.get("actionable_alias"))
|
||||
):
|
||||
action_aliases = [selected_alias]
|
||||
selected_info_candidate = _candidate_from_info(selected_info, action_aliases)
|
||||
if not candidates and selected_info_candidate is not None:
|
||||
candidates = [selected_info_candidate]
|
||||
if action_aliases:
|
||||
for item in candidates:
|
||||
if item["alias"] in action_aliases:
|
||||
item["actionableAlias"] = True
|
||||
if (
|
||||
selected_info_candidate is not None
|
||||
and selected_info_candidate["alias"] in action_aliases
|
||||
):
|
||||
selected_info_candidate["actionableAlias"] = True
|
||||
selected_actionable = bool(
|
||||
decision.get("actionable_alias")
|
||||
or (selected_alias and selected_alias in action_aliases)
|
||||
@@ -173,6 +189,7 @@ def build_binding_evidence(
|
||||
account,
|
||||
action_aliases[0] if action_aliases else "",
|
||||
)
|
||||
pending_role = pending_binding_role_from_result(result)
|
||||
action_pending = next(
|
||||
(
|
||||
item
|
||||
@@ -180,6 +197,14 @@ def build_binding_evidence(
|
||||
if item["alias"] in action_aliases
|
||||
and item["roleName"]
|
||||
and not item["bindAct"]
|
||||
and (
|
||||
item["needBindAct"]
|
||||
or item["confirmable"]
|
||||
or (
|
||||
pending_role
|
||||
and item["roleName"].casefold() == pending_role.casefold()
|
||||
)
|
||||
)
|
||||
),
|
||||
None,
|
||||
)
|
||||
@@ -189,6 +214,15 @@ def build_binding_evidence(
|
||||
and selected_info_candidate["alias"] in action_aliases
|
||||
and selected_info_candidate["roleName"]
|
||||
and not selected_info_candidate["bindAct"]
|
||||
and (
|
||||
selected_info_candidate["needBindAct"]
|
||||
or selected_info_candidate["confirmable"]
|
||||
or (
|
||||
pending_role
|
||||
and selected_info_candidate["roleName"].casefold()
|
||||
== pending_role.casefold()
|
||||
)
|
||||
)
|
||||
):
|
||||
action_pending = selected_info_candidate
|
||||
legacy_latest = next(
|
||||
@@ -207,7 +241,6 @@ def build_binding_evidence(
|
||||
):
|
||||
legacy_latest = selected_info_candidate
|
||||
|
||||
pending_role = pending_binding_role_from_result(result)
|
||||
legacy_role = _text((legacy_latest or {}).get("roleName"))
|
||||
account_current_role = _text(account.game_name) if account is not None else ""
|
||||
# scannedRole 只认“本次新扫码”:
|
||||
@@ -231,10 +264,10 @@ def build_binding_evidence(
|
||||
# 取消 QYOOB-only 门禁后,cjm 的新角色同样可以成为客户确认目标;
|
||||
# 这里展示真实本次扫码角色,避免详情说“不可确认”但客户页可以确认。
|
||||
target_role = scanned_role
|
||||
before_info = result.get("before_bind_info")
|
||||
baseline_role = _text(
|
||||
result.get("baseline_role_name")
|
||||
or (selected_info or {}).get("role_name")
|
||||
or (result.get("before_bind_info") or {}).get("role_name")
|
||||
or (before_info if isinstance(before_info, dict) else {}).get("role_name")
|
||||
)
|
||||
same_pair = bool(
|
||||
scanned_role
|
||||
|
||||
Reference in New Issue
Block a user