feat(fulfillment): 支持共享账号操作并完善时间线

This commit is contained in:
yml
2026-11-18 22:32:45 +08:00
parent 86b586b96d
commit ddead2284d
23 changed files with 538 additions and 15 deletions
+4
View File
@@ -187,6 +187,9 @@ export interface AccountEventItem {
source: string;
actor_type?: string;
actor_id?: number | null;
actor_name?: string;
actor_role?: string;
actor_role_label?: string;
}
export interface AccountEventPage {
@@ -749,6 +752,7 @@ export interface DouyuTaskBatchRequest {
handbook_scope: "elite" | "esports" | "peace";
concurrency?: number;
payload?: Record<string, unknown>;
platform_task_id?: number;
}
export interface DouyuTaskBatchResult {
@@ -56,6 +56,12 @@ const CATEGORY_OPTIONS = [
{ value: 'ops', label: '人工操作' },
];
const ACTOR_TYPE_LABELS: Record<string, string> = {
user: '用户',
system: '系统',
public: '客户',
};
/** 生命周期状态 → 展示色(与账号列表页保持一致,取值域见后端 account_lifecycle)。 */
const STATUS_TONES: Record<string, string> = {
imported: 'default',
@@ -106,6 +112,16 @@ function eventTag(type: string) {
return <Tag color={style.color}>{style.label}</Tag>;
}
function actorLabel(item: AccountEventItem) {
if (item.actor_type === 'user') {
const name = item.actor_name || (item.actor_id ? `用户 #${item.actor_id}` : '用户');
const role = item.actor_role_label ? `(${item.actor_role_label})` : '';
const id = item.actor_id ? ` · ID ${item.actor_id}` : '';
return `${name}${role}${id}`;
}
return ACTOR_TYPE_LABELS[item.actor_type || 'system'] || item.actor_type || '系统';
}
const COMMODITY_STATE: Record<string, { label: string; color: string }> = {
available: { label: '可兑换', color: 'green' },
limited: { label: '已达上限', color: 'orange' },
@@ -296,6 +312,12 @@ export default function AccountDetailPage() {
width: 100,
render: (val: string) => eventTag(val),
},
{
title: '操作人',
key: 'actor',
width: 190,
render: (_value, record) => <Text>{actorLabel(record)}</Text>,
},
{ title: '说明', dataIndex: 'title', ellipsis: true },
{
title: '金额 / 变动',
@@ -97,6 +97,10 @@ const EVENT_LABELS: Record<string, string> = {
manual_exchange_completed: '人工兑换完成',
marked_manual_required: '转人工处理',
released_to_manual: '释放账号并转人工',
douyu_operation_started: '斗鱼操作已提交',
douyu_operation_succeeded: '斗鱼操作成功',
douyu_operation_failed: '斗鱼操作失败',
douyu_operation_stopped: '斗鱼操作已停止',
task_cancelled: '任务已取消',
task_restored: '恢复已取消任务',
};
@@ -187,7 +191,17 @@ function eventLabel(value: string) {
function eventColor(value: string) {
if (value.includes('failed') || value.includes('cancelled')) return 'red';
if (value.includes('manual_required') || value.includes('released_to_manual')) return 'orange';
if (value.includes('completed') || value.includes('allocated') || value.includes('restored')) return 'green';
if (
value.includes('completed') ||
value.includes('allocated') ||
value.includes('restored') ||
value.includes('succeeded')
) {
return 'green';
}
if (value.includes('douyu_operation_failed') || value.includes('douyu_operation_stopped')) {
return value.includes('stopped') ? 'orange' : 'red';
}
return 'blue';
}
@@ -236,6 +250,16 @@ function eventDescription(event: { eventType: string; detail: Record<string, unk
const status = String(detail.restoredExecutionStatus || '');
return `恢复原因:${String(detail.reason || '误取消恢复')};恢复后状态:${statusLabel(status)}`;
}
if (event.eventType === 'douyu_operation_started') {
return `${String(detail.taskLabel || detail.taskType || '斗鱼操作')};批次 ${String(detail.batchId || '-')}`;
}
if (
event.eventType === 'douyu_operation_succeeded' ||
event.eventType === 'douyu_operation_failed' ||
event.eventType === 'douyu_operation_stopped'
) {
return `${String(detail.taskLabel || detail.taskType || '斗鱼操作')}:${String(detail.message || detail.status || '-')}`;
}
if (event.eventType === 'binding_started') return '已生成客户绑定二维码';
if (event.eventType === 'binding_confirm_started') return '已提交游戏角色绑定确认';
if (event.eventType === 'binding_failed') {
@@ -595,6 +619,7 @@ export default function PlatformFulfillmentPage() {
handbook_scope: 'elite',
concurrency: 1,
payload,
platform_task_id: selected.id,
});
setDouyuActionType(taskType);
setDouyuActionBatchId(result.batch_id);