From e3ab28addc3a7e5e069dd26cd25594b4853d35f9 Mon Sep 17 00:00:00 2001 From: guke Date: Fri, 10 Jul 2026 22:14:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin-web):=20=E9=A2=86=E5=88=B8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE/=E6=AF=94=E4=BB=B7=E8=AE=B0=E5=BD=95=E7=9C=8B?= =?UTF-8?q?=E6=9D=BF=E6=96=B0=E5=A2=9E=E3=80=8C=E5=B9=BF=E5=91=8A=E6=94=B6?= =?UTF-8?q?=E7=9B=8A=E3=80=8D=E5=88=97=20(#45)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 背景 后端两个看板接口新增逐行 `ad_revenue_yuan`(元),前端补上展示列。 ## 改动 - `src/lib/types.ts`:`ComparisonRecordListItem` 增 `ad_revenue_yuan: number` (`ComparisonRecordDetail` 自动继承)。 - `comparison-records/page.tsx`:「省」列后新增「广告收益」列(>0 显示绿色 ¥x.xxxx, 否则 `-`);表格 `scroll.x` 1820 → 1920。 - `coupon-data/page.tsx`:`CouponDataRow` 增字段;新增 `fmtYuan` 格式化(¥ 保留 4 位、 空/≤0 显示 `-`);主表「耗时」列后新增「广告收益」列(不动用户抽屉 RECORD_COLUMNS); `scroll.x` 1450 → 1560。 ## 说明 - 后端未更新时该字段为 undefined → 显示 `-`,无害。 - 单次广告收益很小(如 ¥0.0034),故 4 位小数。 - 领券看板默认按会话 app_env=`prod` 筛;真机测试数据在 `dev`,需切换环境才可见。 --------- Co-authored-by: guke Reviewed-on: https://gitea.shaguabijia.com/WonderableAI/shaguabijia-admin-web/pulls/45 --- src/app/(main)/comparison-records/page.tsx | 14 +++++++++++++- src/app/(main)/coupon-data/page.tsx | 14 +++++++++++++- src/lib/types.ts | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/comparison-records/page.tsx b/src/app/(main)/comparison-records/page.tsx index e14468b..3062d13 100644 --- a/src/app/(main)/comparison-records/page.tsx +++ b/src/app/(main)/comparison-records/page.tsx @@ -184,6 +184,18 @@ export default function ComparisonRecordsPage() { 0 ? '#3f8600' : '#999' }}>{yuan(r.saved_amount_cents)} ), }, + { + title: '广告收益', + key: 'ad_revenue', + width: 96, + align: 'right', + render: (_, r) => + r.ad_revenue_yuan > 0 ? ( + ¥{r.ad_revenue_yuan.toFixed(4)} + ) : ( + - + ), + }, { title: '耗时', dataIndex: 'total_ms', width: 64, render: fmtMs }, { title: '步', dataIndex: 'step_count', width: 48, render: (v) => v ?? '-' }, { title: 'LLM', dataIndex: 'llm_call_count', width: 56, render: (v) => v ?? '-' }, @@ -297,7 +309,7 @@ export default function ComparisonRecordsPage() { showTotal: (t) => `共 ${t} 条`, onChange, }} - scroll={{ x: 1820 }} + scroll={{ x: 1920 }} onRow={(r) => ({ onClick: () => openDetail(r.id), style: { cursor: 'pointer' } })} /> diff --git a/src/app/(main)/coupon-data/page.tsx b/src/app/(main)/coupon-data/page.tsx index 7811e16..ffb8c8f 100644 --- a/src/app/(main)/coupon-data/page.tsx +++ b/src/app/(main)/coupon-data/page.tsx @@ -73,6 +73,7 @@ interface CouponDataRow { started_at: string; claimed_count: number | null; trace_url: string | null; + ad_revenue_yuan: number; // 本次领券看的信息流广告预估收益(元) } interface CouponDataReport { date_from: string; @@ -123,6 +124,10 @@ const fmtSec = (ms: number | null | undefined): string => const fmtPct = (v: number | null | undefined): string => v == null ? '-' : `${(v * 100).toFixed(1)}%`; +// 元(小数)→ "¥0.0050"(空/≤0 显示 -)。单次广告收益很小,保留 4 位。 +const fmtYuan = (v: number | null | undefined): string => + v == null || v <= 0 ? '-' : `¥${v.toFixed(4)}`; + // 汇总卡成功率口径 tooltip 文案 const FULL_RATE_HINT = '整单成功率:一次领券勾选的平台全部至少领到一张的场次 ÷ 领券发起数;基数含未完成/失败/中途退出。'; @@ -469,6 +474,13 @@ export default function CouponDataPage() { align: 'right', render: (v: number | null) => fmtSec(v), }, + { + title: '广告收益', + dataIndex: 'ad_revenue_yuan', + width: 100, + align: 'right', + render: (v: number) => fmtYuan(v), + }, { title: '美团耗时', key: 'mt_elapsed', @@ -863,7 +875,7 @@ export default function CouponDataPage() { onChange: (p) => load(p, queriedLimit), }} size="small" - scroll={{ x: 1450 }} + scroll={{ x: 1560 }} /> diff --git a/src/lib/types.ts b/src/lib/types.ts index 81ec88f..e853258 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -359,6 +359,7 @@ export interface ComparisonRecordListItem { rom_name: string | null; android_version: string | null; app_version: string | null; + ad_revenue_yuan: number; // 本次比价看的信息流广告预估收益(元) created_at: string; }