feat(fulfillment): 增加取消恢复与操作人审计
This commit is contained in:
@@ -108,4 +108,9 @@ export const platformFulfillmentApi = {
|
||||
`/platform-fulfillment/tasks/${taskId}/cancel`,
|
||||
{ reason },
|
||||
),
|
||||
restore: (taskId: number, reason: string) =>
|
||||
api.post<PlatformFulfillmentDetail, PlatformFulfillmentDetail>(
|
||||
`/platform-fulfillment/tasks/${taskId}/restore`,
|
||||
{ reason },
|
||||
),
|
||||
};
|
||||
|
||||
@@ -2229,6 +2229,9 @@ export interface PlatformFulfillmentEvent {
|
||||
eventType: string;
|
||||
actorType: string;
|
||||
actorId: string;
|
||||
actorName: string;
|
||||
actorRole: string;
|
||||
actorRoleLabel: string;
|
||||
detail: Record<string, unknown>;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ const EXCHANGE_STATUS_LABELS: Record<string, string> = {
|
||||
|
||||
const ACTOR_TYPE_LABELS: Record<string, string> = {
|
||||
system: '系统',
|
||||
user: '运营',
|
||||
user: '操作人',
|
||||
customer: '客户',
|
||||
connector: '连接器',
|
||||
};
|
||||
@@ -97,6 +97,7 @@ const EVENT_LABELS: Record<string, string> = {
|
||||
manual_exchange_completed: '人工兑换完成',
|
||||
marked_manual_required: '转人工处理',
|
||||
task_cancelled: '任务已取消',
|
||||
task_restored: '恢复已取消任务',
|
||||
};
|
||||
|
||||
const ISSUE_LABELS: Record<string, string> = {
|
||||
@@ -111,6 +112,7 @@ const ISSUE_LABELS: Record<string, string> = {
|
||||
customer_role_cooldown: '游戏角色仍在换绑冷却期',
|
||||
lease_expired: '账号租约已过期',
|
||||
manual_required: '需要人工处理',
|
||||
source_cancelled: '来源订单已取消',
|
||||
};
|
||||
|
||||
const DOUYU_ACTION_LABELS: Record<string, string> = {
|
||||
@@ -184,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('completed') || value.includes('allocated')) return 'green';
|
||||
if (value.includes('completed') || value.includes('allocated') || value.includes('restored')) return 'green';
|
||||
return 'blue';
|
||||
}
|
||||
|
||||
@@ -226,6 +228,10 @@ function eventDescription(event: { eventType: string; detail: Record<string, unk
|
||||
if (event.eventType === 'task_cancelled') {
|
||||
return `取消原因:${String(detail.reason || '人工取消')}`;
|
||||
}
|
||||
if (event.eventType === 'task_restored') {
|
||||
const status = String(detail.restoredExecutionStatus || '');
|
||||
return `恢复原因:${String(detail.reason || '误取消恢复')};恢复后状态:${statusLabel(status)}`;
|
||||
}
|
||||
if (event.eventType === 'binding_started') return '已生成客户绑定二维码';
|
||||
if (event.eventType === 'binding_confirm_started') return '已提交游戏角色绑定确认';
|
||||
if (event.eventType === 'binding_failed') {
|
||||
@@ -273,6 +279,9 @@ export default function PlatformFulfillmentPage() {
|
||||
const [syncing, setSyncing] = useState(false);
|
||||
const [collabSyncing, setCollabSyncing] = useState(false);
|
||||
const [rowCollabSyncingId, setRowCollabSyncingId] = useState<number | null>(null);
|
||||
const [restoreTarget, setRestoreTarget] = useState<PlatformFulfillmentTask | null>(null);
|
||||
const [restoreReason, setRestoreReason] = useState('');
|
||||
const [restoring, setRestoring] = useState(false);
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||
const [selectedId, setSelectedId] = useState<number | null>(null);
|
||||
const [detail, setDetail] = useState<PlatformFulfillmentDetail | null>(null);
|
||||
@@ -492,7 +501,7 @@ export default function PlatformFulfillmentPage() {
|
||||
Modal.confirm({
|
||||
title: '确认取消履约任务?',
|
||||
content:
|
||||
'取消后会立即停止当前绑定或兑换任务,释放已占用的斗鱼账号,并通知订单侧更新为已取消。该操作不可撤销。',
|
||||
'取消后会立即停止当前绑定或兑换任务,释放已占用的斗鱼账号,并通知订单侧更新为已取消。若属误操作,仅超级管理员可核对来源订单后恢复。',
|
||||
okText: '确认取消并释放账号',
|
||||
okButtonProps: { danger: true },
|
||||
cancelText: '返回',
|
||||
@@ -503,6 +512,29 @@ export default function PlatformFulfillmentPage() {
|
||||
});
|
||||
};
|
||||
|
||||
const restoreTask = async () => {
|
||||
if (!restoreTarget) return;
|
||||
const reason = restoreReason.trim();
|
||||
if (reason.length < 2) {
|
||||
message.warning('请填写恢复原因');
|
||||
return;
|
||||
}
|
||||
setRestoring(true);
|
||||
try {
|
||||
const result = await platformFulfillmentApi.restore(restoreTarget.id, reason);
|
||||
setDetail(result);
|
||||
setSelectedId(result.task.id);
|
||||
setRestoreTarget(null);
|
||||
setRestoreReason('');
|
||||
await loadTasks();
|
||||
message.success('任务已恢复并重新进入履约队列');
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setRestoring(false);
|
||||
}
|
||||
};
|
||||
|
||||
const runDouyuAccountAction = async (taskType: string) => {
|
||||
if (!selected?.account) {
|
||||
message.warning('当前履约任务还没有分配斗鱼账号');
|
||||
@@ -866,11 +898,27 @@ export default function PlatformFulfillmentPage() {
|
||||
重置角色资料
|
||||
</Button>
|
||||
) : null}
|
||||
{selected.executionStatus !== 'completed' && selected.executionStatus !== 'cancelled' ? (
|
||||
{can('platform_fulfillment:cancel') &&
|
||||
selected.executionStatus !== 'completed' &&
|
||||
selected.executionStatus !== 'cancelled' ? (
|
||||
<Button danger onClick={() => cancelTask(selected)}>
|
||||
取消
|
||||
</Button>
|
||||
) : null}
|
||||
{can('platform_fulfillment:restore') &&
|
||||
selected.executionStatus === 'cancelled' &&
|
||||
selected.issueCode !== 'source_cancelled' ? (
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<UndoOutlined />}
|
||||
onClick={() => {
|
||||
setRestoreTarget(selected);
|
||||
setRestoreReason('');
|
||||
}}
|
||||
>
|
||||
恢复任务
|
||||
</Button>
|
||||
) : null}
|
||||
</Space>
|
||||
) : null;
|
||||
|
||||
@@ -1166,8 +1214,10 @@ export default function PlatformFulfillmentPage() {
|
||||
<Text strong>{eventLabel(event.eventType)}</Text>
|
||||
<Text>{eventDescription(event)}</Text>
|
||||
<Text type="secondary">
|
||||
{formatTime(event.createdAt)} · {ACTOR_TYPE_LABELS[event.actorType] || '系统'}
|
||||
{event.actorId ? ` · 操作人 ${event.actorId}` : ''}
|
||||
{formatTime(event.createdAt)} ·{' '}
|
||||
{event.actorRoleLabel || ACTOR_TYPE_LABELS[event.actorType] || '系统'}
|
||||
{event.actorName ? ` · ${event.actorName}` : ''}
|
||||
{event.actorId ? ` · ID ${event.actorId}` : ''}
|
||||
</Text>
|
||||
</Space>
|
||||
),
|
||||
@@ -1228,6 +1278,36 @@ export default function PlatformFulfillmentPage() {
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
title={`恢复已取消任务 ${restoreTarget ? `#${restoreTarget.id}` : ''}`}
|
||||
open={Boolean(restoreTarget)}
|
||||
okText="确认恢复"
|
||||
cancelText="取消"
|
||||
confirmLoading={restoring}
|
||||
onOk={() => void restoreTask()}
|
||||
onCancel={() => {
|
||||
setRestoreTarget(null);
|
||||
setRestoreReason('');
|
||||
}}
|
||||
>
|
||||
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="恢复后会重新进入履约队列"
|
||||
description="系统不会复用已释放的旧账号;若商品映射缺失,任务会先恢复到待映射状态。"
|
||||
/>
|
||||
<Input.TextArea
|
||||
rows={3}
|
||||
maxLength={2000}
|
||||
showCount
|
||||
value={restoreReason}
|
||||
placeholder="请填写恢复原因,例如:客服误点取消,经核对订单仍有效"
|
||||
onChange={(event) => setRestoreReason(event.target.value)}
|
||||
/>
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
open={settingsOpen}
|
||||
title="履约同步与租约设置"
|
||||
|
||||
Reference in New Issue
Block a user