修复(履约重试): 绑定失败无账号任务允许重新选号
- prepare_manual_allocation 支持 binding_failed/lease_expired 的人工重新选号 - 客户刷新时把任务重置为 ready 并唤醒选号 - 保留客户资料,分配成功后继续启动绑定 - 补充重试测试
This commit is contained in:
@@ -616,6 +616,34 @@ def prepare_manual_allocation(
|
||||
lease = db.query(AccountLease).filter(AccountLease.id == task.lease_id).first()
|
||||
if lease and lease.status == "active":
|
||||
return get_task_detail(db, task.id)
|
||||
if (
|
||||
task.execution_status == "manual_required"
|
||||
and not task.account_id
|
||||
and not task.lease_id
|
||||
and task.issue_code in {"binding_failed", "lease_expired"}
|
||||
):
|
||||
# 绑定失败账号已释放后,人工触发一次重新选号;
|
||||
# 客户资料保留,分配成功后 auto allocator 会继续启动绑定。
|
||||
task.execution_status = "ready"
|
||||
task.binding_status = "not_started"
|
||||
task.bind_task_id = None
|
||||
task.issue_code = ""
|
||||
task.last_error = ""
|
||||
task.next_allocate_at = _now()
|
||||
task.operator_id = current.id
|
||||
task.updated_at = _now()
|
||||
task.state_version = int(task.state_version or 0) + 1
|
||||
_append_event(
|
||||
db,
|
||||
task.id,
|
||||
"binding_retry_requested",
|
||||
actor_type="user",
|
||||
actor_id=current.id,
|
||||
detail={"reason": "manual_reallocate_after_binding_failure"},
|
||||
)
|
||||
_emit_order_site_binding_state(db, task.id)
|
||||
db.flush()
|
||||
return get_task_detail(db, task.id)
|
||||
if task.execution_status != "ready":
|
||||
raise HTTPException(status_code=409, detail="只有待分配任务可以重新选号")
|
||||
task.next_allocate_at = _now()
|
||||
|
||||
Reference in New Issue
Block a user