fix(fulfillment): 恢复 cjm 新角色客户确认

- 回滚 QYOOB-only 门禁,扫到新角色即进入 role_ready
- 客户页 readiness 与平台任务 role_ready 对齐,避免确认接口 409
- 绑定证据 baseline 不再冒充本次扫码
- 新增人工确认绑定接口与按钮(角色、备注、操作人事件)
- 补充客户确认、证据口径和人工确认回归测试
This commit is contained in:
yml
2026-11-24 14:57:39 +08:00
parent 1f53e1a95b
commit 47be8646bf
11 changed files with 573 additions and 74 deletions
@@ -448,3 +448,112 @@ WHERE t.binding_status = 'bound'
`binding_reused_existing_pair` 事件),不要自动复用。
这样列表和详情就一致:要么等客户扫码,要么运营确认后人工复用。
### 9.8 2026-11-24 回归:cjm 新角色被 QYOOB-only 门禁挡住,客户无法确认
生产现象(订单 2632801844205946 / 任务 7871):
```text
平台任务 7871: binding_status=qr_pending, execution_status=waiting_bind
绑定任务 575198:
status=success
bind_phase=role_ready
role_name=雨佑佑
current_role_name=坏小萌瑶瑶
pending_role_name=雨佑佑
act_alias=cjm
action_act_aliases=["20260120QYOOB"]
客户页: 已识别角色 雨佑佑,角色信息一致
客户点确认: 409 当前没有待确认的游戏角色
```
根因是 2026-11-24 第二轮加的 **QYOOB-only 门禁**:
- `_apply_binding_task` 在 pending 分支要求
`_actionable_pending_role`:`act_alias` 必须在 `action_act_aliases` 里;
- 本单客户扫的是 cjm,QYOOB 还没同步出 pending;
- 于是绑定任务虽然已经 `role_ready`,平台任务却停在 `qr_pending`;
- order_site 客户页的 `bindReadyForConfirm` 读的是绑定任务,显示“角色信息一致”;
- 确认接口读的是平台任务,要求 `binding_status=role_ready`,直接 409。
这不是 order_site 展示错,是两个层的 readiness 语义不一致:
```text
绑定任务:role_ready(客户页读这个)
平台任务:qr_pending(确认接口读这个)
```
修复:
1. **回滚 QYOOB-only 门禁**:cjm/legacy 的新角色重新进入
`role_ready`,客户页可以发起确认;
2. 确认执行器仍会在 `actBind` 前重新查询 QYOOB/cjm;动作通道未同步时
返回可重试失败,不再把客户卡在“没有待确认角色”;
3. 绑定证据只把**本次新扫码角色**放进 `scannedRole`,baseline 不再冒充;
4. 新增 **人工确认绑定**:
- `POST /api/platform-fulfillment/tasks/{id}/bind/manual-confirm`
- 运营填写确认角色 + 依据,任务直接 bound,停止当前二维码轮询,
写 `binding_manually_confirmed` 事件(含操作人、角色、备注);
- 用于客户已在精英宝典/别处完成绑定,但履约工作台没有本次扫码证据的场景。
为什么精英宝典正常、履约工作台总出问题:
- 精英宝典是**账号级**操作:绑定任务成功即可在账号工作台确认,没有订单归属层;
- 履约工作台是**订单级**操作:多了订单归属、租约、7 天锁、客户确认四层;
其中任何一层判据不一致,都会表现成“账号明明绑了,订单却待扫码”;
- 这次就是订单级 QYOOB 门禁与账号级 readiness 不一致。人工确认入口是
订单级的显式兜底,不再依赖自动判据。
### 9.9 用 11.22 成功 HAR 收敛模型:actBind 成功/失败才是唯一结果
抓包:`/Users/yml/抓包/斗鱼/11.22-绑定成功-1.har`
关键链路:
```text
GET bindInfo?actAlias=20260120QYOOB
bindAct=0, gameRole.roleName=只为爱杰宝, changeRoleWaitTime=2592000
POST actBind (actAlias=20260120QYOOB)
{"error":0,"msg":"请求正常","data":{}}
GET bindInfo?actAlias=20260120QYOOB
bindAct=1, gameRole.roleName=只为爱杰宝, changeRoleWaitTime=597865
```
这条成功链路说明:
1. 客户扫到角色后,QYOOB 的 `bindInfo` 会先出现 `bindAct=0` + 角色;
2. `actBind` 成功后才变成 `bindAct=1`,角色被覆盖/确认;
3. 绑前的 `changeRoleWaitTime=2592000`(30 天)**没有阻止**这次 actBind;
`actBind` 返回 `error=0` 才是成功,不能用本地冷却预判替代;
4. 如果 `actBind` 返回失败(换绑冷却/其他限制),就是用户的第二种结果:
角色能扫上,但确认失败,应该给明确失败提示,而不是提前把订单卡在
“没有待确认角色”。
因此履约绑定收敛为最简单的状态机:
```text
扫到角色(cjm 或 QYOOB 任一通道)
→ 平台任务 role_ready
→ 客户点确认
→ actBind:
error=0 → bound,账号角色覆盖为新角色
error!=0 → failed,提示换绑冷却/失败,可换号或稍后重试
```
不再做的事:
- 不再要求“QYOOB 上先出现 pending”才允许任务进入 role_ready;
- 不再用 baseline/旧角色冒充本次扫码;
- 不再让客户页 readiness(读绑定任务)和确认接口(读平台任务)各说各话。
保留的事:
- 7 天锁只用于**选号前置过滤**,不替代 actBind 的最终结果;
- 同账号同角色复用只在**本次确实扫到同角色**时生效;
- 人工确认绑定只作为订单级显式兜底,必须记录角色、操作人、备注。
`order_site` 侧不需要改协议:客户页读 live-hub 的 `bindReadyForConfirm`,
确认时调 live-hub 的 `customer-sessions/{id}/binding/confirm`。修复后两侧读同
一层 `role_ready`,order_site 只是如实展示 live-hub 的结果。
+146 -18
View File
@@ -2837,7 +2837,7 @@ class TestBindingAndCompletion(_Base):
assert evidence["legacyLatest"]["roleName"] == "新扫角色"
assert evidence["selectedAlias"] == "cjm"
assert evidence["selectedActionable"] is False
assert evidence["targetRole"] == ""
assert evidence["targetRole"] == "新扫角色"
assert evidence["scannedRole"] == "新扫角色"
assert evidence["confirmable"] is False
assert evidence["samePair"] is False
@@ -2910,10 +2910,134 @@ class TestBindingAndCompletion(_Base):
assert evidence["samePair"] is True
assert evidence["actionCurrent"]["roleName"] == "同对角色"
assert evidence["legacyLatest"]["roleName"] == "同对角色"
assert evidence["targetRole"] == ""
assert evidence["targetRole"] == "同对角色"
assert evidence["confirmable"] is False
def test_cjm_only_pending_keeps_order_waiting_action_alias(self):
def test_binding_evidence_does_not_treat_baseline_as_scanned(self):
task = self._allocated()
account = self.session.get(Account, task.account_id)
account.game_name = "兔稚儿"
account.role_bind_status = "bound"
qr_task = DouyuTask(
batch_id="evidence-baseline-only",
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={
"act_alias": "cjm",
"role_name": "",
"current_role_name": "兔稚儿",
"baseline_role_name": "兔稚儿",
"baseline_is_bound_act": True,
"action_act_aliases": ["20260120QYOOB"],
"bind_ready_for_confirm": False,
"bind_confirmed": False,
"bind_phase": "waiting_scan",
"bind_decision": {
"alias": "cjm",
"role_name": "",
"reason": "no_role",
"confirmable": False,
"actionable_alias": False,
},
"before_bind_info": {
"act_alias": "20260120QYOOB",
"role_name": "兔稚儿",
"is_bound_act": True,
"is_bound_role": True,
"need_bind_act": True,
"need_bind_role": 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"
self.session.commit()
detail = service.get_task_detail(self.session, task.id)
evidence = detail["task"]["bindingEvidence"]
assert evidence is not None
assert evidence["scannedRole"] == ""
assert evidence["samePair"] is False
assert evidence["baselineRole"] == "兔稚儿"
assert evidence["accountCurrentRole"] == "兔稚儿"
assert evidence["actionCurrent"]["roleName"] == "兔稚儿"
assert evidence["decisionReason"] == "no_role"
def test_manual_confirm_binding_marks_bound_without_scan(self):
task = self._allocated()
account = self.session.get(Account, task.account_id)
account.game_name = "兔稚儿"
account.role_bind_status = "bound"
qr_task = DouyuTask(
batch_id="manual-confirm-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={"bind_phase": "waiting_scan", "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"
self.session.commit()
detail = service.manual_confirm_binding_sync(
self.session,
task_id=task.id,
current=self.admin,
role_name="兔稚儿",
note="客户已在精英宝典完成绑定",
)
self.session.refresh(task)
self.session.refresh(qr_task)
assert detail["task"]["bindingStatus"] == "bound"
assert detail["task"]["executionStatus"] == "bound"
assert task.binding_status == "bound"
assert task.execution_status == "bound"
assert qr_task.status == "stopped"
assert "人工确认绑定" in qr_task.message
assert qr_task.result["manual_confirmed"] is True
assert qr_task.result["manual_confirmed_role"] == "兔稚儿"
event = (
self.session.query(PlatformFulfillmentEvent)
.filter_by(task_id=task.id, event_type="binding_manually_confirmed")
.one()
)
assert event.detail_json["roleName"] == "兔稚儿"
assert event.detail_json["note"] == "客户已在精英宝典完成绑定"
assert event.detail_json["operatorId"] == self.admin_id
# 幂等:重复确认不再重复写事件。
service.manual_confirm_binding_sync(
self.session,
task_id=task.id,
current=self.admin,
role_name="兔稚儿",
note="重复确认",
)
assert (
self.session.query(PlatformFulfillmentEvent)
.filter_by(task_id=task.id, event_type="binding_manually_confirmed")
.count()
== 1
)
def test_cjm_only_new_role_enters_role_ready_for_customer_confirm(self):
task = self._allocated()
qr_task = DouyuTask(
batch_id="cjm-only-pending",
@@ -2969,35 +3093,39 @@ class TestBindingAndCompletion(_Base):
task.execution_status = "waiting_bind"
self.session.commit()
# 客户页 readiness 与确认接口必须读同一层事实:
# 平台任务还在 qr_pending 时不能显示“可确认”。
assert views.customer_binding_out(self.session, task.id)["bindReadyForConfirm"] is False
service.refresh_binding(self.session, task_id=task.id)
self.session.refresh(task)
detail = service.get_task_detail(self.session, task.id)
evidence = detail["task"]["bindingEvidence"]
assert task.binding_status == "qr_pending"
assert task.execution_status == "waiting_bind"
assert evidence["targetRole"] == ""
assert task.binding_status == "role_ready"
assert task.execution_status == "role_ready"
assert evidence["targetRole"] == "cjm新角色"
assert evidence["confirmable"] is True
assert views.customer_binding_out(self.session, task.id)["bindReadyForConfirm"] is True
assert evidence["legacyLatest"]["roleName"] == "cjm新角色"
assert evidence["actionCurrent"]["roleName"] == "旧角色"
# 兼容部署前已经 role_ready 的订单:确认入口也要拦住 cjm-only 角色。
# cjm-only 的新角色也必须能进入客户确认:确认执行器会在 actBind 前
# 重新查询 QYOOB,动作通道未同步时返回可重试失败,而不是把客户卡死。
task.binding_status = "role_ready"
task.execution_status = "role_ready"
self.session.commit()
with pytest.raises(HTTPException) as exc_info:
service.confirm_binding_sync(
self.session,
task_id=task.id,
current=self.admin,
)
assert exc_info.value.status_code == 409
assert "动作通道" in str(exc_info.value.detail)
assert (
service.confirm_binding_sync(
self.session,
task_id=task.id,
current=self.admin,
)
confirm_task = (
self.session.query(DouyuTask)
.filter_by(task_type="confirm_bind")
.count()
== 0
.one()
)
assert confirm_task.result["expected_role_name"] == "cjm新角色"
def _same_pair_qr_task(self, task, include_legacy: bool = True):
candidates = [
@@ -13,6 +13,7 @@ from ..models import User
from ..schemas import (
PlatformFulfillmentCollabSyncRequest,
PlatformFulfillmentCompleteRequest,
PlatformFulfillmentManualBindingRequest,
PlatformFulfillmentMappingUpsert,
PlatformFulfillmentMappingWrite,
PlatformFulfillmentReasonRequest,
@@ -464,6 +465,36 @@ async def confirm_binding(
return result
@router.post("/tasks/{task_id}/bind/manual-confirm")
def manual_confirm_binding(
task_id: int,
req: PlatformFulfillmentManualBindingRequest,
db: Session = Depends(get_db),
current: User = Depends(require_permission("platform_fulfillment:use")),
) -> dict[str, Any]:
"""运营人工确认绑定:用于客户已在别处绑定、或账号当前角色已确认的场景。"""
result = service.manual_confirm_binding_sync(
db,
task_id=task_id,
current=current,
role_name=req.role_name,
note=req.note,
)
record_audit(
db,
current,
action="platform_fulfillment:binding:manual_confirm",
target=f"platform_fulfillment_task:{task_id}",
detail={
"roleName": req.role_name,
"note": req.note,
"bindingStatus": result.get("task", {}).get("bindingStatus"),
},
)
db.commit()
return result
@router.post("/tasks/{task_id}/eligibility/refresh")
def refresh_eligibility(
task_id: int,
+5
View File
@@ -1710,6 +1710,11 @@ class PlatformFulfillmentCompleteRequest(BaseModel):
note: str = Field(default="", max_length=1000)
class PlatformFulfillmentManualBindingRequest(BaseModel):
role_name: str = Field(default="", max_length=128)
note: str = Field(default="", max_length=500)
class PlatformFulfillmentSettingsUpdate(BaseModel):
lease_duration_minutes: int | None = Field(..., ge=1, le=525600)
completed_release_delay_minutes: int | None = Field(
@@ -246,37 +246,10 @@ def _lease_for_task(
return fulfillment_lease_for_task(db, task)
def _actionable_pending_role(
result: dict[str, Any] | None,
role_name: str,
) -> str:
"""只有动作 alias 上的 pending 才能作为订单目标。
cjm/legacy 上先出现的角色只能提示,不能直接确认;否则 actBind 会对
QYOOB 调一个未生效的 pending(11.22 抓包 -200001 的根因)。
"""
role = str(role_name or "").strip()
if not role or not isinstance(result, dict):
return ""
raw_aliases = result.get("action_act_aliases")
action_aliases = (
[str(value).strip() for value in raw_aliases if str(value).strip()]
if isinstance(raw_aliases, (list, tuple))
else []
)
selected_alias = str(result.get("act_alias") or "").strip()
if action_aliases and selected_alias and selected_alias not in action_aliases:
return ""
return role
def _pending_role_of(task: DouyuTask | None) -> str:
if task is None or not isinstance(task.result, dict):
return ""
return _actionable_pending_role(
task.result,
pending_binding_role_from_result(task.result),
)
return pending_binding_role_from_result(task.result)
def _owned_binding_tasks(
@@ -625,6 +598,99 @@ def _mark_reused_pair(
return True
def manual_confirm_binding_sync(
db: Session,
*,
task_id: int,
current: User,
role_name: str = "",
note: str = "",
) -> dict[str, Any]:
"""运营人工确认绑定:不依赖本次扫码/actBind,直接落订单绑定事实。
用于客户已在别处完成绑定、或账号当前角色就是客户角色,但履约工作台没有
本次扫码证据的场景。必须由运营确认角色并记录操作人/备注;不做自动复用。
"""
task = _load_task_for_update(db, task_id)
if _frozen(task):
# 已 bound / completed / cancelled:幂等返回,不重复写事件。
return get_task_detail(db, task.id)
if not task.account_id or not task.lease_id:
raise HTTPException(status_code=409, detail="请先分配账号")
lease = db.query(AccountLease).filter(AccountLease.id == task.lease_id).first()
if lease is None or lease.status != "active":
raise HTTPException(status_code=409, detail="账号租约已失效,请重新分配")
account = db.get(Account, int(task.account_id))
if account is None:
raise HTTPException(status_code=409, detail="账号不存在")
confirmed_role = str(role_name or account.game_name or "").strip()
if not confirmed_role:
raise HTTPException(
status_code=409,
detail="账号没有可确认的角色,请先查询角色或填写确认角色",
)
note = str(note or "").strip()[:500]
previous_binding = str(task.binding_status or "")
previous_execution = str(task.execution_status or "")
bind_task = (
db.query(DouyuTask).filter(DouyuTask.id == int(task.bind_task_id)).first()
if task.bind_task_id
else None
)
if bind_task is not None and str(bind_task.status or "") in {
"planned",
"pending",
"running",
}:
result = dict(bind_task.result or {})
result.update(
{
"manual_confirmed": True,
"manual_confirmed_role": confirmed_role,
"manual_confirmed_by": int(current.id),
"manual_confirm_note": note,
"bind_phase": "manual_confirmed",
"bind_polling": False,
"bind_ready_for_confirm": False,
}
)
bind_task.status = "stopped"
bind_task.message = f"人工确认绑定: {confirmed_role}"[:512]
bind_task.finished_at = _now()
bind_task.result = result
task.binding_status = "bound"
task.execution_status = "bound"
task.issue_code = ""
task.last_error = ""
task.operator_id = int(current.id)
task.updated_at = _now()
_append_event(
db,
task.id,
"binding_manually_confirmed",
actor_type="user",
actor_id=str(current.id),
detail={
"roleName": confirmed_role[:128],
"accountId": int(task.account_id),
"accountName": (account.nickname or account.username),
"operatorId": int(current.id),
"note": note,
"sourceTaskId": int(bind_task.id) if bind_task is not None else None,
"sourceTaskStatus": str(bind_task.status or "") if bind_task else "",
"previousBindingStatus": previous_binding,
"previousExecutionStatus": previous_execution,
"baselineRole": str(account.game_name or "").strip(),
},
)
_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)
def _apply_binding_task(
db: Session,
task: PlatformFulfillmentTask,
@@ -809,9 +875,9 @@ def _apply_binding_task(
role_name = binding.pending_role_name
if not role_name:
return False
if not _actionable_pending_role(source.result, role_name):
# cjm/legacy 先出现的新角色:订单继续保持等待动作通道。
return False
# cjm/legacy 先出现的新角色也进入 role_ready:客户页需要能看到角色并
# 发起确认;确认执行器会在 actBind 前重新查询 QYOOB,若动作通道尚未
# 同步会返回可重试失败,而不是让客户卡在“没有待确认角色”。
if phase == "confirming":
# 确认任务执行中,后到的扫码结果不能把订单打回待确认、丢掉确认任务指针。
return False
@@ -1162,8 +1228,7 @@ def _latest_pending_binding_task(
binding = resolve_douyu_binding(row, account=account)
if binding.status != BINDING_VIEW_PENDING:
continue
if _actionable_pending_role(row.result, binding.pending_role_name):
return row
return row
return None
@@ -1185,10 +1250,6 @@ def _attach_pending_binding_task(
or int(bind_task.account_id or 0) != int(task.account_id)
or bind_task.task_type not in PENDING_BINDING_TASK_TYPES
or binding.status != BINDING_VIEW_PENDING
or not _actionable_pending_role(
bind_task.result if isinstance(bind_task.result, dict) else {},
binding.pending_role_name,
)
or not lease_is_active(lease)
or not source_created_within_lease(lease, bind_task)
or (
@@ -1426,14 +1487,6 @@ def confirm_binding_sync(db: Session, *, task_id: int, current: User) -> dict[st
db.commit()
return get_task_detail(db, task.id)
expected_role_name = str(current_bind_result.get("role_name") or "").strip()
if expected_role_name and not _actionable_pending_role(
current_bind_result,
expected_role_name,
):
raise HTTPException(
status_code=409,
detail="当前动作通道没有待确认角色,请客户重新扫码后再确认",
)
baseline_role_name = str(current_bind_result.get("current_role_name") or "").strip()
batch_id = f"pfconfirm-{task.id}-{uuid.uuid4().hex[:8]}"
confirm_task = DouyuTask(
@@ -208,13 +208,29 @@ def build_binding_evidence(
legacy_latest = selected_info_candidate
pending_role = pending_binding_role_from_result(result)
action_pending_role = (
_text((action_pending or {}).get("roleName")) if action_pending else ""
)
# scannedRole 只认“本次新扫码”:
# - 新 pending(QYOOB bindAct=0 / 可确认角色);
# - legacy(cjm) 上出现的扫码角色;
# - decision 明确可确认时的角色。
# 不能用 result.role_name / before_bind_info 的 baseline 兜底,否则会把
# 账号上一单的旧角色误报成本次扫码,详情就会和列表的“待扫码”冲突。
scanned_role = _text(
decision.get("role_name")
or result.get("role_name")
pending_role
or (legacy_latest or {}).get("roleName")
or pending_role
or action_pending_role
or (decision.get("role_name") if decision.get("confirmable") else "")
)
# 取消 QYOOB-only 门禁后,cjm 的新角色同样可以成为客户确认目标;
# 这里展示真实本次扫码角色,避免详情说“不可确认”但客户页可以确认。
target_role = scanned_role
baseline_role = _text(
result.get("baseline_role_name")
or (selected_info or {}).get("role_name")
or (result.get("before_bind_info") or {}).get("role_name")
)
target_role = pending_role if selected_actionable else ""
account_current_role = _text(account.game_name) if account is not None else ""
same_pair = bool(
scanned_role
@@ -262,6 +278,7 @@ def build_binding_evidence(
"confirmable": confirmable,
"targetRole": target_role,
"scannedRole": scanned_role,
"baselineRole": baseline_role,
"samePair": same_pair,
"actionCurrent": action_current,
"actionPending": action_pending,
@@ -29,6 +29,7 @@ from .allocation import ( # noqa: F401
from .binding import ( # noqa: F401
confirm_binding,
confirm_binding_sync,
manual_confirm_binding_sync,
reconcile_binding_observations,
reconcile_binding_state_outbox,
refresh_binding,
@@ -152,6 +153,7 @@ __all__ = [
"get_task_detail",
"list_mappings",
"list_tasks",
"manual_confirm_binding_sync",
"mapping_impact",
"mark_manual_required",
"prepare_manual_allocation",
@@ -488,7 +488,13 @@ def _task_out(
"areaName": binding.effective_area_name,
"platName": binding.effective_plat_name,
"bindPhase": binding.bind_phase,
"bindReadyForConfirm": binding.status == BINDING_VIEW_PENDING,
# 客户页的“可确认”必须与确认接口读的同一层事实一致:
# 绑定任务 pending 且平台任务已经进入 role_ready,才显示确认按钮。
# 否则会出现客户页让确认、确认接口报“没有待确认角色”的错位。
"bindReadyForConfirm": (
binding.status == BINDING_VIEW_PENDING
and str(task.binding_status or "") == "role_ready"
),
"bindConfirmed": binding.bind_confirmed,
}
if bind_task
@@ -687,7 +693,12 @@ def customer_binding_out(db: Session, task_id: int) -> dict[str, Any]:
"roleName": binding.effective_role_name,
"areaName": binding.effective_area_name,
"platName": binding.effective_plat_name,
"bindReadyForConfirm": binding.status == BINDING_VIEW_PENDING,
# 客户页的“可确认”必须与确认接口读的同一层事实一致:
# 绑定任务 pending 且平台任务已经进入 role_ready,才显示确认按钮。
"bindReadyForConfirm": (
binding.status == BINDING_VIEW_PENDING
and str(task.binding_status or "") == "role_ready"
),
"bindConfirmed": binding.bind_confirmed,
"queueState": queue_state,
"retryAfterMs": retry_after_ms,
@@ -137,6 +137,11 @@ export const platformFulfillmentApi = {
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
`/platform-fulfillment/tasks/${taskId}/bind/confirm`,
),
manualConfirmBinding: (taskId: number, roleName: string, note: string) =>
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
`/platform-fulfillment/tasks/${taskId}/bind/manual-confirm`,
{ role_name: roleName, note },
),
refreshEligibility: (taskId: number) =>
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
`/platform-fulfillment/tasks/${taskId}/eligibility/refresh`,
+1
View File
@@ -2513,6 +2513,7 @@ export interface PlatformFulfillmentBindingEvidence {
confirmable: boolean;
targetRole: string;
scannedRole: string;
baselineRole: string;
samePair: boolean;
actionCurrent: PlatformFulfillmentBindingCandidate | null;
actionPending: PlatformFulfillmentBindingCandidate | null;
@@ -137,6 +137,8 @@ const EVENT_LABELS: Record<string, string> = {
binding_account_locked_elsewhere: '斗鱼账号 7 天内已绑定其他角色',
binding_observation_confirmed: '账号观测确认角色绑定',
binding_confirmed: '履约绑定已确认',
binding_manually_confirmed: '人工确认绑定',
binding_reused_existing_pair: '复用同账号同角色',
binding_sync_rejected: '忽略不匹配的绑定证据',
eligibility_check_failed: '兑换资格查询失败',
eligibility_auto_refresh_failed: '自动刷新兑换资格失败',
@@ -367,6 +369,13 @@ function eventDescription(event: { eventType: string; detail: Record<string, unk
const channel = String(detail.confirmedChannel || '');
return `已确认订单角色 ${String(detail.confirmedRoleName || '-')}${channel ? `(${channel})` : ''}`;
}
if (event.eventType === 'binding_manually_confirmed') {
const note = String(detail.note || '').trim();
return `人工确认角色 ${String(detail.roleName || '-')}${note ? `;依据:${note}` : ''}`;
}
if (event.eventType === 'binding_reused_existing_pair') {
return `本次扫码角色 ${String(detail.roleName || '-')} 与账号当前角色一致,直接复用`;
}
if (event.eventType === 'binding_account_locked_elsewhere') {
return String(detail.message || '斗鱼账号 7 天内已绑定其他角色,请换号或等待');
}
@@ -412,6 +421,11 @@ function canRefreshBindingQr(task: PlatformFulfillmentTask) {
return !['role_ready', 'bound', 'completed', 'cancelled'].includes(task.executionStatus);
}
function canManualConfirmBinding(task: PlatformFulfillmentTask) {
if (!task.account) return false;
return !['bound', 'completed', 'cancelled'].includes(task.executionStatus);
}
export default function PlatformFulfillmentPage() {
const user = getUser();
const navigate = useNavigate();
@@ -434,6 +448,10 @@ export default function PlatformFulfillmentPage() {
const [manualReleaseTarget, setManualReleaseTarget] = useState<PlatformFulfillmentTask | null>(null);
const [manualReleaseReason, setManualReleaseReason] = useState('');
const [manualReleasing, setManualReleasing] = useState(false);
const [manualBindTarget, setManualBindTarget] = useState<PlatformFulfillmentTask | null>(null);
const [manualBindRole, setManualBindRole] = useState('');
const [manualBindNote, setManualBindNote] = useState('');
const [manualBinding, setManualBinding] = useState(false);
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const [selectedId, setSelectedId] = useState<number | null>(null);
const [detail, setDetail] = useState<PlatformFulfillmentDetail | null>(null);
@@ -814,6 +832,45 @@ export default function PlatformFulfillmentPage() {
}
};
const openManualBinding = (task: PlatformFulfillmentTask) => {
setManualBindTarget(task);
setManualBindRole(task.bindingEvidence?.accountCurrentRole || '');
setManualBindNote('');
};
const confirmManualBinding = async () => {
if (!manualBindTarget) return;
const role = manualBindRole.trim();
const note = manualBindNote.trim();
if (!role) {
message.warning('请填写客户确认的游戏角色');
return;
}
if (note.length < 2) {
message.warning('请填写人工确认依据/备注');
return;
}
setManualBinding(true);
try {
const result = await platformFulfillmentApi.manualConfirmBinding(
manualBindTarget.id,
role,
note,
);
setDetail(result);
setSelectedId(result.task.id);
setManualBindTarget(null);
setManualBindRole('');
setManualBindNote('');
await loadTasks();
message.success('已人工确认绑定');
} catch (error) {
message.error(getErrorMessage(error));
} finally {
setManualBinding(false);
}
};
const runDouyuAccountAction = async (taskType: string) => {
if (!selected?.account) {
message.warning('当前履约任务还没有分配斗鱼账号');
@@ -1351,6 +1408,11 @@ export default function PlatformFulfillmentPage() {
确认绑定
</Button>
) : null}
{can('platform_fulfillment:use') && canManualConfirmBinding(task) ? (
<Button size="small" icon={<CheckCircleOutlined />} onClick={() => openManualBinding(task)}>
人工确认绑定
</Button>
) : null}
{canResetBinding(task) ? (
<Button
size="small"
@@ -1396,6 +1458,11 @@ export default function PlatformFulfillmentPage() {
刷新二维码
</Button>
) : null}
{selected && can('platform_fulfillment:use') && canManualConfirmBinding(selected) ? (
<Button icon={<CheckCircleOutlined />} onClick={() => openManualBinding(selected)}>
人工确认绑定
</Button>
) : null}
{selected.account &&
selected.executionStatus !== 'completed' &&
selected.executionStatus !== 'cancelled' &&
@@ -1709,12 +1776,12 @@ export default function PlatformFulfillmentPage() {
<Card size="small" title="绑定判定(QYOOB / cjm / 7 天锁)">
{selected.bindingEvidence ? (
<Space direction="vertical" size={10} style={{ width: '100%' }}>
{!selected.bindingEvidence.selectedActionable && selected.bindingEvidence.legacyLatest ? (
{!selected.bindingEvidence.scannedRole && selected.bindingEvidence.accountCurrentRole ? (
<Alert
type="warning"
type="info"
showIcon
message="当前 cjm 出现的角色不是动作通道待确认角色"
description="不要直接确认;请等 QYOOB 出现 bindAct=0 的 pending,或让客户重新扫码。"
message={`账号已有角色 ${selected.bindingEvidence.accountCurrentRole},但本次没有扫码证据`}
description="列表显示“待扫码”是准确的:账号历史角色不能被当成本次扫码。请让客户扫码,或确认客户角色后使用“人工确认绑定”。"
/>
) : null}
<Descriptions bordered size="small" column={2}>
@@ -1762,6 +1829,23 @@ export default function PlatformFulfillmentPage() {
<Text type="secondary">-</Text>
)}
</Descriptions.Item>
<Descriptions.Item label="本次扫码角色" span={2}>
{selected.bindingEvidence.scannedRole ? (
<Text strong>{selected.bindingEvidence.scannedRole}</Text>
) : (
<Text type="secondary">未扫码(账号已有角色仅作参考)</Text>
)}
</Descriptions.Item>
<Descriptions.Item label="账号当前角色" span={2}>
{selected.bindingEvidence.accountCurrentRole ? (
<Text>{selected.bindingEvidence.accountCurrentRole}</Text>
) : (
<Text type="secondary">-</Text>
)}
{selected.bindingEvidence.baselineRole ? (
<Text type="secondary">(扫码前基线:{selected.bindingEvidence.baselineRole})</Text>
) : null}
</Descriptions.Item>
<Descriptions.Item label="本次可确认" span={2}>
<Space wrap>
<Tag color={selected.bindingEvidence.confirmable ? 'green' : 'default'}>
@@ -1771,7 +1855,9 @@ export default function PlatformFulfillmentPage() {
{selected.bindingEvidence.decisionReason || '-'}
</Text>
{selected.bindingEvidence.samePair ? (
<Tag color="blue">同账号同角色,已绑定可复用</Tag>
<Tag color="blue">本次扫码与账号当前角色相同,可复用</Tag>
) : selected.bindingEvidence.accountCurrentRole && !selected.bindingEvidence.scannedRole ? (
<Tag>账号已有角色,本次未扫码</Tag>
) : null}
</Space>
</Descriptions.Item>
@@ -2090,6 +2176,57 @@ export default function PlatformFulfillmentPage() {
</Space>
</Modal>
<Modal
title={`人工确认绑定 ${manualBindTarget ? `#${manualBindTarget.id}` : ''}`}
open={Boolean(manualBindTarget)}
okText="确认绑定"
cancelText="取消"
confirmLoading={manualBinding}
onOk={() => void confirmManualBinding()}
onCancel={() => {
setManualBindTarget(null);
setManualBindRole('');
setManualBindNote('');
}}
>
<Space direction="vertical" size={12} style={{ width: '100%' }}>
<Alert
type="warning"
showIcon
message="人工确认会直接把订单标记为已绑定"
description="只在已核实客户游戏角色确实绑定在当前账号上时使用;会停止当前二维码轮询,并记录操作人、角色和备注。"
/>
<Text type="secondary">
账号当前角色:{manualBindTarget?.bindingEvidence?.accountCurrentRole || '未知'}
{manualBindTarget?.bindingEvidence?.scannedRole
? `;本次扫码角色:${manualBindTarget.bindingEvidence.scannedRole}`
: ';本次未扫码'}
</Text>
<div>
<Text strong>确认角色</Text>
<Input
value={manualBindRole}
maxLength={128}
placeholder="客户确认的游戏角色"
onChange={(event) => setManualBindRole(event.target.value)}
style={{ marginTop: 8 }}
/>
</div>
<div>
<Text strong>确认依据 / 备注</Text>
<Input.TextArea
rows={3}
maxLength={500}
showCount
value={manualBindNote}
placeholder="例如:客户已在精英宝典完成绑定,客服核对角色一致"
onChange={(event) => setManualBindNote(event.target.value)}
style={{ marginTop: 8 }}
/>
</div>
</Space>
</Modal>
<Modal
open={settingsOpen}
title="履约同步与租约设置"