From 917c11f203f0e3a81c2a1f38c5b5458e847be8a8 Mon Sep 17 00:00:00 2001 From: yml Date: Thu, 26 Nov 2026 16:23:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=B1=A5=E7=BA=A6=E7=BB=91=E5=AE=9A):=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=B7=A5=E4=BD=9C=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E8=B5=84=E6=96=99=E3=80=81=E6=89=AB=E7=A0=81?= =?UTF-8?q?=E4=B8=8D=E5=8C=B9=E9=85=8D=E6=97=B6=E9=97=B4=E7=BA=BF=E5=8F=8A?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=90=8E=E6=96=97=E9=B1=BC=E5=A4=8D=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_douyu_task_concurrency.py | 111 +++++ tests/test_platform_fulfillment.py | 264 ++++++++++++ web/backend/routers/platform_fulfillment.py | 53 +++ web/backend/schemas.py | 7 + web/backend/services/douyu_runner_bind.py | 73 +++- web/backend/services/douyu_runner_core.py | 35 ++ .../services/platform_fulfillment/binding.py | 389 +++++++++++++++++- .../platform_fulfillment/binding_evidence.py | 18 + .../platform_fulfillment/binding_status.py | 17 + .../services/platform_fulfillment/customer.py | 106 ++++- .../services/platform_fulfillment/service.py | 8 + web/frontend/src/api/platformFulfillment.ts | 22 + web/frontend/src/api/types.ts | 9 + .../src/pages/PlatformFulfillmentPage.tsx | 200 ++++++++- 14 files changed, 1293 insertions(+), 19 deletions(-) diff --git a/tests/test_douyu_task_concurrency.py b/tests/test_douyu_task_concurrency.py index aed47ba..7f6b162 100644 --- a/tests/test_douyu_task_concurrency.py +++ b/tests/test_douyu_task_concurrency.py @@ -2030,3 +2030,114 @@ def test_query_esports_game_name_uses_valid_bind_status_enums(db, monkeypatch): ) db.refresh(account) assert account.esports_bind_status == "unbound" + + +def test_poll_bind_role_once_records_mismatched_cjm_and_ignores_bound_action_role( + db, monkeypatch +): + """轮询遇到 cjm 扫出不匹配角色时记录 last_mismatched_role 并同步履约,但忽略 QYOOB 历史已绑定角色。""" + _, account, task = _fixtures(db, status="running") + task.task_type = "get_bind_qr" + task.platform_task_id = 123 + task.run_deadline_at = datetime.now(UTC) + timedelta(minutes=10) + task.result = { + "url": "https://livelink.example/qr", + "expected_role_name": "妎䏓", + "expected_role_required": True, + "baseline_role_name": "愛love恨", + "baseline_is_bound_act": True, + "action_act_aliases": ["20260120QYOOB"], + "query_act_aliases": ["cjm", "20260120QYOOB"], + "bind_poll_initial_legacy_snapshot": { + "role_name": "", + "area_name": "", + "plat_name": "", + "is_bound_act": False, + "is_bound_role": False, + "need_bind_act": False, + "need_bind_role": True, + }, + "bind_poll_legacy_snapshot": { + "role_name": "", + "area_name": "", + "plat_name": "", + "is_bound_act": False, + "is_bound_role": False, + "need_bind_act": False, + "need_bind_role": True, + }, + } + db.commit() + + runner = DouyuBatchRunner(db, task.batch_id, "get_bind_qr", close_db=False) + monkeypatch.setattr(runner, "_client", lambda _cookie: object()) + monkeypatch.setattr( + runner, + "_fetch_bind_info_candidates", + lambda _client, aliases: [ + item + for item in ( + { + "act_alias": "cjm", + "role_name": "妎朊", + "area_name": "手Q", + "plat_name": "苹果(iOS)", + "is_bound_act": False, + "is_bound_role": True, + "need_bind_act": False, + "need_bind_role": True, + }, + { + "act_alias": "20260120QYOOB", + "role_name": "愛love恨", + "area_name": "微信", + "plat_name": "安卓(android)", + "is_bound_act": True, + "is_bound_role": True, + "need_bind_act": True, + "need_bind_role": True, + }, + ) + if item["act_alias"] in aliases + ], + ) + sync_calls: list[bool] = [] + monkeypatch.setattr( + runner, + "_sync_platform_fulfillment", + lambda _task_id, *, enabled: sync_calls.append(enabled), + ) + monkeypatch.setattr( + runner, + "_sync_platform_fulfillment_operation", + lambda *_a, **_kw: None, + ) + + cfg = { + "bind_act_alias": "20260120QYOOB", + "confirm_act_alias": "20260120QYOOB", + "legacy_act_alias": "cjm", + } + # 第 1 次出现新不匹配角色:立即触发一次履约同步写入时间线 + runner.poll_bind_role_once(db, task, account, cfg) + db.refresh(task) + assert task.status == "running" + assert sync_calls == [True] + assert task.result["last_mismatched_role"]["role_name"] == "妎朊" + assert [m["role_name"] for m in task.result["mismatched_roles"]] == ["妎朊"] + + # 同一不匹配角色重复轮询不重复同步 + runner.poll_bind_role_once(db, task, account, cfg) + db.refresh(task) + assert sync_calls == [True] + + # 超时后落失败文案明确指出扫到的不匹配角色 + task.run_deadline_at = datetime.now(UTC) - timedelta(seconds=1) + db.commit() + runner.poll_bind_role_once(db, task, account, cfg) + db.refresh(task) + assert task.status == "failed" + assert "妎朊" in task.message + assert "妎䏓" in task.message + assert task.result["last_mismatched_role"]["role_name"] == "妎朊" + assert [m["role_name"] for m in task.result["mismatched_roles"]] == ["妎朊"] diff --git a/tests/test_platform_fulfillment.py b/tests/test_platform_fulfillment.py index 764f8b4..296ed61 100644 --- a/tests/test_platform_fulfillment.py +++ b/tests/test_platform_fulfillment.py @@ -5896,3 +5896,267 @@ class TestBindingAndCompletion(_Base): .count() == 1 ) + + def test_operator_update_customer_profile_reopens_failed_and_syncs_pending(self): + """工作台修改客户资料:可修正名字/区服/系统并重置失败态,也会同步当前绑定任务与 Outbox。""" + task = self._allocated() + self.complete_customer_profile(task) + task.customer_role_name = "妎䏓" + task.customer_platform = "qq" + task.customer_system = "ios" + qr_task = DouyuTask( + batch_id="edit-profile-failed", + 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, + message="绑定二维码已过期:期间扫到「妎朊」,与填写角色「妎䏓」不一致", + result={"expected_role_name": "妎䏓", "expected_role_required": True}, + 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 = "已扫到角色「妎朊」,与下单填写的「妎䏓」不一致" + self.session.commit() + + detail = service.update_customer_profile_by_operator( + self.session, + task_id=task.id, + current=self.admin, + customer_role_name="妎朊", + platform="qq", + system="ios", + reopen_binding=True, + ) + + self.session.refresh(task) + assert task.customer_role_name == "妎朊" + assert task.binding_status == "not_started" + assert task.execution_status == "allocated" + assert task.bind_task_id is None + assert task.issue_code == "" + assert task.last_error == "" + assert detail["task"]["customerProfile"]["roleName"] == "妎朊" + updated_events = ( + self.session.query(PlatformFulfillmentEvent) + .filter_by(task_id=task.id, event_type="customer_profile_updated") + .all() + ) + assert len(updated_events) == 1 + assert updated_events[0].detail_json["previousRoleName"] == "妎䏓" + assert updated_events[0].detail_json["customerRoleName"] == "妎朊" + assert updated_events[0].detail_json["reopenedBinding"] is True + + # 已绑定订单不允许直接修改资料 + task.binding_status = "bound" + task.execution_status = "bound" + self.session.commit() + with pytest.raises(HTTPException) as exc: + service.update_customer_profile_by_operator( + self.session, + task_id=task.id, + current=self.admin, + customer_role_name="新角色", + platform="wechat", + system="android", + ) + assert exc.value.status_code == 409 + + def test_mismatched_scanned_role_is_recorded_in_timeline_and_evidence(self): + """扫码扫到与下单填写不一致的角色时,应写入时间线并在失败提示/证据中透出。""" + task = self._allocated() + self.complete_customer_profile(task) + task.customer_role_name = "妎䏓" + qr_task = DouyuTask( + batch_id="mismatch-qr", + 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", + "expected_role_name": "妎䏓", + "expected_role_required": True, + "last_mismatched_role": { + "act_alias": "cjm", + "role_name": "妎朊", + "area_name": "手Q", + "plat_name": "苹果(iOS)", + "expected_role_name": "妎䏓", + "observed_at": NOW.isoformat(), + }, + "mismatched_roles": [ + { + "act_alias": "cjm", + "role_name": "妎朊", + "area_name": "手Q", + "plat_name": "苹果(iOS)", + "expected_role_name": "妎䏓", + "observed_at": NOW.isoformat(), + } + ], + }, + 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" + self.session.commit() + + # 轮询期间记录一次不匹配事件(重复同步应去重) + service.sync_task_from_binding_runner(self.session, douyu_task_id=qr_task.id) + service.sync_task_from_binding_runner(self.session, douyu_task_id=qr_task.id) + mismatch_events = ( + self.session.query(PlatformFulfillmentEvent) + .filter_by(task_id=task.id, event_type="binding_scanned_role_mismatch") + .all() + ) + assert len(mismatch_events) == 1 + assert mismatch_events[0].detail_json["scannedRoleName"] == "妎朊" + assert mismatch_events[0].detail_json["expectedRoleName"] == "妎䏓" + + detail = service.get_task_detail(self.session, task.id) + assert detail["task"]["bindingEvidence"]["scannedRole"] == "" + assert detail["task"]["bindingEvidence"]["mismatchedRole"]["roleName"] == "妎朊" + + # 超时失败时明确提示曾扫到的不匹配角色 + qr_task.status = "failed" + qr_task.message = "绑定二维码已过期:期间扫到「妎朊」,与填写角色「妎䏓」不一致" + self.session.commit() + service.sync_task_from_binding_runner(self.session, douyu_task_id=qr_task.id) + self.session.refresh(task) + assert task.binding_status == "failed" + assert "妎朊" in task.last_error + assert "妎䏓" in task.last_error + + def test_verify_task_binding_records_success_and_reverts_mismatch(self, monkeypatch): + """确认绑定后复核斗鱼:一致时记复核通过;斗鱼未绑定或角色不一致时回退转人工。""" + from web.backend.services.platform_fulfillment import binding as pf_binding + + task = self._allocated() + self.complete_customer_profile(task) + task.customer_role_name = "越伤痛" + confirm_task = DouyuTask( + batch_id="verify-confirm", + 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": "越伤痛", "bind_confirmed": True}, + created_by=self.admin_id, + ) + self.session.add(confirm_task) + self.session.flush() + task.bind_task_id = confirm_task.id + task.binding_status = "bound" + task.execution_status = "bound" + self.session.commit() + + monkeypatch.setattr(pf_binding, "activity_client", lambda *_a, **_kw: object()) + monkeypatch.setattr( + pf_binding, + "resolve_elite_role", + lambda _client, _cfg: { + "status": "bound", + "role_name": "越伤痛", + "area_name": "手Q", + "plat_name": "安卓(android)", + "game_channel": "手Q / 安卓(android)", + "source_alias": "20260120QYOOB", + "bind_info": { + "act_alias": "20260120QYOOB", + "role_name": "越伤痛", + "is_bound_act": True, + "is_bound_role": True, + }, + "bind_infos": [ + { + "act_alias": "20260120QYOOB", + "role_name": "越伤痛", + "area_name": "手Q", + "plat_name": "安卓(android)", + "is_bound_act": True, + "is_bound_role": True, + "need_bind_act": True, + "need_bind_role": True, + } + ], + "errors": [], + }, + ) + + detail = service.verify_task_binding_sync( + self.session, + task_id=task.id, + current=self.admin, + automatic=True, + ) + self.session.refresh(task) + assert task.binding_status == "bound" + assert detail["events"][0]["eventType"] == "binding_verified" + assert ( + self.session.query(DouyuRoleApiLog) + .filter_by(account_id=task.account_id, stage="fulfillment.verify_binding") + .count() + == 1 + ) + + # 若复核发现斗鱼当前其实绑在别的旧角色上,应回退为人工处理 + monkeypatch.setattr( + pf_binding, + "resolve_elite_role", + lambda _client, _cfg: { + "status": "bound", + "role_name": "清耆白清万入识", + "area_name": "手Q", + "plat_name": "安卓(android)", + "game_channel": "手Q / 安卓(android)", + "source_alias": "20260120QYOOB", + "bind_info": { + "act_alias": "20260120QYOOB", + "role_name": "清耆白清万入识", + "is_bound_act": True, + "is_bound_role": True, + }, + "bind_infos": [ + { + "act_alias": "20260120QYOOB", + "role_name": "清耆白清万入识", + "is_bound_act": True, + "is_bound_role": True, + "need_bind_act": True, + "need_bind_role": True, + } + ], + "errors": [], + }, + ) + service.verify_task_binding_sync( + self.session, + task_id=task.id, + current=self.admin, + automatic=False, + ) + self.session.refresh(task) + assert task.binding_status == "failed" + assert task.execution_status == "manual_required" + assert task.issue_code == "role_changed" + assert "清耆白清万入识" in task.last_error + assert ( + self.session.query(PlatformFulfillmentEvent) + .filter_by(task_id=task.id, event_type="binding_verify_failed") + .count() + == 1 + ) diff --git a/web/backend/routers/platform_fulfillment.py b/web/backend/routers/platform_fulfillment.py index 0d2643b..39fc939 100644 --- a/web/backend/routers/platform_fulfillment.py +++ b/web/backend/routers/platform_fulfillment.py @@ -13,6 +13,7 @@ from ..models import User from ..schemas import ( PlatformFulfillmentCollabSyncRequest, PlatformFulfillmentCompleteRequest, + PlatformFulfillmentCustomerProfileUpdate, PlatformFulfillmentManualBindingRequest, PlatformFulfillmentMappingUpsert, PlatformFulfillmentMappingWrite, @@ -524,6 +525,58 @@ def manual_confirm_binding( return result +@router.patch("/tasks/{task_id}/customer-profile") +def update_customer_profile( + task_id: int, + req: PlatformFulfillmentCustomerProfileUpdate, + db: Session = Depends(get_db), + current: User = Depends(require_permission("platform_fulfillment:use")), +) -> dict[str, Any]: + """运营在履约工作台修改客户填写的游戏角色、登录方式与系统。""" + result = service.update_customer_profile_by_operator( + db, + task_id=task_id, + current=current, + customer_role_name=req.customer_role_name, + platform=req.customer_platform, + system=req.customer_system, + reopen_binding=req.reopen_binding, + ) + record_audit( + db, + current, + action="platform_fulfillment:customer_profile:update", + target=f"platform_fulfillment_task:{task_id}", + detail={ + "customerRoleName": req.customer_role_name, + "customerPlatform": req.customer_platform, + "customerSystem": req.customer_system, + "reopenBinding": req.reopen_binding, + }, + ) + db.commit() + return result + + +@router.post("/tasks/{task_id}/bind/verify") +async def verify_binding( + task_id: int, + db: Session = Depends(get_db), + current: User = Depends(require_permission("platform_fulfillment:use")), +) -> dict[str, Any]: + """去斗鱼再次实时查询并复核当前绑定是否真正生效。""" + result = await service.verify_task_binding(db, task_id=task_id, current=current) + record_audit( + db, + current, + action="platform_fulfillment:binding:verify", + target=f"platform_fulfillment_task:{task_id}", + detail={"bindingStatus": result.get("task", {}).get("bindingStatus")}, + ) + db.commit() + return result + + @router.post("/tasks/{task_id}/eligibility/refresh") def refresh_eligibility( task_id: int, diff --git a/web/backend/schemas.py b/web/backend/schemas.py index 827bf9d..0d0a25d 100644 --- a/web/backend/schemas.py +++ b/web/backend/schemas.py @@ -1734,6 +1734,13 @@ class PlatformFulfillmentManualBindingRequest(BaseModel): note: str = Field(default="", max_length=500) +class PlatformFulfillmentCustomerProfileUpdate(BaseModel): + customer_role_name: str = Field(..., min_length=1, max_length=128) + customer_platform: str = Field(..., pattern="^(wechat|qq)$") + customer_system: str = Field(..., pattern="^(ios|android)$") + reopen_binding: bool = True + + class PlatformFulfillmentSettingsUpdate(BaseModel): lease_duration_minutes: int | None = Field(..., ge=1, le=525600) completed_release_delay_minutes: int | None = Field( diff --git a/web/backend/services/douyu_runner_bind.py b/web/backend/services/douyu_runner_bind.py index 945f92b..4b7c2db 100644 --- a/web/backend/services/douyu_runner_bind.py +++ b/web/backend/services/douyu_runner_bind.py @@ -1078,6 +1078,24 @@ class BindMixin: def finish_timeout() -> None: self._merge_latest_expected_role(db, task, result) + latest_expected = str(result.get("expected_role_name") or "").strip() + last_mismatch = result.get("last_mismatched_role") + mismatched_role = ( + str(last_mismatch.get("role_name") or "").strip() + if isinstance(last_mismatch, dict) + else "" + ) + if mismatched_role and latest_expected: + timeout_message = ( + f"绑定二维码已过期:期间扫到「{mismatched_role}」," + f"与填写角色「{latest_expected}」不一致" + ) + elif mismatched_role: + timeout_message = ( + f"绑定二维码已过期:期间扫到「{mismatched_role}」,未匹配到目标角色" + ) + else: + timeout_message = "绑定二维码已过期,未识别到新扫码角色" result.update( { "bind_polling": False, @@ -1094,7 +1112,7 @@ class BindMixin: db, task, "failed", - "绑定二维码已过期,未识别到新扫码角色", + timeout_message[:512], result, ) @@ -1370,6 +1388,57 @@ class BindMixin: result["current_role_name"] = snapshot["role_name"] result["current_area_name"] = snapshot["area_name"] result["current_plat_name"] = snapshot["plat_name"] + + new_mismatch_observed = False + if expected_role_name: + candidate_by_alias = { + str(item.get("act_alias") or item.get("alias") or "").strip(): item + for item in candidates + if isinstance(item, dict) + } + recorded_keys = [ + str(v) + for v in (result.get("recorded_mismatched_roles") or []) + if str(v or "").strip() + ] + mismatched_roles = [ + dict(item) + for item in (result.get("mismatched_roles") or []) + if isinstance(item, dict) + ] + for decision in candidate_decisions: + if str(decision.get("reason") or "") != "expected_role_mismatch": + continue + if bool(decision.get("is_bound_act")): + continue + scanned_name = str(decision.get("role_name") or "").strip() + if not scanned_name: + continue + alias = str(decision.get("alias") or "").strip() + cand = candidate_by_alias.get(alias) or {} + cand_snap = self._bind_snapshot(cand) if cand else {} + area_name = str(cand_snap.get("area_name") or cand.get("area_name") or "").strip() + plat_name = str(cand_snap.get("plat_name") or cand.get("plat_name") or "").strip() + dedupe_key = f"{alias}|{scanned_name.casefold()}|{area_name}|{plat_name}" + if dedupe_key in recorded_keys: + continue + recorded_keys.append(dedupe_key) + entry = { + "act_alias": alias, + "role_name": scanned_name, + "area_name": area_name, + "plat_name": plat_name, + "expected_role_name": expected_role_name, + "observed_at": now.isoformat(), + } + mismatched_roles.append(entry) + result["last_mismatched_role"] = entry + new_mismatch_observed = True + if recorded_keys: + result["recorded_mismatched_roles"] = recorded_keys[-20:] + if mismatched_roles: + result["mismatched_roles"] = mismatched_roles[-10:] + result.update( { "bind_info": bind_info, @@ -1413,7 +1482,7 @@ class BindMixin: "running", f"等待扫码绑定 ({summary})", result, - sync_platform=False, + sync_platform=bool(task.platform_task_id and new_mismatch_observed), ) def _execute_get_bind_qr( diff --git a/web/backend/services/douyu_runner_core.py b/web/backend/services/douyu_runner_core.py index eb0f900..2741245 100644 --- a/web/backend/services/douyu_runner_core.py +++ b/web/backend/services/douyu_runner_core.py @@ -265,6 +265,37 @@ class DouyuBatchRunnerCore: "[douyu] 同步直播账号履约状态失败: task_id={}", douyu_task_id ) + def _verify_platform_binding( + self, + douyu_task_id: int, + *, + enabled: bool, + ) -> None: + """确认绑定完成后,再去斗鱼实时查询复核一次。""" + if not enabled: + return + try: + from ..database import WorkerSessionLocal + from .platform_fulfillment.service import verify_active_binding_for_douyu_task + + verify_db = WorkerSessionLocal() + try: + task = verify_db.get(DouyuTask, int(douyu_task_id)) + if task is None or task.status != "success": + return + verify_active_binding_for_douyu_task( + verify_db, + douyu_task_id=int(douyu_task_id), + actor_id=int(task.created_by), + ) + finally: + verify_db.close() + except Exception: # noqa: BLE001 - 复核异常不能覆盖主任务提交 + logger.exception( + "[douyu] 自动复核直播履约绑定状态失败: task_id={}", + douyu_task_id, + ) + def _refresh_platform_exchange_eligibility( self, douyu_task_id: int, @@ -405,6 +436,10 @@ class DouyuBatchRunnerCore: task_id, enabled=sync_platform_fulfillment, ) + self._verify_platform_binding( + task_id, + enabled=(status == "success" and task.task_type == "confirm_bind"), + ) self._refresh_platform_exchange_eligibility( task_id, enabled=( diff --git a/web/backend/services/platform_fulfillment/binding.py b/web/backend/services/platform_fulfillment/binding.py index 295054b..6700ac9 100644 --- a/web/backend/services/platform_fulfillment/binding.py +++ b/web/backend/services/platform_fulfillment/binding.py @@ -45,7 +45,7 @@ from .binding_status import ( _binding_failure_raw_message, _customer_task_message, ) -from .common import FLOW_VERSION_CLEAN, _has_game_home_profile, _now +from .common import FLOW_VERSION_CLEAN, SCOPE_ELITE, _has_game_home_profile, _now from .outbox import _emit_order_site_binding_state from .repository import ( _binding_qr_expired, @@ -65,6 +65,18 @@ from .runtime import ( _apply_task_lease_policy, ) from .views import get_task_detail +from ..douyu_account_probe import ( + ROLE_BOUND, + ROLE_ERROR, + ROLE_UNKNOWN, + activity_client, + config_mapping, + elite_action_aliases, + persist_probe_result, + resolve_elite_role, +) +from ..douyu_role_audit import record_role_api_candidates +from ..douyu_service import ensure_douyu_config BINDING_SYNC_TASK_TYPES = frozenset( { @@ -488,6 +500,85 @@ def _latest_observations_for_task( ) +def _record_mismatched_scan_events( + db: Session, + task: PlatformFulfillmentTask, + source: DouyuTask, +) -> bool: + """把扫码出现的不匹配角色写入时间线(按任务+角色+区服去重)。""" + result = source.result if isinstance(source.result, dict) else {} + entries = [ + item + for item in (result.get("mismatched_roles") or []) + if isinstance(item, dict) and str(item.get("role_name") or "").strip() + ] + last_entry = result.get("last_mismatched_role") + if ( + not entries + and isinstance(last_entry, dict) + and str(last_entry.get("role_name") or "").strip() + ): + entries = [last_entry] + if not entries: + return False + + existing_events = ( + db.query(PlatformFulfillmentEvent.detail_json) + .filter( + PlatformFulfillmentEvent.task_id == int(task.id), + PlatformFulfillmentEvent.event_type == "binding_scanned_role_mismatch", + ) + .order_by(PlatformFulfillmentEvent.id.desc()) + .limit(50) + .all() + ) + seen: set[tuple[int, str, str]] = set() + for row in existing_events: + detail = row[0] if isinstance(row[0], dict) else {} + try: + src_id = int(detail.get("sourceTaskId") or 0) + except (TypeError, ValueError): + src_id = 0 + seen.add( + ( + src_id, + str(detail.get("scannedRoleName") or "").strip().casefold(), + str(detail.get("channel") or "").strip(), + ) + ) + + appended = False + for entry in entries: + scanned_role = str(entry.get("role_name") or "").strip() + if not scanned_role: + continue + area_name = str(entry.get("area_name") or "").strip() + plat_name = str(entry.get("plat_name") or "").strip() + channel = " / ".join(part for part in (area_name, plat_name) if part) + key = (int(source.id), scanned_role.casefold(), channel) + if key in seen: + continue + seen.add(key) + expected_role = str( + entry.get("expected_role_name") or task.customer_role_name or "" + ).strip() + _append_event( + db, + task.id, + "binding_scanned_role_mismatch", + detail={ + "sourceTaskId": int(source.id), + "sourceTaskType": str(source.task_type or ""), + "scannedRoleName": scanned_role[:128], + "expectedRoleName": expected_role[:128], + "channel": channel[:128], + "actAlias": str(entry.get("act_alias") or "")[:64], + }, + ) + appended = True + return appended + + def _record_binding_rejection( db: Session, task: PlatformFulfillmentTask, @@ -1012,24 +1103,43 @@ def _apply_binding_task( ) result = source.result if isinstance(source.result, dict) else {} previous_bind_task_id = task.bind_task_id + mismatch_recorded = _record_mismatched_scan_events(db, task, source) if source.status in {"failed", "error", "stopped"}: # 只有订单当前挂着的任务失败才允许判失败;工作台额外任务失败不能打死订单。 if not is_current: - return False + return mismatch_recorded if phase not in ACTIVE_BINDING_STATUSES | {"confirming", "failed"}: - return False + return mismatch_recorded issue_code = _binding_failure_issue(source, result) if ( task.binding_status == "failed" and task.issue_code == issue_code and int(task.bind_task_id or 0) == int(source.id) ): - return False + return mismatch_recorded task.binding_status = "failed" task.execution_status = "manual_required" task.issue_code = issue_code - task.last_error = _customer_task_message(task) + last_mismatch = result.get("last_mismatched_role") + mismatched_name = ( + str(last_mismatch.get("role_name") or "").strip() + if isinstance(last_mismatch, dict) + else "" + ) + expected_name = str( + (last_mismatch.get("expected_role_name") if isinstance(last_mismatch, dict) else "") + or task.customer_role_name + or "" + ).strip() + if issue_code == "binding_failed" and mismatched_name: + task.last_error = ( + f"已扫到角色「{mismatched_name}」,与下单填写的「{expected_name}」不一致,请核对后修改资料或重扫" + if expected_name + else f"已扫到不匹配角色「{mismatched_name}」,请核对后重扫" + ) + else: + task.last_error = _customer_task_message(task) task.updated_at = _now() _append_event( db, @@ -1052,14 +1162,17 @@ def _apply_binding_task( if source.status != "success": # 运行中的绑码任务可以展示二维码,但不能据此推进角色/结算。 - return _apply_binding_qr_display( - db, - task, - source, - owned=owned, - is_current=is_current, - phase=phase, - lease=lease, + return ( + _apply_binding_qr_display( + db, + task, + source, + owned=owned, + is_current=is_current, + phase=phase, + lease=lease, + ) + or mismatch_recorded ) if binding.status == BINDING_VIEW_CONFIRMED: @@ -1957,3 +2070,253 @@ async def confirm_binding( task_id=task_id, current=current, ) + + +def verify_task_binding_sync( + db: Session, + *, + task_id: int, + current: User | None = None, + automatic: bool = False, +) -> dict[str, Any]: + """确认绑定后,向斗鱼实时复核当前账号绑定状态与角色是否一致。""" + task = _load_task(db, task_id) + if task.execution_status in {"completed", "cancelled"}: + if automatic: + return get_task_detail(db, task.id) + raise HTTPException(status_code=409, detail="已结束任务无需复核绑定") + if task.binding_status != "bound": + if automatic: + return get_task_detail(db, task.id) + raise HTTPException(status_code=409, detail="当前订单尚未绑定确认,无法复核") + if not task.account_id: + if automatic: + return get_task_detail(db, task.id) + raise HTTPException(status_code=409, detail="当前任务尚未分配账号") + + account = db.get(Account, int(task.account_id)) + if account is None or not str(account.cookie or "").strip(): + if automatic: + _append_event( + db, + task.id, + "binding_verify_error", + actor_type="system", + detail={"error": "账号 Cookie 不可用,跳过自动复核", "automatic": True}, + ) + db.commit() + return get_task_detail(db, task.id) + raise HTTPException(status_code=409, detail="账号 Cookie 不可用,无法查询斗鱼") + + config = config_mapping(ensure_douyu_config(db)) + cookie = str(account.cookie or "").strip() + bind_task_id = int(task.bind_task_id) if task.bind_task_id else None + account_id = int(account.id) + client = activity_client(cookie) + try: + role = resolve_elite_role(client, config) + except Exception as exc: # noqa: BLE001 + role = {"status": ROLE_ERROR, "errors": [str(exc)], "bind_infos": []} + + bind_infos = [ + item for item in (role.get("bind_infos") or []) if isinstance(item, dict) + ] + if bind_infos: + record_role_api_candidates( + db, + account_id=account_id, + task_id=bind_task_id, + candidates=bind_infos, + scope=SCOPE_ELITE, + stage="fulfillment.verify_binding", + source="platform.verify_binding", + ) + + task = _load_task_for_update(db, task_id) + account = db.get(Account, int(task.account_id)) if task.account_id else None + if ( + account is None + or task.execution_status in {"completed", "cancelled"} + or task.binding_status != "bound" + ): + if bind_infos: + db.commit() + return get_task_detail(db, task.id) + + role_status = str(role.get("status") or "") + actor_type = "system" if automatic or current is None else "user" + actor_id = None if automatic or current is None else int(current.id) + if role_status in {ROLE_ERROR, ROLE_UNKNOWN}: + err_text = ";".join(str(x) for x in (role.get("errors") or []) if x) or "斗鱼接口查询异常" + _append_event( + db, + task.id, + "binding_verify_error", + actor_type=actor_type, + actor_id=actor_id, + detail={"error": err_text[:500], "automatic": automatic}, + ) + db.commit() + return get_task_detail(db, task.id) + + persist_probe_result( + db, + account, + { + "probe_id": f"pf-verify:{task.id}", + "identity": {"uid": account.uid, "username": account.username}, + "session": {}, + "elite": {}, + "eligibility": {}, + "roles": {"elite": role}, + "gold": {}, + "goods": {}, + "errors": {}, + }, + current=current, + source="platform.verify_binding", + record_event=False, + ) + + action_aliases = set(elite_action_aliases(config)) + action_bound = next( + ( + item + for item in bind_infos + if str(item.get("act_alias") or "").strip() in action_aliases + and bool(item.get("is_bound_act")) + and str(item.get("role_name") or "").strip() + ), + None, + ) + actual_role = ( + str((action_bound or role).get("role_name") or "").strip() + if role_status == ROLE_BOUND + else "" + ) + actual_alias = str( + (action_bound or {}).get("act_alias") + or role.get("source_alias") + or "" + ).strip() + actual_channel = str(role.get("game_channel") or "").strip() + expected_role = str( + task.customer_role_name or _order_target_role(db, task) or "" + ).strip() + + verified = bool( + role_status == ROLE_BOUND + and actual_role + and (not expected_role or role_names_match(actual_role, expected_role)) + ) + if verified: + _append_event( + db, + task.id, + "binding_verified", + actor_type=actor_type, + actor_id=actor_id, + detail={ + "roleName": actual_role[:128], + "expectedRoleName": expected_role[:128], + "channel": actual_channel[:128], + "actAlias": actual_alias[:64], + "automatic": automatic, + }, + ) + db.commit() + return get_task_detail(db, task.id) + + lease = _lease_for_task(db, task) + if actual_role and expected_role: + mismatch_msg = ( + f"斗鱼复核未通过:当前绑定角色为「{actual_role}」," + f"与订单目标「{expected_role}」不一致" + ) + issue_code = "role_changed" + else: + pending_role = str(role.get("pending_role_name") or role.get("role_name") or "").strip() + mismatch_msg = ( + f"斗鱼复核未通过:角色「{pending_role}」仍处于待确认,尚未绑定生效" + if pending_role + else "斗鱼复核未通过:斗鱼接口当前显示未绑定生效" + ) + issue_code = "binding_failed" + task.binding_status = "failed" + task.execution_status = "manual_required" + task.issue_code = issue_code + task.last_error = mismatch_msg + task.updated_at = _now() + _append_event( + db, + task.id, + "binding_verify_failed", + actor_type=actor_type, + actor_id=actor_id, + detail={ + "expectedRoleName": expected_role[:128], + "actualRoleName": actual_role[:128], + "actualStatus": role_status, + "channel": actual_channel[:128], + "actAlias": actual_alias[:64], + "message": mismatch_msg, + "automatic": automatic, + }, + ) + _apply_task_lease_policy(db, task, lease=lease) + _emit_order_site_binding_state(db, task.id) + db.commit() + return get_task_detail(db, task.id) + + +async def verify_task_binding( + db: Session, *, task_id: int, current: User +) -> dict[str, Any]: + return await run_in_threadpool( + verify_task_binding_sync, + db, + task_id=task_id, + current=current, + automatic=False, + ) + + +def verify_active_binding_for_douyu_task( + db: Session, + *, + douyu_task_id: int, + actor_id: int | None = None, +) -> dict[str, Any] | None: + """confirm_bind 完成后,自动向斗鱼再复核一次对应履约订单的绑定结果。""" + douyu_task = db.get(DouyuTask, int(douyu_task_id)) + if ( + douyu_task is None + or douyu_task.status != "success" + or str(douyu_task.task_type or "") != "confirm_bind" + or str(douyu_task.handbook_scope or "") != "elite" + ): + return None + query = db.query(PlatformFulfillmentTask).filter( + PlatformFulfillmentTask.scope == "elite", + PlatformFulfillmentTask.binding_status == "bound", + PlatformFulfillmentTask.execution_status.notin_(("completed", "cancelled")), + ) + if douyu_task.platform_task_id: + task = query.filter( + PlatformFulfillmentTask.id == int(douyu_task.platform_task_id) + ).first() + else: + task = ( + query.filter(PlatformFulfillmentTask.bind_task_id == int(douyu_task.id)) + .order_by(PlatformFulfillmentTask.id.desc()) + .first() + ) + if task is None: + return None + actor = db.get(User, int(actor_id)) if actor_id is not None else None + return verify_task_binding_sync( + db, + task_id=int(task.id), + current=actor, + automatic=True, + ) diff --git a/web/backend/services/platform_fulfillment/binding_evidence.py b/web/backend/services/platform_fulfillment/binding_evidence.py index de2e269..5f47ac8 100644 --- a/web/backend/services/platform_fulfillment/binding_evidence.py +++ b/web/backend/services/platform_fulfillment/binding_evidence.py @@ -315,6 +315,23 @@ def build_binding_evidence( scanned_role, now=now, ) + raw_mismatch = result.get("last_mismatched_role") + mismatched_role = None + if isinstance(raw_mismatch, dict) and _text(raw_mismatch.get("role_name")): + mismatched_role = { + "alias": _text(raw_mismatch.get("act_alias")), + "roleName": _text(raw_mismatch.get("role_name")), + "areaName": _text(raw_mismatch.get("area_name")), + "platName": _text(raw_mismatch.get("plat_name")), + "channel": _channel( + _text(raw_mismatch.get("area_name")), + _text(raw_mismatch.get("plat_name")), + ), + "expectedRoleName": _text( + raw_mismatch.get("expected_role_name") or task.customer_role_name + ), + "observedAt": _text(raw_mismatch.get("observed_at")), + } return { "sourceTaskId": int(bind_task.id), "sourceTaskType": str(bind_task.task_type or ""), @@ -328,6 +345,7 @@ def build_binding_evidence( "confirmable": confirmable, "targetRole": target_role, "scannedRole": scanned_role, + "mismatchedRole": mismatched_role, "baselineRole": baseline_role, "samePair": same_pair, "actionCurrent": action_current, diff --git a/web/backend/services/platform_fulfillment/binding_status.py b/web/backend/services/platform_fulfillment/binding_status.py index dc8bc99..3058589 100644 --- a/web/backend/services/platform_fulfillment/binding_status.py +++ b/web/backend/services/platform_fulfillment/binding_status.py @@ -92,6 +92,23 @@ def _binding_failure_raw_message( f"待绑定游戏账号({role_name or '-'})未到换绑时间" "(不是斗鱼/虎牙账号),请重新换账号扫码绑定" ) + if issue_code == "binding_failed": + last_mismatch = result.get("last_mismatched_role") + mismatched_name = ( + str(last_mismatch.get("role_name") or "").strip() + if isinstance(last_mismatch, dict) + else "" + ) + expected = str( + (last_mismatch.get("expected_role_name") if isinstance(last_mismatch, dict) else "") + or result.get("expected_role_name") + or "" + ).strip() + if mismatched_name and expected: + return ( + f"绑定二维码已过期:期间扫到「{mismatched_name}」," + f"与填写角色「{expected}」不一致" + ) return fallback diff --git a/web/backend/services/platform_fulfillment/customer.py b/web/backend/services/platform_fulfillment/customer.py index 4cc4d5a..077131e 100644 --- a/web/backend/services/platform_fulfillment/customer.py +++ b/web/backend/services/platform_fulfillment/customer.py @@ -13,21 +13,23 @@ from ...models import ( PlatformFulfillmentTask, ) from .binding import ( + ACTIVE_BINDING_STATUSES, confirm_binding, refresh_binding, start_binding, sync_customer_role_to_bind_task, ) -from .common import FLOW_VERSION_CLEAN, _has_game_home_profile +from .common import FLOW_VERSION_CLEAN, _has_game_home_profile, _now from .order_sync import sync_order_item_ids +from .outbox import _emit_order_site_binding_state from .repository import ( _find_customer_task, _integration_actor, _load_task, _load_task_for_update, ) -from .runtime import _append_event -from .views import customer_binding_out +from .runtime import _append_event, _apply_task_lease_policy +from .views import customer_binding_out, get_task_detail def ensure_customer_session( @@ -199,3 +201,101 @@ async def customer_confirm_binding(db: Session, *, task_id: int) -> dict[str, An refresh_binding(db, task_id=task_id) await confirm_binding(db, task_id=task_id, current=_integration_actor(db)) return customer_binding_out(db, task_id) + + +def update_customer_profile_by_operator( + db: Session, + *, + task_id: int, + current: Any, + customer_role_name: str, + platform: str, + system: str, + reopen_binding: bool = True, +) -> dict[str, Any]: + """工作台运营人工修改客户填写的角色、登录方式和系统。""" + task = _load_task_for_update(db, task_id) + if task.execution_status in {"completed", "cancelled"}: + raise HTTPException(status_code=409, detail="订单已结束,不能修改客户资料") + if task.binding_status == "bound": + raise HTTPException(status_code=409, detail="角色已绑定确认,不能直接修改客户资料") + if task.binding_status == "confirming": + raise HTTPException(status_code=409, detail="正在确认绑定中,请稍后再试") + + new_role = str(customer_role_name or "").strip()[:128] + new_platform = str(platform or "").strip()[:16] + new_system = str(system or "").strip()[:16] + if not new_role: + raise HTTPException(status_code=422, detail="请填写客户游戏角色名") + if new_platform not in {"wechat", "qq"}: + raise HTTPException(status_code=422, detail="登录方式只能选择微信或 QQ") + if new_system not in {"ios", "android"}: + raise HTTPException(status_code=422, detail="系统只能选择苹果或安卓") + + old_role = str(task.customer_role_name or "").strip() + old_platform = str(task.customer_platform or "").strip() + old_system = str(task.customer_system or "").strip() + + now = _now() + task.customer_role_name = new_role + task.customer_platform = new_platform + task.customer_system = new_system + task.customer_profile_updated_at = now + task.operator_id = int(current.id) + task.updated_at = now + + reopened = False + if ( + reopen_binding + and task.binding_status == "failed" + and task.issue_code + in { + "binding_failed", + "role_changed", + "customer_role_cooldown", + "customer_role_bound_elsewhere", + } + ): + lease = ( + db.query(AccountLease).filter(AccountLease.id == task.lease_id).first() + if task.lease_id + else None + ) + task.bind_task_id = None + task.binding_status = "not_started" + task.issue_code = "" + task.last_error = "" + if task.account_id and lease is not None and lease.status == "active": + task.execution_status = "allocated" + _apply_task_lease_policy(db, task, lease=lease) + else: + task.account_id = None + task.lease_id = None + task.execution_status = "ready" + reopened = True + elif task.bind_task_id and task.binding_status in ACTIVE_BINDING_STATUSES: + sync_customer_role_to_bind_task(db, task) + + _append_event( + db, + task.id, + "customer_profile_updated", + actor_type="user", + actor_id=current.id, + detail={ + "previousRoleName": old_role, + "customerRoleName": new_role, + "previousPlatform": old_platform, + "platform": new_platform, + "previousSystem": old_system, + "system": new_system, + "reopenedBinding": reopened, + }, + ) + _emit_order_site_binding_state(db, task.id) + db.commit() + if reopened and task.execution_status == "ready": + from .auto_allocator import wake_auto_allocator + + wake_auto_allocator([int(task.id)]) + return get_task_detail(db, task.id) diff --git a/web/backend/services/platform_fulfillment/service.py b/web/backend/services/platform_fulfillment/service.py index 70a5bb7..cfef764 100644 --- a/web/backend/services/platform_fulfillment/service.py +++ b/web/backend/services/platform_fulfillment/service.py @@ -40,6 +40,9 @@ from .binding import ( # noqa: F401 start_binding_sync, sync_active_task_from_account_binding, sync_task_from_binding_runner, + verify_active_binding_for_douyu_task, + verify_task_binding, + verify_task_binding_sync, ) from .binding_status import ( # noqa: F401 _binding_failure_issue, @@ -69,6 +72,7 @@ from .customer import ( customer_start_binding, ensure_customer_session, save_customer_profile, + update_customer_profile_by_operator, ) from .lifecycle import ( cancel_task, @@ -184,7 +188,11 @@ __all__ = [ "sync_pending_tasks", "sync_pending_tasks_if_due", "sync_task_from_binding_runner", + "update_customer_profile_by_operator", "update_mapping", "update_settings", "upsert_mapping", + "verify_active_binding_for_douyu_task", + "verify_task_binding", + "verify_task_binding_sync", ] diff --git a/web/frontend/src/api/platformFulfillment.ts b/web/frontend/src/api/platformFulfillment.ts index 9b9af38..88f523a 100644 --- a/web/frontend/src/api/platformFulfillment.ts +++ b/web/frontend/src/api/platformFulfillment.ts @@ -147,6 +147,28 @@ export const platformFulfillmentApi = { `/platform-fulfillment/tasks/${taskId}/bind/manual-confirm`, { role_name: roleName, note }, ), + verifyBinding: (taskId: number) => + api.post( + `/platform-fulfillment/tasks/${taskId}/bind/verify`, + ), + updateCustomerProfile: ( + taskId: number, + data: { + customerRoleName: string; + customerPlatform: 'wechat' | 'qq'; + customerSystem: 'ios' | 'android'; + reopenBinding: boolean; + }, + ) => + api.patch( + `/platform-fulfillment/tasks/${taskId}/customer-profile`, + { + customer_role_name: data.customerRoleName, + customer_platform: data.customerPlatform, + customer_system: data.customerSystem, + reopen_binding: data.reopenBinding, + }, + ), refreshEligibility: (taskId: number) => api.post( `/platform-fulfillment/tasks/${taskId}/eligibility/refresh`, diff --git a/web/frontend/src/api/types.ts b/web/frontend/src/api/types.ts index 720ea83..0fe701c 100644 --- a/web/frontend/src/api/types.ts +++ b/web/frontend/src/api/types.ts @@ -2555,6 +2555,15 @@ export interface PlatformFulfillmentBindingEvidence { confirmable: boolean; targetRole: string; scannedRole: string; + mismatchedRole?: { + alias: string; + roleName: string; + areaName: string; + platName: string; + channel: string; + expectedRoleName: string; + observedAt: string; + } | null; baselineRole: string; samePair: boolean; actionCurrent: PlatformFulfillmentBindingCandidate | null; diff --git a/web/frontend/src/pages/PlatformFulfillmentPage.tsx b/web/frontend/src/pages/PlatformFulfillmentPage.tsx index 1f21917..cddce3b 100644 --- a/web/frontend/src/pages/PlatformFulfillmentPage.tsx +++ b/web/frontend/src/pages/PlatformFulfillmentPage.tsx @@ -172,6 +172,12 @@ const EVENT_LABELS: Record = { binding_manually_confirmed: '人工确认绑定', binding_reused_existing_pair: '复用同账号同角色', binding_sync_rejected: '忽略不匹配的绑定证据', + binding_scanned_role_mismatch: '扫码角色与下单资料不一致', + binding_verified: '斗鱼绑定复核通过', + binding_verify_failed: '斗鱼绑定复核未通过', + binding_verify_error: '斗鱼绑定复核查询异常', + customer_profile_saved: '客户提交游戏资料', + customer_profile_updated: '工作台修改客户资料', eligibility_check_failed: '兑换资格查询失败', eligibility_auto_refresh_failed: '自动刷新兑换资格失败', exchange_eligibility_checked: '刷新兑换资格', @@ -427,6 +433,34 @@ function eventDescription(event: { eventType: string; detail: Record(null); + const [profileEditRole, setProfileEditRole] = useState(''); + const [profileEditPlatform, setProfileEditPlatform] = useState<'wechat' | 'qq'>('wechat'); + const [profileEditSystem, setProfileEditSystem] = useState<'ios' | 'android'>('ios'); + const [profileEditReopen, setProfileEditReopen] = useState(true); + const [profileEditSaving, setProfileEditSaving] = useState(false); + const [verifyingBinding, setVerifyingBinding] = useState(false); const manualBindCurrentRole = manualBindTarget?.bindingEvidence?.accountCurrentRole || ''; const manualBindMismatch = Boolean( @@ -969,6 +1010,63 @@ export default function PlatformFulfillmentPage() { } }; + const openProfileEdit = (task: PlatformFulfillmentTask) => { + setProfileEditTarget(task); + setProfileEditRole(task.customerProfile?.roleName || ''); + setProfileEditPlatform(task.customerProfile?.platform === 'qq' ? 'qq' : 'wechat'); + setProfileEditSystem(task.customerProfile?.system === 'android' ? 'android' : 'ios'); + setProfileEditReopen(task.bindingStatus === 'failed'); + }; + + const saveCustomerProfile = async () => { + if (!profileEditTarget) return; + const role = profileEditRole.trim(); + if (!role) { + message.warning('请填写客户游戏角色名'); + return; + } + setProfileEditSaving(true); + try { + const result = await platformFulfillmentApi.updateCustomerProfile( + profileEditTarget.id, + { + customerRoleName: role, + customerPlatform: profileEditPlatform, + customerSystem: profileEditSystem, + reopenBinding: profileEditReopen, + }, + ); + setDetail(result); + setSelectedId(result.task.id); + setProfileEditTarget(null); + await loadTasks(); + message.success('客户资料已更新'); + } catch (error) { + message.error(getErrorMessage(error)); + } finally { + setProfileEditSaving(false); + } + }; + + const verifyTaskBinding = async (task: PlatformFulfillmentTask) => { + setVerifyingBinding(true); + try { + const result = await platformFulfillmentApi.verifyBinding(task.id); + setDetail(result); + setSelectedId(result.task.id); + await loadTasks(); + if (result.task.bindingStatus === 'bound') { + message.success('斗鱼复核通过:当前绑定已生效且角色一致'); + } else { + message.warning(result.task.lastError || '斗鱼复核未通过,已转人工处理'); + } + } catch (error) { + message.error(getErrorMessage(error)); + } finally { + setVerifyingBinding(false); + } + }; + const runDouyuAccountAction = async (taskType: string) => { if (!selected?.account) { message.warning('当前履约任务还没有分配斗鱼账号'); @@ -1672,6 +1770,19 @@ export default function PlatformFulfillmentPage() { 强制确认 ) : null} + {selected && + selected.account && + selected.bindingStatus === 'bound' && + !['completed', 'cancelled'].includes(selected.executionStatus) && + can('platform_fulfillment:use') ? ( + + ) : null} {selected.account && selected.executionStatus !== 'completed' && selected.executionStatus !== 'cancelled' && @@ -1975,7 +2086,19 @@ export default function PlatformFulfillmentPage() { - + openProfileEdit(selected)}> + 修改资料 + + ) : null + } + > {selected.customerProfile ? ( @@ -2129,6 +2252,19 @@ export default function PlatformFulfillmentPage() { {selected.bindingEvidence.scannedRole ? ( {selected.bindingEvidence.scannedRole} + ) : selected.bindingEvidence.mismatchedRole ? ( + + 扫到不匹配角色 + {selected.bindingEvidence.mismatchedRole.roleName} + {selected.bindingEvidence.mismatchedRole.channel ? ( + {selected.bindingEvidence.mismatchedRole.channel} + ) : null} + {selected.bindingEvidence.mismatchedRole.expectedRoleName ? ( + + (下单填写:{selected.bindingEvidence.mismatchedRole.expectedRoleName}) + + ) : null} + ) : ( 未扫码(账号已有角色仅作参考) )} @@ -2589,6 +2725,68 @@ export default function PlatformFulfillmentPage() { + void saveCustomerProfile()} + onCancel={() => setProfileEditTarget(null)} + > + + +
+ 客户游戏角色名 + setProfileEditRole(event.target.value)} + style={{ marginTop: 8 }} + /> +
+ + + 登录方式 + setProfileEditSystem(value)} + style={{ width: '100%', marginTop: 8 }} + options={[ + { value: 'ios', label: '苹果' }, + { value: 'android', label: '安卓' }, + ]} + /> + + + {profileEditTarget?.bindingStatus === 'failed' ? ( + + + 保存后重置绑定失败状态(清空旧报错,便于重新出码扫码) + + ) : null} +
+
+