fix(fulfillment): 修正直播账号履约绑定与取消流程

- 按活动 alias 与 cjm 双角色快照建立绑定 baseline,避免旧角色被误判为本次扫码
- 确认绑定任务固化目标角色,禁止回退确认旧角色
- 绑定失败状态优先于旧待确认标记,并支持客服重置客户角色资料
- 取消任务改为终态幂等操作,停止关联批次并默认释放账号和租约
- 补充双角色选择、重置绑定和取消释放账号测试
This commit is contained in:
yml
2026-11-18 10:59:20 +08:00
parent 8ba6379687
commit 1abc0dfdce
9 changed files with 698 additions and 36 deletions
@@ -64,6 +64,11 @@ export const platformFulfillmentApi = {
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
`/platform-fulfillment/tasks/${taskId}/bind/refresh`,
),
resetBinding: (taskId: number, reason = '客服重置角色绑定') =>
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
`/platform-fulfillment/tasks/${taskId}/bind/reset`,
{ reason },
),
confirmBinding: (taskId: number) =>
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
`/platform-fulfillment/tasks/${taskId}/bind/confirm`,
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useState } from 'react';
import { Alert, Button, Card, Descriptions, Drawer, Empty, Input, InputNumber, Modal, QRCode, Segmented, Select, Space, Switch, Table, Tabs, Tag, Timeline, Typography } from 'antd';
import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, GiftOutlined, LinkOutlined, QrcodeOutlined, ReloadOutlined, SettingOutlined, ShoppingOutlined, SyncOutlined, UserSwitchOutlined } from '@ant-design/icons';
import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, GiftOutlined, LinkOutlined, QrcodeOutlined, ReloadOutlined, SettingOutlined, ShoppingOutlined, SyncOutlined, UndoOutlined, UserSwitchOutlined } from '@ant-design/icons';
import type { ColumnsType } from 'antd/es/table';
import { douyuApi, platformFulfillmentApi } from '../api/modules';
import type { DouyuGoodsItem, DouyuTaskItem, PlatformFulfillmentDetail, PlatformFulfillmentMapping, PlatformFulfillmentSettings, PlatformFulfillmentTask } from '../api/modules';
@@ -76,6 +76,7 @@ const EVENT_LABELS: Record<string, string> = {
binding_started: '开始绑定游戏角色',
binding_confirm_started: '提交角色绑定确认',
binding_failed: '游戏角色绑定失败',
binding_reset: '重置角色资料和绑定记录',
eligibility_check_failed: '兑换资格查询失败',
exchange_eligibility_checked: '刷新兑换资格',
manual_exchange_completed: '人工兑换完成',
@@ -211,6 +212,9 @@ function eventDescription(event: { eventType: string; detail: Record<string, unk
if (event.eventType === 'binding_failed') {
return String(detail.rawError || issueLabel(String(detail.issueCode || 'binding_failed')));
}
if (event.eventType === 'binding_reset') {
return `${String(detail.reason || '客服重置角色绑定')};客户需重新填写角色资料`;
}
if (event.eventType === 'task_created') return '订单已进入直播账号履约工作台';
return '履约状态已更新';
}
@@ -229,6 +233,13 @@ function leaseExpiresLabel(expiresAt: string | null | undefined) {
return expiresAt ? formatTime(expiresAt) : '无限制';
}
function canResetBinding(task: PlatformFulfillmentTask) {
if (task.executionStatus === 'completed' || task.executionStatus === 'cancelled') {
return false;
}
return task.bindingStatus === 'failed';
}
export default function PlatformFulfillmentPage() {
const user = getUser();
const { can } = usePermissions(user);
@@ -378,6 +389,36 @@ export default function PlatformFulfillmentPage() {
}
};
const resetBinding = (task: PlatformFulfillmentTask) => {
Modal.confirm({
title: '重置角色资料和绑定记录?',
content:
'将清空本订单已填写的游戏角色、旧二维码和绑定失败状态,保留当前账号与租约。客户需要重新打开领取链接并填写角色资料。平台换绑冷却不会被绕过。',
okText: '确认重置',
okButtonProps: { danger: true },
cancelText: '取消',
onOk: () =>
runTaskAction(() =>
platformFulfillmentApi.resetBinding(task.id, '客服重置角色资料和绑定记录'),
),
});
};
const cancelTask = (task: PlatformFulfillmentTask) => {
Modal.confirm({
title: '确认取消履约任务?',
content:
'取消后会立即停止当前绑定或兑换任务,释放已占用的斗鱼账号,并通知订单侧更新为已取消。该操作不可撤销。',
okText: '确认取消并释放账号',
okButtonProps: { danger: true },
cancelText: '返回',
onOk: () =>
runTaskAction(() =>
platformFulfillmentApi.cancel(task.id, '运营取消并释放账号'),
),
});
};
const runDouyuAccountAction = async (taskType: string) => {
if (!selected?.account) {
message.warning('当前履约任务还没有分配斗鱼账号');
@@ -643,6 +684,16 @@ export default function PlatformFulfillmentPage() {
确认绑定
</Button>
) : null}
{canResetBinding(task) ? (
<Button
size="small"
danger
icon={<UndoOutlined />}
onClick={() => resetBinding(task)}
>
重置角色资料
</Button>
) : null}
{task.executionStatus === 'bound' ? (
<>
<Button size="small" icon={<SyncOutlined />} onClick={() => void runTaskAction(() => platformFulfillmentApi.refreshEligibility(task.id))}>
@@ -666,8 +717,13 @@ export default function PlatformFulfillmentPage() {
</Button>
) : null}
{selected.account ? <Button onClick={() => void runTaskAction(() => platformFulfillmentApi.release(selected.id))}>释放账号</Button> : null}
{canResetBinding(selected) ? (
<Button danger icon={<UndoOutlined />} onClick={() => resetBinding(selected)}>
重置角色资料
</Button>
) : null}
{selected.executionStatus !== 'completed' && selected.executionStatus !== 'cancelled' ? (
<Button danger onClick={() => void runTaskAction(() => platformFulfillmentApi.cancel(selected.id, '运营取消'))}>
<Button danger onClick={() => cancelTask(selected)}>
取消
</Button>
) : null}