Compare commits

..

3 Commits

Author SHA1 Message Date
zhuzihao 2727eaa929 feat(ad-revenue): 收益报表按一次比价/领券聚合展开 + 用户收益详情抽屉 (#33)
- 主表按「单次广告行为」展示:一次比价/领券聚成父行、广告类型标「N 条」,点「+」展开看该次逐条
  发奖复算;信息流统一显示「Draw 信息流」,类型筛选去掉「信息流」选项。
- 新增点用户手机号弹半屏抽屉(UserAdRevenueDrawer,复用 withdraws 的 UserRewardPanel):展示该用户
  看广告统计(6 项)+ 金币记录;抽屉统计区 eCPM 改「元/千」,并补微信昵称。
- 一次比价/领券行显示预估收益(row_revenue_yuan,发奖侧折算);去掉「一致」列 + 应发≠实发行标红 +
  顶部对账 Alert(发奖走「所见即所得」display_coin,与公式复算本就对不上,属噪音)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: zzhyyyyy <2685922758@qq.com>
Reviewed-on: #33
Co-authored-by: zhuzihao <zhuzihao@wonderable.ai>
Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
2026-07-02 08:57:04 +08:00
chenshuobo af74ecf9d3 fix: 恢复后台左侧分组导航并补充领券数据入口 (#32)
Co-authored-by: lowmaster-chen <1119780489@qq.com>
Reviewed-on: #32
Co-authored-by: chenshuobo <chenshuobo@wonderable.ai>
Co-committed-by: chenshuobo <chenshuobo@wonderable.ai>
2026-07-01 21:47:46 +08:00
zhuzihao 3102a96bd3 feat: 运营后台「领券数据」页 (#31)
- 侧边栏在「用户反馈」后、「广告配置」前加「领券数据」菜单(/coupon-data)。
- 两段式:汇总卡(领券发起数 / 完成数 / 平均耗时 + 耗时 P5/P50/P95/P99)+ 自研零依赖 SVG 趋势图
  (发起 / 完成数双柱 + 平均耗时线,按天 / 按小时)+ 逐条领券明细表。
- 「发起平台」=发起来源(傻瓜比价 / 美团 / 淘宝 / 京东);trace 列有 trace_url 给可点链接;
  手机号列可点 → 复用通用 UserRecordsDrawer 看该用户全部领券(为其加了可选 rewardSuffix prop)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: zzhyyyyy <2685922758@qq.com>
Reviewed-on: #31
Co-authored-by: zhuzihao <zhuzihao@wonderable.ai>
Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
2026-06-30 22:59:09 +08:00
6 changed files with 447 additions and 116 deletions
@@ -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>
);
}
+65 -59
View File
@@ -40,13 +40,15 @@ import type {
AdRevenueRow,
AdRevenueTypeStat,
} from '@/lib/types';
import UserAdRevenueDrawer from './UserAdRevenueDrawer';
const { RangePicker } = DatePicker;
// 广告类型标签
const TYPE_TAG: Record<string, { color: string; label: string }> = {
reward_video: { color: 'blue', label: '激励视频' },
feed: { color: 'purple', label: '信息流' },
// 历史误标 feed(领券/比价广告修 adType 之前上报)一律按 Draw 信息流显示——业务已全切 Draw
feed: { color: 'geekblue', label: 'Draw 信息流' },
draw: { color: 'geekblue', label: 'Draw 信息流' },
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: 'actual_coin', width: 100 },
{
title: '一致',
dataIndex: 'matched',
width: 80,
render: (m: boolean) => (m ? <Tag color="green"></Tag> : <Tag color="red"> </Tag>),
},
];
// 趋势图(纯 SVG,零依赖):柱=展示条数(左轴),橙线=客户端预估收益元(右轴),
@@ -309,6 +305,8 @@ export default function AdRevenueReportPage() {
const [queriedLimit, setQueriedLimit] = useState<number>(500);
const [loading, setLoading] = 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');
@@ -364,25 +362,39 @@ export default function AdRevenueReportPage() {
title: '用户',
dataIndex: 'user_phone',
width: 150,
render: (phone: string | null, r: AdRevenueRow) =>
phone ? (
<span>
{phone}
<Typography.Text type="secondary" style={{ fontSize: 11, marginLeft: 6 }}>
#{r.user_id}
</Typography.Text>
</span>
) : (
<Typography.Text type="secondary">#{r.user_id}</Typography.Text>
),
render: (phone: string | null, r: AdRevenueRow) => (
// 点手机号/用户 → 打开该用户「广告收益详情」半屏抽屉(统计卡 + 金币记录)
<a onClick={() => setUserDrawer({ userId: r.user_id, phone })}>
{phone ? (
<span>
{phone}
<Typography.Text type="secondary" style={{ fontSize: 11, marginLeft: 6 }}>
#{r.user_id}
</Typography.Text>
</span>
) : (
<span>#{r.user_id}</span>
)}
</a>
),
},
{
title: '广告类型',
dataIndex: 'ad_type',
width: 110,
render: (s: string) => {
width: 130,
render: (s: string, r: AdRevenueRow) => {
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',
width: 110,
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: '发奖状态',
@@ -456,18 +472,6 @@ export default function AdRevenueReportPage() {
render: (v: number, r: AdRevenueRow) =>
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',
dataIndex: 'our_code_id',
@@ -527,6 +531,10 @@ export default function AdRevenueReportPage() {
title="收益口径说明"
content={
<div style={{ maxWidth: 360, fontSize: 13, lineHeight: 1.7 }}>
<b> = 广</b>( / / );· Draw
( / eCPM / ),+
<br />
<br />
广(onAdShow) eCPM ( ÷1000
),<b>广</b>;穿/,,
<b>穿</b> 0广ID / ,
@@ -578,7 +586,6 @@ export default function AdRevenueReportPage() {
style={{ width: 150 }}
options={[
{ value: 'reward_video', label: '激励视频' },
{ value: 'feed', label: '信息流' },
{ value: 'draw', label: 'Draw 信息流' },
{ value: 'withdrawal_video', label: '提现激励视频' },
]}
@@ -792,22 +799,6 @@ export default function AdRevenueReportPage() {
</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 &&
(queriedMultiDay
? (data.daily?.length ?? 0) > 0
@@ -884,12 +875,27 @@ export default function AdRevenueReportPage() {
}}
size="small"
scroll={{ x: 1380 }}
rowClassName={(r) => (r.has_reward && !r.matched ? 'row-mismatch' : '')}
expandable={{
// 每行都可展开(左侧恒有 + 号):有发奖看「金币复算因子」;纯展示看「展示明细」。
rowExpandable: () => true,
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>
<Typography.Text strong></Typography.Text>{' '}
<Typography.Text type="secondary">
@@ -903,7 +909,6 @@ export default function AdRevenueReportPage() {
pagination={false}
size="small"
scroll={{ x: 900 }}
rowClassName={(d) => (d.matched ? '' : 'row-mismatch')}
/>
</div>
) : (
@@ -979,11 +984,12 @@ export default function AdRevenueReportPage() {
</Typography.Paragraph>
</Modal>
<style jsx global>{`
.row-mismatch > td {
background: #fff1f0 !important;
}
`}</style>
<UserAdRevenueDrawer
open={!!userDrawer}
userId={userDrawer?.userId ?? null}
phone={userDrawer?.phone ?? null}
onClose={() => setUserDrawer(null)}
/>
</div>
);
}
+2 -2
View File
@@ -932,7 +932,7 @@ export default function DashboardPage() {
value={fmtInt(periodData?.coins.reward_video_coin_total)}
delta={rewardVideoCoinRatio.value}
deltaTone={rewardVideoCoinRatio.tone}
hint="激励视频金币已按产品口径计入领券奖励金币,这里单独展示来源占比。"
hint="独立统计激励视频发放,不再重复计入领券奖励。"
/>
<StatCard
title="常规任务金币"
@@ -955,7 +955,7 @@ export default function DashboardPage() {
<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>
</section>
+245 -31
View File
@@ -12,7 +12,6 @@ import {
HeartOutlined,
LogoutOutlined,
MessageOutlined,
MobileOutlined,
MoneyCollectOutlined,
NotificationOutlined,
ProfileOutlined,
@@ -21,26 +20,66 @@ import {
TeamOutlined,
UserOutlined,
} 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 type { AdminInfo } from '@/lib/types';
const { Sider, Header, Content } = Layout;
const MENU = [
{ key: '/dashboard', icon: <DashboardOutlined />, label: '数据大盘' },
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
{ key: '/devices', icon: <MobileOutlined />, label: '设备管理' },
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
{ key: '/withdraws', icon: <MoneyCollectOutlined />, label: '提现管理' },
{ key: '/price-reports', icon: <FlagOutlined />, label: '低价审核' },
{ key: '/comparison-records', icon: <ProfileOutlined />, label: '比价记录' },
{ key: '/feedbacks', icon: <MessageOutlined />, label: '用户反馈' },
{ key: '/coupon-data', icon: <GiftOutlined />, label: '领券数据' },
{ key: '/ad-revenue', icon: <NotificationOutlined />, label: '广告配置' },
{ key: '/ad-revenue-report', icon: <BarChartOutlined />, label: '广告收益' },
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS 分发' },
{ key: '/config', icon: <SettingOutlined />, label: '系统配置' },
type NavItem = {
key: string;
icon: React.ReactNode;
label: string;
superOnly?: boolean;
};
type NavGroup =
| (NavItem & { children?: never })
| {
key: string;
icon: React.ReactNode;
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: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
@@ -50,6 +89,7 @@ export default function MainLayout({ children }: { children: React.ReactNode })
const router = useRouter();
const pathname = usePathname();
const [admin, setAdmin] = useState<AdminInfo | null>(null);
const [collapsed, setCollapsed] = useState(false);
useEffect(() => {
if (!getToken()) {
@@ -61,14 +101,19 @@ export default function MainLayout({ children }: { children: React.ReactNode })
if (!admin) return null; // 守卫期间不闪烁内容
const items = MENU.filter((m) => !m.superOnly || admin.role === 'super_admin').map((m) => ({
key: m.key,
icon: m.icon,
label: m.label,
}));
// 选中态:取路径一级(/users/123 → /users)
// 选中态:取路径一级(/users/123 -> /users)
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 = () => {
clearAuth();
@@ -77,7 +122,15 @@ export default function MainLayout({ children }: { children: React.ReactNode })
return (
<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
style={{
height: 48,
@@ -90,13 +143,61 @@ export default function MainLayout({ children }: { children: React.ReactNode })
>
</div>
<Menu
theme="dark"
mode="inline"
selectedKeys={[selectedKey]}
items={items}
onClick={({ key }) => router.push(key)}
/>
<nav className={`side-nav${collapsed ? ' side-nav-collapsed' : ''}`} aria-label="后台导航">
{collapsed
? flatNavItems.map((item) => (
<Tooltip key={item.key} title={item.label} placement="right">
<button
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>
<Layout>
<Header
@@ -122,6 +223,119 @@ export default function MainLayout({ children }: { children: React.ReactNode })
</Header>
<Content style={{ margin: 24 }}>{children}</Content>
</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>
);
}
+48 -24
View File
@@ -39,10 +39,12 @@ const PAGE_SIZE = 10; // 金币记录每页条数
interface Props {
userId: number;
user: WithdrawUserSnapshot | null;
// 统计区字段集:withdraw(默认,提现详情:含提现细分) / ad(广告收益详情:只看看广告观看统计,对齐参考图 6 项)
statsVariant?: 'withdraw' | 'ad';
}
/** 提现详情抽屉:用户基本信息 + 互斥时间筛选 + 看广告/提现统计区 + 金币发放记录表。 */
export default function UserRewardPanel({ userId, user }: Props) {
/** 用户看广告/提现详情:基本信息 + 互斥时间筛选 + 统计区(按 statsVariant 取字段集)+ 金币发放记录表。 */
export default function UserRewardPanel({ userId, user, statsVariant = 'withdraw' }: Props) {
const [mode, setMode] = useState<'all' | 'range'>('all'); // all=注册至今 / range=自定义区间
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
const [stats, setStats] = useState<UserRewardStats | null>(null);
@@ -164,7 +166,7 @@ export default function UserRewardPanel({ userId, user }: Props) {
</Space>
</Space>
{/* 统计区(受时间筛选;现金余额为当前快照) */}
{/* 统计区(受时间筛选;现金余额为当前快照)。ad 视图只保留看广告观看统计(对齐参考图 6 项) */}
<Descriptions bordered size="small" column={2} style={{ marginBottom: 8 }}>
<Descriptions.Item label="累计提现">
{stats ? yuan(stats.withdraw_success_cents) : '-'}
@@ -172,29 +174,51 @@ export default function UserRewardPanel({ userId, user }: Props) {
<Descriptions.Item label="现金余额">
{stats ? yuan(stats.cash_balance_cents) : '-'}
</Descriptions.Item>
<Descriptions.Item label="提现总次数">{stats?.withdraw_total ?? '-'}</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>
{statsVariant === 'ad' ? (
<>
<Descriptions.Item label="激励视频观看数">
{stats?.reward_video_count ?? '-'}
</Descriptions.Item>
{/* eCPM 均按元展示(reward_video / feed avg_ecpm 原始为分/千次,÷100 转元) */}
<Descriptions.Item label="平均激励视频ECPM">
{stats ? `${(stats.reward_video_avg_ecpm / 100).toFixed(2)} 元/千` : '-'}
</Descriptions.Item>
<Descriptions.Item label="draw信息流视频观看数">
{stats?.feed_count ?? '-'}
</Descriptions.Item>
<Descriptions.Item label="平均draw信息流ECPM">
{stats ? `${(stats.feed_avg_ecpm / 100).toFixed(2)} 元/千` : '-'}
</Descriptions.Item>
</>
) : (
<>
<Descriptions.Item label="提现总次数">{stats?.withdraw_total ?? '-'}</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>
<Text type="secondary" style={{ fontSize: 12 }}>
(,);eCPM /,
{statsVariant === 'ad'
? '统计随上方时间筛选(现金余额除外,为当前快照);eCPM 均按元展示(原始分/千次 ÷100)。'
: '统计随上方时间筛选(现金余额除外,为当前快照);eCPM 单位分/千次,同金币审计。'}
</Text>
{/* 金币记录 */}
+3
View File
@@ -425,6 +425,7 @@ export interface AdRevenueRow {
impressions: number; // 本行展示条数 1/0(供日汇总、趋势图复用)
ecpm: string | null; // 分/千次;展示行取展示值,纯发奖行取发奖采用值
revenue_yuan: number; // 本次展示预估收益(元);纯发奖行=0
row_revenue_yuan?: number | null; // 主表逐行显示用:一次比价/领券聚合行=该次发奖广告 eCPM 折算之和;其它行空(回退 revenue_yuan)
adn: string | null; // 实际填充 ADN;纯发奖行为空
slot_id: string | null; // 底层 mediation rit;纯发奖行为空
// ── 发奖侧 ──
@@ -434,6 +435,8 @@ export interface AdRevenueRow {
actual_coin: number; // 实发金币;纯展示=0
matched: boolean; // 本条应发==实发;纯展示恒 true(不计对账)
reward_detail: AdRevenueRecord | null; // 发奖复算明细(点行展开下钻);纯展示为空
sub_rewards?: AdRevenueRecord[]; // 一次比价/领券聚合行的组内逐条明细(同整场 ad_session_id 的多条广告);展开渲染多行
sub_count?: number; // 本行聚合的发奖条数:一次比价/领券=该次广告条数(≥1);激励视频/纯展示=1
}
export interface AdRevenueReport {