修复(履约绑定): 客户资料不全时禁止开始绑定

- 自动选号后不再在缺少游戏主页截图时启动绑定
- 补启动查询只挑资料完整的任务,避免阻塞后续任务
- 客户绑定启动接口校验角色/登录方式/系统/截图
This commit is contained in:
yml
2026-11-25 10:07:14 +08:00
parent b495a2d999
commit 8aa4ea7342
4 changed files with 55 additions and 2 deletions
+27
View File
@@ -69,6 +69,19 @@ class _Base:
views.invalidate_task_list_count_cache()
self.session.close()
def complete_customer_profile(self, task: PlatformFulfillmentTask) -> None:
task.customer_role_name = "小淋笨"
task.customer_platform = "wechat"
task.customer_system = "android"
task.customer_home_images = [
{
"url": "https://example.com/game-home.png",
"thumbnailUrl": "https://example.com/game-home-thumb.png",
"objectKey": "game-home.png",
}
]
self.session.commit()
def account(
self,
name: str,
@@ -3732,6 +3745,7 @@ class TestBindingAndCompletion(_Base):
def test_customer_start_queues_allocation_without_sync_network(self, monkeypatch):
task = self.task()
self.complete_customer_profile(task)
calls: list[list[int]] = []
monkeypatch.setattr(
"web.backend.services.platform_fulfillment.auto_allocator.wake_auto_allocator",
@@ -3753,6 +3767,7 @@ class TestBindingAndCompletion(_Base):
def test_customer_start_creates_one_binding_task_and_links_platform(self, monkeypatch):
task = self._allocated()
self.complete_customer_profile(task)
monkeypatch.setattr(
service.binding,
"enqueue_execution_job",
@@ -3778,6 +3793,7 @@ class TestBindingAndCompletion(_Base):
def test_customer_started_binding_does_not_capture_request_loop(self, monkeypatch):
task = self._allocated()
self.complete_customer_profile(task)
captured: dict[str, object] = {}
monkeypatch.setattr(
service.binding,
@@ -3790,6 +3806,17 @@ class TestBindingAndCompletion(_Base):
assert captured["job_type"] == "douyu_binding"
assert captured["batch_id"].startswith(f"pfbind-{task.id}-")
def test_customer_start_requires_game_home_profile(self):
task = self._allocated()
with pytest.raises(HTTPException) as exc_info:
asyncio.run(
service.customer_start_binding(self.session, task_id=task.id)
)
assert exc_info.value.status_code == 409
assert "游戏主页截图" in str(exc_info.value.detail)
def test_concurrent_start_binding_creates_one_task(self, monkeypatch):
task = self._allocated()
monkeypatch.setattr(