实现虎牙查询兑换记录
This commit is contained in:
@@ -153,6 +153,7 @@ export default function HuyaTasksPage() {
|
||||
const [batchId, setBatchId] = useState<string | null>(null);
|
||||
const [qrTask, setQrTask] = useState<HuyaTaskItem | null>(null);
|
||||
const [payTask, setPayTask] = useState<HuyaTaskItem | null>(null);
|
||||
const [exchangeRecordsTask, setExchangeRecordsTask] = useState<HuyaTaskItem | null>(null);
|
||||
const autoOpenedQrTaskIds = useRef<Set<number>>(new Set());
|
||||
const autoOpenQrReady = useRef(false);
|
||||
const autoOpenedPayTaskIds = useRef<Set<number>>(new Set());
|
||||
@@ -422,6 +423,14 @@ export default function HuyaTasksPage() {
|
||||
const payAccountName = payTask
|
||||
? payTask.account_nickname || payTask.account_uid || `#${payTask.account_id}`
|
||||
: '';
|
||||
const exchangeRecordsResult = exchangeRecordsTask?.result || null;
|
||||
const exchangeRecordsRaw = exchangeRecordsResult?.records;
|
||||
const exchangeRecords = Array.isArray(exchangeRecordsRaw)
|
||||
? exchangeRecordsRaw.filter((item) => item && typeof item === 'object') as Record<string, unknown>[]
|
||||
: [];
|
||||
const exchangeRecordsAccountName = exchangeRecordsTask
|
||||
? exchangeRecordsTask.account_nickname || exchangeRecordsTask.account_uid || `#${exchangeRecordsTask.account_id}`
|
||||
: '';
|
||||
|
||||
const renderTaskResult = (value: Record<string, unknown> | null, record: HuyaTaskItem) => {
|
||||
const bindQrImage = resultText(value, 'mini_qrcode_image');
|
||||
@@ -463,6 +472,18 @@ export default function HuyaTasksPage() {
|
||||
if (value?.is_bound === false) return <Tag>未绑定</Tag>;
|
||||
return <Text type="secondary">-</Text>;
|
||||
}
|
||||
if (record.task_type === 'query_exchange_records') {
|
||||
const recordCount = value?.record_count;
|
||||
if (typeof recordCount === 'number' && recordCount > 0) {
|
||||
return (
|
||||
<Button size="small" icon={<FieldTimeOutlined />} onClick={() => setExchangeRecordsTask(record)}>
|
||||
查看记录
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
if (typeof recordCount === 'number') return <Tag>记录 {recordCount} 条</Tag>;
|
||||
return <Text type="secondary">-</Text>;
|
||||
}
|
||||
if (record.task_type === 'refresh_goods') {
|
||||
const goodsCount = value?.goods_count;
|
||||
if (typeof goodsCount === 'number') return <Tag color="green">商品 {goodsCount} 个</Tag>;
|
||||
@@ -603,6 +624,49 @@ export default function HuyaTasksPage() {
|
||||
},
|
||||
];
|
||||
|
||||
const exchangeRecordColumns: TableProps<Record<string, unknown>>['columns'] = [
|
||||
{
|
||||
title: '序号',
|
||||
width: 70,
|
||||
align: 'center',
|
||||
render: (_: unknown, record, index) => String(record.index || index + 1),
|
||||
},
|
||||
{
|
||||
title: '消耗',
|
||||
width: 110,
|
||||
render: (_: unknown, record) => {
|
||||
const scoreText = record.score_text;
|
||||
if (typeof scoreText === 'string' && scoreText) return scoreText;
|
||||
const score = record.score;
|
||||
return typeof score === 'number' ? `${score}积分` : <Text type="secondary">-</Text>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '奖品名称',
|
||||
dataIndex: 'prize_name',
|
||||
ellipsis: true,
|
||||
render: (value: unknown) => typeof value === 'string' && value ? value : <Text type="secondary">-</Text>,
|
||||
},
|
||||
{
|
||||
title: '兑换状态',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
render: (_: unknown, record) => {
|
||||
const label = typeof record.status_label === 'string' ? record.status_label : '';
|
||||
const color = label === '已发放' ? 'green' : 'orange';
|
||||
return label ? <Tag color={color}>{label}</Tag> : <Text type="secondary">-</Text>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '兑换时间',
|
||||
width: 170,
|
||||
render: (_: unknown, record) => {
|
||||
const text = record.exchange_time_text;
|
||||
return typeof text === 'string' && text ? text : <Text type="secondary">-</Text>;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||
<div style={{ flexShrink: 0, marginBottom: 12, display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 12 }}>
|
||||
@@ -838,7 +902,7 @@ export default function HuyaTasksPage() {
|
||||
))}
|
||||
</div>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
当前已接入查询积分、绑定、兑换商品、充值商品列表和扫码支付。
|
||||
当前已接入查询积分、绑定、兑换记录、兑换商品、充值商品列表和扫码支付。
|
||||
</Text>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -872,6 +936,29 @@ export default function HuyaTasksPage() {
|
||||
style={{ marginTop: 4 }}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title="兑换记录"
|
||||
open={!!exchangeRecordsTask}
|
||||
onCancel={() => setExchangeRecordsTask(null)}
|
||||
footer={null}
|
||||
width={760}
|
||||
>
|
||||
<Space direction="vertical" size={10} style={{ width: '100%' }}>
|
||||
<Text type="secondary">
|
||||
{exchangeRecordsAccountName}{exchangeRecordsResult?.sid ? ` / SID ${String(exchangeRecordsResult.sid)}` : ''}
|
||||
</Text>
|
||||
<Table
|
||||
columns={exchangeRecordColumns}
|
||||
dataSource={exchangeRecords}
|
||||
rowKey={(record) => String(record.record_id || record.order_id || record.index)}
|
||||
size="small"
|
||||
pagination={false}
|
||||
scroll={{ y: 360 }}
|
||||
locale={{ emptyText: '暂无兑换记录' }}
|
||||
/>
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
title="绑定小程序码"
|
||||
open={!!qrTask}
|
||||
|
||||
Reference in New Issue
Block a user