diff --git a/src/app/(main)/ad-revenue-report/page.tsx b/src/app/(main)/ad-revenue-report/page.tsx index 189f373..5e4aa6e 100644 --- a/src/app/(main)/ad-revenue-report/page.tsx +++ b/src/app/(main)/ad-revenue-report/page.tsx @@ -9,7 +9,6 @@ import { Card, Col, DatePicker, - Descriptions, Divider, InputNumber, Modal, @@ -190,7 +189,61 @@ const LT_FACTOR_ROWS = [ { key: '5', lt: '第 11 条及以后', factor: 1.0 }, ]; -type AdRevenueDetailRow = AdRevenueRecord & { source_adn?: string | null }; +type AdRevenueDetailRow = AdRevenueRecord & { + source_adn?: string | null; + is_impression_only?: boolean; +}; + +const FORMULA_EMPTY_STATUS_LABEL: Record = { + capped: '次数超限', + ecpm_missing: 'eCPM 缺失', + too_short: '观看时长不足', + closed_early: '提前关闭', + impression_only: '仅展示', +}; + +// 未发奖记录用可读状态代替空值,避免误认为数据丢失;悬停时说明为何没有计算因子。 +function renderFormulaValue(value: string | number, row: AdRevenueDetailRow) { + if (value !== '-') return value; + const isGrantedButMissing = row.status === 'granted'; + const reason = isGrantedButMissing + ? '该记录标记为已发奖,但计算因子缺失,需要进一步排查' + : row.is_impression_only + ? '该记录只有广告展示,没有对应发奖记录' + : REWARD_STATUS_HINT[row.status] ?? `发奖状态为 ${row.status || '未知'}`; + const statusLabel = isGrantedButMissing + ? '计算数据缺失' + : (FORMULA_EMPTY_STATUS_LABEL[row.status] ?? row.status) || '未进入计算'; + return ( + + {statusLabel} + + ); +} + +function impressionOnlyDetail(row: AdRevenueRow): AdRevenueDetailRow { + return { + record_id: 0, + created_at: row.created_at, + status: 'impression_only', + ecpm: row.ecpm, + ecpm_factor: null, + units: 0, + lt_index_start: null, + lt_index_end: null, + lt_factor_start: null, + lt_factor_end: null, + expected_coin: 0, + actual_coin: 0, + matched: true, + source_adn: row.adn, + is_impression_only: true, + }; +} // 展开行(逐条事件展开)- 该条的发奖复算明细(还原金币审计的 eCPM/因子1/份数/LT/因子2 等列) const DETAIL_COLUMNS: ColumnsType = [ @@ -208,18 +261,25 @@ const DETAIL_COLUMNS: ColumnsType = [ render: (v: string | null) => (v == null || Number.isNaN(Number(v)) ? '-' : (Number(v) / 100 / 1000).toFixed(4)), }, { title: '实发金币数', dataIndex: 'actual_coin', width: 100 }, - { title: '因子1', dataIndex: 'ecpm_factor', width: 70, render: (v: number | null) => v ?? '-' }, + { + title: '因子1', + dataIndex: 'ecpm_factor', + width: 70, + render: (v: number | null, row: AdRevenueDetailRow) => renderFormulaValue(v ?? '-', row), + }, { title: '因子2', key: 'lt_factor', width: 90, - render: (_: unknown, r: AdRevenueDetailRow) => fmtFactorRange(r.lt_factor_start, r.lt_factor_end), + render: (_: unknown, row: AdRevenueDetailRow) => + renderFormulaValue(fmtFactorRange(row.lt_factor_start, row.lt_factor_end), row), }, { title: 'LT累计条数', key: 'lt_index', width: 100, - render: (_: unknown, r: AdRevenueDetailRow) => fmtIndexRange(r.lt_index_start, r.lt_index_end), + render: (_: unknown, row: AdRevenueDetailRow) => + renderFormulaValue(fmtIndexRange(row.lt_index_start, row.lt_index_end), row), }, ]; @@ -1126,24 +1186,19 @@ export default function AdRevenueReportPage() { ) : (
- 展示明细{' '} - (纯展示事件,未单独发奖,无金币复算) - - {formatUtcTime(r.created_at)} - {r.ecpm ?? '-'} - - {r.ecpm != null && !Number.isNaN(Number(r.ecpm)) - ? (Number(r.ecpm) / 100).toFixed(2) - : '-'} - - - {r.has_impression ? r.revenue_yuan.toFixed(4) : '-'} - - {r.adn ?? '-'} - {r.slot_id ?? '-'} - {r.our_code_id ?? '-'} - {r.app_env ?? '-'} - + 本次广告逐条明细{' '} + + (共 1 条 · 应发 0 / 实发 0;仅展示,未单独发奖) + + + style={{ marginTop: 8 }} + rowKey="record_id" + columns={DETAIL_COLUMNS} + dataSource={[impressionOnlyDetail(r)]} + pagination={false} + size="small" + scroll={{ x: 900 }} + />
), }}