发布(0.4.6): 修复预售兑换记录判定与详情展示并新增工作台强制发放
This commit is contained in:
@@ -301,6 +301,31 @@ export interface DouyuCollabMetric {
|
||||
created_at: string | null;
|
||||
}
|
||||
|
||||
export interface DouyuCollabExchangeRecord {
|
||||
commodity_id: string;
|
||||
commodity_name: string;
|
||||
score: number | null;
|
||||
exchange_num: number;
|
||||
show_name: string;
|
||||
role_name: string;
|
||||
pic: string;
|
||||
occurred_at: string | null;
|
||||
matched: boolean;
|
||||
match_reason: string;
|
||||
}
|
||||
|
||||
export interface DouyuCollabExchangeRecordsResponse {
|
||||
order_id: number;
|
||||
account_id: number | null;
|
||||
account_username: string;
|
||||
refreshed: boolean;
|
||||
synced_at: string | null;
|
||||
total: number;
|
||||
matched_count: number;
|
||||
error: string;
|
||||
records: DouyuCollabExchangeRecord[];
|
||||
}
|
||||
|
||||
export interface DouyuCollabTimeline {
|
||||
id: number;
|
||||
action: string;
|
||||
@@ -526,6 +551,14 @@ export const douyuCollabApi = {
|
||||
api.get<DouyuCollabTimeline[], DouyuCollabTimeline[]>(`/douyu/external-orders/${id}/timeline`),
|
||||
metrics: (id: number) =>
|
||||
api.get<DouyuCollabMetric[], DouyuCollabMetric[]>(`/douyu/external-orders/${id}/metrics`),
|
||||
exchangeRecords: (id: number) =>
|
||||
api.get<DouyuCollabExchangeRecordsResponse, DouyuCollabExchangeRecordsResponse>(
|
||||
`/douyu/external-orders/${id}/exchange-records`,
|
||||
),
|
||||
queryExchangeRecords: (id: number) =>
|
||||
api.post<DouyuCollabExchangeRecordsResponse, DouyuCollabExchangeRecordsResponse>(
|
||||
`/douyu/external-orders/${id}/exchange-records/query`,
|
||||
),
|
||||
deleteOrder: (id: number) =>
|
||||
api.delete<{ success: boolean; order_no: string }, { success: boolean; order_no: string }>(
|
||||
`/douyu/external-orders/${id}`,
|
||||
|
||||
@@ -1025,6 +1025,18 @@ export interface DouyuTaskBatchRequest {
|
||||
payload?: Record<string, unknown>;
|
||||
platform_task_id?: number;
|
||||
recharge_confirmation_token?: string;
|
||||
force_occupied?: boolean;
|
||||
}
|
||||
|
||||
export interface DouyuOccupiedForceCandidate {
|
||||
account_id: number;
|
||||
account_name: string;
|
||||
account_role: string;
|
||||
platform_task_id: number | null;
|
||||
platform_order_id: string;
|
||||
customer_role_name: string;
|
||||
sku_name: string;
|
||||
lease_batch_id: string;
|
||||
}
|
||||
|
||||
export interface DouyuTaskBatchResult {
|
||||
@@ -1036,6 +1048,8 @@ export interface DouyuTaskBatchResult {
|
||||
window_minutes?: number;
|
||||
amount?: number;
|
||||
account_names?: string[];
|
||||
requires_force_confirmation?: boolean;
|
||||
occupied_accounts?: DouyuOccupiedForceCandidate[];
|
||||
message?: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ import type {
|
||||
DouyuCollabAccountLookup,
|
||||
DouyuCollabAccountRecommendation,
|
||||
DouyuCollabCkExportResult,
|
||||
DouyuCollabExchangeRecord,
|
||||
DouyuCollabExchangeRecordsResponse,
|
||||
DouyuCollabGift,
|
||||
DouyuCollabGoods,
|
||||
DouyuCollabMetric,
|
||||
@@ -189,6 +191,9 @@ export default function DouyuCollabPage() {
|
||||
const [detailOpen, setDetailOpen] = useState(false);
|
||||
const [detailMetrics, setDetailMetrics] = useState<DouyuCollabMetric[]>([]);
|
||||
const [detailTimeline, setDetailTimeline] = useState<DouyuCollabTimeline[]>([]);
|
||||
const [detailExchangeRecords, setDetailExchangeRecords] =
|
||||
useState<DouyuCollabExchangeRecordsResponse | null>(null);
|
||||
const [detailRecordsLoading, setDetailRecordsLoading] = useState(false);
|
||||
const [detailLoading, setDetailLoading] = useState(false);
|
||||
const handledQueryOrderIdRef = useRef(0);
|
||||
const queryOrderId = Number(searchParams.get('orderId') || 0);
|
||||
@@ -894,14 +899,16 @@ export default function DouyuCollabPage() {
|
||||
setDetailOpen(true);
|
||||
setDetailLoading(true);
|
||||
try {
|
||||
const [metrics, timeline, latest] = await Promise.all([
|
||||
const [metrics, timeline, latest, exchangeRecords] = await Promise.all([
|
||||
douyuCollabApi.metrics(orderId),
|
||||
douyuCollabApi.timeline(orderId),
|
||||
douyuCollabApi.getOrder(orderId),
|
||||
douyuCollabApi.exchangeRecords(orderId).catch(() => null),
|
||||
]);
|
||||
setDetailMetrics(metrics);
|
||||
setDetailTimeline(timeline);
|
||||
setDetail(latest);
|
||||
setDetailExchangeRecords(exchangeRecords);
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
} finally {
|
||||
@@ -909,6 +916,23 @@ export default function DouyuCollabPage() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const refreshDetailExchangeRecords = async (order: DouyuCollabOrder) => {
|
||||
setDetailRecordsLoading(true);
|
||||
try {
|
||||
const res = await douyuCollabApi.queryExchangeRecords(order.id);
|
||||
setDetailExchangeRecords(res);
|
||||
if (res.error) {
|
||||
message.warning(res.error);
|
||||
} else {
|
||||
message.success(`已获取最新兑换记录 ${res.total} 条(命中 ${res.matched_count} 条)`);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setDetailRecordsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!canView || !Number.isInteger(queryOrderId) || queryOrderId <= 0) return;
|
||||
if (handledQueryOrderIdRef.current === queryOrderId) return;
|
||||
@@ -3023,6 +3047,123 @@ export default function DouyuCollabPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
background: token.colorBgContainer,
|
||||
border: `1px solid ${token.colorBorderSecondary}`,
|
||||
borderRadius: 8,
|
||||
padding: 16,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
flexWrap: 'wrap',
|
||||
gap: 8,
|
||||
}}
|
||||
>
|
||||
<Space size={8} wrap>
|
||||
<Text strong>兑换记录明细</Text>
|
||||
<Tag>共 {detailExchangeRecords?.total ?? 0} 条</Tag>
|
||||
{(detailExchangeRecords?.matched_count ?? 0) > 0 && (
|
||||
<Tag color="green">命中 {detailExchangeRecords?.matched_count} 条</Tag>
|
||||
)}
|
||||
{detailExchangeRecords?.synced_at && (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
同步于 {formatTime(detailExchangeRecords.synced_at)}
|
||||
</Text>
|
||||
)}
|
||||
</Space>
|
||||
{canEdit && detail.account_exists && (
|
||||
<Button
|
||||
size="small"
|
||||
icon={<SearchOutlined />}
|
||||
loading={detailRecordsLoading}
|
||||
onClick={() => void refreshDetailExchangeRecords(detail)}
|
||||
>
|
||||
查询最新兑换记录
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{detailExchangeRecords?.error && (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
style={{ marginTop: 10 }}
|
||||
message={detailExchangeRecords.error}
|
||||
/>
|
||||
)}
|
||||
<div style={{ marginTop: 12 }}>
|
||||
{detailRecordsLoading && !detailExchangeRecords?.records.length ? (
|
||||
<Text type="secondary">正在查询最新兑换记录…</Text>
|
||||
) : detailExchangeRecords?.records.length ? (
|
||||
<Table<DouyuCollabExchangeRecord>
|
||||
size="small"
|
||||
pagination={false}
|
||||
scroll={{ y: 240 }}
|
||||
rowKey={(rec, index) => `${rec.commodity_id}-${rec.occurred_at || index}-${index}`}
|
||||
dataSource={detailExchangeRecords.records}
|
||||
columns={[
|
||||
{
|
||||
title: '礼包名称',
|
||||
dataIndex: 'commodity_name',
|
||||
render: (_: unknown, rec) => (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text strong={rec.matched}>{rec.commodity_name || '-'}</Text>
|
||||
{rec.commodity_id && (
|
||||
<Text type="secondary" style={{ fontSize: 11 }}>
|
||||
{rec.commodity_id}
|
||||
</Text>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '兑换角色',
|
||||
dataIndex: 'show_name',
|
||||
render: (_: unknown, rec) => rec.show_name || rec.role_name || '-',
|
||||
},
|
||||
{
|
||||
title: '积分 / 数量',
|
||||
width: 110,
|
||||
render: (_: unknown, rec) => (
|
||||
<Text>
|
||||
{rec.score ?? '-'} / ×{rec.exchange_num || 1}
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '兑换时间',
|
||||
dataIndex: 'occurred_at',
|
||||
width: 165,
|
||||
render: (value: string | null) => formatTime(value),
|
||||
},
|
||||
{
|
||||
title: '判定',
|
||||
dataIndex: 'matched',
|
||||
width: 125,
|
||||
render: (_: unknown, rec) =>
|
||||
rec.matched ? (
|
||||
<Tag color="green">{rec.match_reason || '命中本单'}</Tag>
|
||||
) : (
|
||||
<Tag color={rec.match_reason === '其他礼包' ? 'default' : 'orange'}>
|
||||
{rec.match_reason || '未命中'}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description="暂无缓存兑换记录,点击右上角「查询最新兑换记录」实时获取"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} xl={12}>
|
||||
<div
|
||||
|
||||
@@ -188,6 +188,7 @@ const EVENT_LABELS: Record<string, string> = {
|
||||
douyu_operation_succeeded: '斗鱼操作成功',
|
||||
douyu_operation_failed: '斗鱼操作失败',
|
||||
douyu_operation_stopped: '斗鱼操作已停止',
|
||||
workbench_force_exchange: '工作台已强制执行兑换',
|
||||
task_cancelled: '任务已取消',
|
||||
task_restored: '恢复已取消任务',
|
||||
};
|
||||
@@ -461,6 +462,14 @@ function eventDescription(event: { eventType: string; detail: Record<string, unk
|
||||
const roleText = prev && prev !== next ? `${prev} → ${next}` : next;
|
||||
return `修改客户资料:${roleText}(${plat} / ${sys})${detail.reopenedBinding ? ';已重置失败状态待重扫' : ''}`;
|
||||
}
|
||||
if (event.eventType === 'workbench_force_exchange') {
|
||||
const op = String(detail.operatorUsername || '运营/管理员');
|
||||
const item = String(detail.goodsName || detail.commodityId || '-');
|
||||
const role = String(detail.accountRole || '-');
|
||||
const acc = String(detail.accountUsername || '-');
|
||||
const label = String(detail.taskLabel || detail.taskType || '兑换商品');
|
||||
return `${op} 在总工作台强制执行「${label}」:商品 ${item},账号 ${acc}(绑定角色 ${role},批次 ${String(detail.batchId || '-')})`;
|
||||
}
|
||||
if (event.eventType === 'task_created') return '订单已进入直播账号履约工作台';
|
||||
return '履约状态已更新';
|
||||
}
|
||||
|
||||
@@ -1043,6 +1043,7 @@ export default function DouyuTasksPage({
|
||||
accountIds?: number[],
|
||||
extraPayload: Record<string, unknown> = {},
|
||||
rechargeConfirmationToken?: string,
|
||||
forceOccupied = false,
|
||||
) => {
|
||||
const ids = accountIds || selectedIds;
|
||||
if (ids.length === 0) {
|
||||
@@ -1087,7 +1088,59 @@ export default function DouyuTasksPage({
|
||||
concurrency: batchConcurrency,
|
||||
payload,
|
||||
recharge_confirmation_token: rechargeConfirmationToken,
|
||||
force_occupied: forceOccupied || undefined,
|
||||
});
|
||||
if (result.requires_force_confirmation) {
|
||||
const occupiedRows = result.occupied_accounts || [];
|
||||
Modal.confirm({
|
||||
title: '确认账号与角色后强制发放',
|
||||
width: 560,
|
||||
content: (
|
||||
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
||||
<Text>{result.message || '以下账号当前由平台履约订单占用,确认斗鱼号与角色一致后可强制发放:'}</Text>
|
||||
{occupiedRows.map((item) => (
|
||||
<div
|
||||
key={item.account_id}
|
||||
style={{
|
||||
padding: '8px 10px',
|
||||
borderRadius: 6,
|
||||
border: '1px solid #d9d9d9',
|
||||
fontSize: 12,
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<Text strong>{item.account_name}</Text> · 当前绑定角色:
|
||||
<Text strong>{item.account_role || '未获取'}</Text>
|
||||
</div>
|
||||
<div style={{ marginTop: 2, color: '#666' }}>
|
||||
占用订单:{item.platform_order_id || item.lease_batch_id}
|
||||
{item.sku_name ? ` · 原商品:${item.sku_name}` : ''}
|
||||
{item.customer_role_name ? ` · 订单角色:${item.customer_role_name}` : ''}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{selectedXpdGoods?.name || selectedGoodsId ? (
|
||||
<Text type="secondary">
|
||||
即将发放商品:<Text strong>{selectedXpdGoods?.name || selectedGoodsId}</Text>(履约单保持当前状态,将在履约时间线留痕)
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
okText: '确认强制发放',
|
||||
okButtonProps: { danger: true },
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
await startTask(
|
||||
taskType,
|
||||
ids,
|
||||
extraPayload,
|
||||
rechargeConfirmationToken,
|
||||
true,
|
||||
);
|
||||
},
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if (result.requires_confirmation) {
|
||||
const accountText = (result.account_names || []).join('、');
|
||||
Modal.confirm({
|
||||
|
||||
Reference in New Issue
Block a user