Compare commits

..

3 Commits

Author SHA1 Message Date
linkeyu 926b65b453 fix(admin): 区分领券点位完成比例颜色 2026-07-22 13:50:01 +08:00
linkeyu efa443ea8a 修复:拆分广告发奖状态与播放状态 (#59)
## 改动
- 将广告收益列表中的混合状态拆为「发奖状态」和「广告播放状态」两列
- 聚合行按全部子记录展示「已发 / 部分已发 / 未发」及「已完成 / 混合状态」
- 保留次数超限、缺 eCPM、未满 10 秒、提前关闭等原因的悬停说明
- 未知后端状态明确显示为「未知」,避免误判为已完成

## 验证
- npm run build

---------

Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #59
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-22 12:09:54 +08:00
linkeyu f3cfd622a7 feat(admin): 领券点位分数支持查看明细 (#56)
## 变更内容
- 领券记录列表的点位成功率展示为成功数/尝试数,例如 8/8
- 点击分数弹出点位明细
- 逐条展示点位名称、ID、成功、已领、失败或跳过状态
- 失败点位额外展示失败原因
- 无逐券埋点的旧记录显示 -

## 依赖
- 依赖 app-server #153 提供 point_success_count、point_total_count 和 point_details

## 验证
- npx tsc --noEmit
- npm run build
- 本地实际验证 8/8 全部成功和 7/8 含失败原因两种状态

---------

Co-authored-by: guke <guke@wonderable.ai>
Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #56
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-22 11:46:47 +08:00
2 changed files with 103 additions and 20 deletions
+95 -18
View File
@@ -66,21 +66,89 @@ const APP_TAG: Record<string, { color: string; label: string }> = {
test: { color: 'default', label: '测试应用' },
};
// 发奖状态 → 颜色 + 中文(含「不发金币的原因」:提前关闭/未满10秒/缺eCPM/次数超限)
const STATUS_TAG: Record<string, { color: string; label: string }> = {
granted: { color: 'green', label: '已发' },
capped: { color: 'orange', label: '次数超限' },
ecpm_missing: { color: 'red', label: '缺 eCPM' },
const REWARD_STATUS_HINT: Record<string, string> = {
granted: '已完成金币发放',
capped: '次数超限,未发金币',
ecpm_missing: '缺少有效 eCPM,未发金币',
too_short: '播放时长未达到发奖条件,未发金币',
closed_early: '用户提前关闭广告,未发金币',
};
const PLAYBACK_STATUS_TAG: Record<string, { color: string; label: string }> = {
completed: { color: 'green', label: '已完成' },
too_short: { color: 'gold', label: '未满10秒' },
closed_early: { color: 'default', label: '提前关闭' },
unknown: { color: 'default', label: '未知' },
};
const STATUS_HINT: Record<string, string> = {
granted: '已满足当前客户端发奖条件并完成金币发放。',
too_short: '旧版 Draw 信息流观看不足 10 秒,不发金币;新版按观看比例发放时会记为已发。',
closed_early: '用户在达到发奖条件前主动关闭,不发金币。',
capped: '已达到次数上限,不再发金币。',
ecpm_missing: '缺少有效 eCPM,无法计算金币。',
};
function rewardStatuses(row: AdRevenueRow): string[] {
if (row.sub_rewards?.length) return row.sub_rewards.map((reward) => reward.status);
return row.status ? [row.status] : [];
}
function rewardStatusTag(row: AdRevenueRow) {
const statuses = rewardStatuses(row);
if (!row.has_reward || statuses.length === 0) {
return { color: 'default', label: '无记录', hint: '仅记录到广告展示,没有对应发奖记录。' };
}
const grantedCount = statuses.filter((status) => status === 'granted').length;
const reasonSummary = Object.entries(
statuses
.filter((status) => status !== 'granted')
.reduce<Record<string, number>>((counts, status) => {
counts[status] = (counts[status] ?? 0) + 1;
return counts;
}, {}),
)
.map(([status, count]) => `${REWARD_STATUS_HINT[status] ?? status} ${count}`)
.join('');
if (grantedCount === statuses.length) {
return { color: 'green', label: '已发', hint: `已完成金币发放${statuses.length > 1 ? ` ${statuses.length}` : ''}` };
}
if (grantedCount > 0) {
return {
color: 'blue',
label: '部分已发',
hint: `已发 ${grantedCount} 条,未发 ${statuses.length - grantedCount}${reasonSummary ? `${reasonSummary}` : ''}`,
};
}
return { color: 'default', label: '未发', hint: reasonSummary ? `${reasonSummary}` : '未发放金币。' };
}
function playbackStatusTag(row: AdRevenueRow) {
const statuses = rewardStatuses(row);
if (statuses.length === 0) {
return row.has_impression
? { color: 'blue', label: '仅展示', hint: '记录到广告展示,但没有对应的播放结果。' }
: { color: 'default', label: '无记录', hint: '没有可用的广告播放记录。' };
}
const playbackCounts = statuses.reduce<Record<string, number>>((counts, status) => {
const playbackStatus =
status === 'too_short' || status === 'closed_early'
? status
: status === 'granted' || status === 'capped' || status === 'ecpm_missing'
? 'completed'
: 'unknown';
counts[playbackStatus] = (counts[playbackStatus] ?? 0) + 1;
return counts;
}, {});
const entries = Object.entries(playbackCounts);
if (entries.length === 1) {
const [status, count] = entries[0];
const tag = PLAYBACK_STATUS_TAG[status];
return {
...tag,
hint: `${tag.label}${count > 1 ? ` ${count}` : ''}`,
};
}
const hint = entries
.map(([status, count]) => `${PLAYBACK_STATUS_TAG[status].label} ${count}`)
.join('');
return { color: 'purple', label: '混合状态', hint: `${hint}` };
}
const fmtFactorRange = (a: number | null, b: number | null) => {
if (a == null) return '-';
@@ -485,12 +553,20 @@ export default function AdRevenueReportPage() {
},
{
title: '发奖状态',
dataIndex: 'status',
key: 'reward_status',
width: 100,
render: (s: string | null) => {
if (!s) return <Tooltip title="仅记录广告展示,没有对应发奖事件。"><Tag></Tag></Tooltip>;
const t = STATUS_TAG[s] ?? { color: 'default', label: s };
return <Tooltip title={STATUS_HINT[s]}><Tag color={t.color}>{t.label}</Tag></Tooltip>;
render: (_: unknown, row: AdRevenueRow) => {
const tag = rewardStatusTag(row);
return <Tooltip title={tag.hint}><Tag color={tag.color}>{tag.label}</Tag></Tooltip>;
},
},
{
title: '广告播放状态',
key: 'playback_status',
width: 120,
render: (_: unknown, row: AdRevenueRow) => {
const tag = playbackStatusTag(row);
return <Tooltip title={tag.hint}><Tag color={tag.color}>{tag.label}</Tag></Tooltip>;
},
},
{
@@ -532,7 +608,8 @@ export default function AdRevenueReportPage() {
'ecpm_yuan',
'revenue_yuan',
'actual_coin',
'status',
'reward_status',
'playback_status',
'ad_type',
'app_env',
'our_code_id',
+8 -2
View File
@@ -149,6 +149,10 @@ function PointScorePopover({ row }: { row: CouponDataRow }) {
return <Typography.Text type="secondary">-</Typography.Text>;
}
const score = `${row.point_success_count}/${row.point_total_count}`;
const scoreColor =
row.point_success_count === row.point_total_count
? STATUS_TAG.completed.color
: STATUS_TAG.abandoned.color;
const loadDetails = async () => {
if (details !== null || loading) return;
setLoading(true);
@@ -215,7 +219,9 @@ function PointScorePopover({ row }: { row: CouponDataRow }) {
</div>
)}
>
<Button type="link" size="small" style={{ height: 'auto', padding: 0 }}>{score}</Button>
<Button type="link" size="small" style={{ height: 'auto', padding: 0, color: scoreColor }}>
{score}
</Button>
</Popover>
);
}
@@ -596,7 +602,7 @@ export default function CouponDataPage() {
render: (v: number | null) => fmtSec(v),
},
{
title: '点位成功率',
title: '百分比',
key: 'point_success_rate',
width: 110,
render: (_: unknown, r: CouponDataRow) => <PointScorePopover row={r} />,