fix(douyu): 拆分账号资格活动窗口与库存语义

This commit is contained in:
yml
2026-11-22 20:04:49 +08:00
parent d78437c6ac
commit 1906f924bc
26 changed files with 896 additions and 174 deletions
+4 -1
View File
@@ -115,7 +115,10 @@ export const accountApi = {
exchangeRecords: (id: number) =>
api.get<AccountExchangeRecords, AccountExchangeRecords>(`/accounts/${id}/exchange-records`),
// 账号 × 商品当前能力索引(查询快照,带最后确认时间)
commodities: (id: number, params?: { scope?: string; availability?: string; limit?: number }) =>
commodities: (
id: number,
params?: { scope?: string; availability?: string; eligibility?: string; limit?: number },
) =>
api.get<AccountCommodityStates, AccountCommodityStates>(`/accounts/${id}/commodities`, { params }),
// 时间线(倒序分页),event_type 为空表示全部
events: (
+9
View File
@@ -212,6 +212,12 @@ export interface AccountCommodityState {
commodity_id: string;
commodity_name: string;
scope: string;
account_eligibility: 'eligible' | 'limited' | 'unknown';
offer_state: 'before' | 'active' | 'expired' | 'not_offered' | 'unknown';
stock_state: 'in_stock' | 'out_of_stock' | 'unknown';
stock_count: number | null;
store_status: number | null;
open_status: number | null;
availability: AccountCommodityAvailability;
blocking_reason: string;
raw_status: string;
@@ -897,6 +903,8 @@ export interface DouyuAccountPlatformStatus {
sync_domains: Record<string, Record<string, number>>;
commodities: {
by_availability: Record<string, { total: number; fresh: number }>;
by_account_eligibility: Record<string, { total: number; fresh: number }>;
fresh_eligible: number;
fresh_available: number;
fresh_limited: number;
};
@@ -2444,6 +2452,7 @@ export interface PlatformFulfillmentTask {
scope: string;
commodityMappingId: number | null;
commodityId: string;
goodsName: string;
requiredPoints: number | null;
saleMode: 'presale' | 'direct' | 'manual' | 'unknown';
campaignKey: string;
+54 -2
View File
@@ -138,6 +138,34 @@ function commodityStateTag(value: string) {
return <Tag color={state.color}>{state.label}</Tag>;
}
const ACCOUNT_ELIGIBILITY: Record<string, { label: string; color: string }> = {
eligible: { label: '账号可兑换', color: 'green' },
limited: { label: '账号已限兑', color: 'orange' },
unknown: { label: '资格待确认', color: 'default' },
};
const OFFER_STATE: Record<string, { label: string; color: string }> = {
before: { label: '活动未开始', color: 'gold' },
active: { label: '活动进行中', color: 'blue' },
expired: { label: '活动已结束', color: 'default' },
not_offered: { label: '商品未上架', color: 'default' },
unknown: { label: '时间待确认', color: 'default' },
};
const STOCK_STATE: Record<string, { label: string; color: string }> = {
in_stock: { label: '有库存', color: 'green' },
out_of_stock: { label: '官方无库存', color: 'default' },
unknown: { label: '库存未知', color: 'default' },
};
function splitStateTag(
value: string,
states: Record<string, { label: string; color: string }>,
) {
const state = states[value] ?? Object.values(states).at(-1);
return <Tag color={state?.color}>{state?.label || value}</Tag>;
}
/** 金额展示:充值为正(绿色 ¥),兑换消耗为负(红色积分)。 */
function amountText(item: AccountEventItem) {
if (item.amount === null || item.amount === undefined) return null;
@@ -352,9 +380,33 @@ export default function AccountDetailPage() {
),
},
{
title: '当前能力',
title: '账号兑换资格',
dataIndex: 'account_eligibility',
width: 130,
render: (value: string) => splitStateTag(value, ACCOUNT_ELIGIBILITY),
},
{
title: '活动状态',
dataIndex: 'offer_state',
width: 120,
render: (value: string) => splitStateTag(value, OFFER_STATE),
},
{
title: '官方库存(仅参考)',
width: 150,
render: (_value, row) => (
<Space direction="vertical" size={0}>
{splitStateTag(row.stock_state, STOCK_STATE)}
<Text type="secondary" style={{ fontSize: 12 }}>
数量 {row.stock_count ?? '-'}
</Text>
</Space>
),
},
{
title: '兑换执行',
dataIndex: 'availability',
width: 110,
width: 120,
render: (value: string) => commodityStateTag(value),
},
{
@@ -266,7 +266,7 @@ function eventDescription(event: { eventType: string; detail: Record<string, unk
return reasons.length ? `${base};后续需要:${reasons.join('、')}` : `${base};可直接兑换`;
}
if (event.eventType === 'mapping_updated') {
return `斗鱼商品 ${String(detail.commodityId || '-')},映射${detail.enabled === false ? '已停用' : '已启用'}`;
return `斗鱼商品 ${String(detail.goodsName || detail.commodityId || '-')},映射${detail.enabled === false ? '已停用' : '已启用'}`;
}
if (event.eventType === 'exchange_eligibility_checked') {
return `兑换状态:${exchangeStatusLabel(String(detail.exchangeStatus || ''))};限兑商品 ${String(detail.limitedCount ?? 0)} 个`;
@@ -1060,7 +1060,9 @@ export default function PlatformFulfillmentPage() {
width: 230,
render: (_, task) => (
<Space direction="vertical" size={2}>
<Text>{task.commodityId || '未映射'}</Text>
<Text ellipsis title={task.commodityId}>
{task.goodsName || task.skuName || task.internalSkuKey || '未映射'}
</Text>
<Text type="secondary">{task.requiredPoints != null ? `${task.requiredPoints} 积分` : '价格未知'}</Text>
</Space>
),
@@ -1518,7 +1520,7 @@ export default function PlatformFulfillmentPage() {
{selected.internalSkuKey || '-'}
</Descriptions.Item>
<Descriptions.Item label="斗鱼商品" span={2}>
{selected.commodityId || '未映射'}
{selected.goodsName || selected.skuName || '未映射'}
</Descriptions.Item>
<Descriptions.Item label="销售模式">
{SALE_MODE_LABELS[selected.saleMode] || selected.saleMode}