fix(platform-fulfillment): 释放空闲连接并合并选号请求

This commit is contained in:
yml
2026-11-21 17:35:34 +08:00
parent f74573a9c0
commit 7f7943a1e8
17 changed files with 690 additions and 74 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
import api from './client';
import type {
PlatformFulfillmentAllocationResult,
PlatformFulfillmentDetail,
PlatformFulfillmentCollabSyncResult,
PlatformFulfillmentListResponse,
@@ -105,7 +106,7 @@ export const platformFulfillmentApi = {
groups: Array<{ executionStatus: string; saleMode: string; count: number }>;
}>(`/platform-fulfillment/mappings/${mappingId}/impact`),
allocate: (taskId: number) =>
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
api.post<PlatformFulfillmentAllocationResult, PlatformFulfillmentAllocationResult>(
`/platform-fulfillment/tasks/${taskId}/allocate`,
),
startBinding: (taskId: number) =>
+4
View File
@@ -2278,6 +2278,10 @@ export interface PlatformFulfillmentDetail {
events: PlatformFulfillmentEvent[];
}
export interface PlatformFulfillmentAllocationResult extends PlatformFulfillmentDetail {
allocationQueued: boolean;
}
export interface PlatformFulfillmentMapping {
id: number;
targetPlatform: string;
@@ -348,6 +348,7 @@ export default function PlatformFulfillmentPage() {
const [syncing, setSyncing] = useState(false);
const [collabSyncing, setCollabSyncing] = useState(false);
const [rowCollabSyncingId, setRowCollabSyncingId] = useState<number | null>(null);
const [allocatingTaskId, setAllocatingTaskId] = useState<number | null>(null);
const [restoreTarget, setRestoreTarget] = useState<PlatformFulfillmentTask | null>(null);
const [restoreReason, setRestoreReason] = useState('');
const [restoring, setRestoring] = useState(false);
@@ -603,6 +604,26 @@ export default function PlatformFulfillmentPage() {
}
};
const requestAllocation = async (task: PlatformFulfillmentTask) => {
if (allocatingTaskId !== null) return;
setAllocatingTaskId(task.id);
try {
const result = await platformFulfillmentApi.allocate(task.id);
setDetail(result);
setSelectedId(result.task.id);
await loadTasks();
if (result.allocationQueued) {
message.info('选号请求已提交,后台完成后会自动刷新');
} else {
message.info('该任务已在选号队列中或已经分配,请稍候刷新');
}
} catch (error) {
message.error(getErrorMessage(error));
} finally {
setAllocatingTaskId(null);
}
};
const resetBinding = (task: PlatformFulfillmentTask) => {
Modal.confirm({
title: '重置角色资料和绑定记录?',
@@ -1156,7 +1177,14 @@ export default function PlatformFulfillmentPage() {
</Button>
) : null}
{task.executionStatus === 'ready' ? (
<Button size="small" type="primary" icon={<UserSwitchOutlined />} onClick={() => void runTaskAction(() => platformFulfillmentApi.allocate(task.id))}>
<Button
size="small"
type="primary"
icon={<UserSwitchOutlined />}
loading={allocatingTaskId === task.id}
disabled={allocatingTaskId !== null && allocatingTaskId !== task.id}
onClick={() => void requestAllocation(task)}
>
人工重试选号
</Button>
) : null}