Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c22f774d8 | |||
| 26b1adb769 | |||
| c4b3fcfedb | |||
| 0040c5795d | |||
| 5acfb05c57 | |||
| bea35fb707 | |||
| 93c3daa784 |
@@ -30,7 +30,7 @@ import {
|
||||
} from '@ant-design/icons';
|
||||
import dayjs, { type Dayjs } from 'dayjs';
|
||||
import { api, errMsg } from '@/lib/api';
|
||||
import { formatUtcTime, percentile } from '@/lib/format';
|
||||
import { formatUtcTime, nearestRankPercentile } from '@/lib/format';
|
||||
import type {
|
||||
AdRevenueDaily,
|
||||
AdRevenueHourly,
|
||||
@@ -758,9 +758,9 @@ export default function AdRevenueReportPage() {
|
||||
.filter((item) => item.feed_scene === sceneName)
|
||||
.map((item) => item.sub_count ?? 1);
|
||||
return {
|
||||
p5: percentile(counts, 0.05, false),
|
||||
p50: percentile(counts, 0.5, false),
|
||||
p95: percentile(counts, 0.95, false),
|
||||
p5: nearestRankPercentile(counts, 0.05),
|
||||
p50: nearestRankPercentile(counts, 0.5),
|
||||
p95: nearestRankPercentile(counts, 0.95),
|
||||
};
|
||||
};
|
||||
return { coupon: summarize('coupon'), comparison: summarize('comparison') };
|
||||
@@ -1083,12 +1083,12 @@ export default function AdRevenueReportPage() {
|
||||
</Typography.Text>
|
||||
</Divider>
|
||||
<Row gutter={[16, 12]}>
|
||||
<Col span={4}><Statistic title="单次领券广告数 P5" value={sessionAdCounts.coupon.p5 ?? '-'} precision={1} /></Col>
|
||||
<Col span={4}><Statistic title="单次领券广告数 P50" value={sessionAdCounts.coupon.p50 ?? '-'} precision={1} /></Col>
|
||||
<Col span={4}><Statistic title="单次领券广告数 P95" value={sessionAdCounts.coupon.p95 ?? '-'} precision={1} /></Col>
|
||||
<Col span={4}><Statistic title="单次比价广告数 P5" value={sessionAdCounts.comparison.p5 ?? '-'} precision={1} /></Col>
|
||||
<Col span={4}><Statistic title="单次比价广告数 P50" value={sessionAdCounts.comparison.p50 ?? '-'} precision={1} /></Col>
|
||||
<Col span={4}><Statistic title="单次比价广告数 P95" value={sessionAdCounts.comparison.p95 ?? '-'} precision={1} /></Col>
|
||||
<Col span={4}><Statistic title="单次领券广告数 P5" value={sessionAdCounts.coupon.p5 ?? '-'} precision={0} /></Col>
|
||||
<Col span={4}><Statistic title="单次领券广告数 P50" value={sessionAdCounts.coupon.p50 ?? '-'} precision={0} /></Col>
|
||||
<Col span={4}><Statistic title="单次领券广告数 P95" value={sessionAdCounts.coupon.p95 ?? '-'} precision={0} /></Col>
|
||||
<Col span={4}><Statistic title="单次比价广告数 P5" value={sessionAdCounts.comparison.p5 ?? '-'} precision={0} /></Col>
|
||||
<Col span={4}><Statistic title="单次比价广告数 P50" value={sessionAdCounts.comparison.p50 ?? '-'} precision={0} /></Col>
|
||||
<Col span={4}><Statistic title="单次比价广告数 P95" value={sessionAdCounts.comparison.p95 ?? '-'} precision={0} /></Col>
|
||||
</Row>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
@@ -46,6 +46,41 @@ const fmtTok = (inTok: number | null, outTok: number | null) =>
|
||||
inTok == null && outTok == null ? '-' : `${inTok ?? 0}/${outTok ?? 0}`;
|
||||
const fmtRate = (value: number | null) => (value == null ? '-' : `${(value * 100).toFixed(1)}%`);
|
||||
|
||||
function deviceName(record: ComparisonRecordListItem): string {
|
||||
return record.device_model_name || record.device_model || '-';
|
||||
}
|
||||
|
||||
function romName(record: ComparisonRecordListItem): string {
|
||||
return [
|
||||
record.rom_vendor,
|
||||
record.rom_name,
|
||||
record.rom_version != null ? String(record.rom_version) : null,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ') || '-';
|
||||
}
|
||||
|
||||
function renderDevice(record: ComparisonRecordListItem): ReactNode {
|
||||
const readableName = deviceName(record);
|
||||
const showRawModel =
|
||||
record.device_model_name
|
||||
&& record.device_model
|
||||
&& record.device_model_name !== record.device_model;
|
||||
return (
|
||||
<Space direction="vertical" size={0}>
|
||||
<span>{readableName}</span>
|
||||
{showRawModel ? (
|
||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{record.device_model}
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{romName(record)}
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
// LLM 价格快照只展示 prices 里各模型的单价(元/每百万 token),忽略 mode/_source 等元字段。
|
||||
function llmPriceRows(snapshot: Record<string, unknown> | null): string[] {
|
||||
const prices = snapshot?.prices;
|
||||
@@ -298,6 +333,14 @@ export default function ComparisonRecordsPage() {
|
||||
<b style={{ color: r.saved_amount_cents > 0 ? '#3f8600' : '#999' }}>{yuan(r.saved_amount_cents)}</b>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '是否下单',
|
||||
dataIndex: 'ordered',
|
||||
width: 84,
|
||||
render: (ordered: boolean) => (
|
||||
<Tag color={ordered ? 'green' : 'default'}>{ordered ? '已下单' : '未下单'}</Tag>
|
||||
),
|
||||
},
|
||||
{ title: 'LLM', dataIndex: 'llm_call_count', width: 56, render: (v) => v ?? '-' },
|
||||
{
|
||||
title: 'TOKEN',
|
||||
@@ -308,9 +351,9 @@ export default function ComparisonRecordsPage() {
|
||||
{
|
||||
title: '机型/ROM',
|
||||
key: 'device',
|
||||
width: 150,
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
render: (_, r) => [r.device_model, r.rom_name].filter(Boolean).join(' / ') || '-',
|
||||
render: (_, r) => renderDevice(r),
|
||||
},
|
||||
{
|
||||
title: 'traceid',
|
||||
@@ -499,8 +542,15 @@ export default function ComparisonRecordsPage() {
|
||||
|
||||
<Card size="small" title="设备环境">
|
||||
<Descriptions size="small" column={2}>
|
||||
<Descriptions.Item label="机型">{detail.device_model || '-'}({detail.device_manufacturer || '-'})</Descriptions.Item>
|
||||
<Descriptions.Item label="ROM">{[detail.rom_vendor, detail.rom_name, detail.rom_version].filter(Boolean).join(' ') || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="机型">
|
||||
{deviceName(detail)}
|
||||
{detail.device_model_name && detail.device_model_name !== detail.device_model
|
||||
? `(${[detail.device_manufacturer, detail.device_model].filter(Boolean).join(' · ')})`
|
||||
: detail.device_manufacturer
|
||||
? `(${detail.device_manufacturer})`
|
||||
: ''}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="ROM">{romName(detail)}</Descriptions.Item>
|
||||
<Descriptions.Item label="Android">{detail.android_version || '-'}(SDK {detail.android_sdk ?? '-'})</Descriptions.Item>
|
||||
<Descriptions.Item label="App 版本">{detail.app_version || '-'}({detail.app_version_code ?? '-'})</Descriptions.Item>
|
||||
<Descriptions.Item label="源 App 版本" span={2}>{detail.source_app_version || '-'}</Descriptions.Item>
|
||||
|
||||
@@ -710,7 +710,7 @@ export default function DashboardPage() {
|
||||
<div>
|
||||
<h1>数据大盘</h1>
|
||||
<p>
|
||||
数据更新于 {updatedAt ?? '--'} · 北京时间 · 日期窗口按 00:00 自然日切分,不包含今日
|
||||
数据更新于 {updatedAt ?? '--'} · 北京时间 · 日期窗口按 00:00 自然日切分,自定义日期可选择今日
|
||||
</p>
|
||||
</div>
|
||||
<div className="controls">
|
||||
@@ -734,7 +734,7 @@ export default function DashboardPage() {
|
||||
format="YYYY-MM-DD"
|
||||
allowClear={false}
|
||||
open={datePickerOpen}
|
||||
disabledDate={(date) => date.isAfter(dayjs().subtract(1, 'day'), 'day')}
|
||||
disabledDate={(date) => date.isAfter(dayjs(), 'day')}
|
||||
suffixIcon={<CalendarOutlined />}
|
||||
onClick={() => setDatePickerOpen(true)}
|
||||
onOpenChange={setDatePickerOpen}
|
||||
|
||||
@@ -570,6 +570,7 @@ export function WithdrawReviewPage({ mode = 'other' }: { mode?: WithdrawReviewMo
|
||||
},
|
||||
{
|
||||
title: '失败/拒绝原因',
|
||||
key: 'fail_reason',
|
||||
dataIndex: 'fail_reason',
|
||||
ellipsis: true,
|
||||
render: (v: string | null) => v || <Text type="secondary">-</Text>,
|
||||
@@ -647,6 +648,10 @@ export function WithdrawReviewPage({ mode = 'other' }: { mode?: WithdrawReviewMo
|
||||
},
|
||||
},
|
||||
];
|
||||
const visibleColumns =
|
||||
activeStatus === 'pending' || activeStatus === 'success'
|
||||
? columns.filter((column) => column.key !== 'fail_reason')
|
||||
: columns;
|
||||
|
||||
const inviteeColumns: ColumnsType<InviteeDetail> = [
|
||||
{ title: '手机号', dataIndex: 'phone', width: 130 },
|
||||
@@ -945,7 +950,7 @@ export function WithdrawReviewPage({ mode = 'other' }: { mode?: WithdrawReviewMo
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
columns={columns}
|
||||
columns={visibleColumns}
|
||||
dataSource={items}
|
||||
loading={loading}
|
||||
pagination={{
|
||||
@@ -989,12 +994,6 @@ export function WithdrawReviewPage({ mode = 'other' }: { mode?: WithdrawReviewMo
|
||||
<Descriptions.Item label="金额">
|
||||
<Text strong>{yuan(detail.order.amount_cents)}</Text>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="提现类型">
|
||||
{detail.order.source === 'invite_cash' ? '邀请奖励提现' : '福利页提现'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="累计成功提现">
|
||||
{yuan(detail.cumulative_success_cents)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="提交时间">
|
||||
{dt(detail.order.created_at)}
|
||||
</Descriptions.Item>
|
||||
|
||||
@@ -37,6 +37,18 @@ export function percentile(values: readonly number[], q: number, round = true):
|
||||
return round ? Math.round(result) : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 离散计数分位数(nearest-rank)。
|
||||
* 广告条数等不可拆分的计数不做线性插值,结果始终取自真实样本。
|
||||
*/
|
||||
export function nearestRankPercentile(values: readonly number[], q: number): number | null {
|
||||
if (!values.length) return null;
|
||||
const sorted = [...values].sort((a, b) => a - b);
|
||||
const quantile = Math.min(1, Math.max(0, q));
|
||||
const rank = Math.max(1, Math.ceil(quantile * sorted.length));
|
||||
return sorted[rank - 1];
|
||||
}
|
||||
|
||||
const hasTz = (v: string) => /(?:Z|[+-]\d{2}:?\d{2})$/i.test(v);
|
||||
|
||||
/** 把 UTC 口径字符串解析为带时区的 dayjs(无时区后缀的补 Z 当 UTC)。 */
|
||||
|
||||
+3
-1
@@ -457,6 +457,7 @@ export interface ComparisonRecordListItem {
|
||||
source_price_cents: number | null;
|
||||
best_price_cents: number | null;
|
||||
saved_amount_cents: number | null;
|
||||
ordered: boolean;
|
||||
total_ms: number | null;
|
||||
step_count: number | null;
|
||||
llm_call_count: number | null;
|
||||
@@ -465,8 +466,10 @@ export interface ComparisonRecordListItem {
|
||||
output_tokens: number | null;
|
||||
llm_cost_yuan: number | null; // 后端按「当时价」冻结的实际成本(元);旧记录 null → 「成本」列回退估算
|
||||
device_model: string | null;
|
||||
device_model_name: string | null;
|
||||
rom_vendor: string | null;
|
||||
rom_name: string | null;
|
||||
rom_version: number | null;
|
||||
android_version: string | null;
|
||||
app_version: string | null;
|
||||
ad_revenue_yuan: number; // 本次比价看的信息流广告预估收益(元)
|
||||
@@ -517,7 +520,6 @@ export interface ComparisonRecordDetail extends ComparisonRecordListItem {
|
||||
comparison_results: Record<string, unknown>[];
|
||||
skipped_dish_names: string[];
|
||||
device_manufacturer: string | null;
|
||||
rom_version: number | null;
|
||||
android_sdk: number | null;
|
||||
app_version_code: number | null;
|
||||
source_app_version: string | null;
|
||||
|
||||
Reference in New Issue
Block a user