fix(fulfillment): 保持外部协作人工数据并支持转人工
This commit is contained in:
@@ -98,6 +98,11 @@ export const platformFulfillmentApi = {
|
||||
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||
`/platform-fulfillment/tasks/${taskId}/release`,
|
||||
),
|
||||
releaseToManual: (taskId: number, reason: string) =>
|
||||
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||
`/platform-fulfillment/tasks/${taskId}/release-manual`,
|
||||
{ reason },
|
||||
),
|
||||
markManual: (taskId: number, reason = '') =>
|
||||
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||
`/platform-fulfillment/tasks/${taskId}/manual`,
|
||||
|
||||
@@ -96,6 +96,7 @@ const EVENT_LABELS: Record<string, string> = {
|
||||
exchange_eligibility_checked: '刷新兑换资格',
|
||||
manual_exchange_completed: '人工兑换完成',
|
||||
marked_manual_required: '转人工处理',
|
||||
released_to_manual: '释放账号并转人工',
|
||||
task_cancelled: '任务已取消',
|
||||
task_restored: '恢复已取消任务',
|
||||
};
|
||||
@@ -185,7 +186,7 @@ function eventLabel(value: string) {
|
||||
|
||||
function eventColor(value: string) {
|
||||
if (value.includes('failed') || value.includes('cancelled')) return 'red';
|
||||
if (value.includes('manual_required')) return 'orange';
|
||||
if (value.includes('manual_required') || value.includes('released_to_manual')) return 'orange';
|
||||
if (value.includes('completed') || value.includes('allocated') || value.includes('restored')) return 'green';
|
||||
return 'blue';
|
||||
}
|
||||
@@ -225,6 +226,9 @@ function eventDescription(event: { eventType: string; detail: Record<string, unk
|
||||
if (event.eventType === 'marked_manual_required') {
|
||||
return String(detail.reason || '已转人工处理');
|
||||
}
|
||||
if (event.eventType === 'released_to_manual') {
|
||||
return `转人工原因:${String(detail.reason || '以外部单协作人工处理为准')}`;
|
||||
}
|
||||
if (event.eventType === 'task_cancelled') {
|
||||
return `取消原因:${String(detail.reason || '人工取消')}`;
|
||||
}
|
||||
@@ -282,6 +286,9 @@ export default function PlatformFulfillmentPage() {
|
||||
const [restoreTarget, setRestoreTarget] = useState<PlatformFulfillmentTask | null>(null);
|
||||
const [restoreReason, setRestoreReason] = useState('');
|
||||
const [restoring, setRestoring] = useState(false);
|
||||
const [manualReleaseTarget, setManualReleaseTarget] = useState<PlatformFulfillmentTask | null>(null);
|
||||
const [manualReleaseReason, setManualReleaseReason] = useState('');
|
||||
const [manualReleasing, setManualReleasing] = useState(false);
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||
const [selectedId, setSelectedId] = useState<number | null>(null);
|
||||
const [detail, setDetail] = useState<PlatformFulfillmentDetail | null>(null);
|
||||
@@ -535,6 +542,32 @@ export default function PlatformFulfillmentPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const releaseTaskToManual = async () => {
|
||||
if (!manualReleaseTarget) return;
|
||||
const reason = manualReleaseReason.trim();
|
||||
if (reason.length < 2) {
|
||||
message.warning('请填写转人工原因');
|
||||
return;
|
||||
}
|
||||
setManualReleasing(true);
|
||||
try {
|
||||
const result = await platformFulfillmentApi.releaseToManual(
|
||||
manualReleaseTarget.id,
|
||||
reason,
|
||||
);
|
||||
setDetail(result);
|
||||
setSelectedId(result.task.id);
|
||||
setManualReleaseTarget(null);
|
||||
setManualReleaseReason('');
|
||||
await loadTasks();
|
||||
message.success('账号已释放,任务已转人工处理');
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setManualReleasing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const runDouyuAccountAction = async (taskType: string) => {
|
||||
if (!selected?.account) {
|
||||
message.warning('当前履约任务还没有分配斗鱼账号');
|
||||
@@ -892,7 +925,25 @@ export default function PlatformFulfillmentPage() {
|
||||
查看二维码
|
||||
</Button>
|
||||
) : null}
|
||||
{selected.account ? <Button onClick={() => void runTaskAction(() => platformFulfillmentApi.release(selected.id))}>释放账号</Button> : null}
|
||||
{selected.account ? (
|
||||
<Button onClick={() => void runTaskAction(() => platformFulfillmentApi.release(selected.id))}>
|
||||
释放并重新选号
|
||||
</Button>
|
||||
) : null}
|
||||
{selected.account &&
|
||||
selected.executionStatus !== 'completed' &&
|
||||
selected.executionStatus !== 'cancelled' &&
|
||||
can('platform_fulfillment:use') ? (
|
||||
<Button
|
||||
icon={<UserSwitchOutlined />}
|
||||
onClick={() => {
|
||||
setManualReleaseTarget(selected);
|
||||
setManualReleaseReason('以外部单协作人工处理为准');
|
||||
}}
|
||||
>
|
||||
释放并转人工
|
||||
</Button>
|
||||
) : null}
|
||||
{canResetBinding(selected) ? (
|
||||
<Button danger icon={<UndoOutlined />} onClick={() => resetBinding(selected)}>
|
||||
重置角色资料
|
||||
@@ -1308,6 +1359,36 @@ export default function PlatformFulfillmentPage() {
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
title={`释放并转人工 ${manualReleaseTarget ? `#${manualReleaseTarget.id}` : ''}`}
|
||||
open={Boolean(manualReleaseTarget)}
|
||||
okText="确认转人工"
|
||||
cancelText="取消"
|
||||
confirmLoading={manualReleasing}
|
||||
onOk={() => void releaseTaskToManual()}
|
||||
onCancel={() => {
|
||||
setManualReleaseTarget(null);
|
||||
setManualReleaseReason('');
|
||||
}}
|
||||
>
|
||||
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="释放当前账号后不会自动重新选号"
|
||||
description="任务会进入“待人工”,并通知订单侧当前由人工处理。"
|
||||
/>
|
||||
<Input.TextArea
|
||||
rows={3}
|
||||
maxLength={2000}
|
||||
showCount
|
||||
value={manualReleaseReason}
|
||||
placeholder="请填写转人工原因"
|
||||
onChange={(event) => setManualReleaseReason(event.target.value)}
|
||||
/>
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
open={settingsOpen}
|
||||
title="履约同步与租约设置"
|
||||
|
||||
Reference in New Issue
Block a user