fix(fulfillment): 修复历史账号绑定覆盖当前待确认角色

This commit is contained in:
yml
2026-11-23 19:42:38 +08:00
parent 17ec07b63a
commit 0a32f24fa8
7 changed files with 347 additions and 9 deletions
@@ -57,6 +57,13 @@ BINDING_SYNC_TASK_TYPES = frozenset(
"confirm_xpd_bind",
}
)
ACCOUNT_CONFIRMATION_TASK_TYPES = frozenset(
{
"confirm_bind",
"confirm_esports_bind",
"confirm_xpd_bind",
}
)
def start_binding_sync(
@@ -294,6 +301,15 @@ def sync_task_from_binding_runner(db: Session, *, douyu_task_id: int) -> int:
douyu_task = db.get(DouyuTask, int(douyu_task_id))
if douyu_task is None or douyu_task.task_type not in BINDING_SYNC_TASK_TYPES:
return len(task_ids)
result = douyu_task.result or {}
if (
douyu_task.task_type not in ACCOUNT_CONFIRMATION_TASK_TYPES
or result.get("bind_confirmed") is not True
):
# 查询/出码任务只能证明“账号历史绑定是什么”,不能证明本次订单已经确认。
# 只有明确执行成功并回查到 bind_confirmed 的确认任务,才允许把账号权威
# 绑定投影到履约任务。
return len(task_ids)
return len(task_ids) + sync_active_task_from_account_binding(
db,
account_id=int(douyu_task.account_id),
@@ -317,6 +333,17 @@ def sync_active_task_from_account_binding(
"""
if scope != "elite":
return 0
source_task = (
db.get(DouyuTask, int(source_task_id))
if source_task_id is not None
else None
)
if (
source_task is None
or source_task.task_type not in ACCOUNT_CONFIRMATION_TASK_TYPES
or (source_task.result or {}).get("bind_confirmed") is not True
):
return 0
account = db.get(Account, int(account_id))
if account is None or account.role_bind_status != "bound":
return 0
@@ -341,6 +368,7 @@ def sync_active_task_from_account_binding(
)
if task is None:
return 0
task.bind_task_id = int(source_task.id)
task.binding_status = "bound"
task.execution_status = "bound"
task.issue_code = ""