diff --git a/web/frontend/src/pages/DouyuCollabPage.tsx b/web/frontend/src/pages/DouyuCollabPage.tsx index 05f7d91..6627403 100644 --- a/web/frontend/src/pages/DouyuCollabPage.tsx +++ b/web/frontend/src/pages/DouyuCollabPage.tsx @@ -150,6 +150,195 @@ const CK_META: Record = { '': { label: '未检测', color: 'default' }, }; +const COLLAB_ACTION_LABELS: Record = { + 'douyu:collab:create': '新建协作单', + 'douyu:collab:update': '编辑订单资料', + 'douyu:collab:account': '更换账号', + 'douyu:collab:account_unlink': '解除账号关联', + 'douyu:collab:verify': '校验账号', + 'douyu:collab:status': '修改订单状态', + 'douyu:collab:status_auto': '自动推进订单状态', + 'douyu:collab:void': '作废订单', + 'douyu:collab:void_restore': '恢复作废订单', + 'douyu:collab:points_error': '标记积分异常', + 'douyu:collab:role_error': '标记角色异常', + 'douyu:collab:activity': '查询兑换记录', + 'douyu:collab:ck_export': '导出账号与登录凭据', + 'douyu:collab:archive': '归档订单', + 'douyu:collab:unarchive': '取消归档', + 'douyu:collab:sync_from_platform_fulfillment': '同步直播履约单', + 'douyu:collab:lease_acquired': '建立账号占用', + 'douyu:collab:lease_released': '释放账号占用', + 'douyu:collab:lease_takeover': '接管账号占用', + 'douyu:collab:goods_refresh': '刷新活动商品', + 'douyu:collab:shop_update': '修改店铺', + 'douyu:collab:shop_delete': '删除店铺', + 'douyu:collab:gift_update': '修改礼包', + 'douyu:collab:gift_delete': '删除礼包', +}; + +const COLLAB_DETAIL_LABELS: Record = { + order_no: '订单编号', + orderNo: '平台订单编号', + shop: '店铺', + owner_id: '负责人编号', + account_id: '内部账号编号', + accountId: '内部账号编号', + account_username: '斗鱼账号', + accountName: '账号名称', + account_uid: '斗鱼用户编号', + account_nickname: '账号昵称', + gift_name: '礼包', + commodity_id: '商品编号', + required_points: '所需积分', + requiredPoints: '所需积分', + home_images: '主页截图', + bind_game_role: '绑定角色', + role: '当前角色', + ck_status: '登录凭据状态', + ck: '登录凭据状态', + fish_fin_balance: '鱼翅', + points: '积分', + points_balance: '当前积分', + required_total: '同账号所需积分', + surplus: '积分结余', + message: '说明', + scope: '查询范围', + verdict: '查询判定', + records: '兑换记录', + records_matched: '命中记录', + records_total: '记录总数', + from: '原状态', + to: '新状态', + status: '状态', + rollback: '是否回退', + reason: '原因', + taskId: '履约任务编号', + created: '是否新建', + released_lease: '是否释放账号占用', + previous: '原账号信息', + lease_id: '账号占用编号', + purpose: '占用用途', + batch_id: '批次编号', + draft: '是否草稿', + exchangeStatus: '兑换资格', + softReasons: '后续处理', + eliteOpened: '精英宝典已开通', + limited: '是否达到限兑上限', + limitedCount: '限兑商品数量', +}; + +const COLLAB_DETAIL_VALUE_LABELS: Record = { + valid: '正常', + invalid: '异常', + error: '异常', + unverified: '未检测', + unknown: '无法判定', + success: '成功', + failed: '失败', + incomplete: '待补资料', + to_recharge: '待充值', + recharged: '已充值', + scripted: '已上脚本', + done: '抢购成功', + points_error: '积分异常', + role_error: '账号角色异常', + void: '已作废', + allocated: '已分配', + bound: '已绑定', + ready: '待分配', + manual_required: '已转人工', + eligible: '资格正常', + points_short: '积分不足', + not_opened: '精英宝典未开通', + activity: '兑换记录', + balances: '鱼翅与积分', + balance_manual: '人工查询鱼翅与积分', + balance_batch: '批量查询鱼翅与积分', + batch: '批量查询', + platform_fulfillment: '直播账号履约', + douyu_collab: '外部单协作', +}; + +const COLLAB_DETAIL_PREFERRED_KEYS = Object.keys(COLLAB_DETAIL_LABELS); + +function collabActionLabel(action: string): string { + return COLLAB_ACTION_LABELS[action] || '其他操作'; +} + +function collabCkLabel(status: string): string { + if (status === 'valid') return '正常'; + if (status === 'invalid' || status === 'error') return '异常'; + return '未检测'; +} + +function collabValueLabel(value: unknown): string { + if (typeof value === 'boolean') return value ? '是' : '否'; + if (value === null || value === undefined || value === '') return '-'; + if (typeof value === 'number') return String(value); + if (Array.isArray(value)) { + return value.map((item) => collabValueLabel(item)).filter((item) => item !== '-').join('、') || '-'; + } + if (typeof value === 'object') { + const row = value as Record; + if ('old' in row || 'new' in row) { + return `${collabValueLabel(row.old)} → ${collabValueLabel(row.new)}`; + } + return '-'; + } + const text = String(value); + return COLLAB_DETAIL_VALUE_LABELS[text] || collabText(text); +} + +function collabText(value: string): string { + return value + .replace(/\bCookie\b/gi, '登录凭据') + .replace(/\bCK\b/gi, '登录凭据') + .replace(/\s*act=[^,,;;\s]+/gi, '') + .trim(); +} + +function collabTimelineDetailLines(detail: string): string[] { + if (!detail) return []; + let parsed: unknown; + try { + parsed = JSON.parse(detail); + } catch { + return ['明细格式无法识别']; + } + if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) { + return [collabValueLabel(parsed)]; + } + const data = parsed as Record; + const lines: string[] = []; + for (const key of COLLAB_DETAIL_PREFERRED_KEYS) { + if (!(key in data)) continue; + const value = data[key]; + if (key === 'previous' && value && typeof value === 'object' && !Array.isArray(value)) { + const previous = value as Record; + const parts = [ + previous.account_username ? `账号 ${collabValueLabel(previous.account_username)}` : '', + previous.bind_game_role ? `角色 ${collabValueLabel(previous.bind_game_role)}` : '', + previous.status ? `状态 ${collabValueLabel(previous.status)}` : '', + ].filter(Boolean); + if (parts.length) lines.push(`${COLLAB_DETAIL_LABELS[key]}:${parts.join(';')}`); + continue; + } + if (key === 'ck_status' || key === 'ck') { + lines.push(`${COLLAB_DETAIL_LABELS[key]}:${collabCkLabel(String(value || ''))}`); + continue; + } + if (key === 'home_images') { + const count = Array.isArray(value) ? value.length : Number(value || 0); + lines.push(`${COLLAB_DETAIL_LABELS[key]}:${Number.isFinite(count) ? count : 0} 张`); + continue; + } + const text = collabValueLabel(value); + if (text !== '-') lines.push(`${COLLAB_DETAIL_LABELS[key]}:${text}`); + } + return lines; +} + function formatTime(value?: string | null): string { if (!value) return '-'; const date = new Date(value); @@ -2570,144 +2759,352 @@ export default function DouyuCollabPage() { + + + {detail.order_no} + + + {detail.status_label} + + {detail.is_archived && 已归档} + +
+ + {detail.shop || '未填店铺'} · {detail.owner_name || '未指派负责人'} + +
+ + ) : ( + '协作单详情' + ) + } open={detailOpen} onClose={closeDetail} - width={760} + width="min(1180px, 96vw)" + styles={{ body: { padding: 24, background: '#f5f7fa' } }} extra={ detail && canEdit ? ( - + {detail.account_id && ( - )} - - - ) : undefined } > {detail ? ( - - - {detail.order_no} + + + + {detail.order_no} + {detail.shop || '-'} - {detail.owner_name || '-'} - - {detail.status_label} + + {detail.owner_name || '未指派'} - {detail.source_type === 'platform_fulfillment' ? ( - <> - - #{detail.source_task_id ?? '-'} - - - {detail.source_platform_order_id || detail.source_order_id || '-'} - - - {detail.last_synced_at ? formatTime(detail.last_synced_at) : '-'} - - - ) : null} - {detail.account_username || '-'} - {detail.account_nickname || '-'} - {detail.bind_game_role || '-'} - {detail.bind_game_channel || '-'} - - {detail.gift_name || '-'}({detail.required_points ?? '-'} 积分) + + + {detail.status_label} + - - 鱼翅 {detail.fish_fin_balance ?? '-'} / 积分 {detail.points_balance ?? '-'} + + {detail.created_by_name || '-'} - - 需 {detail.points_required_total ?? '-'},结余 {detail.points_surplus ?? '-'} + + {formatTime(detail.created_at)} - - {detail.points_check_message || '-'} + + {detail.updated_by_name || '-'} · {formatTime(detail.updated_at)} - - {detail.remark || '-'} + + {detail.source_type === 'platform_fulfillment' ? ( + + 直播账号履约 + 履约任务 #{detail.source_task_id ?? '-'} + {(detail.source_platform_order_id || detail.source_order_id) && ( + + 来源订单 {detail.source_platform_order_id || detail.source_order_id} + + )} + {detail.last_synced_at && ( + + 最近同步 {formatTime(detail.last_synced_at)} + + )} + + ) : ( + 人工录入 + )} + + + {detail.remark || '无'} -
+ + + {detail.account_username ? ( + {detail.account_username} + ) : ( + 尚未关联账号 + )} + + + {detail.account_nickname || '-'} + + + + {!detail.account_exists ? ( + 账号不存在 + ) : detail.has_cookie ? ( + + 登录凭据{collabCkLabel(detail.account_ck_status)} + + ) : ( + 未配置登录凭据 + )} + {detail.account_cluster && detail.account_cluster.total > 1 && ( + 同账号 {detail.account_cluster.total} 单 + )} + + + + {detail.bind_game_role || '尚未读取'} + + + {detail.bind_game_channel || '-'} + + + {formatTime(detail.bind_snapshot_at)} + + + + + + {detail.gift_name || '未选择礼包'} + + + {detail.required_points ?? '-'} + + + {detail.fish_fin_balance ?? '-'} + + + {detail.points_balance ?? '-'} + + + {detail.points_required_total ?? '-'} + + + + {detail.points_surplus ?? '-'} + + + + + {detail.points_check_reason ? ( + + {pointsReasonMeta(detail.points_check_reason).label} + + ) : ( + 未核账 + )} + {detail.points_check_message || '-'} + + + + {formatTime(detail.points_checked_at)} + + + +
主页截图 -
+
{detail.home_image_urls.length ? ( - + {detail.home_image_thumb_urls.map((url, index) => ( - {`主页截图${index + {`主页截图${index ))} ) : ( - 未上传 + )}
-
- 查询时间线 - {detailLoading ? ( - 加载中… - ) : detailMetrics.length ? ( - ({ - color: metric.verdict === 'success' ? 'green' : metric.verdict === 'failed' ? 'red' : 'gray', - children: ( - - - {metric.verdict_label || '查询'} · {formatTime(metric.created_at)} - - {metric.message} - - 鱼翅 {metric.fish_fin_balance ?? '-'} / 积分 {metric.points_balance ?? '-'} / 记录 {metric.records_matched}/{metric.records_total} - - - ), - }))} - /> - ) : ( - - )} -
- -
- 操作记录 - ({ - children: ( - - - {item.username || '-'} · {item.action} - - - {formatTime(item.created_at)} - - {item.detail && ( - - {item.detail} - - )} - - ), - }))} - /> -
+ + +
+ 查询记录 +
+ {detailLoading ? ( + 加载中… + ) : detailMetrics.length ? ( + ({ + color: + metric.verdict === 'success' + ? 'green' + : metric.verdict === 'failed' + ? 'red' + : 'gray', + children: ( + + {metric.verdict_label || '查询记录'} + + {formatTime(metric.created_at)} + + {metric.message} + + 鱼翅 {metric.fish_fin_balance ?? '-'} · 积分{' '} + {metric.points_balance ?? '-'} · 兑换记录{' '} + {metric.records_matched}/{metric.records_total} + + + ), + }))} + /> + ) : ( + + )} +
+
+ + +
+ 操作记录 +
+ {detailLoading ? ( + 加载中… + ) : detailTimeline.length ? ( + { + const detailLines = collabTimelineDetailLines(item.detail); + return { + color: item.success === false ? 'red' : 'blue', + children: ( + + + {collabActionLabel(item.action)} + + {item.username || '系统'} + + + + {formatTime(item.created_at)} + + {detailLines.map((line, index) => ( + + {line} + + ))} + + ), + }; + })} + /> + ) : ( + + )} +
+
+ +
) : detailLoading ? ( 加载中…