Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2727eaa929 | |||
| af74ecf9d3 | |||
| 3102a96bd3 | |||
| 7f5dde5c2f | |||
| c8293d57b3 |
@@ -0,0 +1,84 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
// 点收益报表里的用户手机号 → 半屏抽屉展示该用户的广告收益详情(统计卡 + 金币记录)。
|
||||||
|
// 复用「提现详情」里的 UserRewardPanel(数据走 /users/{id}/reward-stats + /coin-records);
|
||||||
|
// 用户基本信息(昵称/注册时间/钱包)取自 /users/{id} 概览。抽屉样式(width 50% 半屏)与提现详情一致。
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Drawer } from 'antd';
|
||||||
|
import { api } from '@/lib/api';
|
||||||
|
import type { WithdrawUserSnapshot } from '@/lib/types';
|
||||||
|
import UserRewardPanel from '../withdraws/UserRewardPanel';
|
||||||
|
|
||||||
|
// GET /admin/api/users/{id} 概览里我们要用到的子集(前端未单独定义 AdminUserOverview 类型)。
|
||||||
|
interface UserOverviewResp {
|
||||||
|
user: {
|
||||||
|
id: number;
|
||||||
|
phone: string;
|
||||||
|
nickname: string | null;
|
||||||
|
status: string;
|
||||||
|
wechat_nickname: string | null;
|
||||||
|
created_at: string;
|
||||||
|
last_login_at: string;
|
||||||
|
};
|
||||||
|
cash_balance_cents: number;
|
||||||
|
withdraw_total: number;
|
||||||
|
withdraw_success_cents: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
userId: number | null;
|
||||||
|
phone: string | null; // 报表行已有的手机号:概览拉取失败时兜底展示
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function UserAdRevenueDrawer({ open, onClose, userId, phone }: Props) {
|
||||||
|
// UserRewardPanel 的 user 快照:它只读 phone/nickname/wechat_nickname/created_at,其余按 snapshot 形状补齐。
|
||||||
|
const [user, setUser] = useState<WithdrawUserSnapshot | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open || userId == null) return;
|
||||||
|
let alive = true;
|
||||||
|
setUser(null);
|
||||||
|
api
|
||||||
|
.get<UserOverviewResp>(`/admin/api/users/${userId}`)
|
||||||
|
.then((r) => {
|
||||||
|
if (!alive) return;
|
||||||
|
const o = r.data;
|
||||||
|
setUser({
|
||||||
|
id: o.user.id,
|
||||||
|
phone: o.user.phone,
|
||||||
|
nickname: o.user.nickname,
|
||||||
|
status: o.user.status,
|
||||||
|
wechat_nickname: o.user.wechat_nickname, // 概览接口已返回微信昵称
|
||||||
|
wechat_avatar_url: null,
|
||||||
|
created_at: o.user.created_at,
|
||||||
|
last_login_at: o.user.last_login_at,
|
||||||
|
cash_balance_cents: o.cash_balance_cents,
|
||||||
|
withdraw_total: o.withdraw_total,
|
||||||
|
withdraw_success_cents: o.withdraw_success_cents,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// 概览失败:退回只带手机号,昵称/注册天数显示「-」,不阻塞统计/金币记录(它们由 userId 独立拉)
|
||||||
|
if (alive) setUser(phone ? ({ phone } as WithdrawUserSnapshot) : null);
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
alive = false;
|
||||||
|
};
|
||||||
|
}, [open, userId, phone]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
title={`用户广告收益详情${phone ? ` · ${phone}` : ''}`}
|
||||||
|
width="50%"
|
||||||
|
open={open}
|
||||||
|
onClose={onClose}
|
||||||
|
destroyOnHidden
|
||||||
|
>
|
||||||
|
{/* userId 就绪即渲染;UserRewardPanel 内部按 userId 自行拉统计与金币记录,user 基本信息随后补上。
|
||||||
|
statsVariant="ad":统计区只显示 6 项看广告统计(累计提现/现金余额/激励视频观看数+eCPM/draw观看数+eCPM) */}
|
||||||
|
{userId != null && <UserRewardPanel userId={userId} user={user} statsVariant="ad" />}
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -40,13 +40,15 @@ import type {
|
|||||||
AdRevenueRow,
|
AdRevenueRow,
|
||||||
AdRevenueTypeStat,
|
AdRevenueTypeStat,
|
||||||
} from '@/lib/types';
|
} from '@/lib/types';
|
||||||
|
import UserAdRevenueDrawer from './UserAdRevenueDrawer';
|
||||||
|
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
// 广告类型标签
|
// 广告类型标签
|
||||||
const TYPE_TAG: Record<string, { color: string; label: string }> = {
|
const TYPE_TAG: Record<string, { color: string; label: string }> = {
|
||||||
reward_video: { color: 'blue', label: '激励视频' },
|
reward_video: { color: 'blue', label: '激励视频' },
|
||||||
feed: { color: 'purple', label: '信息流' },
|
// 历史误标 feed(领券/比价广告修 adType 之前上报)一律按 Draw 信息流显示——业务已全切 Draw
|
||||||
|
feed: { color: 'geekblue', label: 'Draw 信息流' },
|
||||||
draw: { color: 'geekblue', label: 'Draw 信息流' },
|
draw: { color: 'geekblue', label: 'Draw 信息流' },
|
||||||
withdrawal_video: { color: 'gold', label: '提现激励视频' },
|
withdrawal_video: { color: 'gold', label: '提现激励视频' },
|
||||||
};
|
};
|
||||||
@@ -131,12 +133,6 @@ const DETAIL_COLUMNS: ColumnsType<AdRevenueRecord> = [
|
|||||||
},
|
},
|
||||||
{ title: '应发金币', dataIndex: 'expected_coin', width: 100, render: (v: number) => <b>{v}</b> },
|
{ title: '应发金币', dataIndex: 'expected_coin', width: 100, render: (v: number) => <b>{v}</b> },
|
||||||
{ title: '实发金币', dataIndex: 'actual_coin', width: 100 },
|
{ title: '实发金币', dataIndex: 'actual_coin', width: 100 },
|
||||||
{
|
|
||||||
title: '一致',
|
|
||||||
dataIndex: 'matched',
|
|
||||||
width: 80,
|
|
||||||
render: (m: boolean) => (m ? <Tag color="green">✓</Tag> : <Tag color="red">✗ 不符</Tag>),
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// 趋势图(纯 SVG,零依赖):柱=展示条数(左轴),橙线=客户端预估收益元(右轴),
|
// 趋势图(纯 SVG,零依赖):柱=展示条数(左轴),橙线=客户端预估收益元(右轴),
|
||||||
@@ -309,6 +305,8 @@ export default function AdRevenueReportPage() {
|
|||||||
const [queriedLimit, setQueriedLimit] = useState<number>(500);
|
const [queriedLimit, setQueriedLimit] = useState<number>(500);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [formulaOpen, setFormulaOpen] = useState(false);
|
const [formulaOpen, setFormulaOpen] = useState(false);
|
||||||
|
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
|
||||||
|
const [userDrawer, setUserDrawer] = useState<{ userId: number; phone: string | null } | null>(null);
|
||||||
|
|
||||||
// 当前选择是否跨多天:跨多天时「按小时」无意义,粒度强制按天
|
// 当前选择是否跨多天:跨多天时「按小时」无意义,粒度强制按天
|
||||||
const rangeMultiDay = range[0].format('YYYY-MM-DD') !== range[1].format('YYYY-MM-DD');
|
const rangeMultiDay = range[0].format('YYYY-MM-DD') !== range[1].format('YYYY-MM-DD');
|
||||||
@@ -364,25 +362,39 @@ export default function AdRevenueReportPage() {
|
|||||||
title: '用户',
|
title: '用户',
|
||||||
dataIndex: 'user_phone',
|
dataIndex: 'user_phone',
|
||||||
width: 150,
|
width: 150,
|
||||||
render: (phone: string | null, r: AdRevenueRow) =>
|
render: (phone: string | null, r: AdRevenueRow) => (
|
||||||
phone ? (
|
// 点手机号/用户 → 打开该用户「广告收益详情」半屏抽屉(统计卡 + 金币记录)
|
||||||
<span>
|
<a onClick={() => setUserDrawer({ userId: r.user_id, phone })}>
|
||||||
{phone}
|
{phone ? (
|
||||||
<Typography.Text type="secondary" style={{ fontSize: 11, marginLeft: 6 }}>
|
<span>
|
||||||
#{r.user_id}
|
{phone}
|
||||||
</Typography.Text>
|
<Typography.Text type="secondary" style={{ fontSize: 11, marginLeft: 6 }}>
|
||||||
</span>
|
#{r.user_id}
|
||||||
) : (
|
</Typography.Text>
|
||||||
<Typography.Text type="secondary">#{r.user_id}(无手机号)</Typography.Text>
|
</span>
|
||||||
),
|
) : (
|
||||||
|
<span>#{r.user_id}(无手机号)</span>
|
||||||
|
)}
|
||||||
|
</a>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '广告类型',
|
title: '广告类型',
|
||||||
dataIndex: 'ad_type',
|
dataIndex: 'ad_type',
|
||||||
width: 110,
|
width: 130,
|
||||||
render: (s: string) => {
|
render: (s: string, r: AdRevenueRow) => {
|
||||||
const t = TYPE_TAG[s] ?? { color: 'default', label: s };
|
const t = TYPE_TAG[s] ?? { color: 'default', label: s };
|
||||||
return <Tag color={t.color}>{t.label}</Tag>;
|
return (
|
||||||
|
<span>
|
||||||
|
<Tag color={t.color}>{t.label}</Tag>
|
||||||
|
{/* 一次比价/领券聚合了多条广告时标出条数,点「+」展开看逐条 */}
|
||||||
|
{r.sub_count && r.sub_count > 1 ? (
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 11 }}>
|
||||||
|
{r.sub_count} 条
|
||||||
|
</Typography.Text>
|
||||||
|
) : null}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -428,7 +440,11 @@ export default function AdRevenueReportPage() {
|
|||||||
dataIndex: 'revenue_yuan',
|
dataIndex: 'revenue_yuan',
|
||||||
width: 110,
|
width: 110,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
render: (v: number, r: AdRevenueRow) => (r.has_impression ? v.toFixed(4) : '-'),
|
// 一次比价/领券聚合行用 row_revenue_yuan(该次发奖广告 eCPM 折算之和),其它行用展示侧 revenue_yuan
|
||||||
|
render: (v: number, r: AdRevenueRow) => {
|
||||||
|
const rev = r.row_revenue_yuan ?? v;
|
||||||
|
return r.has_impression || rev > 0 ? rev.toFixed(4) : '-';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '发奖状态',
|
title: '发奖状态',
|
||||||
@@ -456,18 +472,6 @@ export default function AdRevenueReportPage() {
|
|||||||
render: (v: number, r: AdRevenueRow) =>
|
render: (v: number, r: AdRevenueRow) =>
|
||||||
r.has_reward ? v : <Typography.Text type="secondary">-</Typography.Text>,
|
r.has_reward ? v : <Typography.Text type="secondary">-</Typography.Text>,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '一致',
|
|
||||||
dataIndex: 'matched',
|
|
||||||
width: 70,
|
|
||||||
align: 'center',
|
|
||||||
render: (m: boolean, r: AdRevenueRow) =>
|
|
||||||
r.has_reward ? (
|
|
||||||
m ? <Tag color="green">✓</Tag> : <Tag color="red">✗ 不符</Tag>
|
|
||||||
) : (
|
|
||||||
<Typography.Text type="secondary">-</Typography.Text>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '广告位ID',
|
title: '广告位ID',
|
||||||
dataIndex: 'our_code_id',
|
dataIndex: 'our_code_id',
|
||||||
@@ -527,6 +531,10 @@ export default function AdRevenueReportPage() {
|
|||||||
title="收益口径说明"
|
title="收益口径说明"
|
||||||
content={
|
content={
|
||||||
<div style={{ maxWidth: 360, fontSize: 13, lineHeight: 1.7 }}>
|
<div style={{ maxWidth: 360, fontSize: 13, lineHeight: 1.7 }}>
|
||||||
|
<b>主表每行 = 一次广告行为</b>(激励视频一次观看 / 一次比价 / 一次领券);比价·领券的 Draw
|
||||||
|
逐条展示不单独占行(其展示数 / eCPM / 预估收益已计入上方合计与大盘),点行左侧「+」展开看该次金币复算。
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
「预估收益」为客户端在广告展示(onAdShow)时上报 eCPM 折算的预估值(每千次展示 ÷1000
|
「预估收益」为客户端在广告展示(onAdShow)时上报 eCPM 折算的预估值(每千次展示 ÷1000
|
||||||
累加),<b>只要广告展示就计入、不论是否看完发奖</b>;穿山甲会过滤无效/过短曝光,故预估值可能偏高,
|
累加),<b>只要广告展示就计入、不论是否看完发奖</b>;穿山甲会过滤无效/过短曝光,故预估值可能偏高,
|
||||||
<b>实际收益一律以穿山甲后台结算为准</b>。测试应用多为 0。「广告位ID / 来源应用」为本期新增,历史记录留空。
|
<b>实际收益一律以穿山甲后台结算为准</b>。测试应用多为 0。「广告位ID / 来源应用」为本期新增,历史记录留空。
|
||||||
@@ -578,7 +586,6 @@ export default function AdRevenueReportPage() {
|
|||||||
style={{ width: 150 }}
|
style={{ width: 150 }}
|
||||||
options={[
|
options={[
|
||||||
{ value: 'reward_video', label: '激励视频' },
|
{ value: 'reward_video', label: '激励视频' },
|
||||||
{ value: 'feed', label: '信息流' },
|
|
||||||
{ value: 'draw', label: 'Draw 信息流' },
|
{ value: 'draw', label: 'Draw 信息流' },
|
||||||
{ value: 'withdrawal_video', label: '提现激励视频' },
|
{ value: 'withdrawal_video', label: '提现激励视频' },
|
||||||
]}
|
]}
|
||||||
@@ -792,22 +799,6 @@ export default function AdRevenueReportPage() {
|
|||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{data && (
|
|
||||||
<Space direction="vertical" style={{ width: '100%', marginBottom: 12 }}>
|
|
||||||
{data.mismatch_count > 0 ? (
|
|
||||||
<Alert
|
|
||||||
type="error"
|
|
||||||
showIcon
|
|
||||||
message={`共 ${data.total} 条广告事件,其中 ${data.mismatch_count} 条应发≠实发(✗);应发−实发 合计 ${
|
|
||||||
derived && derived.coinGap >= 0 ? '+' : ''
|
|
||||||
}${derived?.coinGap ?? 0} 金币(正=少发/负=多发)——公式可能未生效或发奖有问题。定位到具体记录可用后端逐条审计接口。`}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Alert type="success" showIcon message={`共 ${data.total} 条广告事件,应发与实发全部一致。`} />
|
|
||||||
)}
|
|
||||||
</Space>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{data &&
|
{data &&
|
||||||
(queriedMultiDay
|
(queriedMultiDay
|
||||||
? (data.daily?.length ?? 0) > 0
|
? (data.daily?.length ?? 0) > 0
|
||||||
@@ -884,12 +875,27 @@ export default function AdRevenueReportPage() {
|
|||||||
}}
|
}}
|
||||||
size="small"
|
size="small"
|
||||||
scroll={{ x: 1380 }}
|
scroll={{ x: 1380 }}
|
||||||
rowClassName={(r) => (r.has_reward && !r.matched ? 'row-mismatch' : '')}
|
|
||||||
expandable={{
|
expandable={{
|
||||||
// 每行都可展开(左侧恒有 + 号):有发奖看「金币复算因子」;纯展示看「展示明细」。
|
// 每行都可展开(左侧恒有 + 号):有发奖看「金币复算因子」;纯展示看「展示明细」。
|
||||||
rowExpandable: () => true,
|
rowExpandable: () => true,
|
||||||
expandedRowRender: (r) =>
|
expandedRowRender: (r) =>
|
||||||
r.reward_detail ? (
|
r.sub_rewards && r.sub_rewards.length > 0 ? (
|
||||||
|
<div>
|
||||||
|
<Typography.Text strong>本次广告逐条明细</Typography.Text>{' '}
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
(共 {r.sub_count ?? r.sub_rewards.length} 条 · 应发 {r.expected_coin} / 实发 {r.actual_coin})
|
||||||
|
</Typography.Text>
|
||||||
|
<Table<AdRevenueRecord>
|
||||||
|
style={{ marginTop: 8 }}
|
||||||
|
rowKey="record_id"
|
||||||
|
columns={DETAIL_COLUMNS}
|
||||||
|
dataSource={r.sub_rewards}
|
||||||
|
pagination={false}
|
||||||
|
size="small"
|
||||||
|
scroll={{ x: 900 }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : r.reward_detail ? (
|
||||||
<div>
|
<div>
|
||||||
<Typography.Text strong>金币复算明细</Typography.Text>{' '}
|
<Typography.Text strong>金币复算明细</Typography.Text>{' '}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
@@ -903,7 +909,6 @@ export default function AdRevenueReportPage() {
|
|||||||
pagination={false}
|
pagination={false}
|
||||||
size="small"
|
size="small"
|
||||||
scroll={{ x: 900 }}
|
scroll={{ x: 900 }}
|
||||||
rowClassName={(d) => (d.matched ? '' : 'row-mismatch')}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -979,11 +984,12 @@ export default function AdRevenueReportPage() {
|
|||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<style jsx global>{`
|
<UserAdRevenueDrawer
|
||||||
.row-mismatch > td {
|
open={!!userDrawer}
|
||||||
background: #fff1f0 !important;
|
userId={userDrawer?.userId ?? null}
|
||||||
}
|
phone={userDrawer?.phone ?? null}
|
||||||
`}</style>
|
onClose={() => setUserDrawer(null)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,677 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import {
|
||||||
|
App,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Col,
|
||||||
|
DatePicker,
|
||||||
|
Divider,
|
||||||
|
Input,
|
||||||
|
Row,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Statistic,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
Typography,
|
||||||
|
} from 'antd';
|
||||||
|
import dayjs, { type Dayjs } from 'dayjs';
|
||||||
|
import { api, errMsg } from '@/lib/api';
|
||||||
|
import { formatUtcTime } from '@/lib/format';
|
||||||
|
import UserRecordsDrawer from '@/components/UserRecordsDrawer';
|
||||||
|
|
||||||
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
|
// ── 领券数据看板类型(仅本页用,内联定义)──
|
||||||
|
interface CouponDataSummary {
|
||||||
|
started_count: number;
|
||||||
|
completed_count: number;
|
||||||
|
avg_elapsed_ms: number | null;
|
||||||
|
p5_ms: number | null;
|
||||||
|
p50_ms: number | null;
|
||||||
|
p95_ms: number | null;
|
||||||
|
p99_ms: number | null;
|
||||||
|
}
|
||||||
|
interface CouponDataDaily {
|
||||||
|
date: string;
|
||||||
|
started_count: number;
|
||||||
|
completed_count: number;
|
||||||
|
avg_elapsed_ms: number | null;
|
||||||
|
}
|
||||||
|
interface CouponDataHourly {
|
||||||
|
hour: number;
|
||||||
|
started_count: number;
|
||||||
|
completed_count: number;
|
||||||
|
avg_elapsed_ms: number | null;
|
||||||
|
}
|
||||||
|
interface CouponDataRow {
|
||||||
|
id: number;
|
||||||
|
trace_id: string;
|
||||||
|
user_id: number | null;
|
||||||
|
user_phone: string | null;
|
||||||
|
user_nickname: string | null;
|
||||||
|
status: string;
|
||||||
|
platforms: string[] | null;
|
||||||
|
origin_package: string | null;
|
||||||
|
elapsed_ms: number | null;
|
||||||
|
platform_elapsed: Record<string, number> | null;
|
||||||
|
device_model: string | null;
|
||||||
|
rom: string | null;
|
||||||
|
app_env: string | null;
|
||||||
|
started_at: string;
|
||||||
|
claimed_count: number | null;
|
||||||
|
trace_url: string | null;
|
||||||
|
}
|
||||||
|
interface CouponDataReport {
|
||||||
|
date_from: string;
|
||||||
|
date_to: string;
|
||||||
|
summary: CouponDataSummary;
|
||||||
|
daily: CouponDataDaily[];
|
||||||
|
hourly: CouponDataHourly[];
|
||||||
|
total: number;
|
||||||
|
items: CouponDataRow[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发起来源 App 包名 → 中文(「发起平台」列):空=傻瓜比价首页发起,外卖 App 包名→对应平台。
|
||||||
|
function originLabel(pkg: string | null): string {
|
||||||
|
if (!pkg) return '傻瓜比价';
|
||||||
|
if (pkg.includes('meituan') || pkg.includes('sankuai')) return '美团';
|
||||||
|
if (pkg.includes('taobao') || pkg.includes('ele')) return '淘宝';
|
||||||
|
if (pkg.includes('jingdong') || pkg.includes('jd')) return '京东';
|
||||||
|
return pkg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 领券状态 → 颜色 + 中文(started 无终态 = 中途流失)
|
||||||
|
const STATUS_TAG: Record<string, { color: string; label: string }> = {
|
||||||
|
started: { color: 'default', label: '未完成' },
|
||||||
|
completed: { color: 'green', label: '完成' },
|
||||||
|
failed: { color: 'red', label: '失败' },
|
||||||
|
abandoned: { color: 'orange', label: '中途退出' },
|
||||||
|
};
|
||||||
|
|
||||||
|
// ms → "1.5s"(空值显示 -)
|
||||||
|
const fmtSec = (ms: number | null | undefined): string =>
|
||||||
|
ms == null ? '-' : `${(ms / 1000).toFixed(1)}s`;
|
||||||
|
|
||||||
|
// 点手机号弹出的「该用户全部领券」抽屉列(精简版:单用户,不含用户/手机号列)。
|
||||||
|
const RECORD_COLUMNS: ColumnsType<CouponDataRow> = [
|
||||||
|
{ title: '时间', dataIndex: 'started_at', width: 160, render: (v: string) => formatUtcTime(v) },
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 80,
|
||||||
|
render: (s: string) => {
|
||||||
|
const t = STATUS_TAG[s] ?? { color: 'default', label: s };
|
||||||
|
return <Tag color={t.color}>{t.label}</Tag>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ title: '发起平台', dataIndex: 'origin_package', width: 90, render: (pkg: string | null) => originLabel(pkg) },
|
||||||
|
{ title: '耗时', dataIndex: 'elapsed_ms', width: 80, align: 'right', render: (v: number | null) => fmtSec(v) },
|
||||||
|
{ title: '美团', key: 'mt', width: 70, align: 'right', render: (_: unknown, r: CouponDataRow) => fmtSec(r.platform_elapsed?.['meituan-waimai']) },
|
||||||
|
{ title: '淘宝', key: 'tb', width: 70, align: 'right', render: (_: unknown, r: CouponDataRow) => fmtSec(r.platform_elapsed?.['taobao-shanguang']) },
|
||||||
|
{ title: '京东', key: 'jd', width: 70, align: 'right', render: (_: unknown, r: CouponDataRow) => fmtSec(r.platform_elapsed?.['jd-waimai']) },
|
||||||
|
{
|
||||||
|
title: 'trace',
|
||||||
|
dataIndex: 'trace_id',
|
||||||
|
width: 90,
|
||||||
|
render: (v: string, r: CouponDataRow) =>
|
||||||
|
r.trace_url ? (
|
||||||
|
<a href={r.trace_url} target="_blank" rel="noreferrer" title={v}>trace</a>
|
||||||
|
) : (
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>{v.slice(0, 6)}…</Typography.Text>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// ── 趋势图(纯 SVG,零依赖,复用广告报表同款):浅蓝柱=发起数、深蓝柱=完成数(左轴 次数),橙线=平均耗时(右轴 秒)──
|
||||||
|
const CHART_BAR_STARTED = '#bae0ff';
|
||||||
|
const CHART_BAR_COMPLETED = '#1677ff';
|
||||||
|
const CHART_LINE = '#fa8c16';
|
||||||
|
|
||||||
|
interface TrendPoint {
|
||||||
|
label: string; // x 轴刻度(小时数 / MM-DD)
|
||||||
|
tip: string; // hover 原生 tooltip
|
||||||
|
started: number;
|
||||||
|
completed: number;
|
||||||
|
avgSec: number | null; // 平均耗时(秒);该桶无完成为 null(不画线点)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按天聚合:用 from..to 补齐空缺日为 0,轴连续。
|
||||||
|
function aggregateDaily(dateFrom: string, dateTo: string, daily: CouponDataDaily[]): TrendPoint[] {
|
||||||
|
const map = new Map(daily.map((d) => [d.date, d]));
|
||||||
|
const out: TrendPoint[] = [];
|
||||||
|
let cur = dayjs(dateFrom);
|
||||||
|
let guard = 0;
|
||||||
|
while (cur.format('YYYY-MM-DD') <= dateTo && guard < 400) {
|
||||||
|
const ds = cur.format('YYYY-MM-DD');
|
||||||
|
const d = map.get(ds);
|
||||||
|
const started = d?.started_count ?? 0;
|
||||||
|
const completed = d?.completed_count ?? 0;
|
||||||
|
const avgSec = d?.avg_elapsed_ms != null ? d.avg_elapsed_ms / 1000 : null;
|
||||||
|
out.push({
|
||||||
|
label: ds.slice(5),
|
||||||
|
tip: `${ds} 发起 ${started} · 完成 ${completed} · 平均耗时 ${avgSec == null ? '-' : avgSec.toFixed(1) + 's'}`,
|
||||||
|
started,
|
||||||
|
completed,
|
||||||
|
avgSec,
|
||||||
|
});
|
||||||
|
cur = cur.add(1, 'day');
|
||||||
|
guard += 1;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按小时聚合(0–23)。
|
||||||
|
function aggregateHourly(rows: CouponDataHourly[]): TrendPoint[] {
|
||||||
|
const byHour = new Map(rows.map((r) => [r.hour, r]));
|
||||||
|
return Array.from({ length: 24 }, (_, h) => {
|
||||||
|
const r = byHour.get(h);
|
||||||
|
const started = r?.started_count ?? 0;
|
||||||
|
const completed = r?.completed_count ?? 0;
|
||||||
|
const avgSec = r?.avg_elapsed_ms != null ? r.avg_elapsed_ms / 1000 : null;
|
||||||
|
return {
|
||||||
|
label: String(h),
|
||||||
|
tip: `${String(h).padStart(2, '0')}:00 发起 ${started} · 完成 ${completed} · 平均耗时 ${avgSec == null ? '-' : avgSec.toFixed(1) + 's'}`,
|
||||||
|
started,
|
||||||
|
completed,
|
||||||
|
avgSec,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function TrendChart({ points }: { points: TrendPoint[] }) {
|
||||||
|
const n = points.length;
|
||||||
|
const maxBar = Math.max(1, ...points.map((p) => p.started));
|
||||||
|
const maxSec = Math.max(1e-9, ...points.map((p) => p.avgSec ?? 0));
|
||||||
|
|
||||||
|
const W = 960;
|
||||||
|
const H = 280;
|
||||||
|
const padL = 48;
|
||||||
|
const padR = 56;
|
||||||
|
const padT = 16;
|
||||||
|
const padB = 32;
|
||||||
|
const plotW = W - padL - padR;
|
||||||
|
const plotH = H - padT - padB;
|
||||||
|
const step = plotW / Math.max(1, n);
|
||||||
|
const barW = Math.min(24, step * 0.5);
|
||||||
|
const yBase = padT + plotH;
|
||||||
|
|
||||||
|
const barX = (i: number) => padL + i * step + (step - barW) / 2;
|
||||||
|
const cx = (i: number) => padL + i * step + step / 2;
|
||||||
|
const barH = (v: number) => (v / maxBar) * plotH;
|
||||||
|
const secY = (v: number) => yBase - (v / maxSec) * plotH;
|
||||||
|
// X 轴刻度按天/按小时尽量每格都标(≤31 个点每个都标,超出才抽稀),避免跨度稍大就隔天显示。
|
||||||
|
const labelEvery = Math.max(1, Math.ceil(n / 31));
|
||||||
|
|
||||||
|
// 平均耗时线:仅 avgSec 非 null 的点连线(无完成的桶断开)。
|
||||||
|
const linePts = points
|
||||||
|
.map((p, i) => (p.avgSec == null ? null : `${cx(i)},${secY(p.avgSec)}`))
|
||||||
|
.filter((x): x is string => x !== null)
|
||||||
|
.join(' ');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<svg viewBox={`0 0 ${W} ${H}`} width="100%" style={{ display: 'block' }} role="img" aria-label="趋势图">
|
||||||
|
{[0, 0.25, 0.5, 0.75, 1].map((t) => {
|
||||||
|
const y = yBase - t * plotH;
|
||||||
|
return (
|
||||||
|
<g key={t}>
|
||||||
|
<line x1={padL} y1={y} x2={W - padR} y2={y} stroke="#f0f0f0" />
|
||||||
|
<text x={padL - 8} y={y + 4} textAnchor="end" fontSize={11} fill={CHART_BAR_COMPLETED}>
|
||||||
|
{Math.round(maxBar * t)}
|
||||||
|
</text>
|
||||||
|
<text x={W - padR + 8} y={y + 4} textAnchor="start" fontSize={11} fill={CHART_LINE}>
|
||||||
|
{(maxSec * t).toFixed(1)}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{/* 发起数柱(浅) */}
|
||||||
|
{points.map((p, i) => (
|
||||||
|
<rect
|
||||||
|
key={`s-${i}`}
|
||||||
|
x={barX(i)}
|
||||||
|
y={yBase - barH(p.started)}
|
||||||
|
width={barW}
|
||||||
|
height={barH(p.started)}
|
||||||
|
fill={CHART_BAR_STARTED}
|
||||||
|
rx={2}
|
||||||
|
>
|
||||||
|
<title>{p.tip}</title>
|
||||||
|
</rect>
|
||||||
|
))}
|
||||||
|
{/* 完成数柱(深,窄,叠中间) */}
|
||||||
|
{points.map((p, i) => {
|
||||||
|
const cw = barW * 0.55;
|
||||||
|
return (
|
||||||
|
<rect
|
||||||
|
key={`c-${i}`}
|
||||||
|
x={cx(i) - cw / 2}
|
||||||
|
y={yBase - barH(p.completed)}
|
||||||
|
width={cw}
|
||||||
|
height={barH(p.completed)}
|
||||||
|
fill={CHART_BAR_COMPLETED}
|
||||||
|
rx={1}
|
||||||
|
>
|
||||||
|
<title>{p.tip}</title>
|
||||||
|
</rect>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{/* 平均耗时线(橙,右轴) */}
|
||||||
|
<polyline points={linePts} fill="none" stroke={CHART_LINE} strokeWidth={2} />
|
||||||
|
{points.map((p, i) =>
|
||||||
|
p.avgSec == null ? null : (
|
||||||
|
<circle key={`p-${i}`} cx={cx(i)} cy={secY(p.avgSec)} r={2.5} fill={CHART_LINE}>
|
||||||
|
<title>{p.tip}</title>
|
||||||
|
</circle>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
{points.map((p, i) =>
|
||||||
|
i % labelEvery === 0 || i === n - 1 ? (
|
||||||
|
<text key={`x-${i}`} x={cx(i)} y={H - 14} textAnchor="middle" fontSize={11} fill="#999">
|
||||||
|
{p.label}
|
||||||
|
</text>
|
||||||
|
) : null,
|
||||||
|
)}
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 领券数据看板:上半汇总卡 + 按天/小时趋势(参考广告收益大盘),下半逐条领券明细。
|
||||||
|
// 数据源 coupon_session(客户端 /api/v1/coupon/session 两段上报);耗时统计只算 completed。
|
||||||
|
export default function CouponDataPage() {
|
||||||
|
const { message } = App.useApp();
|
||||||
|
const [range, setRange] = useState<[Dayjs, Dayjs]>([dayjs().subtract(6, 'day'), dayjs()]);
|
||||||
|
const [user, setUser] = useState<string>('');
|
||||||
|
const [appEnv, setAppEnv] = useState<string>('prod');
|
||||||
|
const [granularity, setGranularity] = useState<'day' | 'hour'>('day');
|
||||||
|
const [sortBy, setSortBy] = useState<'time' | 'elapsed'>('time');
|
||||||
|
const [limit, setLimit] = useState<number>(100);
|
||||||
|
const [page, setPage] = useState<number>(1);
|
||||||
|
const [queriedGranularity, setQueriedGranularity] = useState<'day' | 'hour'>('day');
|
||||||
|
const [queriedMultiDay, setQueriedMultiDay] = useState(false);
|
||||||
|
const [queriedLimit, setQueriedLimit] = useState<number>(100);
|
||||||
|
const [data, setData] = useState<CouponDataReport | null>(null);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
// 点手机号:抽屉看该用户全部领券(总次数 + 记录)
|
||||||
|
const [recordsUser, setRecordsUser] = useState<{ userId: number; phone: string | null } | null>(null);
|
||||||
|
const openUserRecords = (r: CouponDataRow) => {
|
||||||
|
if (r.user_id != null) setRecordsUser({ userId: r.user_id, phone: r.user_phone });
|
||||||
|
};
|
||||||
|
|
||||||
|
// 跨多天时「按小时」无意义,粒度强制按天(同广告报表)。
|
||||||
|
const rangeMultiDay = range[0].format('YYYY-MM-DD') !== range[1].format('YYYY-MM-DD');
|
||||||
|
|
||||||
|
const load = useCallback(
|
||||||
|
async (targetPage = 1, targetLimit = limit, targetSort = sortBy) => {
|
||||||
|
const from = range[0].format('YYYY-MM-DD');
|
||||||
|
const to = range[1].format('YYYY-MM-DD');
|
||||||
|
const multiDay = from !== to;
|
||||||
|
const gran = multiDay ? 'day' : granularity;
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const res = await api.get<CouponDataReport>('/admin/api/coupon-data', {
|
||||||
|
params: {
|
||||||
|
date_from: from,
|
||||||
|
date_to: to,
|
||||||
|
user: user.trim() || undefined,
|
||||||
|
app_env: appEnv,
|
||||||
|
granularity: gran,
|
||||||
|
limit: targetLimit,
|
||||||
|
offset: (targetPage - 1) * targetLimit,
|
||||||
|
sort: targetSort,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setData(res.data);
|
||||||
|
setPage(targetPage);
|
||||||
|
setQueriedLimit(targetLimit);
|
||||||
|
setQueriedGranularity(gran);
|
||||||
|
setQueriedMultiDay(multiDay);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[range, user, appEnv, granularity, limit, sortBy, message],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
load();
|
||||||
|
// 仅首次自动拉近 7 天;之后由「查询」按钮触发
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const columns: ColumnsType<CouponDataRow> = [
|
||||||
|
{
|
||||||
|
title: '用户',
|
||||||
|
dataIndex: 'user_nickname',
|
||||||
|
width: 140,
|
||||||
|
render: (_: unknown, r: CouponDataRow) => {
|
||||||
|
if (r.user_nickname) {
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{r.user_nickname}
|
||||||
|
{r.user_id != null && (
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 11, marginLeft: 6 }}>
|
||||||
|
#{r.user_id}
|
||||||
|
</Typography.Text>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (r.user_id != null) return <Typography.Text type="secondary">#{r.user_id}</Typography.Text>;
|
||||||
|
return <Typography.Text type="secondary">游客</Typography.Text>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '手机号',
|
||||||
|
dataIndex: 'user_phone',
|
||||||
|
width: 130,
|
||||||
|
// 点手机号 → 抽屉看该用户全部领券(参考低价审核/反馈页)。游客(无 user_id)不可点。
|
||||||
|
render: (phone: string | null, r: CouponDataRow) =>
|
||||||
|
r.user_id != null ? (
|
||||||
|
<a onClick={() => openUserRecords(r)}>{phone || `#${r.user_id}`}</a>
|
||||||
|
) : (
|
||||||
|
<Typography.Text type="secondary">游客</Typography.Text>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 90,
|
||||||
|
render: (s: string) => {
|
||||||
|
const t = STATUS_TAG[s] ?? { color: 'default', label: s };
|
||||||
|
return <Tag color={t.color}>{t.label}</Tag>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '发起平台',
|
||||||
|
dataIndex: 'origin_package',
|
||||||
|
width: 110,
|
||||||
|
render: (pkg: string | null) => originLabel(pkg),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '耗时',
|
||||||
|
dataIndex: 'elapsed_ms',
|
||||||
|
width: 90,
|
||||||
|
align: 'right',
|
||||||
|
render: (v: number | null) => fmtSec(v),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '美团耗时',
|
||||||
|
key: 'mt_elapsed',
|
||||||
|
width: 90,
|
||||||
|
align: 'right',
|
||||||
|
render: (_: unknown, r: CouponDataRow) => fmtSec(r.platform_elapsed?.['meituan-waimai']),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '淘宝耗时',
|
||||||
|
key: 'tb_elapsed',
|
||||||
|
width: 90,
|
||||||
|
align: 'right',
|
||||||
|
render: (_: unknown, r: CouponDataRow) => fmtSec(r.platform_elapsed?.['taobao-shanguang']),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '京东耗时',
|
||||||
|
key: 'jd_elapsed',
|
||||||
|
width: 90,
|
||||||
|
align: 'right',
|
||||||
|
render: (_: unknown, r: CouponDataRow) => fmtSec(r.platform_elapsed?.['jd-waimai']),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '机型/ROM',
|
||||||
|
key: 'device',
|
||||||
|
width: 200,
|
||||||
|
render: (_: unknown, r: CouponDataRow) => {
|
||||||
|
const parts = [r.device_model, r.rom].filter(Boolean);
|
||||||
|
return parts.length ? parts.join(' / ') : <Typography.Text type="secondary">-</Typography.Text>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '时间',
|
||||||
|
dataIndex: 'started_at',
|
||||||
|
width: 165,
|
||||||
|
render: (v: string) => formatUtcTime(v),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '领券 trace',
|
||||||
|
dataIndex: 'trace_id',
|
||||||
|
width: 150,
|
||||||
|
// 有 trace_url(pricebot 上云,仅 completed)→ 可点链接打开完整现场;否则降级为可复制 trace_id。
|
||||||
|
render: (v: string, r: CouponDataRow) =>
|
||||||
|
r.trace_url ? (
|
||||||
|
<a href={r.trace_url} target="_blank" rel="noreferrer" title={v}>
|
||||||
|
trace({v.slice(0, 8)}…)
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<Typography.Text copyable={{ text: v }} style={{ fontSize: 12 }}>
|
||||||
|
{v.slice(0, 8)}…
|
||||||
|
</Typography.Text>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const summary = data?.summary;
|
||||||
|
const items = data?.items ?? [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Space align="center" style={{ display: 'flex', marginBottom: 16 }}>
|
||||||
|
<h2 style={{ margin: 0 }}>领券数据</h2>
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
发起→完成耗时口径为客户端全程计时;均值/分位仅统计「完成」的领券
|
||||||
|
</Typography.Text>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<Card size="small" style={{ marginBottom: 16 }}>
|
||||||
|
<Space wrap size="middle" align="center">
|
||||||
|
<Space size={6}>
|
||||||
|
<Typography.Text type="secondary">日期</Typography.Text>
|
||||||
|
<RangePicker
|
||||||
|
value={range}
|
||||||
|
onChange={(v) => v && v[0] && v[1] && setRange([v[0], v[1]])}
|
||||||
|
allowClear={false}
|
||||||
|
presets={[
|
||||||
|
{ label: '今天', value: [dayjs(), dayjs()] },
|
||||||
|
{ label: '近 7 天', value: [dayjs().subtract(6, 'day'), dayjs()] },
|
||||||
|
{ label: '近 30 天', value: [dayjs().subtract(29, 'day'), dayjs()] },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<Space size={6}>
|
||||||
|
<Typography.Text type="secondary">用户</Typography.Text>
|
||||||
|
<Input
|
||||||
|
placeholder="手机号/昵称"
|
||||||
|
value={user}
|
||||||
|
onChange={(e) => setUser(e.target.value)}
|
||||||
|
onPressEnter={() => load(1)}
|
||||||
|
allowClear
|
||||||
|
style={{ width: 150 }}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<Space size={6}>
|
||||||
|
<Typography.Text type="secondary">环境</Typography.Text>
|
||||||
|
<Select
|
||||||
|
value={appEnv}
|
||||||
|
onChange={setAppEnv}
|
||||||
|
style={{ width: 120 }}
|
||||||
|
options={[
|
||||||
|
{ value: 'prod', label: '正式(prod)' },
|
||||||
|
{ value: 'dev', label: '测试(dev)' },
|
||||||
|
{ value: 'all', label: '全部' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<Space size={6}>
|
||||||
|
<Typography.Text type="secondary">粒度</Typography.Text>
|
||||||
|
<Select
|
||||||
|
value={rangeMultiDay ? 'day' : granularity}
|
||||||
|
onChange={setGranularity}
|
||||||
|
disabled={rangeMultiDay}
|
||||||
|
style={{ width: 110 }}
|
||||||
|
title={rangeMultiDay ? '跨多天仅支持按天' : undefined}
|
||||||
|
options={[
|
||||||
|
{ value: 'day', label: '按天' },
|
||||||
|
{ value: 'hour', label: '按小时' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<Space size={6}>
|
||||||
|
<Typography.Text type="secondary">排序</Typography.Text>
|
||||||
|
<Select
|
||||||
|
value={sortBy}
|
||||||
|
onChange={(v) => {
|
||||||
|
setSortBy(v);
|
||||||
|
load(1, limit, v);
|
||||||
|
}}
|
||||||
|
style={{ width: 130 }}
|
||||||
|
options={[
|
||||||
|
{ value: 'time', label: '时间倒序' },
|
||||||
|
{ value: 'elapsed', label: '耗时倒序' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<Space size={6}>
|
||||||
|
<Typography.Text type="secondary">每页</Typography.Text>
|
||||||
|
<Select
|
||||||
|
value={limit}
|
||||||
|
onChange={(v) => {
|
||||||
|
setLimit(v);
|
||||||
|
load(1, v);
|
||||||
|
}}
|
||||||
|
style={{ width: 120 }}
|
||||||
|
options={[20, 50, 100, 200, 500].map((nn) => ({ value: nn, label: `${nn} 条/页` }))}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<Button type="primary" onClick={() => load(1)} loading={loading}>
|
||||||
|
查询
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{summary && (
|
||||||
|
<Card size="small" style={{ marginBottom: 16 }}>
|
||||||
|
<Row gutter={[16, 12]}>
|
||||||
|
<Col flex="1 1 0">
|
||||||
|
<Statistic title="领券发起数" value={summary.started_count} />
|
||||||
|
</Col>
|
||||||
|
<Col flex="1 1 0">
|
||||||
|
<Statistic title="领券完成数" value={summary.completed_count} />
|
||||||
|
</Col>
|
||||||
|
<Col flex="1 1 0">
|
||||||
|
<Statistic title="平均耗时" value={fmtSec(summary.avg_elapsed_ms)} />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Divider style={{ marginTop: 16, marginBottom: 16 }} />
|
||||||
|
<Row gutter={[16, 12]}>
|
||||||
|
<Col flex="1 1 0">
|
||||||
|
<Statistic title="耗时 5 分位" value={fmtSec(summary.p5_ms)} />
|
||||||
|
</Col>
|
||||||
|
<Col flex="1 1 0">
|
||||||
|
<Statistic title="耗时 50 分位" value={fmtSec(summary.p50_ms)} />
|
||||||
|
</Col>
|
||||||
|
<Col flex="1 1 0">
|
||||||
|
<Statistic title="耗时 95 分位" value={fmtSec(summary.p95_ms)} />
|
||||||
|
</Col>
|
||||||
|
<Col flex="1 1 0">
|
||||||
|
<Statistic title="耗时 99 分位" value={fmtSec(summary.p99_ms)} />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{data &&
|
||||||
|
(queriedMultiDay
|
||||||
|
? (data.daily?.length ?? 0) > 0
|
||||||
|
: queriedGranularity === 'hour' && (data.hourly?.length ?? 0) > 0) && (
|
||||||
|
<Card
|
||||||
|
size="small"
|
||||||
|
title={queriedMultiDay ? '按天趋势' : '按小时趋势'}
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
extra={
|
||||||
|
<Space size={16}>
|
||||||
|
<span style={{ fontSize: 12, color: '#666' }}>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
display: 'inline-block',
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
background: CHART_BAR_STARTED,
|
||||||
|
borderRadius: 2,
|
||||||
|
marginRight: 4,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
发起数
|
||||||
|
</span>
|
||||||
|
<span style={{ fontSize: 12, color: '#666' }}>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
display: 'inline-block',
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
background: CHART_BAR_COMPLETED,
|
||||||
|
borderRadius: 2,
|
||||||
|
marginRight: 4,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
完成数
|
||||||
|
</span>
|
||||||
|
<span style={{ fontSize: 12, color: '#666' }}>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
display: 'inline-block',
|
||||||
|
width: 14,
|
||||||
|
borderTop: `2px solid ${CHART_LINE}`,
|
||||||
|
marginRight: 4,
|
||||||
|
verticalAlign: 'middle',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
平均耗时(秒)
|
||||||
|
</span>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{queriedMultiDay ? (
|
||||||
|
<TrendChart points={aggregateDaily(data.date_from, data.date_to, data.daily)} />
|
||||||
|
) : (
|
||||||
|
<TrendChart points={aggregateHourly(data.hourly)} />
|
||||||
|
)}
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Table
|
||||||
|
rowKey="trace_id"
|
||||||
|
columns={columns}
|
||||||
|
dataSource={items}
|
||||||
|
loading={loading}
|
||||||
|
pagination={{
|
||||||
|
current: page,
|
||||||
|
pageSize: queriedLimit,
|
||||||
|
total: data?.total ?? 0,
|
||||||
|
showSizeChanger: false,
|
||||||
|
showTotal: (t) => `共 ${t} 条`,
|
||||||
|
onChange: (p) => load(p, queriedLimit),
|
||||||
|
}}
|
||||||
|
size="small"
|
||||||
|
scroll={{ x: 1450 }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<UserRecordsDrawer<CouponDataRow>
|
||||||
|
open={recordsUser != null}
|
||||||
|
onClose={() => setRecordsUser(null)}
|
||||||
|
userId={recordsUser?.userId ?? null}
|
||||||
|
phone={recordsUser?.phone ?? null}
|
||||||
|
endpoint="/admin/api/coupon-data/user-records"
|
||||||
|
columns={RECORD_COLUMNS}
|
||||||
|
recordLabel="领券"
|
||||||
|
countLabel="领券次数"
|
||||||
|
rewardLabel="领到券张数"
|
||||||
|
rewardSuffix="张"
|
||||||
|
rewardOf={(r) => r.claimed_count ?? 0}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState, type ReactNode } from 'react';
|
||||||
import { Alert, Select, Spin, Tag, Tooltip, message } from 'antd';
|
import { Alert, App, Select, Spin, Tag, Tooltip } from 'antd';
|
||||||
import { CalendarOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
import { CalendarOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
@@ -10,6 +10,8 @@ import type { AdRevenueReport, DashboardOverview } from '@/lib/types';
|
|||||||
type PeriodKey = 'yesterday' | '7d' | '30d';
|
type PeriodKey = 'yesterday' | '7d' | '30d';
|
||||||
type TrendSeriesKey = 'dau' | 'newUsers' | 'comparisons';
|
type TrendSeriesKey = 'dau' | 'newUsers' | 'comparisons';
|
||||||
type DashboardTrendPoint = DashboardOverview['period']['trend'][number];
|
type DashboardTrendPoint = DashboardOverview['period']['trend'][number];
|
||||||
|
type DeltaTone = 'muted' | 'up' | 'down' | 'flat';
|
||||||
|
type DeltaInfo = { value: ReactNode; tone: DeltaTone };
|
||||||
|
|
||||||
const PERIODS: { key: PeriodKey; label: string; days: number }[] = [
|
const PERIODS: { key: PeriodKey; label: string; days: number }[] = [
|
||||||
{ key: 'yesterday', label: '昨日', days: 1 },
|
{ key: 'yesterday', label: '昨日', days: 1 },
|
||||||
@@ -35,6 +37,72 @@ const fmtYuan = (yuan: number | null | undefined) => (yuan == null ? '--' : `¥$
|
|||||||
const fmtMsAsSeconds = (ms: number | null | undefined) => (ms == null ? '--' : (ms / 1000).toFixed(1));
|
const fmtMsAsSeconds = (ms: number | null | undefined) => (ms == null ? '--' : (ms / 1000).toFixed(1));
|
||||||
const pct = (v: number | null | undefined) => (v == null ? '--' : `${(v * 100).toFixed(1)}%`);
|
const pct = (v: number | null | undefined) => (v == null ? '--' : `${(v * 100).toFixed(1)}%`);
|
||||||
const compact = (v: number) => (v >= 1000 ? `${(v / 1000).toFixed(v >= 10000 ? 0 : 1)}k` : String(v));
|
const compact = (v: number) => (v >= 1000 ? `${(v / 1000).toFixed(v >= 10000 ? 0 : 1)}k` : String(v));
|
||||||
|
const fmtCoinAmount = (v: number | null | undefined) => {
|
||||||
|
if (v == null) return '--';
|
||||||
|
if (Math.abs(v) >= 10000) return `${(v / 10000).toFixed(2).replace(/\.?0+$/, '')} 万`;
|
||||||
|
return numberFmt.format(v);
|
||||||
|
};
|
||||||
|
const CMP_LABEL = 'vs 上周期';
|
||||||
|
|
||||||
|
function withCompare(main: string) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{main}
|
||||||
|
<span className="cmp">{CMP_LABEL}</span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function percentDelta(current: number | null | undefined, previous: number | null | undefined): DeltaInfo {
|
||||||
|
if (current == null || previous == null) return { value: '暂无上期', tone: 'flat' };
|
||||||
|
if (previous === 0) {
|
||||||
|
if (current === 0) return { value: withCompare('持平'), tone: 'flat' };
|
||||||
|
return { value: '上期为 0', tone: current > 0 ? 'up' : 'down' };
|
||||||
|
}
|
||||||
|
const diff = (current - previous) / Math.abs(previous);
|
||||||
|
if (Math.abs(diff) < 0.0005) return { value: withCompare('持平'), tone: 'flat' };
|
||||||
|
const arrow = diff > 0 ? '▲' : '▼';
|
||||||
|
return {
|
||||||
|
value: withCompare(`${arrow} ${(Math.abs(diff) * 100).toFixed(1)}%`),
|
||||||
|
tone: diff > 0 ? 'up' : 'down',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function pointDelta(current: number | null | undefined, previous: number | null | undefined): DeltaInfo {
|
||||||
|
if (current == null || previous == null) return { value: '暂无上期', tone: 'flat' };
|
||||||
|
const diff = (current - previous) * 100;
|
||||||
|
if (Math.abs(diff) < 0.05) return { value: withCompare('持平'), tone: 'flat' };
|
||||||
|
const arrow = diff > 0 ? '▲' : '▼';
|
||||||
|
return {
|
||||||
|
value: withCompare(`${arrow} ${Math.abs(diff).toFixed(1)}pt`),
|
||||||
|
tone: diff > 0 ? 'up' : 'down',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function durationDelta(currentMs: number | null | undefined, previousMs: number | null | undefined): DeltaInfo {
|
||||||
|
if (currentMs == null || previousMs == null) return { value: '暂无上期', tone: 'flat' };
|
||||||
|
const diffSeconds = (currentMs - previousMs) / 1000;
|
||||||
|
if (Math.abs(diffSeconds) < 0.05) return { value: withCompare('持平'), tone: 'flat' };
|
||||||
|
return diffSeconds < 0
|
||||||
|
? { value: `▼ ${Math.abs(diffSeconds).toFixed(1)}s 更快`, tone: 'up' }
|
||||||
|
: { value: `▲ ${Math.abs(diffSeconds).toFixed(1)}s 更慢`, tone: 'down' };
|
||||||
|
}
|
||||||
|
|
||||||
|
function moneyDeltaCents(current: number | null | undefined, previous: number | null | undefined): DeltaInfo {
|
||||||
|
if (current == null || previous == null) return { value: '暂无上期', tone: 'flat' };
|
||||||
|
const diff = current - previous;
|
||||||
|
if (Math.abs(diff) < 0.5) return { value: withCompare('持平'), tone: 'flat' };
|
||||||
|
const arrow = diff > 0 ? '▲' : '▼';
|
||||||
|
return {
|
||||||
|
value: withCompare(`${arrow} ${fmtCents(Math.abs(diff))}`),
|
||||||
|
tone: diff > 0 ? 'up' : 'down',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function ratioBadge(value: number | null | undefined, total: number | null | undefined): DeltaInfo {
|
||||||
|
if (value == null || total == null || total <= 0) return { value: '占 --', tone: 'flat' };
|
||||||
|
return { value: `占 ${((value / total) * 100).toFixed(1)}%`, tone: 'flat' };
|
||||||
|
}
|
||||||
|
|
||||||
function periodRange(period: PeriodKey) {
|
function periodRange(period: PeriodKey) {
|
||||||
const p = PERIODS.find((it) => it.key === period) ?? PERIODS[0];
|
const p = PERIODS.find((it) => it.key === period) ?? PERIODS[0];
|
||||||
@@ -43,6 +111,12 @@ function periodRange(period: PeriodKey) {
|
|||||||
return { start, end, label: `${start.format('MM-DD')} ~ ${end.format('MM-DD')}`, days: p.days };
|
return { start, end, label: `${start.format('MM-DD')} ~ ${end.format('MM-DD')}`, days: p.days };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function previousPeriodRange(range: ReturnType<typeof periodRange>) {
|
||||||
|
const end = range.start.subtract(1, 'day');
|
||||||
|
const start = end.subtract(range.days - 1, 'day');
|
||||||
|
return { start, end, label: `${start.format('MM-DD')} ~ ${end.format('MM-DD')}` };
|
||||||
|
}
|
||||||
|
|
||||||
function retentionTitle(period: PeriodKey) {
|
function retentionTitle(period: PeriodKey) {
|
||||||
if (period === '7d') return '近 7 日新增留存';
|
if (period === '7d') return '近 7 日新增留存';
|
||||||
if (period === '30d') return '近 30 日新增留存';
|
if (period === '30d') return '近 30 日新增留存';
|
||||||
@@ -92,6 +166,16 @@ function sceneAdEcpm(summary: ReturnType<typeof adSceneSummary>) {
|
|||||||
return fmtYuan((summary.revenue_yuan / summary.impressions) * 1000);
|
return fmtYuan((summary.revenue_yuan / summary.impressions) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cpsCommissionCents(data: DashboardOverview | null | undefined) {
|
||||||
|
if (!data?.cps.available) return null;
|
||||||
|
return (data.cps.meituan_commission_cents ?? 0) + (data.cps.jd_commission_cents ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function revenueYuan(ad: AdRevenueReport | null | undefined, cpsCents: number | null | undefined) {
|
||||||
|
if (ad?.total_revenue_yuan == null && cpsCents == null) return null;
|
||||||
|
return (ad?.total_revenue_yuan ?? 0) + ((cpsCents ?? 0) / 100);
|
||||||
|
}
|
||||||
|
|
||||||
function niceMax(v: number) {
|
function niceMax(v: number) {
|
||||||
if (v <= 5) return 5;
|
if (v <= 5) return 5;
|
||||||
if (v <= 10) return 10;
|
if (v <= 10) return 10;
|
||||||
@@ -99,7 +183,7 @@ function niceMax(v: number) {
|
|||||||
return Math.ceil(v / base) * base;
|
return Math.ceil(v / base) * base;
|
||||||
}
|
}
|
||||||
|
|
||||||
function StatusText({ children, tone = 'muted' }: { children: React.ReactNode; tone?: 'muted' | 'ok' | 'warn' }) {
|
function StatusText({ children, tone = 'muted' }: { children: ReactNode; tone?: 'muted' | 'ok' | 'warn' }) {
|
||||||
return <span className={`status status-${tone}`}>{children}</span>;
|
return <span className={`status status-${tone}`}>{children}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +191,8 @@ function DeltaBadge({
|
|||||||
children,
|
children,
|
||||||
tone = 'muted',
|
tone = 'muted',
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: ReactNode;
|
||||||
tone?: 'muted' | 'up' | 'down';
|
tone?: DeltaTone;
|
||||||
}) {
|
}) {
|
||||||
return <span className={`delta delta-${tone}`}>{children}</span>;
|
return <span className={`delta delta-${tone}`}>{children}</span>;
|
||||||
}
|
}
|
||||||
@@ -116,11 +200,15 @@ function DeltaBadge({
|
|||||||
function MiniSpark({
|
function MiniSpark({
|
||||||
color = '#2F6BFF',
|
color = '#2F6BFF',
|
||||||
down,
|
down,
|
||||||
|
flat,
|
||||||
}: {
|
}: {
|
||||||
color?: string;
|
color?: string;
|
||||||
down?: boolean;
|
down?: boolean;
|
||||||
|
flat?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const points = down
|
const points = flat
|
||||||
|
? '0,16 13,16 26,15 39,16 52,15 65,16 78,15'
|
||||||
|
: down
|
||||||
? '0,8 13,10 26,9 39,14 52,12 65,18 78,20'
|
? '0,8 13,10 26,9 39,14 52,12 65,18 78,20'
|
||||||
: '0,24 13,22 26,20 39,15 52,13 65,8 78,5';
|
: '0,24 13,22 26,20 39,15 52,13 65,8 78,5';
|
||||||
return (
|
return (
|
||||||
@@ -149,9 +237,9 @@ function StatCard({
|
|||||||
status?: string;
|
status?: string;
|
||||||
tone?: 'muted' | 'ok' | 'warn';
|
tone?: 'muted' | 'ok' | 'warn';
|
||||||
emphasis?: boolean;
|
emphasis?: boolean;
|
||||||
spark?: 'up' | 'down';
|
spark?: 'up' | 'down' | 'flat';
|
||||||
delta?: string;
|
delta?: ReactNode;
|
||||||
deltaTone?: 'muted' | 'up' | 'down';
|
deltaTone?: DeltaTone;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className={`stat-card${emphasis ? ' stat-card-emphasis' : ''}`}>
|
<div className={`stat-card${emphasis ? ' stat-card-emphasis' : ''}`}>
|
||||||
@@ -168,7 +256,13 @@ function StatCard({
|
|||||||
{value}
|
{value}
|
||||||
{unit && value !== '--' && <span>{unit}</span>}
|
{unit && value !== '--' && <span>{unit}</span>}
|
||||||
</div>
|
</div>
|
||||||
{spark && <MiniSpark color={spark === 'down' ? '#EF4444' : '#2F6BFF'} down={spark === 'down'} />}
|
{spark && (
|
||||||
|
<MiniSpark
|
||||||
|
color={spark === 'down' ? '#EF4444' : '#2F6BFF'}
|
||||||
|
down={spark === 'down'}
|
||||||
|
flat={spark === 'flat'}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{delta ? <DeltaBadge tone={deltaTone}>{delta}</DeltaBadge> : status && <StatusText tone={tone}>{status}</StatusText>}
|
{delta ? <DeltaBadge tone={deltaTone}>{delta}</DeltaBadge> : status && <StatusText tone={tone}>{status}</StatusText>}
|
||||||
</div>
|
</div>
|
||||||
@@ -181,18 +275,20 @@ function RevenueCard({
|
|||||||
meta,
|
meta,
|
||||||
accent,
|
accent,
|
||||||
delta,
|
delta,
|
||||||
|
deltaTone = 'up',
|
||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
value: string;
|
value: string;
|
||||||
meta?: { label: string; value: string }[];
|
meta?: { label: string; value: string }[];
|
||||||
accent?: 'blue' | 'green' | 'yellow' | 'red';
|
accent?: 'blue' | 'green' | 'yellow' | 'red' | 'jd';
|
||||||
delta?: string;
|
delta?: ReactNode;
|
||||||
|
deltaTone?: DeltaTone;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className={`revenue-card ${accent ? `rev-${accent}` : ''}`}>
|
<div className={`revenue-card ${accent ? `rev-${accent}` : ''}`}>
|
||||||
<div className="revenue-top">
|
<div className="revenue-top">
|
||||||
<div className="revenue-tag">{title}</div>
|
<div className="revenue-tag">{title}</div>
|
||||||
{delta && <DeltaBadge tone="up">{delta}</DeltaBadge>}
|
{delta && <DeltaBadge tone={deltaTone}>{delta}</DeltaBadge>}
|
||||||
</div>
|
</div>
|
||||||
<div className="revenue-value">{value}</div>
|
<div className="revenue-value">{value}</div>
|
||||||
{meta && meta.length > 0 && (
|
{meta && meta.length > 0 && (
|
||||||
@@ -349,9 +445,12 @@ function TrendChart({ rangeLabel, points }: { rangeLabel: string; points: Dashbo
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function DashboardPage() {
|
export default function DashboardPage() {
|
||||||
|
const { message } = App.useApp();
|
||||||
const [period, setPeriod] = useState<PeriodKey>('yesterday');
|
const [period, setPeriod] = useState<PeriodKey>('yesterday');
|
||||||
const [data, setData] = useState<DashboardOverview | null>(null);
|
const [data, setData] = useState<DashboardOverview | null>(null);
|
||||||
|
const [previousData, setPreviousData] = useState<DashboardOverview | null>(null);
|
||||||
const [adReport, setAdReport] = useState<AdRevenueReport | null>(null);
|
const [adReport, setAdReport] = useState<AdRevenueReport | null>(null);
|
||||||
|
const [previousAdReport, setPreviousAdReport] = useState<AdRevenueReport | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [adLoading, setAdLoading] = useState(false);
|
const [adLoading, setAdLoading] = useState(false);
|
||||||
const [overviewError, setOverviewError] = useState<string | null>(null);
|
const [overviewError, setOverviewError] = useState<string | null>(null);
|
||||||
@@ -361,7 +460,9 @@ export default function DashboardPage() {
|
|||||||
const [cpsSyncing, setCpsSyncing] = useState(false);
|
const [cpsSyncing, setCpsSyncing] = useState(false);
|
||||||
|
|
||||||
const range = useMemo(() => periodRange(period), [period]);
|
const range = useMemo(() => periodRange(period), [period]);
|
||||||
|
const previousRange = useMemo(() => previousPeriodRange(range), [range]);
|
||||||
const periodData = data?.period ?? null;
|
const periodData = data?.period ?? null;
|
||||||
|
const previousPeriodData = previousData?.period ?? null;
|
||||||
const adAvgEcpm = avgEcpm(adReport);
|
const adAvgEcpm = avgEcpm(adReport);
|
||||||
const rewardVideoAdSummary = adTypeSummary(adReport, 'reward_video');
|
const rewardVideoAdSummary = adTypeSummary(adReport, 'reward_video');
|
||||||
const couponAdSummary = adSceneSummary(adReport, 'coupon');
|
const couponAdSummary = adSceneSummary(adReport, 'coupon');
|
||||||
@@ -381,44 +482,84 @@ export default function DashboardPage() {
|
|||||||
const regularTaskCoinTotal =
|
const regularTaskCoinTotal =
|
||||||
periodData?.coins.regular_task_coin_total ??
|
periodData?.coins.regular_task_coin_total ??
|
||||||
((signinCoinTotal ?? 0) + (signinBoostCoinTotal ?? 0) + (taskCoinTotal ?? 0));
|
((signinCoinTotal ?? 0) + (signinBoostCoinTotal ?? 0) + (taskCoinTotal ?? 0));
|
||||||
const cpsCommissionCents = data?.cps.meituan_commission_cents;
|
|
||||||
const cpsAvailable = data?.cps.available === true;
|
const cpsAvailable = data?.cps.available === true;
|
||||||
const totalRevenueYuan =
|
const meituanCpsCommissionCents = data?.cps.meituan_commission_cents;
|
||||||
adReport?.total_revenue_yuan == null && (!cpsAvailable || cpsCommissionCents == null)
|
const jdCpsCommissionCents = data?.cps.jd_commission_cents;
|
||||||
? null
|
const totalCpsCommissionCents = cpsCommissionCents(data);
|
||||||
: (adReport?.total_revenue_yuan ?? 0) + (cpsAvailable ? (cpsCommissionCents ?? 0) / 100 : 0);
|
const previousTotalCpsCommissionCents = cpsCommissionCents(previousData);
|
||||||
|
const totalRevenueYuan = revenueYuan(adReport, totalCpsCommissionCents);
|
||||||
|
const previousTotalRevenueYuan = revenueYuan(previousAdReport, previousTotalCpsCommissionCents);
|
||||||
const yesterdayTrendPoint = periodData?.trend?.[periodData.trend.length - 1];
|
const yesterdayTrendPoint = periodData?.trend?.[periodData.trend.length - 1];
|
||||||
const yesterdayActiveUsers = yesterdayTrendPoint?.active_users ?? null;
|
const yesterdayActiveUsers = yesterdayTrendPoint?.active_users ?? null;
|
||||||
const arpuYuan =
|
const arpuYuan =
|
||||||
totalRevenueYuan == null || yesterdayActiveUsers == null || yesterdayActiveUsers <= 0
|
totalRevenueYuan == null || yesterdayActiveUsers == null || yesterdayActiveUsers <= 0
|
||||||
? null
|
? null
|
||||||
: totalRevenueYuan / yesterdayActiveUsers;
|
: totalRevenueYuan / yesterdayActiveUsers;
|
||||||
const cpsRevenueText = cpsAvailable ? fmtCents(cpsCommissionCents) : '--';
|
const cpsRevenueText = cpsAvailable ? fmtCents(totalCpsCommissionCents) : '--';
|
||||||
|
const meituanCpsRevenueText = cpsAvailable ? fmtCents(meituanCpsCommissionCents) : '--';
|
||||||
|
const jdCpsRevenueText = cpsAvailable ? fmtCents(jdCpsCommissionCents) : '--';
|
||||||
const cpsHitRate = !cpsAvailable || data?.cps.meituan_hit_rate == null ? '--' : pct(data.cps.meituan_hit_rate);
|
const cpsHitRate = !cpsAvailable || data?.cps.meituan_hit_rate == null ? '--' : pct(data.cps.meituan_hit_rate);
|
||||||
const retentionValue =
|
const retentionValue =
|
||||||
periodData?.users.retention_rate == null
|
periodData?.users.retention_rate == null
|
||||||
? '--'
|
? '--'
|
||||||
: (periodData.users.retention_rate * 100).toFixed(1);
|
: (periodData.users.retention_rate * 100).toFixed(1);
|
||||||
|
const activeUserDelta = percentDelta(periodData?.users.active, previousPeriodData?.users.active);
|
||||||
|
const newUserDelta = percentDelta(periodData?.users.new, previousPeriodData?.users.new);
|
||||||
|
const retentionDelta = pointDelta(periodData?.users.retention_rate, previousPeriodData?.users.retention_rate);
|
||||||
|
const retentionSpark: 'up' | 'down' | 'flat' | undefined =
|
||||||
|
periodData?.users.retention_rate == null
|
||||||
|
? undefined
|
||||||
|
: retentionDelta.tone === 'down'
|
||||||
|
? 'down'
|
||||||
|
: retentionDelta.tone === 'up' || periodData.users.retention_rate >= 1
|
||||||
|
? 'up'
|
||||||
|
: 'flat';
|
||||||
|
const comparisonTotalDelta = percentDelta(periodData?.comparison.total, previousPeriodData?.comparison.total);
|
||||||
|
const comparisonSuccessDelta = percentDelta(periodData?.comparison.success, previousPeriodData?.comparison.success);
|
||||||
|
const comparisonOrderedDelta = percentDelta(periodData?.comparison.ordered, previousPeriodData?.comparison.ordered);
|
||||||
|
const durationDeltaInfo = durationDelta(
|
||||||
|
periodData?.comparison.average_duration_ms,
|
||||||
|
previousPeriodData?.comparison.average_duration_ms,
|
||||||
|
);
|
||||||
|
const averageSavedDelta = moneyDeltaCents(
|
||||||
|
periodData?.comparison.average_saved_cents,
|
||||||
|
previousPeriodData?.comparison.average_saved_cents,
|
||||||
|
);
|
||||||
|
const totalRevenueDelta = percentDelta(totalRevenueYuan, previousTotalRevenueYuan);
|
||||||
|
const adRevenueDelta = percentDelta(adReport?.total_revenue_yuan, previousAdReport?.total_revenue_yuan);
|
||||||
|
const cpsRevenueDelta = percentDelta(totalCpsCommissionCents, previousTotalCpsCommissionCents);
|
||||||
|
const grantedCoinDelta = percentDelta(periodData?.coins.granted_total, previousPeriodData?.coins.granted_total);
|
||||||
|
const couponCoinRatio = ratioBadge(couponRewardCoinTotal, periodData?.coins.granted_total);
|
||||||
|
const comparisonCoinRatio = ratioBadge(comparisonRewardCoinTotal, periodData?.coins.granted_total);
|
||||||
|
const rewardVideoCoinRatio = ratioBadge(periodData?.coins.reward_video_coin_total, periodData?.coins.granted_total);
|
||||||
|
const regularTaskCoinRatio = ratioBadge(regularTaskCoinTotal, periodData?.coins.granted_total);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let alive = true;
|
let alive = true;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setOverviewError(null);
|
setOverviewError(null);
|
||||||
api
|
const currentParams = {
|
||||||
.get<DashboardOverview>('/admin/api/stats/overview', {
|
date_from: range.start.format('YYYY-MM-DD'),
|
||||||
params: {
|
date_to: range.end.format('YYYY-MM-DD'),
|
||||||
date_from: range.start.format('YYYY-MM-DD'),
|
};
|
||||||
date_to: range.end.format('YYYY-MM-DD'),
|
const previousParams = {
|
||||||
},
|
date_from: previousRange.start.format('YYYY-MM-DD'),
|
||||||
})
|
date_to: previousRange.end.format('YYYY-MM-DD'),
|
||||||
.then((r) => {
|
};
|
||||||
|
Promise.allSettled([
|
||||||
|
api.get<DashboardOverview>('/admin/api/stats/overview', { params: currentParams }),
|
||||||
|
api.get<DashboardOverview>('/admin/api/stats/overview', { params: previousParams }),
|
||||||
|
])
|
||||||
|
.then(([current, previous]) => {
|
||||||
if (!alive) return;
|
if (!alive) return;
|
||||||
setData(r.data);
|
if (current.status === 'fulfilled') {
|
||||||
setUpdatedAt(dayjs().format('YYYY-MM-DD HH:mm'));
|
setData(current.value.data);
|
||||||
})
|
setUpdatedAt(dayjs().format('YYYY-MM-DD HH:mm'));
|
||||||
.catch(() => {
|
} else {
|
||||||
if (!alive) return;
|
setData(null);
|
||||||
setOverviewError('总览接口加载失败');
|
setOverviewError('总览接口加载失败');
|
||||||
|
}
|
||||||
|
setPreviousData(previous.status === 'fulfilled' ? previous.value.data : null);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
if (alive) setLoading(false);
|
if (alive) setLoading(false);
|
||||||
@@ -426,29 +567,37 @@ export default function DashboardPage() {
|
|||||||
return () => {
|
return () => {
|
||||||
alive = false;
|
alive = false;
|
||||||
};
|
};
|
||||||
}, [range.start, range.end, refreshKey]);
|
}, [range.start, range.end, previousRange.start, previousRange.end, refreshKey]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let alive = true;
|
let alive = true;
|
||||||
setAdLoading(true);
|
setAdLoading(true);
|
||||||
setAdError(null);
|
setAdError(null);
|
||||||
api
|
const currentParams = {
|
||||||
.get<AdRevenueReport>('/admin/api/ad-revenue-report', {
|
date_from: range.start.format('YYYY-MM-DD'),
|
||||||
params: {
|
date_to: range.end.format('YYYY-MM-DD'),
|
||||||
date_from: range.start.format('YYYY-MM-DD'),
|
granularity: 'day',
|
||||||
date_to: range.end.format('YYYY-MM-DD'),
|
limit: 1000,
|
||||||
granularity: 'day',
|
};
|
||||||
limit: 1000,
|
const previousParams = {
|
||||||
},
|
date_from: previousRange.start.format('YYYY-MM-DD'),
|
||||||
})
|
date_to: previousRange.end.format('YYYY-MM-DD'),
|
||||||
.then((r) => {
|
granularity: 'day',
|
||||||
|
limit: 1000,
|
||||||
|
};
|
||||||
|
Promise.allSettled([
|
||||||
|
api.get<AdRevenueReport>('/admin/api/ad-revenue-report', { params: currentParams }),
|
||||||
|
api.get<AdRevenueReport>('/admin/api/ad-revenue-report', { params: previousParams }),
|
||||||
|
])
|
||||||
|
.then(([current, previous]) => {
|
||||||
if (!alive) return;
|
if (!alive) return;
|
||||||
setAdReport(r.data);
|
if (current.status === 'fulfilled') {
|
||||||
})
|
setAdReport(current.value.data);
|
||||||
.catch(() => {
|
} else {
|
||||||
if (!alive) return;
|
setAdReport(null);
|
||||||
setAdReport(null);
|
setAdError('广告收益接口加载失败');
|
||||||
setAdError('广告收益接口加载失败');
|
}
|
||||||
|
setPreviousAdReport(previous.status === 'fulfilled' ? previous.value.data : null);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
if (alive) setAdLoading(false);
|
if (alive) setAdLoading(false);
|
||||||
@@ -456,7 +605,7 @@ export default function DashboardPage() {
|
|||||||
return () => {
|
return () => {
|
||||||
alive = false;
|
alive = false;
|
||||||
};
|
};
|
||||||
}, [range.start, range.end]);
|
}, [range.start, range.end, previousRange.start, previousRange.end]);
|
||||||
|
|
||||||
if (loading) return <Spin style={{ display: 'block', marginTop: 80 }} />;
|
if (loading) return <Spin style={{ display: 'block', marginTop: 80 }} />;
|
||||||
|
|
||||||
@@ -464,7 +613,7 @@ export default function DashboardPage() {
|
|||||||
return <Alert type="error" showIcon message={overviewError ?? '数据大盘加载失败'} />;
|
return <Alert type="error" showIcon message={overviewError ?? '数据大盘加载失败'} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const syncMeituanCps = async () => {
|
const syncCpsOrders = async () => {
|
||||||
setCpsSyncing(true);
|
setCpsSyncing(true);
|
||||||
try {
|
try {
|
||||||
const resp = await api.post<{
|
const resp = await api.post<{
|
||||||
@@ -476,12 +625,13 @@ export default function DashboardPage() {
|
|||||||
params: {
|
params: {
|
||||||
date_from: range.start.format('YYYY-MM-DD'),
|
date_from: range.start.format('YYYY-MM-DD'),
|
||||||
date_to: range.end.format('YYYY-MM-DD'),
|
date_to: range.end.format('YYYY-MM-DD'),
|
||||||
|
platform: 'all',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
message.success(`已同步 ${resp.data.fetched} 单`);
|
message.success(`已同步 ${resp.data.fetched} 单`);
|
||||||
setRefreshKey((v) => v + 1);
|
setRefreshKey((v) => v + 1);
|
||||||
} catch {
|
} catch {
|
||||||
message.error('美团订单刷新失败');
|
message.error('CPS 订单刷新失败');
|
||||||
} finally {
|
} finally {
|
||||||
setCpsSyncing(false);
|
setCpsSyncing(false);
|
||||||
}
|
}
|
||||||
@@ -527,20 +677,20 @@ export default function DashboardPage() {
|
|||||||
<h3>核心趋势</h3>
|
<h3>核心趋势</h3>
|
||||||
<span>先看用户、留存与比价活跃度</span>
|
<span>先看用户、留存与比价活跃度</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid g5">
|
<div className="grid g4">
|
||||||
<StatCard title="总用户" value={fmtInt(data.users.total)} status="累计用户数" tone="ok" spark="up" />
|
|
||||||
<StatCard
|
<StatCard
|
||||||
title="活跃用户"
|
title="活跃用户"
|
||||||
value={fmtInt(periodData?.users.active)}
|
value={fmtInt(periodData?.users.active)}
|
||||||
status="本期活跃去重"
|
delta={activeUserDelta.value}
|
||||||
tone="ok"
|
deltaTone={activeUserDelta.tone}
|
||||||
hint="当前按本期内进入 App、完成比价记录、开始领券流程任一满足去重;未完成上报的比价开始事件待后续补埋点。"
|
hint="当前按本期内登录、开始比价、开始领券任一满足去重;比价按 real_compare_start,领券按 real_coupon_start/claim_started。"
|
||||||
spark="up"
|
spark="up"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="新增用户"
|
title="新增用户"
|
||||||
value={fmtInt(periodData?.users.new)}
|
value={fmtInt(periodData?.users.new)}
|
||||||
status="本期新用户"
|
delta={newUserDelta.value}
|
||||||
|
deltaTone={newUserDelta.tone}
|
||||||
hint="当前按注册时间落在所选日期范围统计;若产品要按首次进入 App/首次流程启动定义新增,需要补首次行为聚合。"
|
hint="当前按注册时间落在所选日期范围统计;若产品要按首次进入 App/首次流程启动定义新增,需要补首次行为聚合。"
|
||||||
spark="up"
|
spark="up"
|
||||||
/>
|
/>
|
||||||
@@ -548,16 +698,16 @@ export default function DashboardPage() {
|
|||||||
title={retentionTitle(period)}
|
title={retentionTitle(period)}
|
||||||
value={retentionValue}
|
value={retentionValue}
|
||||||
unit="%"
|
unit="%"
|
||||||
status={`${fmtInt(periodData?.users.retained_new_users)} / ${fmtInt(periodData?.users.new)} 新用户`}
|
delta={retentionDelta.value}
|
||||||
tone="warn"
|
deltaTone={retentionDelta.tone}
|
||||||
hint={periodData?.users.retention_note ?? '暂无留存数据'}
|
hint={periodData?.users.retention_note ?? '暂无留存数据'}
|
||||||
spark="down"
|
spark={retentionSpark}
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="比价次数"
|
title="比价次数"
|
||||||
value={fmtInt(periodData?.comparison.total)}
|
value={fmtInt(periodData?.comparison.total)}
|
||||||
status="本期比价次数"
|
delta={comparisonTotalDelta.value}
|
||||||
tone="muted"
|
deltaTone={comparisonTotalDelta.tone}
|
||||||
spark="up"
|
spark="up"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -571,23 +721,43 @@ export default function DashboardPage() {
|
|||||||
<span>发起、成功、下单与效率</span>
|
<span>发起、成功、下单与效率</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid g5">
|
<div className="grid g5">
|
||||||
<StatCard title="发起比价" value={fmtInt(periodData?.comparison.total)} unit="次" status="本期发起次数" />
|
<StatCard
|
||||||
<StatCard title="比价成功" value={fmtInt(periodData?.comparison.success)} unit="次" status={pct(compareSuccessRate)} tone="ok" />
|
title="发起比价"
|
||||||
|
value={fmtInt(periodData?.comparison.total)}
|
||||||
|
unit="次"
|
||||||
|
delta={comparisonTotalDelta.value}
|
||||||
|
deltaTone={comparisonTotalDelta.tone}
|
||||||
|
/>
|
||||||
|
<StatCard
|
||||||
|
title="比价成功"
|
||||||
|
value={fmtInt(periodData?.comparison.success)}
|
||||||
|
unit="次"
|
||||||
|
delta={comparisonSuccessDelta.value}
|
||||||
|
deltaTone={comparisonSuccessDelta.tone}
|
||||||
|
hint={`当前成功率 ${pct(compareSuccessRate)}`}
|
||||||
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="成功下单"
|
title="成功下单"
|
||||||
value={fmtInt(periodData?.comparison.ordered)}
|
value={fmtInt(periodData?.comparison.ordered)}
|
||||||
unit="单"
|
unit="单"
|
||||||
status="已下单记录"
|
delta={comparisonOrderedDelta.value}
|
||||||
|
deltaTone={comparisonOrderedDelta.tone}
|
||||||
hint="按比价记录页同一口径:用户有通过比价产生的下单记录,且店名与比价记录店名一致,则这条比价记录记为已下单。"
|
hint="按比价记录页同一口径:用户有通过比价产生的下单记录,且店名与比价记录店名一致,则这条比价记录记为已下单。"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="平均耗时"
|
title="平均耗时"
|
||||||
value={fmtMsAsSeconds(averageDurationMs)}
|
value={fmtMsAsSeconds(averageDurationMs)}
|
||||||
unit="秒"
|
unit="秒"
|
||||||
status={averageDurationMs == null ? '暂无耗时数据' : '本期平均耗时'}
|
delta={durationDeltaInfo.value}
|
||||||
|
deltaTone={durationDeltaInfo.tone}
|
||||||
hint="按比价记录页同一口径:取所选日期范围内已上报耗时的比价记录,求平均后换算为秒。"
|
hint="按比价记录页同一口径:取所选日期范围内已上报耗时的比价记录,求平均后换算为秒。"
|
||||||
/>
|
/>
|
||||||
<StatCard title="平均节省金额" value={fmtCents(periodData?.comparison.average_saved_cents)} status="有节省的成功比价" />
|
<StatCard
|
||||||
|
title="平均节省金额"
|
||||||
|
value={fmtCents(periodData?.comparison.average_saved_cents)}
|
||||||
|
delta={averageSavedDelta.value}
|
||||||
|
deltaTone={averageSavedDelta.tone}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -597,7 +767,7 @@ export default function DashboardPage() {
|
|||||||
<h3>变现</h3>
|
<h3>变现</h3>
|
||||||
<span>
|
<span>
|
||||||
{cpsAvailable
|
{cpsAvailable
|
||||||
? (adError ? '广告收益接口当前后端不可用,美团 CPS 已接入' : '广告收益与美团 CPS 已接入')
|
? (adError ? '广告收益接口当前后端不可用,美团/京东 CPS 已接入' : '广告收益与美团/京东 CPS 已接入')
|
||||||
: (adError ? '广告收益接口当前后端不可用,订单/佣金数据待接' : '广告收益已接入,订单/佣金数据待接')}
|
: (adError ? '广告收益接口当前后端不可用,订单/佣金数据待接' : '广告收益已接入,订单/佣金数据待接')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -607,6 +777,8 @@ export default function DashboardPage() {
|
|||||||
title="总收入"
|
title="总收入"
|
||||||
value={adLoading ? '--' : fmtYuan(totalRevenueYuan)}
|
value={adLoading ? '--' : fmtYuan(totalRevenueYuan)}
|
||||||
accent="blue"
|
accent="blue"
|
||||||
|
delta={totalRevenueDelta.value}
|
||||||
|
deltaTone={totalRevenueDelta.tone}
|
||||||
meta={[
|
meta={[
|
||||||
{ label: '广告收入', value: adLoading ? '--' : fmtYuan(adReport?.total_revenue_yuan) },
|
{ label: '广告收入', value: adLoading ? '--' : fmtYuan(adReport?.total_revenue_yuan) },
|
||||||
{ label: 'CPS 收入', value: cpsRevenueText },
|
{ label: 'CPS 收入', value: cpsRevenueText },
|
||||||
@@ -615,38 +787,58 @@ export default function DashboardPage() {
|
|||||||
<RevenueCard
|
<RevenueCard
|
||||||
title="广告收入"
|
title="广告收入"
|
||||||
value={adLoading ? '--' : fmtYuan(adReport?.total_revenue_yuan)}
|
value={adLoading ? '--' : fmtYuan(adReport?.total_revenue_yuan)}
|
||||||
meta={[{ label: '展示数', value: adLoading ? '--' : fmtInt(adReport?.total_impressions) }]}
|
delta={adRevenueDelta.value}
|
||||||
|
deltaTone={adRevenueDelta.tone}
|
||||||
|
meta={[
|
||||||
|
{
|
||||||
|
label: '占总收入',
|
||||||
|
value:
|
||||||
|
totalRevenueYuan && totalRevenueYuan > 0 && adReport?.total_revenue_yuan != null
|
||||||
|
? `${((adReport.total_revenue_yuan / totalRevenueYuan) * 100).toFixed(1)}%`
|
||||||
|
: '--',
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
<RevenueCard
|
<RevenueCard
|
||||||
title="CPS 收入"
|
title="CPS 收入"
|
||||||
value={cpsRevenueText}
|
value={cpsRevenueText}
|
||||||
meta={[{ label: '来源', value: cpsAvailable ? '美团已接,淘宝/京东暂空' : '订单/佣金待接' }]}
|
delta={cpsRevenueDelta.value}
|
||||||
|
deltaTone={cpsRevenueDelta.tone}
|
||||||
|
meta={[
|
||||||
|
{
|
||||||
|
label: '占总收入',
|
||||||
|
value:
|
||||||
|
totalRevenueYuan && totalRevenueYuan > 0 && totalCpsCommissionCents != null
|
||||||
|
? `${(((totalCpsCommissionCents / 100) / totalRevenueYuan) * 100).toFixed(1)}%`
|
||||||
|
: '--',
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
<RevenueCard
|
<RevenueCard
|
||||||
title="ARPU"
|
title="ARPU"
|
||||||
value={adLoading ? '--' : fmtYuan(arpuYuan)}
|
value={adLoading ? '--' : fmtYuan(arpuYuan)}
|
||||||
meta={[
|
meta={[
|
||||||
{ label: '口径', value: '收入 / 活跃用户' },
|
{ label: '口径', value: '总收入 / 昨日活跃用户' },
|
||||||
{ label: 'ARPPU', value: '待确认付费用户口径' },
|
{ label: '分母', value: yesterdayActiveUsers == null ? '--' : `${fmtInt(yesterdayActiveUsers)} 人` },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="sub-label cps-sub-label">
|
<div className="sub-label cps-sub-label">
|
||||||
<span>CPS 收益</span>
|
<span>CPS 收益</span>
|
||||||
<button type="button" onClick={syncMeituanCps} disabled={cpsSyncing}>
|
<button type="button" onClick={syncCpsOrders} disabled={cpsSyncing}>
|
||||||
{cpsSyncing ? '刷新中' : '刷新美团订单'}
|
{cpsSyncing ? '刷新中' : '刷新 CPS 订单'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid g4">
|
<div className="grid g4">
|
||||||
<RevenueCard
|
<RevenueCard
|
||||||
title="总 CPS 收益"
|
title="总 CPS 收益"
|
||||||
value={cpsRevenueText}
|
value={cpsRevenueText}
|
||||||
meta={[{ label: '来源', value: cpsAvailable ? '美团订单佣金,淘宝/京东暂空' : '订单/佣金待接' }]}
|
meta={[{ label: '来源', value: cpsAvailable ? '美团+京东订单佣金,淘宝暂未接入' : '订单/佣金待接' }]}
|
||||||
/>
|
/>
|
||||||
<RevenueCard
|
<RevenueCard
|
||||||
title="美团 CPS"
|
title="美团 CPS"
|
||||||
value={cpsRevenueText}
|
value={meituanCpsRevenueText}
|
||||||
meta={[
|
meta={[
|
||||||
{ label: '订单量', value: cpsAvailable ? fmtInt(data?.cps.meituan_order_count) : '待订单数据' },
|
{ label: '订单量', value: cpsAvailable ? fmtInt(data?.cps.meituan_order_count) : '待订单数据' },
|
||||||
{
|
{
|
||||||
@@ -658,8 +850,16 @@ export default function DashboardPage() {
|
|||||||
]}
|
]}
|
||||||
accent="yellow"
|
accent="yellow"
|
||||||
/>
|
/>
|
||||||
<RevenueCard title="淘宝 CPS" value="--" meta={[{ label: '状态', value: '后续接入后填写' }]} accent="red" />
|
<RevenueCard title="淘宝 CPS" value="--" meta={[{ label: '状态', value: '暂未接入' }]} accent="red" />
|
||||||
<RevenueCard title="京东 CPS" value="--" meta={[{ label: '状态', value: '后续接入后填写' }]} accent="red" />
|
<RevenueCard
|
||||||
|
title="京东 CPS"
|
||||||
|
value={jdCpsRevenueText}
|
||||||
|
meta={[
|
||||||
|
{ label: '有效订单', value: cpsAvailable ? fmtInt(data?.cps.jd_order_count) : '待订单数据' },
|
||||||
|
{ label: '无效订单', value: cpsAvailable ? fmtInt(data?.cps.jd_invalid_count ?? 0) : '待订单数据' },
|
||||||
|
]}
|
||||||
|
accent="jd"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="sub-label">广告收益</div>
|
<div className="sub-label">广告收益</div>
|
||||||
@@ -705,32 +905,58 @@ export default function DashboardPage() {
|
|||||||
<span className="bar" />
|
<span className="bar" />
|
||||||
<h3>金币经济</h3>
|
<h3>金币经济</h3>
|
||||||
<Tag color="warning">风控重点</Tag>
|
<Tag color="warning">风控重点</Tag>
|
||||||
<span>发放是账面负债,提现是真实现金成本</span>
|
<span>发放 = 平台负债,提现 = 真实现金成本</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid g6">
|
<div className="grid g6">
|
||||||
<StatCard title="本期发放金币" value={fmtInt(periodData?.coins.granted_total)} status="本期发放合计" />
|
<StatCard
|
||||||
|
title="本期发放金币"
|
||||||
|
value={fmtInt(periodData?.coins.granted_total)}
|
||||||
|
delta={grantedCoinDelta.value}
|
||||||
|
deltaTone={grantedCoinDelta.tone}
|
||||||
|
emphasis
|
||||||
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="领券奖励金币"
|
title="领券奖励金币"
|
||||||
value={fmtInt(couponRewardCoinTotal)}
|
value={fmtInt(couponRewardCoinTotal)}
|
||||||
status="领券相关发放"
|
delta={couponCoinRatio.value}
|
||||||
|
deltaTone={couponCoinRatio.tone}
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="比价奖励金币"
|
title="比价奖励金币"
|
||||||
value={fmtInt(comparisonRewardCoinTotal)}
|
value={fmtInt(comparisonRewardCoinTotal)}
|
||||||
status="比价相关发放"
|
delta={comparisonCoinRatio.value}
|
||||||
|
deltaTone={comparisonCoinRatio.tone}
|
||||||
|
/>
|
||||||
|
<StatCard
|
||||||
|
title="激励视频金币"
|
||||||
|
value={fmtInt(periodData?.coins.reward_video_coin_total)}
|
||||||
|
delta={rewardVideoCoinRatio.value}
|
||||||
|
deltaTone={rewardVideoCoinRatio.tone}
|
||||||
|
hint="独立统计激励视频发放,不再重复计入领券奖励。"
|
||||||
/>
|
/>
|
||||||
<StatCard title="激励视频金币" value="--" status="并入领券奖励" />
|
|
||||||
<StatCard
|
<StatCard
|
||||||
title="常规任务金币"
|
title="常规任务金币"
|
||||||
value={fmtInt(regularTaskCoinTotal)}
|
value={fmtInt(regularTaskCoinTotal)}
|
||||||
status="任务等发放"
|
delta={regularTaskCoinRatio.value}
|
||||||
|
deltaTone={regularTaskCoinRatio.tone}
|
||||||
|
/>
|
||||||
|
<StatCard
|
||||||
|
title="本期提现金额"
|
||||||
|
value={fmtCents(periodData?.cash.withdraw_success_cents)}
|
||||||
|
delta="实付现金"
|
||||||
|
deltaTone="flat"
|
||||||
/>
|
/>
|
||||||
<StatCard title="本期提现金额" value={fmtCents(periodData?.cash.withdraw_success_cents)} status="成功提现" />
|
|
||||||
</div>
|
</div>
|
||||||
<div className="risk-note">
|
<div className="risk-note">
|
||||||
本期已发放 {fmtInt(periodData?.coins.granted_total)} 金币,成功提现 {fmtCents(periodData?.cash.withdraw_success_cents)};
|
⚠️
|
||||||
累计已发放 {fmtInt(data.coins.granted_total)} 金币,累计成功提现 {fmtCents(data.cash.withdraw_success_cents)}。
|
<div>
|
||||||
金币分类已按产品口径归类;邀请、后台手动加金币、福利页广告、无法判断来源的广告不进入上述分类。
|
本期 4 项奖励合计发放 <b>{fmtCoinAmount(periodData?.coins.granted_total)}</b> 金币
|
||||||
|
(账面负债 ≈ <b>{fmtYuan((periodData?.coins.granted_total ?? 0) / 1000)}</b>),
|
||||||
|
实际提现兑付 <b>{fmtCents(periodData?.cash.withdraw_success_cents)}</b>。
|
||||||
|
累计已发放 <b>{fmtCoinAmount(data.coins.granted_total)}</b> 金币但累计真实提现仅
|
||||||
|
<b>{fmtCents(data.cash.withdraw_success_cents)}</b>,发放与现金兑付背离属正常(金币沉淀/过期);
|
||||||
|
邀请奖励、后台手动加金币、福利页/老版本未打标签信息流不进入这 4 项,需盯紧各来源占比突变与异常领取。
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -772,7 +998,7 @@ export default function DashboardPage() {
|
|||||||
--coin: #ffb300;
|
--coin: #ffb300;
|
||||||
--p-mt-waimai: #ffc300;
|
--p-mt-waimai: #ffc300;
|
||||||
--p-taobao: #ff4400;
|
--p-taobao: #ff4400;
|
||||||
--p-jd: #e1251b;
|
--p-jd: #b91c1c;
|
||||||
--radius: 10px;
|
--radius: 10px;
|
||||||
--shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.04);
|
--shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.04);
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
@@ -967,10 +1193,17 @@ export default function DashboardPage() {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.status-muted,
|
.status-muted,
|
||||||
.delta-muted {
|
.delta-muted,
|
||||||
|
.delta-flat {
|
||||||
color: var(--ink-3);
|
color: var(--ink-3);
|
||||||
background: #f1f3f7;
|
background: #f1f3f7;
|
||||||
}
|
}
|
||||||
|
.delta .cmp {
|
||||||
|
margin-left: 3px;
|
||||||
|
color: var(--ink-3);
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
.status-ok,
|
.status-ok,
|
||||||
.delta-up {
|
.delta-up {
|
||||||
color: var(--up);
|
color: var(--up);
|
||||||
@@ -1144,6 +1377,10 @@ export default function DashboardPage() {
|
|||||||
background: var(--p-taobao);
|
background: var(--p-taobao);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
.rev-jd .revenue-tag {
|
||||||
|
background: var(--p-jd);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
.revenue-value {
|
.revenue-value {
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font-family: "DIN Alternate", "Helvetica Neue", sans-serif;
|
font-family: "DIN Alternate", "Helvetica Neue", sans-serif;
|
||||||
|
|||||||
+246
-30
@@ -8,10 +8,10 @@ import {
|
|||||||
DatabaseOutlined,
|
DatabaseOutlined,
|
||||||
FileSearchOutlined,
|
FileSearchOutlined,
|
||||||
FlagOutlined,
|
FlagOutlined,
|
||||||
|
GiftOutlined,
|
||||||
HeartOutlined,
|
HeartOutlined,
|
||||||
LogoutOutlined,
|
LogoutOutlined,
|
||||||
MessageOutlined,
|
MessageOutlined,
|
||||||
MobileOutlined,
|
|
||||||
MoneyCollectOutlined,
|
MoneyCollectOutlined,
|
||||||
NotificationOutlined,
|
NotificationOutlined,
|
||||||
ProfileOutlined,
|
ProfileOutlined,
|
||||||
@@ -20,25 +20,66 @@ import {
|
|||||||
TeamOutlined,
|
TeamOutlined,
|
||||||
UserOutlined,
|
UserOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { Avatar, Dropdown, Layout, Menu } from 'antd';
|
import { Avatar, Dropdown, Layout, Tooltip } from 'antd';
|
||||||
import { clearAuth, getAdmin, getToken } from '@/lib/auth';
|
import { clearAuth, getAdmin, getToken } from '@/lib/auth';
|
||||||
import type { AdminInfo } from '@/lib/types';
|
import type { AdminInfo } from '@/lib/types';
|
||||||
|
|
||||||
const { Sider, Header, Content } = Layout;
|
const { Sider, Header, Content } = Layout;
|
||||||
|
|
||||||
const MENU = [
|
type NavItem = {
|
||||||
{ key: '/dashboard', icon: <DashboardOutlined />, label: '数据大盘' },
|
key: string;
|
||||||
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
icon: React.ReactNode;
|
||||||
{ key: '/devices', icon: <MobileOutlined />, label: '设备管理' },
|
label: string;
|
||||||
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
|
superOnly?: boolean;
|
||||||
{ key: '/withdraws', icon: <MoneyCollectOutlined />, label: '提现管理' },
|
};
|
||||||
{ key: '/price-reports', icon: <FlagOutlined />, label: '低价审核' },
|
|
||||||
{ key: '/comparison-records', icon: <ProfileOutlined />, label: '比价记录' },
|
type NavGroup =
|
||||||
{ key: '/feedbacks', icon: <MessageOutlined />, label: '用户反馈' },
|
| (NavItem & { children?: never })
|
||||||
{ key: '/ad-revenue', icon: <NotificationOutlined />, label: '广告配置' },
|
| {
|
||||||
{ key: '/ad-revenue-report', icon: <BarChartOutlined />, label: '广告收益' },
|
key: string;
|
||||||
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS 分发' },
|
icon: React.ReactNode;
|
||||||
{ key: '/config', icon: <SettingOutlined />, label: '系统配置' },
|
label: string;
|
||||||
|
children: NavItem[];
|
||||||
|
superOnly?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasChildren = (group: NavGroup): group is NavGroup & { children: NavItem[] } =>
|
||||||
|
Array.isArray(group.children);
|
||||||
|
|
||||||
|
const NAV_GROUPS: NavGroup[] = [
|
||||||
|
{
|
||||||
|
key: 'dashboard',
|
||||||
|
icon: <DashboardOutlined />,
|
||||||
|
label: '看板',
|
||||||
|
children: [
|
||||||
|
{ key: '/dashboard', icon: <DashboardOutlined />, label: '数据大盘' },
|
||||||
|
{ key: '/coupon-data', icon: <GiftOutlined />, label: '领券数据' },
|
||||||
|
{ key: '/ad-revenue-report', icon: <BarChartOutlined />, label: '广告收益' },
|
||||||
|
{ key: '/comparison-records', icon: <ProfileOutlined />, label: '比价记录' },
|
||||||
|
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS收益' },
|
||||||
|
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'reward-review',
|
||||||
|
icon: <MoneyCollectOutlined />,
|
||||||
|
label: '奖励审核',
|
||||||
|
children: [
|
||||||
|
{ key: '/withdraws', icon: <MoneyCollectOutlined />, label: '提现审核' },
|
||||||
|
{ key: '/price-reports', icon: <FlagOutlined />, label: '低价审核' },
|
||||||
|
{ key: '/feedbacks', icon: <MessageOutlined />, label: '用户反馈' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'data-config',
|
||||||
|
icon: <SettingOutlined />,
|
||||||
|
label: '数据配置',
|
||||||
|
children: [
|
||||||
|
{ key: '/config', icon: <SettingOutlined />, label: '系统配置' },
|
||||||
|
{ key: '/ad-revenue', icon: <NotificationOutlined />, label: '广告配置' },
|
||||||
|
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
||||||
|
],
|
||||||
|
},
|
||||||
{ key: '/admins', icon: <TeamOutlined />, label: '管理员', superOnly: true },
|
{ key: '/admins', icon: <TeamOutlined />, label: '管理员', superOnly: true },
|
||||||
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
||||||
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
||||||
@@ -48,6 +89,7 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const [admin, setAdmin] = useState<AdminInfo | null>(null);
|
const [admin, setAdmin] = useState<AdminInfo | null>(null);
|
||||||
|
const [collapsed, setCollapsed] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!getToken()) {
|
if (!getToken()) {
|
||||||
@@ -59,14 +101,19 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
|
|
||||||
if (!admin) return null; // 守卫期间不闪烁内容
|
if (!admin) return null; // 守卫期间不闪烁内容
|
||||||
|
|
||||||
const items = MENU.filter((m) => !m.superOnly || admin.role === 'super_admin').map((m) => ({
|
// 选中态:取路径一级(/users/123 -> /users)
|
||||||
key: m.key,
|
|
||||||
icon: m.icon,
|
|
||||||
label: m.label,
|
|
||||||
}));
|
|
||||||
|
|
||||||
// 选中态:取路径一级(/users/123 → /users)
|
|
||||||
const selectedKey = '/' + (pathname.split('/')[1] || 'dashboard');
|
const selectedKey = '/' + (pathname.split('/')[1] || 'dashboard');
|
||||||
|
const canShow = (item: { superOnly?: boolean }) => !item.superOnly || admin.role === 'super_admin';
|
||||||
|
const visibleGroups = NAV_GROUPS
|
||||||
|
.filter(canShow)
|
||||||
|
.map((group) => {
|
||||||
|
if (!hasChildren(group)) return group;
|
||||||
|
return { ...group, children: group.children.filter(canShow) };
|
||||||
|
})
|
||||||
|
.filter((group) => !hasChildren(group) || group.children.length > 0);
|
||||||
|
const flatNavItems = visibleGroups.flatMap((group) =>
|
||||||
|
hasChildren(group) ? group.children : [group],
|
||||||
|
);
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
clearAuth();
|
clearAuth();
|
||||||
@@ -75,7 +122,15 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout style={{ minHeight: '100vh' }}>
|
<Layout style={{ minHeight: '100vh' }}>
|
||||||
<Sider theme="dark" breakpoint="lg" collapsible>
|
<Sider
|
||||||
|
theme="dark"
|
||||||
|
breakpoint="lg"
|
||||||
|
collapsible
|
||||||
|
collapsed={collapsed}
|
||||||
|
collapsedWidth={72}
|
||||||
|
width={220}
|
||||||
|
onCollapse={setCollapsed}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
height: 48,
|
height: 48,
|
||||||
@@ -88,13 +143,61 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
>
|
>
|
||||||
运营后台
|
运营后台
|
||||||
</div>
|
</div>
|
||||||
<Menu
|
<nav className={`side-nav${collapsed ? ' side-nav-collapsed' : ''}`} aria-label="后台导航">
|
||||||
theme="dark"
|
{collapsed
|
||||||
mode="inline"
|
? flatNavItems.map((item) => (
|
||||||
selectedKeys={[selectedKey]}
|
<Tooltip key={item.key} title={item.label} placement="right">
|
||||||
items={items}
|
<button
|
||||||
onClick={({ key }) => router.push(key)}
|
type="button"
|
||||||
/>
|
className={`nav-icon-button${selectedKey === item.key ? ' is-selected' : ''}`}
|
||||||
|
onClick={() => router.push(item.key)}
|
||||||
|
aria-label={item.label}
|
||||||
|
>
|
||||||
|
{item.icon}
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
))
|
||||||
|
: visibleGroups.map((group) => {
|
||||||
|
const isGroup = hasChildren(group);
|
||||||
|
const groupSelected = isGroup
|
||||||
|
? group.children.some((child) => child.key === selectedKey)
|
||||||
|
: selectedKey === group.key;
|
||||||
|
if (!isGroup) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={group.key}
|
||||||
|
type="button"
|
||||||
|
className={`nav-primary nav-direct${groupSelected ? ' is-selected' : ''}`}
|
||||||
|
onClick={() => router.push(group.key)}
|
||||||
|
>
|
||||||
|
<span className="nav-primary-icon">{group.icon}</span>
|
||||||
|
<span>{group.label}</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<section key={group.key} className={`nav-group${groupSelected ? ' is-active' : ''}`}>
|
||||||
|
<div className="nav-primary">
|
||||||
|
<span className="nav-primary-icon">{group.icon}</span>
|
||||||
|
<span>{group.label}</span>
|
||||||
|
</div>
|
||||||
|
<div className="nav-children">
|
||||||
|
{group.children.map((child) => (
|
||||||
|
<button
|
||||||
|
key={child.key}
|
||||||
|
type="button"
|
||||||
|
className={`nav-child${selectedKey === child.key ? ' is-selected' : ''}`}
|
||||||
|
onClick={() => router.push(child.key)}
|
||||||
|
>
|
||||||
|
<span className="nav-child-icon">{child.icon}</span>
|
||||||
|
<span>{child.label}</span>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</nav>
|
||||||
</Sider>
|
</Sider>
|
||||||
<Layout>
|
<Layout>
|
||||||
<Header
|
<Header
|
||||||
@@ -120,6 +223,119 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
</Header>
|
</Header>
|
||||||
<Content style={{ margin: 24 }}>{children}</Content>
|
<Content style={{ margin: 24 }}>{children}</Content>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
<style jsx global>{`
|
||||||
|
.side-nav {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 0 10px 14px;
|
||||||
|
}
|
||||||
|
.nav-group {
|
||||||
|
padding: 6px 0 8px;
|
||||||
|
}
|
||||||
|
.nav-group + .nav-group,
|
||||||
|
.nav-group + .nav-direct,
|
||||||
|
.nav-direct + .nav-direct {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
.nav-primary {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
min-height: 36px;
|
||||||
|
padding: 0 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.88);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0;
|
||||||
|
}
|
||||||
|
.nav-primary-icon,
|
||||||
|
.nav-child-icon {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: rgba(255, 255, 255, 0.72);
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.nav-direct,
|
||||||
|
.nav-child,
|
||||||
|
.nav-icon-button {
|
||||||
|
border: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
font: inherit;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.nav-direct {
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
.nav-direct:hover,
|
||||||
|
.nav-direct.is-selected {
|
||||||
|
background: #1677ff;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.nav-direct:hover .nav-primary-icon,
|
||||||
|
.nav-direct.is-selected .nav-primary-icon {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.nav-children {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
margin-left: 34px;
|
||||||
|
margin-top: -2px;
|
||||||
|
padding-right: 2px;
|
||||||
|
}
|
||||||
|
.nav-child {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 34px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: rgba(255, 255, 255, 0.72);
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
.nav-child:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.nav-child.is-selected {
|
||||||
|
background: #1677ff;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.nav-child.is-selected .nav-child-icon {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.nav-group.is-active .nav-primary {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.side-nav-collapsed {
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 0 8px 14px;
|
||||||
|
}
|
||||||
|
.nav-icon-button {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: rgba(255, 255, 255, 0.72);
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
.nav-icon-button:hover,
|
||||||
|
.nav-icon-button.is-selected {
|
||||||
|
background: #1677ff;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ const PAGE_SIZE = 10; // 金币记录每页条数
|
|||||||
interface Props {
|
interface Props {
|
||||||
userId: number;
|
userId: number;
|
||||||
user: WithdrawUserSnapshot | null;
|
user: WithdrawUserSnapshot | null;
|
||||||
|
// 统计区字段集:withdraw(默认,提现详情:含提现细分) / ad(广告收益详情:只看看广告观看统计,对齐参考图 6 项)
|
||||||
|
statsVariant?: 'withdraw' | 'ad';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 提现详情抽屉:用户基本信息 + 互斥时间筛选 + 看广告/提现统计区 + 金币发放记录表。 */
|
/** 用户看广告/提现详情:基本信息 + 互斥时间筛选 + 统计区(按 statsVariant 取字段集)+ 金币发放记录表。 */
|
||||||
export default function UserRewardPanel({ userId, user }: Props) {
|
export default function UserRewardPanel({ userId, user, statsVariant = 'withdraw' }: Props) {
|
||||||
const [mode, setMode] = useState<'all' | 'range'>('all'); // all=注册至今 / range=自定义区间
|
const [mode, setMode] = useState<'all' | 'range'>('all'); // all=注册至今 / range=自定义区间
|
||||||
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
|
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
|
||||||
const [stats, setStats] = useState<UserRewardStats | null>(null);
|
const [stats, setStats] = useState<UserRewardStats | null>(null);
|
||||||
@@ -164,7 +166,7 @@ export default function UserRewardPanel({ userId, user }: Props) {
|
|||||||
</Space>
|
</Space>
|
||||||
</Space>
|
</Space>
|
||||||
|
|
||||||
{/* 统计区(受时间筛选;现金余额为当前快照) */}
|
{/* 统计区(受时间筛选;现金余额为当前快照)。ad 视图只保留看广告观看统计(对齐参考图 6 项) */}
|
||||||
<Descriptions bordered size="small" column={2} style={{ marginBottom: 8 }}>
|
<Descriptions bordered size="small" column={2} style={{ marginBottom: 8 }}>
|
||||||
<Descriptions.Item label="累计提现">
|
<Descriptions.Item label="累计提现">
|
||||||
{stats ? yuan(stats.withdraw_success_cents) : '-'}
|
{stats ? yuan(stats.withdraw_success_cents) : '-'}
|
||||||
@@ -172,29 +174,51 @@ export default function UserRewardPanel({ userId, user }: Props) {
|
|||||||
<Descriptions.Item label="现金余额">
|
<Descriptions.Item label="现金余额">
|
||||||
{stats ? yuan(stats.cash_balance_cents) : '-'}
|
{stats ? yuan(stats.cash_balance_cents) : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="提现总次数">{stats?.withdraw_total ?? '-'}</Descriptions.Item>
|
{statsVariant === 'ad' ? (
|
||||||
<Descriptions.Item label="传统任务提现">
|
<>
|
||||||
{stats ? yuan(stats.traditional_task_cash_cents) : '-'}
|
<Descriptions.Item label="激励视频观看数">
|
||||||
</Descriptions.Item>
|
{stats?.reward_video_count ?? '-'}
|
||||||
<Descriptions.Item label="累计激励视频数">
|
</Descriptions.Item>
|
||||||
{stats?.reward_video_count ?? '-'}
|
{/* eCPM 均按元展示(reward_video / feed avg_ecpm 原始为分/千次,÷100 转元) */}
|
||||||
</Descriptions.Item>
|
<Descriptions.Item label="平均激励视频ECPM">
|
||||||
<Descriptions.Item label="平均激励视频ECPM">
|
{stats ? `${(stats.reward_video_avg_ecpm / 100).toFixed(2)} 元/千` : '-'}
|
||||||
{stats ? `${stats.reward_video_avg_ecpm} 分/千` : '-'}
|
</Descriptions.Item>
|
||||||
</Descriptions.Item>
|
<Descriptions.Item label="draw信息流视频观看数">
|
||||||
<Descriptions.Item label="激励视频提现">
|
{stats?.feed_count ?? '-'}
|
||||||
{stats ? yuan(stats.reward_video_cash_cents) : '-'}
|
</Descriptions.Item>
|
||||||
</Descriptions.Item>
|
<Descriptions.Item label="平均draw信息流ECPM">
|
||||||
<Descriptions.Item label="累计信息流广告数">{stats?.feed_count ?? '-'}</Descriptions.Item>
|
{stats ? `${(stats.feed_avg_ecpm / 100).toFixed(2)} 元/千` : '-'}
|
||||||
<Descriptions.Item label="平均信息流广告ECPM">
|
</Descriptions.Item>
|
||||||
{stats ? `${stats.feed_avg_ecpm} 分/千` : '-'}
|
</>
|
||||||
</Descriptions.Item>
|
) : (
|
||||||
<Descriptions.Item label="信息流广告提现">
|
<>
|
||||||
{stats ? yuan(stats.feed_cash_cents) : '-'}
|
<Descriptions.Item label="提现总次数">{stats?.withdraw_total ?? '-'}</Descriptions.Item>
|
||||||
</Descriptions.Item>
|
<Descriptions.Item label="传统任务提现">
|
||||||
|
{stats ? yuan(stats.traditional_task_cash_cents) : '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="累计激励视频数">
|
||||||
|
{stats?.reward_video_count ?? '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="平均激励视频ECPM">
|
||||||
|
{stats ? `${stats.reward_video_avg_ecpm} 分/千` : '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="激励视频提现">
|
||||||
|
{stats ? yuan(stats.reward_video_cash_cents) : '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="累计信息流广告数">{stats?.feed_count ?? '-'}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="平均信息流广告ECPM">
|
||||||
|
{stats ? `${stats.feed_avg_ecpm} 分/千` : '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="信息流广告提现">
|
||||||
|
{stats ? yuan(stats.feed_cash_cents) : '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
统计随上方时间筛选(现金余额除外,为当前快照);eCPM 单位分/千次,同金币审计。
|
{statsVariant === 'ad'
|
||||||
|
? '统计随上方时间筛选(现金余额除外,为当前快照);eCPM 均按元展示(原始分/千次 ÷100)。'
|
||||||
|
: '统计随上方时间筛选(现金余额除外,为当前快照);eCPM 单位分/千次,同金币审计。'}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{/* 金币记录 */}
|
{/* 金币记录 */}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// 调金币 / 调现金弹窗(受控)。列表页与用户详情页共用,避免两处各写一套。
|
// 调金币 / 调现金弹窗(受控)。列表页与用户详情页共用,避免两处各写一套。
|
||||||
// 每个弹窗自带「增减 / 设为指定值」两种模式;打开时拉一次 360 概览展示当前余额。
|
// 每个弹窗自带「增减 / 设为指定值」两种模式;打开时拉一次 360 概览展示当前余额。
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { App, Form, Input, InputNumber, Modal, Segmented } from 'antd';
|
import { App, Form, Input, InputNumber, Modal, Radio, Segmented } from 'antd';
|
||||||
import { api, errMsg } from '@/lib/api';
|
import { api, errMsg } from '@/lib/api';
|
||||||
import { yuan } from '@/lib/format';
|
import { yuan } from '@/lib/format';
|
||||||
import type { UserOverview } from '@/lib/types';
|
import type { UserOverview } from '@/lib/types';
|
||||||
@@ -17,15 +17,19 @@ interface ModalProps {
|
|||||||
onDone?: () => void; // 调整成功后回调(刷新余额/列表)
|
onDone?: () => void; // 调整成功后回调(刷新余额/列表)
|
||||||
}
|
}
|
||||||
|
|
||||||
const balanceLine = (balances: { coin: number; cashCents: number } | null) => (
|
type Balances = { coin: number; cashCents: number; inviteCashCents: number };
|
||||||
|
|
||||||
|
const balanceLine = (balances: Balances | null) => (
|
||||||
<p style={{ color: '#888', marginBottom: 12 }}>
|
<p style={{ color: '#888', marginBottom: 12 }}>
|
||||||
当前余额:金币 {balances ? balances.coin : '…'} | 现金 {balances ? yuan(balances.cashCents) : '…'}
|
当前余额:金币 {balances ? balances.coin : '…'} | 现金(金币兑现金){' '}
|
||||||
|
{balances ? yuan(balances.cashCents) : '…'} | 邀请奖励金{' '}
|
||||||
|
{balances ? yuan(balances.inviteCashCents) : '…'}
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
|
|
||||||
// 弹窗打开时拉一次该用户余额;用户切换/关闭时丢弃过期响应(alive 标记防竞态)。
|
// 弹窗打开时拉一次该用户余额;用户切换/关闭时丢弃过期响应(alive 标记防竞态)。
|
||||||
function useBalances(userId: number | undefined, open: boolean) {
|
function useBalances(userId: number | undefined, open: boolean) {
|
||||||
const [balances, setBalances] = useState<{ coin: number; cashCents: number } | null>(null);
|
const [balances, setBalances] = useState<Balances | null>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open || userId == null) {
|
if (!open || userId == null) {
|
||||||
setBalances(null);
|
setBalances(null);
|
||||||
@@ -36,7 +40,12 @@ function useBalances(userId: number | undefined, open: boolean) {
|
|||||||
api
|
api
|
||||||
.get<UserOverview>(`/admin/api/users/${userId}`)
|
.get<UserOverview>(`/admin/api/users/${userId}`)
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
if (alive) setBalances({ coin: r.data.coin_balance, cashCents: r.data.cash_balance_cents });
|
if (alive)
|
||||||
|
setBalances({
|
||||||
|
coin: r.data.coin_balance,
|
||||||
|
cashCents: r.data.cash_balance_cents,
|
||||||
|
inviteCashCents: r.data.invite_cash_balance_cents,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
return () => {
|
return () => {
|
||||||
@@ -113,39 +122,39 @@ export function AdjustCoinModal({ user, open, onClose, onDone }: ModalProps) {
|
|||||||
export function AdjustCashModal({ user, open, onClose, onDone }: ModalProps) {
|
export function AdjustCashModal({ user, open, onClose, onDone }: ModalProps) {
|
||||||
const { message } = App.useApp();
|
const { message } = App.useApp();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [mode, setMode] = useState<'delta' | 'set'>('delta');
|
// 操作方式改为表单必选项(无默认、手动选);用 watch 驱动金额栏文案/最小值
|
||||||
|
const mode = Form.useWatch('mode', form) as 'delta' | 'set' | undefined;
|
||||||
const balances = useBalances(user?.id, open);
|
const balances = useBalances(user?.id, open);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (open) form.resetFields(); // 目标账户 / 操作方式 都重置为「未选」
|
||||||
setMode('delta');
|
|
||||||
form.resetFields();
|
|
||||||
}
|
|
||||||
}, [open, form]);
|
}, [open, form]);
|
||||||
|
|
||||||
// 输入元,×100 转分后调后端(主要给无现金用户发钱直接测试提现)
|
// 输入元,×100 转分后调后端(主要给无现金用户发钱直接测试提现)
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
const v = await form.validateFields();
|
const v = await form.validateFields(); // 任一必填/必选缺失 → 该项下方红字 + 阻断提交
|
||||||
const amountCents = Math.round(Number(v.amount_yuan) * 100);
|
const amountCents = Math.round(Number(v.amount_yuan) * 100);
|
||||||
if (mode === 'delta' && amountCents === 0) {
|
if (v.mode === 'delta' && amountCents === 0) {
|
||||||
message.warning('金额不能为 0(且不小于 1 分)');
|
message.warning('金额不能为 0(且不小于 1 分)');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mode === 'set' && amountCents < 0) {
|
if (v.mode === 'set' && amountCents < 0) {
|
||||||
message.warning('目标金额不能为负');
|
message.warning('目标金额不能为负');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const acctName = v.account === 'invite_cash' ? '邀请奖励金' : '现金';
|
||||||
try {
|
try {
|
||||||
await api.post(`/admin/api/users/${user.id}/cash`, {
|
await api.post(`/admin/api/users/${user.id}/cash`, {
|
||||||
mode,
|
account: v.account,
|
||||||
|
mode: v.mode,
|
||||||
amount_cents: amountCents,
|
amount_cents: amountCents,
|
||||||
reason: v.reason,
|
reason: v.reason,
|
||||||
});
|
});
|
||||||
message.success(
|
message.success(
|
||||||
mode === 'set'
|
v.mode === 'set'
|
||||||
? `已设为 ¥${(amountCents / 100).toFixed(2)} 现金`
|
? `已设为 ¥${(amountCents / 100).toFixed(2)} ${acctName}`
|
||||||
: `已${amountCents > 0 ? '发放' : '扣减'} ¥${(Math.abs(amountCents) / 100).toFixed(2)} 现金`,
|
: `已${amountCents > 0 ? '发放' : '扣减'} ¥${(Math.abs(amountCents) / 100).toFixed(2)} ${acctName}`,
|
||||||
);
|
);
|
||||||
onClose();
|
onClose();
|
||||||
onDone?.();
|
onDone?.();
|
||||||
@@ -164,10 +173,20 @@ export function AdjustCashModal({ user, open, onClose, onDone }: ModalProps) {
|
|||||||
>
|
>
|
||||||
{balanceLine(balances)}
|
{balanceLine(balances)}
|
||||||
<Form form={form} layout="vertical">
|
<Form form={form} layout="vertical">
|
||||||
<Form.Item label="操作方式">
|
<Form.Item name="account" label="目标账户" rules={[{ required: true, message: '请选择目标账户' }]}>
|
||||||
<Segmented
|
<Radio.Group
|
||||||
value={mode}
|
optionType="button"
|
||||||
onChange={(v) => setMode(v as 'delta' | 'set')}
|
buttonStyle="solid"
|
||||||
|
options={[
|
||||||
|
{ label: '金币兑现金账户', value: 'coin_cash' },
|
||||||
|
{ label: '邀请账户', value: 'invite_cash' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="mode" label="操作方式" rules={[{ required: true, message: '请选择操作方式' }]}>
|
||||||
|
<Radio.Group
|
||||||
|
optionType="button"
|
||||||
|
buttonStyle="solid"
|
||||||
options={[
|
options={[
|
||||||
{ label: '增减', value: 'delta' },
|
{ label: '增减', value: 'delta' },
|
||||||
{ label: '设为指定值', value: 'set' },
|
{ label: '设为指定值', value: 'set' },
|
||||||
@@ -182,7 +201,7 @@ export function AdjustCashModal({ user, open, onClose, onDone }: ModalProps) {
|
|||||||
: '现金变动(元,正=发放,负=扣减;不可扣成负)'
|
: '现金变动(元,正=发放,负=扣减;不可扣成负)'
|
||||||
}
|
}
|
||||||
rules={[
|
rules={[
|
||||||
{ required: true },
|
{ required: true, message: '请输入现金变动金额' },
|
||||||
...(mode === 'set' ? [{ type: 'number' as const, min: 0, message: '目标值不能为负' }] : []),
|
...(mode === 'set' ? [{ type: 'number' as const, min: 0, message: '目标值不能为负' }] : []),
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
@@ -194,7 +213,7 @@ export function AdjustCashModal({ user, open, onClose, onDone }: ModalProps) {
|
|||||||
min={mode === 'set' ? 0 : undefined}
|
min={mode === 'set' ? 0 : undefined}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="reason" label="原因(入审计)" rules={[{ required: true }]}>
|
<Form.Item name="reason" label="原因(入审计)" rules={[{ required: true, message: '请填写原因' }]}>
|
||||||
<Input.TextArea rows={2} />
|
<Input.TextArea rows={2} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ interface Props<T> {
|
|||||||
countLabel: string; // 顶部计数卡标题,如「提交总计」/「上报总计」
|
countLabel: string; // 顶部计数卡标题,如「提交总计」/「上报总计」
|
||||||
rewardLabel: string; // 顶部奖励卡标题,如「提交奖励总计」/「上报奖励总计」
|
rewardLabel: string; // 顶部奖励卡标题,如「提交奖励总计」/「上报奖励总计」
|
||||||
rewardOf: (item: T) => number; // 单条已发奖励金币(未采纳/未通过返回 0)
|
rewardOf: (item: T) => number; // 单条已发奖励金币(未采纳/未通过返回 0)
|
||||||
|
rewardSuffix?: string; // 第二个汇总卡单位,默认「金币」;领券场景可传「张」(领到券张数)等
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function UserRecordsDrawer<T extends { id: number }>({
|
export default function UserRecordsDrawer<T extends { id: number }>({
|
||||||
@@ -34,6 +35,7 @@ export default function UserRecordsDrawer<T extends { id: number }>({
|
|||||||
countLabel,
|
countLabel,
|
||||||
rewardLabel,
|
rewardLabel,
|
||||||
rewardOf,
|
rewardOf,
|
||||||
|
rewardSuffix = '金币',
|
||||||
}: Props<T>) {
|
}: Props<T>) {
|
||||||
const [items, setItems] = useState<T[]>([]);
|
const [items, setItems] = useState<T[]>([]);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
@@ -91,7 +93,7 @@ export default function UserRecordsDrawer<T extends { id: number }>({
|
|||||||
<>
|
<>
|
||||||
<Space size={48} style={{ marginBottom: 20 }}>
|
<Space size={48} style={{ marginBottom: 20 }}>
|
||||||
<Statistic title={countLabel} value={total} />
|
<Statistic title={countLabel} value={total} />
|
||||||
<Statistic title={rewardLabel} value={rewardTotal} suffix="金币" />
|
<Statistic title={rewardLabel} value={rewardTotal} suffix={rewardSuffix} />
|
||||||
</Space>
|
</Space>
|
||||||
{items.length === 0 ? (
|
{items.length === 0 ? (
|
||||||
<Empty description={`该用户暂无${recordLabel}`} style={{ marginTop: 24 }} />
|
<Empty description={`该用户暂无${recordLabel}`} style={{ marginTop: 24 }} />
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export interface UserOverview {
|
|||||||
user: UserListItem;
|
user: UserListItem;
|
||||||
coin_balance: number;
|
coin_balance: number;
|
||||||
cash_balance_cents: number;
|
cash_balance_cents: number;
|
||||||
|
invite_cash_balance_cents: number; // 邀请奖励金余额(与 cash_balance_cents 物理隔离)
|
||||||
total_coin_earned: number;
|
total_coin_earned: number;
|
||||||
comparison_total: number;
|
comparison_total: number;
|
||||||
comparison_success: number;
|
comparison_success: number;
|
||||||
@@ -424,6 +425,7 @@ export interface AdRevenueRow {
|
|||||||
impressions: number; // 本行展示条数 1/0(供日汇总、趋势图复用)
|
impressions: number; // 本行展示条数 1/0(供日汇总、趋势图复用)
|
||||||
ecpm: string | null; // 分/千次;展示行取展示值,纯发奖行取发奖采用值
|
ecpm: string | null; // 分/千次;展示行取展示值,纯发奖行取发奖采用值
|
||||||
revenue_yuan: number; // 本次展示预估收益(元);纯发奖行=0
|
revenue_yuan: number; // 本次展示预估收益(元);纯发奖行=0
|
||||||
|
row_revenue_yuan?: number | null; // 主表逐行显示用:一次比价/领券聚合行=该次发奖广告 eCPM 折算之和;其它行空(回退 revenue_yuan)
|
||||||
adn: string | null; // 实际填充 ADN;纯发奖行为空
|
adn: string | null; // 实际填充 ADN;纯发奖行为空
|
||||||
slot_id: string | null; // 底层 mediation rit;纯发奖行为空
|
slot_id: string | null; // 底层 mediation rit;纯发奖行为空
|
||||||
// ── 发奖侧 ──
|
// ── 发奖侧 ──
|
||||||
@@ -433,6 +435,8 @@ export interface AdRevenueRow {
|
|||||||
actual_coin: number; // 实发金币;纯展示=0
|
actual_coin: number; // 实发金币;纯展示=0
|
||||||
matched: boolean; // 本条应发==实发;纯展示恒 true(不计对账)
|
matched: boolean; // 本条应发==实发;纯展示恒 true(不计对账)
|
||||||
reward_detail: AdRevenueRecord | null; // 发奖复算明细(点行展开下钻);纯展示为空
|
reward_detail: AdRevenueRecord | null; // 发奖复算明细(点行展开下钻);纯展示为空
|
||||||
|
sub_rewards?: AdRevenueRecord[]; // 一次比价/领券聚合行的组内逐条明细(同整场 ad_session_id 的多条广告);展开渲染多行
|
||||||
|
sub_count?: number; // 本行聚合的发奖条数:一次比价/领券=该次广告条数(≥1);激励视频/纯展示=1
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdRevenueReport {
|
export interface AdRevenueReport {
|
||||||
@@ -536,6 +540,11 @@ export interface DashboardOverview {
|
|||||||
meituan_miss_count: number;
|
meituan_miss_count: number;
|
||||||
meituan_unknown_rate_count: number;
|
meituan_unknown_rate_count: number;
|
||||||
meituan_hit_rate: number | null;
|
meituan_hit_rate: number | null;
|
||||||
|
jd_order_count?: number;
|
||||||
|
jd_commission_cents?: number;
|
||||||
|
jd_actual_commission_cents?: number;
|
||||||
|
jd_estimated_commission_cents?: number;
|
||||||
|
jd_invalid_count?: number;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user