发布(0.4.2): 修复履约绑定同步并支持特殊角色名核对
This commit is contained in:
@@ -2943,9 +2943,11 @@ class TestBindingAndCompletion(_Base):
|
||||
.filter_by(task_id=task.id, event_type="binding_sync_rejected")
|
||||
.one()
|
||||
)
|
||||
assert synced == 0
|
||||
assert synced == 1
|
||||
assert task.binding_status == "role_ready"
|
||||
assert task.bind_task_id == qr_task.id
|
||||
assert task.bind_task_id == confirm_task.id
|
||||
assert "别的角色" in (task.last_error or "")
|
||||
assert "本单目标角色" in (task.last_error or "")
|
||||
assert rejection.detail_json["reason"] == "target_mismatch"
|
||||
|
||||
def _role_lock_event(self, account, role_name, *, occurred_at=None):
|
||||
@@ -5655,10 +5657,89 @@ class TestBindingAndCompletion(_Base):
|
||||
.filter_by(task_id=task.id, event_type="binding_sync_rejected")
|
||||
.one()
|
||||
)
|
||||
assert synced >= 0
|
||||
assert synced == 1
|
||||
assert task.binding_status != "bound"
|
||||
assert task.binding_status == "role_ready"
|
||||
assert task.execution_status == "role_ready"
|
||||
assert "账号旧角色" in (task.last_error or "")
|
||||
assert "客户指定角色" in (task.last_error or "")
|
||||
assert rejection.detail_json["reason"] == "target_mismatch"
|
||||
|
||||
def test_refresh_absorbs_newer_owned_confirm_and_operator_can_fix_special_role_name(
|
||||
self,
|
||||
):
|
||||
"""精英宝典确认后应吸收最新角色;特殊字符名可直接复制并修正后结算。"""
|
||||
task = self._allocated()
|
||||
task.customer_role_name = "狞王ゞ"
|
||||
task.customer_platform = "wechat"
|
||||
task.customer_system = "android"
|
||||
qr_task = DouyuTask(
|
||||
batch_id="older-qr-still-polling",
|
||||
account_id=task.account_id,
|
||||
account_assigned_to=self.admin_id,
|
||||
task_type="get_bind_qr",
|
||||
handbook_scope="elite",
|
||||
status="running",
|
||||
platform_task_id=task.id,
|
||||
result={"url": "https://livelink.example/qr", "bind_polling": True},
|
||||
created_by=self.admin_id,
|
||||
)
|
||||
self.session.add(qr_task)
|
||||
self.session.flush()
|
||||
task.bind_task_id = qr_task.id
|
||||
task.binding_status = "qr_pending"
|
||||
task.execution_status = "waiting_bind"
|
||||
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="elite-workbench-confirmed-special-name",
|
||||
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 detail["task"]["customerProfile"]["platformRoleName"] == "゚狙王゜"
|
||||
assert "゚狙王゜" in (task.last_error or "")
|
||||
assert "狞王ゞ" in (task.last_error or "")
|
||||
|
||||
updated = service.update_customer_profile_by_operator(
|
||||
self.session,
|
||||
task_id=task.id,
|
||||
current=self.admin,
|
||||
customer_role_name=detail["task"]["customerProfile"]["platformRoleName"],
|
||||
platform="wechat",
|
||||
system="android",
|
||||
reopen_binding=False,
|
||||
)
|
||||
|
||||
self.session.refresh(task)
|
||||
assert task.customer_role_name == "゚狙王゜"
|
||||
assert task.binding_status == "bound"
|
||||
assert task.execution_status == "bound"
|
||||
assert task.last_error == ""
|
||||
assert updated["task"]["bindingStatus"] == "bound"
|
||||
|
||||
def test_save_customer_profile_immediately_reconciles_existing_qr_candidates(self):
|
||||
"""先出码扫码、后提交客户资料时,保存资料应立即把订单收敛到 role_ready。"""
|
||||
task = self._allocated()
|
||||
|
||||
Reference in New Issue
Block a user