feat(account): 详情页重排 + 列表高价值套装列 + 兑换记录点击预览
## 详情页重排(4 张卡,消除重复) 用户反馈「设计太乱、数据不好看、布局也乱」——根因是**同一份数据在一屏出现两次**: 积分/鱼翅/兑换余额在状态条和资产区各一次,角色绑定在状态条和信息表各一次。 新布局:**账号信息**(身份+状态+归属,一张 Descriptions)→ **资产与统计** (数字只出现一次,上面"现在有多少"、下面"历史累计")→ **高价值套装与兑换记录** (从最顶上移到这里,它是补充信息,不该抢主视觉)→ **账号时间线**。 零散的 `flex + gap` 统计行改成 `Row/Col` 栅格,列宽对齐。 ## 高价值套装:颜色按**价值**口径,别标反 用户澄清的业务语义与直觉相反: - **没兑换过** = 还能用来绑定兑换 = **高价值**(绿色「可兑换」) - 兑换过 1 个 → 价值降低;两个都兑换过 → 价值最低(橙色「已兑换」) 判定依据是**斗鱼官方兑换记录**(账号级)。⚠️ 不能用 `query_limited_goods` 的 `count`/`storeStatus` —— 那是**全局库存**(同一时刻不同账号看到的都一样), 用它判"这个账号有没有"必然给错结论。这个结论是推翻过一版才得到的: 第一版拿相隔两个月的两条快照对比,把**时间差异**当成了**账号差异**。 ## 列表 - 新增「高价值套装」列:🟢两个都可兑换 / 🟠某套装已兑换 / ⚪未查询 (「未查询」必须与「没兑换」分开,否则会把未知当成高价值) - 「兑换记录」列只显示官方口径,**点击弹窗**看全部(按作用域分组, 含商品/积分/真实兑换时间/当时用的昵称与平台),不用进详情页 ## 三个作用域的记录展示 面板与预览都按 精英宝典 / 电竞手册 / 和平小店 分三块展示, 每条带**真实兑换时间**与"使用昵称"(排查时有用)。 ## 顺带修 `exchange_records` 从数组改成按作用域分组的对象后,面板同步适配; `formatTime` 对 `0` 显示 `-`(斗鱼用 0 表示"没有这个时间", 直接格式化会显示成 1970/1/1)。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Alert, Card, Descriptions, Empty, Space, Table, Tag, Typography } from 'antd';
|
||||
import { Alert, Card, Empty, Space, Table, Tag, Tooltip, Typography } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
|
||||
const { Text } = Typography;
|
||||
@@ -42,7 +42,8 @@ export interface AccountOverviewResult {
|
||||
};
|
||||
high_value_goods?: HighValueGoods[];
|
||||
limited_goods_total?: number;
|
||||
exchange_records?: Array<Record<string, unknown>>;
|
||||
/** 按作用域分组:elite / esports / peace */
|
||||
exchange_records?: Record<string, Array<Record<string, unknown>>>;
|
||||
exchange_record_count?: number;
|
||||
/** 单项失败:**必须展示**,否则「没查到」会被读成「没有」 */
|
||||
errors?: Record<string, string>;
|
||||
@@ -90,93 +91,131 @@ function formatTime(value: string | number | null | undefined): string {
|
||||
* 我们没法只凭它断言账号真的拿到了。所以写「不可再兑」并把 count 一起显示,
|
||||
* 让运营自己判断 —— 这比给一个可能错的结论好。
|
||||
*/
|
||||
function HighValueCard({ goods }: { goods: HighValueGoods }) {
|
||||
if (goods.missing) {
|
||||
return (
|
||||
<Card size="small" style={{ width: 280, borderStyle: 'dashed' }}>
|
||||
<Space direction="vertical" size={2}>
|
||||
<Text strong>{goods.name}</Text>
|
||||
<Tag color="default">未查到该商品</Tag>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{goods.reason || '限兑列表和官方兑换记录里都没有它'}
|
||||
</Text>
|
||||
</Space>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
// ⚠️ 「是否已获得」只看官方兑换记录。`count`/`store_status` 是**全局库存**,
|
||||
// 同一时刻不同账号看到的都一样,**不能**用来判断这个账号有没有。
|
||||
const owned = goods.owned === true;
|
||||
return (
|
||||
<Card
|
||||
size="small"
|
||||
style={{ width: 280, borderColor: owned ? '#52c41a' : undefined }}
|
||||
title={<Text strong>{goods.name}</Text>}
|
||||
extra={
|
||||
<Tag color={owned ? 'green' : 'default'}>{owned ? '✅ 已获得' : '未获得'}</Tag>
|
||||
}
|
||||
>
|
||||
<Descriptions size="small" column={1} colon={false}>
|
||||
{owned && (
|
||||
<Descriptions.Item label="记录">
|
||||
{(goods.obtained_names || []).join('、') || '-'}
|
||||
</Descriptions.Item>
|
||||
)}
|
||||
<Descriptions.Item label="积分价">{goods.score ?? '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="当前库存">
|
||||
{goods.count ?? '-'}
|
||||
{goods.count === 0 ? '(已售罄)' : ''}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="活动时间">
|
||||
{formatTime(goods.start_time)} ~ {formatTime(goods.end_time)}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
{!goods.in_goods_list && (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
当前限兑列表里没有它(活动窗口可能已结束),但兑换记录仍在。
|
||||
</Text>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
/**
|
||||
* 高价值套装的展示状态。
|
||||
*
|
||||
* ⚠️ **颜色是「价值」口径,不是「有没有」口径** —— 别标反:
|
||||
* 没兑换过 → 「可兑换」**绿色**(这个账号还值钱,能用来绑定兑换)
|
||||
* 兑换过 → 「已兑换」**橙色**(价值降低)
|
||||
* 同一件东西两个都兑换过,账号价值最低。
|
||||
*
|
||||
* 「是否已获得」只看**官方兑换记录**:`count`/`store_status` 是全局库存,
|
||||
* 同一时刻不同账号看到的都一样,不能用来判断这个账号有没有。
|
||||
*/
|
||||
function goodsState(g: HighValueGoods): { text: string; color: string } {
|
||||
if (g.missing) return { text: '未查到该商品', color: 'default' };
|
||||
return g.owned
|
||||
? { text: '已兑换(价值降低)', color: 'orange' }
|
||||
: { text: '可兑换', color: 'green' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键查询结果面板。
|
||||
*
|
||||
* ⚠️ **只展示账号表里没有的东西**(高价值套装是否已获得、官方兑换记录)。
|
||||
*
|
||||
* 鱼翅 / 积分 / 钱包余额 / 开通状态这些,账号表本来就有对应字段
|
||||
* (`gold_balance` / `points` / `exchange_balance` / `elite_opened` / `esports_opened`),
|
||||
* 查询的作用是**刷新它们**,然后由账号详情里已有的界面直接反映出来 ——
|
||||
* 在这里再复制一份展示是多余的,还会让人分不清哪份才是准的。
|
||||
*/
|
||||
const goodsColumns: ColumnsType<HighValueGoods> = [
|
||||
{
|
||||
title: '高价值套装',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 200,
|
||||
render: (name: string, g) =>
|
||||
g.missing ? (
|
||||
<Tooltip title={g.reason || '限兑列表和官方兑换记录里都没有它'}>
|
||||
<Text type="secondary">{name}</Text>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Text strong>{name}</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '可兑换 / 已兑换',
|
||||
key: 'owned',
|
||||
width: 130,
|
||||
render: (_, g) => {
|
||||
const state = goodsState(g);
|
||||
return <Tag color={state.color}>{state.text}</Tag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '兑换记录里的名字',
|
||||
key: 'obtained',
|
||||
render: (_, g) =>
|
||||
g.obtained_names?.length ? (
|
||||
<Text style={{ fontSize: 12 }}>{g.obtained_names.join('、')}</Text>
|
||||
) : (
|
||||
<Text type="secondary">—</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '积分价',
|
||||
dataIndex: 'score',
|
||||
key: 'score',
|
||||
width: 90,
|
||||
render: (v: number | null | undefined) => v ?? '—',
|
||||
},
|
||||
{
|
||||
title: '当前库存',
|
||||
dataIndex: 'count',
|
||||
key: 'count',
|
||||
width: 120,
|
||||
render: (v: number | null | undefined, g) =>
|
||||
v == null ? (
|
||||
'—'
|
||||
) : (
|
||||
<Space size={4}>
|
||||
<span>{v}</span>
|
||||
{v === 0 && <Text type="secondary">(售罄)</Text>}
|
||||
{g.in_goods_list === false && <Text type="secondary">(已下架)</Text>}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '活动时间',
|
||||
key: 'window',
|
||||
width: 200,
|
||||
render: (_, g) =>
|
||||
g.missing ? '—' : `${formatTime(g.start_time)} ~ ${formatTime(g.end_time)}`,
|
||||
},
|
||||
];
|
||||
|
||||
/** 三个作用域的展示顺序(后端按 scope 分组返回)。 */
|
||||
const EXCHANGE_SCOPES: Array<{ key: string; label: string }> = [
|
||||
{ key: 'elite', label: '精英宝典' },
|
||||
{ key: 'esports', label: '电竞手册' },
|
||||
{ key: 'peace', label: '和平小店' },
|
||||
];
|
||||
|
||||
export default function AccountOverviewPanel({
|
||||
result,
|
||||
queriedAt,
|
||||
}: {
|
||||
result: AccountOverviewResult;
|
||||
/** 查询时间(优先用账号上记录的,回落到结果里的) */
|
||||
queriedAt?: string | null;
|
||||
}) {
|
||||
if (!result) return <Empty description="暂无结果" />;
|
||||
const errors = result.errors || {};
|
||||
const goods = result.high_value_goods || [];
|
||||
const records = result.exchange_records || [];
|
||||
const recordGroups = result.exchange_records || {};
|
||||
|
||||
const recordColumns: ColumnsType<Record<string, unknown>> = [
|
||||
{
|
||||
title: '商品',
|
||||
dataIndex: 'commodityName',
|
||||
key: 'commodityName',
|
||||
render: (v: unknown) => String(v ?? '-'),
|
||||
key: 'name',
|
||||
render: (_, row) => String(row.commodityName ?? row.commodity_name ?? '-'),
|
||||
},
|
||||
{
|
||||
title: '时间',
|
||||
title: '积分',
|
||||
key: 'score',
|
||||
width: 90,
|
||||
render: (_, row) => String(row.score ?? '-'),
|
||||
},
|
||||
{
|
||||
// 官方记录带**真实兑换时间**
|
||||
title: '兑换时间',
|
||||
key: 'time',
|
||||
width: 170,
|
||||
render: (_, row) =>
|
||||
formatTime(
|
||||
(row.createTime ?? row.create_time ?? row.time) as string | number | null,
|
||||
),
|
||||
formatTime((row.time ?? row.occurred_at) as string | number | null),
|
||||
},
|
||||
{
|
||||
title: '使用昵称',
|
||||
key: 'show',
|
||||
render: (_, row) => String(row.showName ?? row.show_name ?? '-'),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -199,38 +238,47 @@ export default function AccountOverviewPanel({
|
||||
/>
|
||||
)}
|
||||
|
||||
<Card size="small" title="🎯 高价值套装">
|
||||
{goods.length === 0 ? (
|
||||
<Text type="secondary">没有配置关注的高价值套装,或本次没取到</Text>
|
||||
) : (
|
||||
<Space wrap size={12}>
|
||||
{goods.map((g) => (
|
||||
<HighValueCard key={g.commodity_id || g.name} goods={g} />
|
||||
))}
|
||||
</Space>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
size="small"
|
||||
title={`兑换记录${result.exchange_record_count ? `(${result.exchange_record_count} 条)` : ''}`}
|
||||
>
|
||||
{records.length === 0 ? (
|
||||
<Text type="secondary">官方暂无兑换记录</Text>
|
||||
title="🎯 高价值套装(没兑换过才值钱)" styles={{ body: { padding: 0 } }}>
|
||||
{goods.length === 0 ? (
|
||||
<div style={{ padding: 12 }}>
|
||||
<Text type="secondary">没有配置关注的高价值套装,或本次没取到</Text>
|
||||
</div>
|
||||
) : (
|
||||
<Table
|
||||
size="small"
|
||||
rowKey={(_, i) => String(i)}
|
||||
columns={recordColumns}
|
||||
dataSource={records}
|
||||
pagination={{ pageSize: 10, size: 'small' }}
|
||||
rowKey={(g) => g.commodity_id || g.name}
|
||||
columns={goodsColumns}
|
||||
dataSource={goods}
|
||||
pagination={false}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
查询时间:{formatTime(queriedAt ?? result.queried_at)}
|
||||
</Text>
|
||||
{EXCHANGE_SCOPES.map(({ key, label }) => {
|
||||
const rows = recordGroups[key] ?? [];
|
||||
return (
|
||||
<Card
|
||||
key={key}
|
||||
size="small"
|
||||
title={`兑换记录 · ${label}${rows.length ? `(${rows.length} 条)` : ''}`}
|
||||
styles={{ body: { padding: rows.length ? 0 : 12 } }}
|
||||
>
|
||||
{rows.length === 0 ? (
|
||||
<Text type="secondary">官方暂无{label}兑换记录</Text>
|
||||
) : (
|
||||
<Table
|
||||
size="small"
|
||||
rowKey={(_, i) => String(i)}
|
||||
columns={recordColumns}
|
||||
dataSource={rows}
|
||||
pagination={{ pageSize: 10, size: 'small' }}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user