fix(fulfillment): 人工确认必须匹配账号当前角色
- 账号当前角色与确认角色不一致时拒绝人工确认 - 前端不一致时禁用确认并提示 - 补充角色不匹配回归测试 - 记录订单 2632801603123492 强制确认问题
This commit is contained in:
@@ -588,3 +588,64 @@ GET bindInfo?actAlias=20260120QYOOB
|
|||||||
bindAct、换绑等待、错误/消息;
|
bindAct、换绑等待、错误/消息;
|
||||||
- 以后先看这张表,再看平台任务状态,不再把“绑定任务 role_ready”和
|
- 以后先看这张表,再看平台任务状态,不再把“绑定任务 role_ready”和
|
||||||
“平台任务 qr_pending”混为一谈。
|
“平台任务 qr_pending”混为一谈。
|
||||||
|
|
||||||
|
### 9.11 2026-11-24 人工确认被误用:账号旧角色 ≠ 客户角色(订单 2632801603123492)
|
||||||
|
|
||||||
|
生产只读:
|
||||||
|
|
||||||
|
```text
|
||||||
|
平台任务 7882:
|
||||||
|
binding_status=bound, execution_status=bound
|
||||||
|
account_id=24087, bind_task_id=575407
|
||||||
|
账号 24087:
|
||||||
|
game_name=小乖悄, role_bind_status=bound
|
||||||
|
绑定任务 575407:
|
||||||
|
status=success, role_ready
|
||||||
|
role_name=等清晰, current_role_name=小乖悄
|
||||||
|
act_alias=cjm, action_act_aliases=[20260120QYOOB]
|
||||||
|
手工事件 58716:
|
||||||
|
binding_manually_confirmed
|
||||||
|
roleName=等清晰, account_role=小乖悄
|
||||||
|
note=等清晰, operator=45
|
||||||
|
```
|
||||||
|
|
||||||
|
后续确认:
|
||||||
|
|
||||||
|
```text
|
||||||
|
08:44/08:46 confirm_bind.precheck:
|
||||||
|
QYOOB 小乖悄 bindAct=1
|
||||||
|
cjm 等清晰 bindAct=0
|
||||||
|
confirm_bind.error:
|
||||||
|
error=-200001
|
||||||
|
msg=该账号未到可换绑时间,请使用其他账号
|
||||||
|
```
|
||||||
|
|
||||||
|
判断:
|
||||||
|
|
||||||
|
1. 客户扫到的是 cjm 的「等清晰」;
|
||||||
|
2. 账号 24087 官方当前角色仍是「小乖悄」,QYOOB 没有「等清晰」pending;
|
||||||
|
3. 账号的 `canChangeTime` 已过(2026-11-24 00:00 北京时间),所以不是账号侧冷却;
|
||||||
|
4. actBind 仍返回 `-200001`,说明更可能是**客户角色侧**未到换绑时间/绑定在其他账号;
|
||||||
|
5. 本地 `account_events` 没有「等清晰」的 bind_ok,所以本地角色锁无法提前发现,只有官方 actBind 是权威;
|
||||||
|
6. 人工确认在 08:38 直接把订单标成 bound,但账号角色仍是「小乖悄」,这是**错误的强制确认**。
|
||||||
|
|
||||||
|
根因:
|
||||||
|
|
||||||
|
- 人工确认接口只要求“填写确认角色”,没有要求账号当前角色等于确认角色;
|
||||||
|
- 运营填了「等清晰」,就绕过了 actBind 和角色校验;
|
||||||
|
- 结果订单 bound,但账号并没有换绑到客户角色,兑换会在错误角色上执行。
|
||||||
|
|
||||||
|
修复:
|
||||||
|
|
||||||
|
- 人工确认必须同时满足:
|
||||||
|
- 账号 `role_bind_status=bound`;
|
||||||
|
- 账号 `game_name` 与确认角色完全一致;
|
||||||
|
- 备注至少 2 个字;
|
||||||
|
- 不一致直接 409,提示“账号当前角色是 X,确认角色是 Y,不能人工确认;换绑请先 actBind 或使用正确账号”;
|
||||||
|
- 前端确认角色与账号当前角色不一致时禁用“确认绑定”,并显示错误提示;
|
||||||
|
- 该订单 7882 应释放/转人工,重新分配能绑定「等清晰」的账号,或等角色冷却结束,不能继续按 bound 走兑换。
|
||||||
|
|
||||||
|
教训:
|
||||||
|
|
||||||
|
人工确认只能作为“账号已经绑定到该角色、只是缺本次扫码证据”的兜底,
|
||||||
|
不能作为“换绑失败后强行标记成功”的按钮。
|
||||||
|
|||||||
@@ -3089,6 +3089,50 @@ class TestBindingAndCompletion(_Base):
|
|||||||
== 1
|
== 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_manual_confirm_rejects_role_not_currently_bound(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-mismatch-qr",
|
||||||
|
account_id=task.account_id,
|
||||||
|
account_assigned_to=self.admin_id,
|
||||||
|
task_type="get_bind_qr",
|
||||||
|
handbook_scope="elite",
|
||||||
|
status="success",
|
||||||
|
platform_task_id=task.id,
|
||||||
|
result={"bind_phase": "waiting_scan", "role_name": "等清晰"},
|
||||||
|
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()
|
||||||
|
|
||||||
|
with pytest.raises(HTTPException) as exc_info:
|
||||||
|
service.manual_confirm_binding_sync(
|
||||||
|
self.session,
|
||||||
|
task_id=task.id,
|
||||||
|
current=self.admin,
|
||||||
|
role_name="等清晰",
|
||||||
|
note="客户说角色是等清晰",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.session.refresh(task)
|
||||||
|
assert exc_info.value.status_code == 409
|
||||||
|
assert "不一致" in str(exc_info.value.detail)
|
||||||
|
assert task.binding_status == "qr_pending"
|
||||||
|
assert task.execution_status == "waiting_bind"
|
||||||
|
assert (
|
||||||
|
self.session.query(PlatformFulfillmentEvent)
|
||||||
|
.filter_by(task_id=task.id, event_type="binding_manually_confirmed")
|
||||||
|
.count()
|
||||||
|
== 0
|
||||||
|
)
|
||||||
|
|
||||||
def test_cjm_only_new_role_enters_role_ready_for_customer_confirm(self):
|
def test_cjm_only_new_role_enters_role_ready_for_customer_confirm(self):
|
||||||
task = self._allocated()
|
task = self._allocated()
|
||||||
qr_task = DouyuTask(
|
qr_task = DouyuTask(
|
||||||
|
|||||||
@@ -629,7 +629,24 @@ def manual_confirm_binding_sync(
|
|||||||
status_code=409,
|
status_code=409,
|
||||||
detail="账号没有可确认的角色,请先查询角色或填写确认角色",
|
detail="账号没有可确认的角色,请先查询角色或填写确认角色",
|
||||||
)
|
)
|
||||||
|
account_role = str(account.game_name or "").strip()
|
||||||
|
if str(account.role_bind_status or "") != "bound" or not account_role:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=409,
|
||||||
|
detail="账号当前没有已生效角色,不能人工确认;请先刷新/查询角色",
|
||||||
|
)
|
||||||
|
if account_role != confirmed_role:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=409,
|
||||||
|
detail=(
|
||||||
|
f"账号当前角色是「{account_role}」,确认角色是「{confirmed_role}」,"
|
||||||
|
"不一致,不能人工确认。人工确认只能用于账号已经绑定到该角色的场景;"
|
||||||
|
"换绑请先完成 actBind 或使用正确账号。"
|
||||||
|
),
|
||||||
|
)
|
||||||
note = str(note or "").strip()[:500]
|
note = str(note or "").strip()[:500]
|
||||||
|
if len(note) < 2:
|
||||||
|
raise HTTPException(status_code=409, detail="请填写人工确认依据/备注")
|
||||||
previous_binding = str(task.binding_status or "")
|
previous_binding = str(task.binding_status or "")
|
||||||
previous_execution = str(task.execution_status or "")
|
previous_execution = str(task.execution_status or "")
|
||||||
|
|
||||||
|
|||||||
@@ -466,6 +466,13 @@ export default function PlatformFulfillmentPage() {
|
|||||||
const [manualBindRole, setManualBindRole] = useState('');
|
const [manualBindRole, setManualBindRole] = useState('');
|
||||||
const [manualBindNote, setManualBindNote] = useState('');
|
const [manualBindNote, setManualBindNote] = useState('');
|
||||||
const [manualBinding, setManualBinding] = useState(false);
|
const [manualBinding, setManualBinding] = useState(false);
|
||||||
|
const manualBindCurrentRole =
|
||||||
|
manualBindTarget?.bindingEvidence?.accountCurrentRole || '';
|
||||||
|
const manualBindMismatch = Boolean(
|
||||||
|
manualBindCurrentRole &&
|
||||||
|
manualBindRole.trim() &&
|
||||||
|
manualBindRole.trim() !== manualBindCurrentRole,
|
||||||
|
);
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||||
const [selectedId, setSelectedId] = useState<number | null>(null);
|
const [selectedId, setSelectedId] = useState<number | null>(null);
|
||||||
const [detail, setDetail] = useState<PlatformFulfillmentDetail | null>(null);
|
const [detail, setDetail] = useState<PlatformFulfillmentDetail | null>(null);
|
||||||
@@ -860,6 +867,10 @@ export default function PlatformFulfillmentPage() {
|
|||||||
message.warning('请填写客户确认的游戏角色');
|
message.warning('请填写客户确认的游戏角色');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (manualBindCurrentRole && role !== manualBindCurrentRole) {
|
||||||
|
message.error(`账号当前角色是「${manualBindCurrentRole}」,不能人工确认「${role}」`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (note.length < 2) {
|
if (note.length < 2) {
|
||||||
message.warning('请填写人工确认依据/备注');
|
message.warning('请填写人工确认依据/备注');
|
||||||
return;
|
return;
|
||||||
@@ -2245,6 +2256,9 @@ export default function PlatformFulfillmentPage() {
|
|||||||
okText="确认绑定"
|
okText="确认绑定"
|
||||||
cancelText="取消"
|
cancelText="取消"
|
||||||
confirmLoading={manualBinding}
|
confirmLoading={manualBinding}
|
||||||
|
okButtonProps={{
|
||||||
|
disabled: manualBindMismatch || !manualBindRole.trim() || manualBindNote.trim().length < 2,
|
||||||
|
}}
|
||||||
onOk={() => void confirmManualBinding()}
|
onOk={() => void confirmManualBinding()}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
setManualBindTarget(null);
|
setManualBindTarget(null);
|
||||||
@@ -2259,6 +2273,14 @@ export default function PlatformFulfillmentPage() {
|
|||||||
message="人工确认会直接把订单标记为已绑定"
|
message="人工确认会直接把订单标记为已绑定"
|
||||||
description="只在已核实客户游戏角色确实绑定在当前账号上时使用;会停止当前二维码轮询,并记录操作人、角色和备注。"
|
description="只在已核实客户游戏角色确实绑定在当前账号上时使用;会停止当前二维码轮询,并记录操作人、角色和备注。"
|
||||||
/>
|
/>
|
||||||
|
{manualBindMismatch ? (
|
||||||
|
<Alert
|
||||||
|
type="error"
|
||||||
|
showIcon
|
||||||
|
message="确认角色与账号当前角色不一致"
|
||||||
|
description="人工确认只能用于账号已经绑定到该角色的场景;换绑必须先完成 actBind 或使用正确账号。"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
<Text type="secondary">
|
<Text type="secondary">
|
||||||
账号当前角色:{manualBindTarget?.bindingEvidence?.accountCurrentRole || '未知'}
|
账号当前角色:{manualBindTarget?.bindingEvidence?.accountCurrentRole || '未知'}
|
||||||
{manualBindTarget?.bindingEvidence?.scannedRole
|
{manualBindTarget?.bindingEvidence?.scannedRole
|
||||||
|
|||||||
Reference in New Issue
Block a user