From 8c55ceccf8801a6879bf7938cecb12addee82c85 Mon Sep 17 00:00:00 2001 From: linkeyu <798648091@qq.com> Date: Tue, 21 Jul 2026 11:22:42 +0800 Subject: [PATCH] feat(admin): show coupon rate calculation details --- src/app/(main)/coupon-data/page.tsx | 49 +++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/src/app/(main)/coupon-data/page.tsx b/src/app/(main)/coupon-data/page.tsx index 9ab3319..2b070d1 100644 --- a/src/app/(main)/coupon-data/page.tsx +++ b/src/app/(main)/coupon-data/page.tsx @@ -137,11 +137,6 @@ const slotRateMean = (rows: CouponSlotRow[]): number | null => { return rates.length ? rates.reduce((a, b) => a + b, 0) / rates.length : null; }; -// 汇总卡成功率口径 tooltip 文案 -const POINT_RATE_HINT = - '点位成功率(合计):当前区间内全部券成功率的算术平均(每张券等权);' + - '单券成功率=成功(含已领)÷尝试(不含跳过),源自领券每券记录。'; - // 按券表:coupon_id 平台 → 中文 const SLOT_PLATFORM: Record = { 'meituan-waimai': '美团', @@ -597,6 +592,10 @@ export default function CouponDataPage() { const successDenominator = summary ? Math.max(0, summary.started_count - abandonedCount) : 0; const couponSuccessRate = summary && successDenominator > 0 ? summary.completed_count / successDenominator : null; + const validCouponSlots = couponSlots.filter((r) => r.success_rate != null); + const pointSuccessRate = slotRateMean(validCouponSlots); + const pointSucceededTotal = validCouponSlots.reduce((total, r) => total + r.succeeded, 0); + const pointTriedTotal = validCouponSlots.reduce((total, r) => total + r.tried, 0); const items = data?.items ?? []; return ( @@ -714,8 +713,19 @@ export default function CouponDataPage() { - 领券成功率{' '} - + 领券完成率{' '} + +
计算逻辑:领券完成数 ÷(领券发起数-中途退出数)
+
+ 本期:{summary.completed_count} ÷({summary.started_count}-{abandonedCount}) + = {fmtPct(couponSuccessRate)} +
+ + } + >
@@ -728,12 +738,33 @@ export default function CouponDataPage() { title={ 点位成功率{' '} - + +
计算逻辑:全部单券成功率的算术平均,每张券等权。
+
单券成功率=成功数(含已领)÷ 尝试数(不含跳过)。
+
+ 本期共 {validCouponSlots.length} 张有效券: +
+ {validCouponSlots.map((slot) => ( +
+ {slot.coupon_name || slot.coupon_id}:{slot.succeeded} ÷ {slot.tried}= + {fmtPct(slot.success_rate)} +
+ ))} +
+ 等权平均={fmtPct(pointSuccessRate)};累计成功/尝试= + {pointSucceededTotal}/{pointTriedTotal}(累计数仅辅助核对,不作为当前加权公式)。 +
+ + } + >
} - value={fmtPct(slotRateMean(couponSlots))} + value={fmtPct(pointSuccessRate)} /> -- 2.52.0