修复(履约绑定): 恢复已超时扫码后的成功确认
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 直播账号运营后台
|
||||
|
||||
斗鱼 / 虎牙账号运营 Web 平台:批量登录拿 Cookie、按工作台跑活动任务、应用宝点券充值。版本见 `pyproject.toml`(当前 0.4.2)。
|
||||
斗鱼 / 虎牙账号运营 Web 平台:批量登录拿 Cookie、按工作台跑活动任务、应用宝点券充值。版本见 `pyproject.toml`(当前 0.4.3)。
|
||||
|
||||
## 能做什么
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "live-hub-py"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
description = "直播账号运营 Web 后台"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12,<3.13"
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -381,7 +381,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "live-hub-py"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "alembic" },
|
||||
|
||||
@@ -104,6 +104,12 @@ ACTIVE_BINDING_STATUSES = frozenset(
|
||||
"role_ready",
|
||||
}
|
||||
)
|
||||
#: 已归属本单的成功确认任务可以让这些状态重新收敛。failed 包含旧二维码已超时,
|
||||
#: 但精英宝典工作台随后已经确认成功的情况。
|
||||
CONFIRM_EVIDENCE_BINDING_STATUSES = ACTIVE_BINDING_STATUSES | {
|
||||
"confirming",
|
||||
"failed",
|
||||
}
|
||||
#: 订单的权威绑定任务类型。查询任务只能展示,不能结算。
|
||||
BINDING_EVIDENCE_TASK_TYPES = frozenset({"get_bind_qr", "confirm_bind"})
|
||||
assert BINDING_EVIDENCE_TASK_TYPES <= BINDING_TASK_TYPES
|
||||
@@ -1212,7 +1218,7 @@ def _apply_binding_task(
|
||||
accepted = False
|
||||
elif source.task_type == "confirm_bind":
|
||||
accepted = (
|
||||
phase in ACTIVE_BINDING_STATUSES | {"confirming"}
|
||||
phase in CONFIRM_EVIDENCE_BINDING_STATUSES
|
||||
and bool(expected_role)
|
||||
and role_names_match(confirmed_role, expected_role)
|
||||
)
|
||||
@@ -1230,7 +1236,7 @@ def _apply_binding_task(
|
||||
if (
|
||||
source.task_type == "confirm_bind"
|
||||
and (owned or is_current)
|
||||
and phase in ACTIVE_BINDING_STATUSES | {"confirming"}
|
||||
and phase in CONFIRM_EVIDENCE_BINDING_STATUSES
|
||||
):
|
||||
message = _binding_target_mismatch_message(
|
||||
confirmed_role,
|
||||
|
||||
Reference in New Issue
Block a user