修复(履约绑定): 恢复已超时扫码后的成功确认
This commit is contained in:
@@ -5740,6 +5740,74 @@ class TestBindingAndCompletion(_Base):
|
||||
assert task.last_error == ""
|
||||
assert updated["task"]["bindingStatus"] == "bound"
|
||||
|
||||
def test_refresh_recovers_old_qr_timeout_with_newer_owned_confirm(self):
|
||||
"""旧二维码已超时失败时,更晚且归属本单的成功确认仍应恢复待确认。"""
|
||||
task = self._allocated()
|
||||
task.customer_role_name = "狞王ゞ"
|
||||
task.customer_platform = "wechat"
|
||||
task.customer_system = "android"
|
||||
qr_task = DouyuTask(
|
||||
batch_id="timed-out-qr-before-confirm",
|
||||
account_id=task.account_id,
|
||||
account_assigned_to=self.admin_id,
|
||||
task_type="get_bind_qr",
|
||||
handbook_scope="elite",
|
||||
status="failed",
|
||||
platform_task_id=task.id,
|
||||
result={"bind_phase": "role_timeout"},
|
||||
message="等待扫码绑定超时",
|
||||
created_by=self.admin_id,
|
||||
)
|
||||
self.session.add(qr_task)
|
||||
self.session.flush()
|
||||
task.bind_task_id = qr_task.id
|
||||
task.binding_status = "failed"
|
||||
task.execution_status = "manual_required"
|
||||
task.issue_code = "binding_failed"
|
||||
task.last_error = "等待扫码绑定超时"
|
||||
account = self.session.get(Account, task.account_id)
|
||||
account.role_bind_status = "bound"
|
||||
account.game_name = "゚狙王゜"
|
||||
account.game_channel = "微信 · 安卓(android)"
|
||||
confirm_task = DouyuTask(
|
||||
batch_id="late-confirm-after-qr-timeout",
|
||||
account_id=task.account_id,
|
||||
account_assigned_to=self.admin_id,
|
||||
task_type="confirm_bind",
|
||||
handbook_scope="elite",
|
||||
status="success",
|
||||
platform_task_id=task.id,
|
||||
result={
|
||||
"role_name": "゚狙王゜",
|
||||
"area_name": "微信",
|
||||
"plat_name": "安卓(android)",
|
||||
"bind_confirmed": True,
|
||||
"bind_phase": "confirmed",
|
||||
},
|
||||
created_by=self.admin_id,
|
||||
)
|
||||
self.session.add(confirm_task)
|
||||
self.session.commit()
|
||||
|
||||
detail = service.refresh_binding(self.session, task_id=task.id)
|
||||
|
||||
self.session.refresh(task)
|
||||
assert task.bind_task_id == confirm_task.id
|
||||
assert detail["task"]["bindingStatus"] == "role_ready"
|
||||
assert detail["task"]["executionStatus"] == "role_ready"
|
||||
assert task.issue_code == ""
|
||||
assert "゚狙王゜" in (task.last_error or "")
|
||||
assert (
|
||||
self.session.query(PlatformFulfillmentEvent)
|
||||
.filter_by(task_id=task.id, event_type="binding_sync_rejected")
|
||||
.filter(
|
||||
PlatformFulfillmentEvent.detail_json["sourceTaskId"].as_integer()
|
||||
== int(confirm_task.id)
|
||||
)
|
||||
.count()
|
||||
== 1
|
||||
)
|
||||
|
||||
def test_save_customer_profile_immediately_reconciles_existing_qr_candidates(self):
|
||||
"""先出码扫码、后提交客户资料时,保存资料应立即把订单收敛到 role_ready。"""
|
||||
task = self._allocated()
|
||||
|
||||
Reference in New Issue
Block a user