feat(fulfillment): 自动选号并补充精英宝典操作
- 增加直播履约自动选号 worker、重试与任务扫描 - 履约详情复用斗鱼任务能力开通宝典、充值和兑换皮肤 - 补充自动选号与精英宝典操作测试
This commit is contained in:
@@ -560,12 +560,30 @@ def _customer_task_message(task: PlatformFulfillmentTask) -> str:
|
||||
"points_short": "账号正在补充积分,请稍后重试",
|
||||
"commodity_limit_reached": "当前商品暂时无法兑换,请联系客服",
|
||||
"binding_failed": "暂未识别到绑定角色,请继续使用当前二维码完成扫码",
|
||||
"account_role_cooldown": "当前绑定账号暂不可换绑,请截图本页面并联系客服处理",
|
||||
"customer_role_cooldown": "该游戏角色仍在换绑冷却期,请截图本页面并联系客服处理",
|
||||
"eligibility_check_failed": "状态查询异常,请稍后刷新",
|
||||
"manual_required": "当前需要人工处理,请联系客服",
|
||||
}
|
||||
return messages.get(task.issue_code, "") if task.issue_code else ""
|
||||
|
||||
|
||||
def _binding_failure_issue(bind_task: DouyuTask, result: dict[str, Any]) -> str:
|
||||
phase = str(result.get("bind_phase") or "")
|
||||
message = str(bind_task.message or "")
|
||||
if phase == "change_waiting" or "暂不能换绑" in message:
|
||||
task_issue = "account_role_cooldown"
|
||||
elif phase == "confirm_failed" or "待绑定游戏账号" in message or "未到换绑时间" in message:
|
||||
task_issue = "customer_role_cooldown"
|
||||
else:
|
||||
return "binding_failed"
|
||||
messages = {
|
||||
"account_role_cooldown": "当前绑定账号暂不可换绑,请截图本页面并联系客服处理",
|
||||
"customer_role_cooldown": "该游戏角色仍在换绑冷却期,请截图本页面并联系客服处理",
|
||||
}
|
||||
return task_issue if messages.get(task_issue) else "binding_failed"
|
||||
|
||||
|
||||
def customer_binding_out(db: Session, task_id: int) -> dict[str, Any]:
|
||||
"""面向前端客户页的安全绑定快照,不包含账号、CK、积分和租约。"""
|
||||
task = _load_task(db, task_id)
|
||||
@@ -1093,8 +1111,8 @@ def refresh_binding(db: Session, *, task_id: int) -> dict[str, Any]:
|
||||
if bind_task.status in {"failed", "error", "stopped"}:
|
||||
task.binding_status = "failed"
|
||||
task.execution_status = "manual_required"
|
||||
task.issue_code = "binding_failed"
|
||||
task.last_error = bind_task.message or "绑定任务失败"
|
||||
task.issue_code = _binding_failure_issue(bind_task, result)
|
||||
task.last_error = _customer_task_message(task)
|
||||
elif bool(result.get("bind_confirmed")):
|
||||
task.binding_status = "bound"
|
||||
task.execution_status = "bound"
|
||||
@@ -1119,6 +1137,21 @@ def refresh_binding(db: Session, *, task_id: int) -> dict[str, Any]:
|
||||
)
|
||||
if after != before:
|
||||
task.updated_at = _now()
|
||||
if task.issue_code in {
|
||||
"account_role_cooldown",
|
||||
"customer_role_cooldown",
|
||||
}:
|
||||
_append_event(
|
||||
db,
|
||||
task.id,
|
||||
"binding_failed",
|
||||
detail={
|
||||
"issueCode": task.issue_code,
|
||||
"bindTaskId": bind_task.id,
|
||||
"bindPhase": str(result.get("bind_phase") or ""),
|
||||
"rawError": str(bind_task.message or "")[:1000],
|
||||
},
|
||||
)
|
||||
_emit_order_site_binding_state(db, task.id)
|
||||
db.commit()
|
||||
return get_task_detail(db, task.id)
|
||||
|
||||
Reference in New Issue
Block a user