Compare commits

..

8 Commits

Author SHA1 Message Date
zuochenyong c564e9df12 feat(config): 增加两套引导视频奖励配置 (#96)
Co-authored-by: guke <guke@wonderable.ai>
Co-authored-by: exinglang <exinglang@qq.com>
Reviewed-on: #96
Co-authored-by: zuochenyong <zuochenyong@wonderable.ai>
Co-committed-by: zuochenyong <zuochenyong@wonderable.ai>
2026-07-29 15:18:51 +08:00
linkeyu a286f859ee 修复:业务收益详情继承广告收益筛选口径 (#94)
## 修复

- 点击广告收益页用户后,详情默认继承已执行查询的日期范围
- 同步传递正式/测试环境、业务/全量代码位口径、领券/比价场景
- 传递的是上一次成功查询的快照,避免用户改了筛选但尚未点“查询”时详情口径漂移
- 文案明确 Draw eCPM 基于全部实际展示(含未发奖)

## 验证

- 已重放到最新 `main`,无冲突
- `npm run build` 通过(含 TypeScript 类型检查)

## 依赖/上线顺序

依赖 app-server 配套 PR 新增的 `app_env`、`revenue_scope`、`feed_scene` 查询参数;请先上线后端,再上线本 PR。

---------

Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #94
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-28 17:58:04 +08:00
linkeyu 549c9bdfad 修复:统一领券与比价广告数百分位口径 (#92)
## 改动说明

- 将单次领券、比价广告数从线性插值百分位改为 nearest-rank 离散百分位
- 百分位结果始终取自真实观测样本,不再出现 13.5 条这类小数广告数
- 指标展示改为整数

## 线上数据复算

2026-07-24 正式业务口径:

- 领券 P5/P50/P95:`1/7/13.5` 修正为 `1/7/15`
- 比价 P5/P50/P95:`1/2/8.3` 修正为 `1/2/9`

## 验证

- 线上数据完整分组复算通过
- 空样本、单样本边界校验通过
- `npm run build` 通过(含 TypeScript 类型检查)

---------

Co-authored-by: guke <guke@wonderable.ai>
Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #92
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-28 13:50:40 +08:00
linkeyu 26b1adb769 优化:数据大盘支持选择今日 (#93)
## 改动说明

- 数据大盘自定义日期范围放开今日选择
- 仍禁止选择明日及未来日期
- 同步修正页面日期口径文案
- 快捷窗口仍按原口径默认截至昨日

## 口径核对

后端 `stats/overview` 及广告收益查询已支持北京时间今日自然日区间,本次无需修改后端。

## 验证

- 昨日:可选
- 今日:可选
- 明日/未来日期:禁用
- `npm run build` 通过(含 TypeScript 类型检查)

---------

Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #93
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-28 13:50:14 +08:00
linkeyu 0040c5795d 优化提现审核页原因列展示 (#90)
## 改动内容
- 已到账页签隐藏无关的失败/拒绝原因列
- 打款中页签隐藏无关的失败/拒绝原因列
- 待审核、已拒绝、打款失败及全部页签继续保留原因列
- 详情抽屉中的失败/拒绝原因保持不变

## 验证
- npm run build 通过
- git diff --check 通过

---------

Co-authored-by: guke <guke@wonderable.ai>
Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #90
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-28 10:04:21 +08:00
linkeyu 5acfb05c57 优化提现审核侧页基础信息展示 (#91)
## 改动内容
- 删除提现详情侧页的提现类型
- 删除提现单区域重复展示的累计成功提现
- 用户详情和邀请详情中的累计成功提现继续保留
- 两类累计金额继续按 coin_cash / invite_cash 账户分别统计

## 验证
- 前端 npm run build 通过
- 后端账户隔离相关测试 2 passed
- 线上数据库抽查确认两类提现金额独立
- git diff --check 通过

---------

Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #91
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-28 10:04:04 +08:00
linkeyu bea35fb707 在比价记录中展示是否下单 (#88)
## 改动说明
- 在“省”列后新增“是否下单”列
- 使用“已下单/未下单”标签展示
- 同步补充前端接口类型

## 验证
- Next.js 生产构建和类型检查通过

---------

Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #88
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-27 17:33:23 +08:00
linkeyu 93c3daa784 优化比价记录设备信息展示 (#87)
## 改动说明
- 机型优先显示可读商品名,同时保留原始设备编码
- 列表和详情展示 ROM 厂商、名称与版本
- 同步补充前端接口类型

## 验证
- Next.js 生产构建通过
- 本地页面列表与详情抽屉已检查

---------

Co-authored-by: guke <guke@wonderable.ai>
Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #87
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-27 16:38:35 +08:00
10 changed files with 219 additions and 152 deletions
@@ -32,9 +32,24 @@ interface Props {
onClose: () => void;
userId: number | null;
phone: string | null; // 报表行已有的手机号:概览拉取失败时兜底展示
dateFrom: string | null;
dateTo: string | null;
appEnv?: 'prod' | 'test';
revenueScope: 'business' | 'all';
feedScene?: 'comparison' | 'coupon' | 'welfare';
}
export default function UserAdRevenueDrawer({ open, onClose, userId, phone }: Props) {
export default function UserAdRevenueDrawer({
open,
onClose,
userId,
phone,
dateFrom,
dateTo,
appEnv,
revenueScope,
feedScene,
}: Props) {
// UserRewardPanel 的 user 快照:它只读 phone/nickname/wechat_nickname/created_at,其余按 snapshot 形状补齐。
const [user, setUser] = useState<WithdrawUserSnapshot | null>(null);
@@ -82,7 +97,19 @@ export default function UserAdRevenueDrawer({ open, onClose, userId, phone }: Pr
>
{/* userId 就绪即渲染;UserRewardPanel 内部按 userId 自行拉统计与金币记录,user 基本信息随后补上。
statsVariant="ad":统计区只显示 6 项看广告统计(累计提现/现金余额/激励视频观看数+eCPM/draw观看数+eCPM) */}
{userId != null && <UserRewardPanel userId={userId} user={user} statsVariant="ad" />}
{userId != null && (
<UserRewardPanel
key={`${userId}-${dateFrom}-${dateTo}-${appEnv}-${revenueScope}-${feedScene}`}
userId={userId}
user={user}
statsVariant="ad"
initialDateFrom={dateFrom ?? undefined}
initialDateTo={dateTo ?? undefined}
appEnv={appEnv}
revenueScope={revenueScope}
feedScene={feedScene}
/>
)}
</Drawer>
);
}
+44 -12
View File
@@ -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,
@@ -470,7 +470,27 @@ export default function AdRevenueReportPage() {
const [loading, setLoading] = useState(false);
const [formulaOpen, setFormulaOpen] = useState(false);
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
const [userDrawer, setUserDrawer] = useState<{ userId: number; phone: string | null } | null>(null);
const [userDrawer, setUserDrawer] = useState<{
userId: number;
phone: string | null;
dateFrom: string;
dateTo: string;
appEnv?: 'prod' | 'test';
revenueScope: 'business' | 'all';
feedScene?: 'comparison' | 'coupon' | 'welfare';
} | null>(null);
const [queriedDetailFilters, setQueriedDetailFilters] = useState<{
dateFrom: string;
dateTo: string;
appEnv?: 'prod' | 'test';
revenueScope: 'business' | 'all';
feedScene?: 'comparison' | 'coupon' | 'welfare';
}>({
dateFrom: range[0].format('YYYY-MM-DD'),
dateTo: range[1].format('YYYY-MM-DD'),
appEnv: 'prod',
revenueScope: 'business',
});
// 当前选择是否跨多天:跨多天时「按小时」无意义,粒度强制按天
const rangeMultiDay = range[0].format('YYYY-MM-DD') !== range[1].format('YYYY-MM-DD');
@@ -503,6 +523,13 @@ export default function AdRevenueReportPage() {
},
});
setData(res.data);
setQueriedDetailFilters({
dateFrom: from,
dateTo: to,
appEnv: appEnv === 'all' ? undefined : appEnv,
revenueScope,
feedScene: scene as 'comparison' | 'coupon' | 'welfare' | undefined,
});
setPage(targetPage);
setQueriedLimit(targetLimit);
setQueriedGranularity(gran);
@@ -551,7 +578,7 @@ export default function AdRevenueReportPage() {
width: 150,
render: (phone: string | null, r: AdRevenueRow) => (
// 点手机号/用户 → 打开该用户「广告收益详情」半屏抽屉(统计卡 + 金币记录)
<a onClick={() => setUserDrawer({ userId: r.user_id, phone })}>
<a onClick={() => setUserDrawer({ userId: r.user_id, phone, ...queriedDetailFilters })}>
{phone ? (
<span>
{phone}
@@ -758,9 +785,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 +1110,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>
)}
@@ -1284,6 +1311,11 @@ export default function AdRevenueReportPage() {
open={!!userDrawer}
userId={userDrawer?.userId ?? null}
phone={userDrawer?.phone ?? null}
dateFrom={userDrawer?.dateFrom ?? null}
dateTo={userDrawer?.dateTo ?? null}
appEnv={userDrawer?.appEnv}
revenueScope={userDrawer?.revenueScope ?? 'all'}
feedScene={userDrawer?.feedScene}
onClose={() => setUserDrawer(null)}
/>
</div>
@@ -333,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',
+94 -123
View File
@@ -1,7 +1,7 @@
'use client';
import { useEffect, useState } from 'react';
import { Button, Card, Space, Spin, Switch, Tag, Typography, Upload, message } from 'antd';
import { Button, Card, InputNumber, Space, Spin, Switch, Tag, Typography, Upload, message } from 'antd';
import { DeleteOutlined, UploadOutlined } from '@ant-design/icons';
import { api, errMsg } from '@/lib/api';
import { canDo } from '@/lib/auth';
@@ -9,55 +9,58 @@ import { mediaUrl } from '@/lib/media';
import type { GuideVideoConfig as GuideCfg } from '@/lib/types';
const { Text } = Typography;
/** 后端 media.save_guide_video 只认 MP4 魔数;这里先在浏览器挡一道,省得白传 100MB。 */
const MAX_BYTES = 100 * 1024 * 1024;
type Scene = 'coupon' | 'comparison';
/**
* 领券等候浮层的「新手引导视频」配置。
*
* 用户点首页「一键自动领取」→ 出等候浮层,浮层下方那块位置**前 3 次**放这支引导视频
* (而不是广告),每次固定发 120 金币;播完若浮层还开着,自动接着放广告(原逻辑)。
* 「系统配置 → 领券引导视频」tab 的一个区块。
*
* 后台只管两件事:**开关** 和 **换片**。次数(3)/ 金币(120)走服务端默认值,产品已拍板不再
* 开放配置,所以这里不渲染输入框、PATCH 也不带这两个字段(后端仍保留字段与默认值)。
*/
export default function GuideVideoConfig() {
const META: Record<Scene, { title: string; action: string }> = {
coupon: { title: '一键自动领取引导视频', action: '一键自动领取' },
comparison: { title: '开始比价引导视频', action: '开始比价' },
};
function SceneConfig({ scene }: { scene: Scene }) {
const meta = META[scene];
const [cfg, setCfg] = useState<GuideCfg | null>(null);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [uploading, setUploading] = useState(false);
// 本地编辑态,保存时一次性 PATCH
const [enabled, setEnabled] = useState(true);
const [maxPlays, setMaxPlays] = useState(3);
const [rewardCoin, setRewardCoin] = useState(100);
const canEdit = canDo(['operator']);
const sync = (c: GuideCfg) => {
setCfg(c);
setEnabled(c.enabled);
const sync = (value: GuideCfg) => {
setCfg(value);
setEnabled(value.enabled);
setMaxPlays(value.max_plays);
setRewardCoin(value.reward_coin);
};
const load = async () => {
setLoading(true);
try {
const { data } = await api.get<GuideCfg>('/admin/api/guide-video');
const { data } = await api.get<GuideCfg>('/admin/api/guide-video', { params: { scene } });
sync(data);
} catch (e) {
message.error(errMsg(e));
} finally {
setLoading(false);
}
};
useEffect(() => {
load();
}, []);
void load();
}, [scene]);
const save = async () => {
setSaving(true);
try {
const { data } = await api.patch<GuideCfg>('/admin/api/guide-video', { enabled });
const { data } = await api.patch<GuideCfg>(
'/admin/api/guide-video',
{ enabled, max_plays: maxPlays, reward_coin: rewardCoin },
{ params: { scene } },
);
sync(data);
message.success('已保存,用户下一次进入领券浮层即生效');
message.success(`${meta.title}配置已保存,下次触发即生效`);
} catch (e) {
message.error(errMsg(e));
} finally {
@@ -65,11 +68,27 @@ export default function GuideVideoConfig() {
}
};
// antd Upload:beforeUpload 里自行 POST(multipart),返回 false 阻止其默认上传。
const uploadVideo = async (file: File) => {
const form = new FormData();
form.append('file', file);
setUploading(true);
try {
const { data } = await api.post<GuideCfg>(
'/admin/api/guide-video/video',
form,
{ params: { scene } },
);
sync(data);
message.success(`${meta.title}已更新`);
} catch (e) {
message.error(errMsg(e));
} finally {
setUploading(false);
}
};
const beforeUpload = (file: File) => {
// 有些系统给 .mp4 的 type 是空串,不能只看 type,再兜一层扩展名。
const looksMp4 = file.type === 'video/mp4' || /\.mp4$/i.test(file.name);
if (!looksMp4) {
if (file.type !== 'video/mp4' && !/\.mp4$/i.test(file.name)) {
message.error('仅支持 MP4 视频(H.264 编码)');
return Upload.LIST_IGNORE;
}
@@ -81,27 +100,15 @@ export default function GuideVideoConfig() {
return false;
};
const uploadVideo = async (file: File) => {
const form = new FormData();
form.append('file', file);
setUploading(true);
try {
const { data } = await api.post<GuideCfg>('/admin/api/guide-video/video', form);
sync(data);
message.success('引导视频已更新,用户下一次进入领券浮层即生效');
} catch (e) {
message.error(errMsg(e));
} finally {
setUploading(false);
}
};
const removeVideo = async () => {
setUploading(true);
try {
const { data } = await api.delete<GuideCfg>('/admin/api/guide-video/video');
const { data } = await api.delete<GuideCfg>(
'/admin/api/guide-video/video',
{ params: { scene } },
);
sync(data);
message.success('已移除引导视频,领券浮层恢复为只放广告');
message.success(`已移除${meta.title}`);
} catch (e) {
message.error(errMsg(e));
} finally {
@@ -112,82 +119,48 @@ export default function GuideVideoConfig() {
return (
<Card
size="small"
title="领券引导视频(App 领券等候浮层,前 3 次替代广告)"
title={meta.title}
style={{ marginBottom: 16 }}
extra={
cfg?.updated_at ? (
<Text type="secondary" style={{ fontSize: 12 }}>
{new Date(cfg.updated_at).toLocaleString('zh-CN')}
</Text>
) : null
}
extra={cfg?.updated_at ? <Text type="secondary"> {new Date(cfg.updated_at).toLocaleString('zh-CN')}</Text> : null}
>
<p style={{ color: '#999', marginTop: 0 }}>
广<b> 3 </b>
<b></b> <b>120 </b>广
<b></b><b></b>
<b></b><b></b>
<p style={{ color: '#777', marginTop: 0 }}>
Android {meta.action}广
</p>
{loading || !cfg ? (
<Spin style={{ display: 'block', margin: '24px 0' }} />
) : (
<Space align="start" size={32} wrap>
{/* 左:视频预览 */}
<div>
<Text type="secondary" style={{ fontSize: 12 }}>
</Text>
<div style={{ marginTop: 8, width: 240 }}>
{cfg.video_url ? (
// eslint-disable-next-line jsx-a11y/media-has-caption
<video
src={mediaUrl(cfg.video_url)}
controls
style={{
width: 240,
maxHeight: 420,
borderRadius: 12,
background: '#000',
border: '1px solid #f0f0f0',
}}
/>
) : (
<div
style={{
width: 240,
height: 320,
borderRadius: 12,
border: '1px dashed #d9d9d9',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: '#bbb',
fontSize: 13,
textAlign: 'center',
padding: 16,
}}
>
<br />
广
</div>
)}
</div>
{!enabled && cfg.video_url && (
<div style={{ color: '#fa8c16', fontSize: 12, marginTop: 6 }}>
广
<div style={{ width: 240 }}>
{cfg.video_url ? (
// eslint-disable-next-line jsx-a11y/media-has-caption
<video
src={mediaUrl(cfg.video_url)}
controls
style={{ width: 240, maxHeight: 420, borderRadius: 12, background: '#000' }}
/>
) : (
<div style={{ height: 280, border: '1px dashed #d9d9d9', borderRadius: 12, display: 'grid', placeItems: 'center', color: '#aaa' }}>
</div>
)}
</div>
{/* 右:编辑控件 */}
<Space direction="vertical" size="middle" style={{ minWidth: 360 }}>
<Space direction="vertical" size="middle" style={{ minWidth: 390 }}>
<Space>
<span></span>
<span></span>
<Switch checked={enabled} disabled={!canEdit} onChange={setEnabled} />
{!enabled && <Tag color="orange"></Tag>}
</Space>
<Space>
<span></span>
<InputNumber min={0} max={50} precision={0} value={maxPlays} disabled={!canEdit} onChange={(v) => setMaxPlays(v ?? 0)} />
<Text type="secondary"> N 3</Text>
</Space>
<Space>
<span></span>
<InputNumber min={0} max={10000} precision={0} value={rewardCoin} disabled={!canEdit} onChange={(v) => setRewardCoin(v ?? 0)} />
<Text type="secondary"> 100</Text>
</Space>
<Space wrap>
<Upload accept="video/mp4,.mp4" showUploadList={false} beforeUpload={beforeUpload} disabled={!canEdit}>
<Button icon={<UploadOutlined />} loading={uploading} disabled={!canEdit}>
@@ -195,28 +168,26 @@ export default function GuideVideoConfig() {
</Button>
</Upload>
{cfg.video_url && (
<Button
icon={<DeleteOutlined />}
danger
loading={uploading}
disabled={!canEdit}
onClick={removeVideo}
>
<Button icon={<DeleteOutlined />} danger loading={uploading} disabled={!canEdit} onClick={removeVideo}>
</Button>
)}
<Text type="secondary" style={{ fontSize: 12 }}>
MP4H.264100MB
</Text>
<Text type="secondary">MP4H.264100MB</Text>
</Space>
<Button type="primary" loading={saving} disabled={!canEdit} onClick={save}>
</Button>
{!canEdit && <Text type="secondary"> operator / super_admin </Text>}
<Button type="primary" loading={saving} disabled={!canEdit} onClick={save}></Button>
<Text type="secondary"> {cfg.total_plays} {cfg.granted_plays} </Text>
</Space>
</Space>
)}
</Card>
);
}
export default function GuideVideoConfig() {
return (
<>
<SceneConfig scene="coupon" />
<SceneConfig scene="comparison" />
</>
);
}
+1 -1
View File
@@ -165,7 +165,7 @@ export default function ConfigPage() {
},
{ key: 'welfare', label: '福利页', children: welfareConfig },
{ key: 'feedback-qr', label: '反馈二维码', children: <FeedbackQrConfig /> },
{ key: 'guide-video', label: '领券引导视频', children: <GuideVideoConfig /> },
{ key: 'guide-video', label: '引导视频奖励', children: <GuideVideoConfig /> },
]}
/>
</div>
+2 -2
View File
@@ -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}
+20 -4
View File
@@ -44,6 +44,11 @@ interface Props {
withdrawSource?: 'coin_cash' | 'invite_cash';
// 统计区字段集:withdraw(默认,提现详情:含提现细分) / ad(广告收益详情:只看看广告观看统计,对齐参考图 6 项)
statsVariant?: 'withdraw' | 'ad';
initialDateFrom?: string;
initialDateTo?: string;
appEnv?: 'prod' | 'test';
revenueScope?: 'business' | 'all';
feedScene?: 'comparison' | 'coupon' | 'welfare';
}
/** 用户看广告/提现详情:基本信息 + 互斥时间筛选 + 统计区(按 statsVariant 取字段集)+ 金币发放记录表。 */
@@ -52,9 +57,17 @@ export default function UserRewardPanel({
user,
withdrawSource,
statsVariant = 'withdraw',
initialDateFrom,
initialDateTo,
appEnv,
revenueScope = 'all',
feedScene,
}: Props) {
const [mode, setMode] = useState<'all' | 'range'>('all'); // all=注册至今 / range=自定义区间
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
const hasInitialRange = Boolean(initialDateFrom && initialDateTo);
const [mode, setMode] = useState<'all' | 'range'>(hasInitialRange ? 'range' : 'all');
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(() =>
hasInitialRange ? [dayjs(initialDateFrom), dayjs(initialDateTo)] : null,
);
const [stats, setStats] = useState<UserRewardStats | null>(null);
const [statsLoading, setStatsLoading] = useState(false);
@@ -80,6 +93,9 @@ export default function UserRewardPanel({
params: {
...JSON.parse(paramsKey),
...(withdrawSource ? { withdraw_source: withdrawSource } : {}),
...(appEnv ? { app_env: appEnv } : {}),
revenue_scope: revenueScope,
...(feedScene ? { feed_scene: feedScene } : {}),
},
});
setStats(data);
@@ -88,7 +104,7 @@ export default function UserRewardPanel({
} finally {
setStatsLoading(false);
}
}, [userId, paramsKey, withdrawSource]);
}, [userId, paramsKey, withdrawSource, appEnv, revenueScope, feedScene]);
const loadRecords = useCallback(
async (p: number) => {
@@ -236,7 +252,7 @@ export default function UserRewardPanel({
</Descriptions>
<Text type="secondary" style={{ fontSize: 12 }}>
{statsVariant === 'ad'
? '统计随上方时间筛选(现金余额除外,为当前快照);次数仅统计成功发奖记录,信息流按奖励份数统计;eCPM 为预估值。'
? '统计继承广告收益页已查询的日期、环境、业务代码位和场景;次数仅统计成功发奖记录,信息流按奖励份数统计;Draw eCPM 按全部实际展示统计(含未发奖)。'
: '统计随上方时间筛选(现金余额除外,为当前快照);提现按申请提交时间统计;累计收益为已发金币按当前汇率折算,不代表实际已提现金额;eCPM 为预估值。'}
</Text>
@@ -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>
+12
View File
@@ -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
View File
@@ -233,7 +233,7 @@ export interface UserRewardStats {
reward_video_avg_ecpm: number; // 平均激励视频 eCPM(分/千次)
reward_video_cash_cents: number; // 激励视频提现
feed_count: number; // 累计信息流广告数(份)
feed_avg_ecpm: number; // 平均信息流广告 eCPM(分/千次)
feed_avg_ecpm: number; // 全部 Draw/feed 实际展示的平均 eCPM(分/千次,含未发奖展示)
feed_cash_cents: number; // 信息流广告提现
}
@@ -417,6 +417,7 @@ export interface FeedbackQrConfig {
/** 领券等候浮层的「新手引导视频」配置(前 3 次用它替代广告,每次固定 120 金币)。
* 后台只开放 enabled + 换片;下面几个字段接口仍返回,但页面不展示、也不回传。 */
export interface GuideVideoConfig {
scene: 'coupon' | 'comparison';
enabled: boolean;
video_url: string | null; // /media/guide_video/xxx.mp4;null = 未配片(浮层照旧只放广告)
max_plays: number; // 每个账号前 N 次浮层放引导视频(服务端默认 3,后台不开放调整)
@@ -457,6 +458,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;