重构(半自动履约): 收敛状态同步并拆分任务服务
This commit is contained in:
@@ -526,6 +526,10 @@ function applyAdminRealtimeEvent(
|
||||
if (event.type === 'order.changed' && event.scopes.includes('admin_douyu_fulfillment')) {
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-douyu-fulfillment'] })
|
||||
}
|
||||
if (event.type === 'order.changed' && event.scopes.includes('admin_semi_auto_tasks')) {
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-semi-auto-tasks'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-semi-auto-task'] })
|
||||
}
|
||||
|
||||
if (event.type === 'admin_notification.changed' && isRecord(event.data)) {
|
||||
queryClient.setQueryData(['admin-notifications'], (current: unknown) => {
|
||||
|
||||
@@ -128,13 +128,11 @@ export default function AdminSemiAutoTasksPage() {
|
||||
const listQuery = useQuery({
|
||||
queryKey: ['admin-semi-auto-tasks', params],
|
||||
queryFn: () => fetchAdminSemiAutoTasks(params),
|
||||
refetchInterval: 3000,
|
||||
})
|
||||
const detailQuery = useQuery({
|
||||
queryKey: ['admin-semi-auto-task', detailTaskId],
|
||||
queryFn: () => fetchAdminSemiAutoTask(Number(detailTaskId)),
|
||||
enabled: Boolean(detailTaskId),
|
||||
refetchInterval: detailTaskId ? 3000 : false,
|
||||
})
|
||||
const list = listQuery.data?.data?.items || []
|
||||
const pagination = listQuery.data?.data?.pagination
|
||||
@@ -479,6 +477,7 @@ export default function AdminSemiAutoTasksPage() {
|
||||
render: (_, task) => (
|
||||
<Space direction="vertical" size={2}>
|
||||
<Tag>{task.displayStatus.label}</Tag>
|
||||
<Text type="secondary">{task.displayStatus.nextAction}</Text>
|
||||
<Text type="secondary">{task.huyaUid ? `UID ${task.huyaUid}` : '未获取 UID'}</Text>
|
||||
<Text type="secondary">
|
||||
{task.platform === 'huya'
|
||||
|
||||
@@ -194,11 +194,25 @@ export default function CustomerFulfillmentPage({
|
||||
) {
|
||||
return
|
||||
}
|
||||
const dedicatedLoginPoll =
|
||||
selectedTask.loginStatus === 'qr_pending' || selectedTask.loginStatus === 'scanned'
|
||||
const dedicatedBindingPoll =
|
||||
selectedTask.platform === 'huya' &&
|
||||
(selectedTask.bindingStatus === 'qr_pending' || selectedTask.bindingStatus === 'scanned')
|
||||
if (dedicatedLoginPoll || dedicatedBindingPoll) return
|
||||
const timer = window.setInterval(() => {
|
||||
void load(true)
|
||||
}, POLL_INTERVAL_MS)
|
||||
}, 10_000)
|
||||
return () => window.clearInterval(timer)
|
||||
}, [load, orderNo, selectedTask?.executionStatus, selectedTask?.id])
|
||||
}, [
|
||||
load,
|
||||
orderNo,
|
||||
selectedTask?.bindingStatus,
|
||||
selectedTask?.executionStatus,
|
||||
selectedTask?.id,
|
||||
selectedTask?.loginStatus,
|
||||
selectedTask?.platform,
|
||||
])
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedTask) return
|
||||
@@ -725,19 +739,6 @@ export default function CustomerFulfillmentPage({
|
||||
}
|
||||
}
|
||||
|
||||
/** 资料变更后重新打开核对弹窗:只有三项完全一致才让客户直接提交平台绑定。 */
|
||||
function reopenBindingConfirm(
|
||||
nextTask: CustomerSemiAutoTask,
|
||||
nextBinding: CustomerBindingInfo | null | undefined,
|
||||
) {
|
||||
if (nextTask.bindingStatus !== 'role_ready') return false
|
||||
if (!nextBinding?.comparison || nextBinding.rebindUnchanged) return false
|
||||
if (nextBinding.comparison.verdict !== 'match') return false
|
||||
autoOpenedRoleRef.current = `${nextTask.id}:${nextBinding.bindGameRoleId || ''}`
|
||||
setBindingConfirmOpen(true)
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回第二步修改资料:
|
||||
* 立即切回资料表单(步骤条高亮第 2 步、隐藏绑定/换绑结果),同时调后端清空虎牙
|
||||
@@ -802,15 +803,7 @@ export default function CustomerFulfillmentPage({
|
||||
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
|
||||
)
|
||||
setProfileEditing(false)
|
||||
let reopened = false
|
||||
try {
|
||||
const bindingResponse = await pollCustomerBinding(orderNo, selectedTask.id)
|
||||
if (bindingResponse.data.binding) setBindingInfo(bindingResponse.data.binding)
|
||||
reopened = reopenBindingConfirm(bindingResponse.data.task, bindingResponse.data.binding)
|
||||
} catch {
|
||||
// 绑定尚未开始时没有 binding,可忽略。
|
||||
}
|
||||
message.success(reopened ? '资料已保存且与平台角色一致,请提交平台绑定' : '资料已保存')
|
||||
message.success('资料已保存,正在重新核对平台角色')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '保存角色资料失败')
|
||||
} finally {
|
||||
@@ -1460,6 +1453,15 @@ export default function CustomerFulfillmentPage({
|
||||
<span>
|
||||
三项完全一致才能提交平台绑定;请重新扫码换绑,或上一步修改资料。
|
||||
</span>
|
||||
{nextRebindText ? (
|
||||
<span>平台预计下次允许换绑:{nextRebindText}</span>
|
||||
) : null}
|
||||
{Number(bindingInfo?.rebindCooldownDays || 0) > 0 ? (
|
||||
<span>
|
||||
当前仍处于虎牙换绑冷却期,剩余约{' '}
|
||||
{Number(bindingInfo?.rebindCooldownDays || 0)} 天。
|
||||
</span>
|
||||
) : null}
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -3,6 +3,8 @@ export type SemiAutoPlatform = 'huya' | 'weibo'
|
||||
export type SemiAutoDisplayStatus = {
|
||||
key: string
|
||||
label: string
|
||||
owner: 'none' | 'customer' | 'operator' | 'system'
|
||||
nextAction: string
|
||||
}
|
||||
|
||||
export type SemiAutoTask = {
|
||||
|
||||
@@ -21,7 +21,12 @@ export type CustomerSemiAutoTask = {
|
||||
loginStatus: string
|
||||
bindingStatus: string
|
||||
executionStatus: string
|
||||
displayStatus: { key: string; label: string }
|
||||
displayStatus: {
|
||||
key: string
|
||||
label: string
|
||||
owner: 'none' | 'customer' | 'operator' | 'system'
|
||||
nextAction: string
|
||||
}
|
||||
huyaUid: string
|
||||
platformNickname: string
|
||||
bindGameAccount: string
|
||||
|
||||
Reference in New Issue
Block a user