fix(douyu): 同步履约状态并补齐角色资料重置流程
- 接收 order_site 客户资料重置标记,清理旧角色并恢复待填写状态 - 统一绑定失败、待人工和已分配状态的投影与页面文案 - 新增 allocated 状态迁移,避免已分配账号被折叠为准备账号 - 立即同步时同时刷新直播履约状态,主动校正历史状态差异 - 补充状态优先级、资料重置和已分配状态测试
This commit is contained in:
@@ -40,13 +40,14 @@ const { Text } = Typography
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
waiting_profile: '待客户填资料',
|
||||
preparing: '准备账号',
|
||||
allocated: '已分配',
|
||||
qr_pending: '待扫码',
|
||||
role_ready: '待确认角色',
|
||||
bound: '角色已绑定',
|
||||
waiting_operator: '待客服处理',
|
||||
processing: '处理中',
|
||||
completed: '已完成',
|
||||
failed: '失败',
|
||||
failed: '绑定失败',
|
||||
manual_required: '人工处理',
|
||||
cancelled: '已取消',
|
||||
}
|
||||
@@ -54,6 +55,7 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
waiting_profile: 'blue',
|
||||
preparing: 'gold',
|
||||
allocated: 'geekblue',
|
||||
qr_pending: 'cyan',
|
||||
role_ready: 'orange',
|
||||
bound: 'green',
|
||||
@@ -75,6 +77,14 @@ const SYSTEM_LABELS: Record<string, string> = {
|
||||
android: '安卓',
|
||||
}
|
||||
|
||||
const EVENT_LABELS: Record<string, string> = {
|
||||
task_created: '订单进入斗鱼领取队列',
|
||||
customer_link_opened: '客户打开领取链接',
|
||||
customer_profile_saved: '客户保存游戏资料',
|
||||
customer_profile_reset: '客服重置客户角色资料',
|
||||
status_changed: '领取状态更新',
|
||||
}
|
||||
|
||||
export default function AdminDouyuFulfillmentPage() {
|
||||
const { message } = App.useApp()
|
||||
const queryClient = useQueryClient()
|
||||
@@ -118,7 +128,9 @@ export default function AdminDouyuFulfillmentPage() {
|
||||
const syncMutation = useMutation({
|
||||
mutationFn: syncAdminDouyuFulfillmentTasks,
|
||||
onSuccess: async (response) => {
|
||||
message.success(`同步完成:新增 ${response.data.created},更新 ${response.data.updated}`)
|
||||
message.success(
|
||||
`同步完成:新增 ${response.data.created},更新 ${response.data.updated},核验状态 ${response.data.checked}`,
|
||||
)
|
||||
await refreshAll()
|
||||
},
|
||||
onError: (error) => message.error(error instanceof Error ? error.message : '同步失败'),
|
||||
@@ -371,7 +383,11 @@ export default function AdminDouyuFulfillmentPage() {
|
||||
color: event.event_type.includes('failed') ? 'red' : 'blue',
|
||||
children: (
|
||||
<Space direction="vertical" size={2}>
|
||||
<Text strong>{event.event_type}</Text>
|
||||
<Text strong>{EVENT_LABELS[event.event_type] || event.event_type}</Text>
|
||||
{event.event_type === 'customer_profile_reset' &&
|
||||
event.detail_json.reason ? (
|
||||
<Text>{String(event.detail_json.reason)}</Text>
|
||||
) : null}
|
||||
<Text type="secondary">
|
||||
{formatAdminDateTime(event.created_at)} · {event.actor_type}
|
||||
</Text>
|
||||
|
||||
@@ -34,13 +34,14 @@ const BINDING_FAILURE_ISSUES = new Set([
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
waiting_profile: '等待填写资料',
|
||||
preparing: '正在准备账号',
|
||||
allocated: '账号已分配',
|
||||
qr_pending: '等待扫码绑定',
|
||||
role_ready: '请确认游戏角色',
|
||||
bound: '角色已绑定',
|
||||
waiting_operator: '待客服处理',
|
||||
processing: '正在兑换',
|
||||
completed: '领取完成',
|
||||
failed: '处理失败',
|
||||
failed: '角色绑定失败',
|
||||
manual_required: '等待人工处理',
|
||||
cancelled: '订单已取消',
|
||||
}
|
||||
@@ -79,10 +80,20 @@ export default function DouyuFulfillmentPage() {
|
||||
const [bindingQrExpanded, setBindingQrExpanded] = useState(false)
|
||||
const [nowMs, setNowMs] = useState(() => Date.now())
|
||||
const autoStartRef = useRef('')
|
||||
const customerRoleRef = useRef('')
|
||||
|
||||
const applyData = useCallback((next: DouyuCustomerFulfillment) => {
|
||||
const previousRole = customerRoleRef.current
|
||||
const nextRole = next.task.customer_role_name || ''
|
||||
customerRoleRef.current = nextRole
|
||||
setData(next)
|
||||
setRoleName((current) => current || next.task.customer_role_name || '')
|
||||
if (previousRole && !nextRole) {
|
||||
setRoleName('')
|
||||
setPlatform('wechat')
|
||||
setSystem('android')
|
||||
} else {
|
||||
setRoleName((current) => current || nextRole)
|
||||
}
|
||||
if (next.task.customer_platform === 'qq' || next.task.customer_platform === 'wechat') {
|
||||
setPlatform(next.task.customer_platform)
|
||||
}
|
||||
@@ -167,7 +178,13 @@ export default function DouyuFulfillmentPage() {
|
||||
useEffect(() => {
|
||||
if (!task || !live || needsProfile || live.qrUrl || live.bindConfirmed) return
|
||||
if (!live.accountReady) return
|
||||
if (task.status !== 'preparing' && task.status !== 'waiting_profile') return
|
||||
if (
|
||||
task.status !== 'preparing' &&
|
||||
task.status !== 'allocated' &&
|
||||
task.status !== 'waiting_profile'
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (autoStartRef.current === orderNo) return
|
||||
autoStartRef.current = orderNo
|
||||
let cancelled = false
|
||||
|
||||
@@ -14,7 +14,10 @@ export function fetchAdminDouyuFulfillmentTasks(params: {
|
||||
}
|
||||
|
||||
export function syncAdminDouyuFulfillmentTasks() {
|
||||
return apiPost<{ created: number; updated: number }>('/api/v1/admin/douyu-fulfillment/sync', {})
|
||||
return apiPost<{ created: number; updated: number; checked: number }>(
|
||||
'/api/v1/admin/douyu-fulfillment/sync',
|
||||
{},
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchAdminDouyuFulfillmentDetail(orderNo: string) {
|
||||
|
||||
@@ -58,6 +58,8 @@ export type DouyuLiveBindingState = {
|
||||
platName: string
|
||||
bindReadyForConfirm: boolean
|
||||
bindConfirmed: boolean
|
||||
customerProfileReset?: boolean
|
||||
resetReason?: string
|
||||
completedAt: string | null
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user