Compare commits

..

3 Commits

Author SHA1 Message Date
zzhyyyyy c6a8cb2cf0 feat: 反馈加反馈类型/运营回复 + 提现加提现类型筛选
用户反馈后台 + 提现审核后台的运营字段与筛选。

- 反馈页:新增「反馈类型」列(比价反馈/普通反馈 + 场景)、顶部「反馈类型」筛选;审核抽屉采纳/拒绝
  都能填「给用户的回复」(用户端可见),并回显反馈类型/场景/运营回复。
- 提现页:新增「提现类型」列(福利页提现/邀请提现)、顶部「提现类型」筛选,详情抽屉展示提现类型。
- types.ts:Feedback 加 source/scene/admin_reply,WithdrawOrder 加 source。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 16:43:17 +08:00
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
9 changed files with 611 additions and 126 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>
@@ -49,6 +49,17 @@ const statusTag = (s: string) => {
return <Tag color={m.color}>{m.label}</Tag>;
};
// 反馈类型:comparison=比价反馈 / profile(及旧数据)=普通反馈
const SOURCE_META: Record<string, { label: string; color: string }> = {
comparison: { label: '比价反馈', color: 'geekblue' },
profile: { label: '普通反馈', color: 'default' },
};
const sourceTag = (s: string) => {
const m = SOURCE_META[s] ?? { label: '普通反馈', color: 'default' };
return <Tag color={m.color}>{m.label}</Tag>;
};
function FeedbackImages({ images }: { images: string[] | null }) {
if (!images || !images.length) return <Text type="secondary"></Text>;
return (
@@ -113,12 +124,14 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
await api.post(`/admin/api/feedbacks/${feedback.id}/approve`, {
reward_coins: v.reward_coins,
note: v.note?.trim() || null,
reply: v.reply?.trim() || null,
});
message.success(`已采纳,发放 ${v.reward_coins} 金币`);
} else {
await api.post(`/admin/api/feedbacks/${feedback.id}/reject`, {
reason: v.reason.trim(),
note: v.note?.trim() || null,
reply: v.reply?.trim() || null,
});
message.success('已拒绝');
}
@@ -155,6 +168,14 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
<Text type="secondary">
{feedback.user_id} · {formatWallTime(feedback.created_at)}
</Text>
<div style={{ marginTop: 6 }}>
{sourceTag(feedback.source)}
{feedback.scene ? (
<Text type="secondary" style={{ marginLeft: 6 }}>
:{feedback.scene}
</Text>
) : null}
</div>
<Paragraph style={{ whiteSpace: 'pre-wrap', marginTop: 8, marginBottom: 8 }}>
{feedback.content || '-'}
</Paragraph>
@@ -200,7 +221,11 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
</div>
)}
<div style={{ marginTop: 6 }}>
:{feedback.review_note || <Text type="secondary"></Text>}
():{feedback.review_note || <Text type="secondary"></Text>}
</div>
<div style={{ marginTop: 6 }}>
():
{feedback.admin_reply || <Text type="secondary"></Text>}
</div>
{isPending(feedback.status) && (
<div style={{ marginTop: 6 }}>
@@ -243,11 +268,23 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
</Form.Item>
<Form.Item
name="note"
label="采纳要点 / 审核备注(选填)"
label="采纳要点 / 审核备注(选填,内部)"
rules={[{ max: 256, message: '最多 256 字' }]}
>
<Input.TextArea rows={3} maxLength={256} showCount placeholder="如:建议已采纳,将在下个版本上线" />
</Form.Item>
<Form.Item
name="reply"
label="给用户的回复(选填,用户端可见)"
rules={[{ max: 256, message: '最多 256 字' }]}
>
<Input.TextArea
rows={2}
maxLength={256}
showCount
placeholder="将展示在用户的「我的反馈」里,如:感谢反馈,已收到~"
/>
</Form.Item>
</>
) : (
<>
@@ -268,6 +305,18 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
>
<Input.TextArea rows={2} maxLength={256} showCount placeholder="运营内部备注" />
</Form.Item>
<Form.Item
name="reply"
label="给用户的回复(选填,用户端可见)"
rules={[{ max: 256, message: '最多 256 字' }]}
>
<Input.TextArea
rows={2}
maxLength={256}
showCount
placeholder="除未采纳原因外,想额外对用户说的话(选填)"
/>
</Form.Item>
</>
)}
</Form>
@@ -294,7 +343,10 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
<Text type="secondary">
#{h.id} · {formatWallTime(h.created_at)}
</Text>
{statusTag(h.status)}
<Space size={4}>
{sourceTag(h.source)}
{statusTag(h.status)}
</Space>
</div>
<Paragraph
style={{ whiteSpace: 'pre-wrap', margin: '6px 0 0' }}
@@ -313,6 +365,9 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
:{h.reject_reason || '-'}
</Text>
)}
{h.admin_reply ? (
<div style={{ fontSize: 12, marginTop: 2 }}>:{h.admin_reply}</div>
) : null}
</div>
))}
</Space>
+62 -5
View File
@@ -49,7 +49,42 @@ const statusTag = (s: string) => {
return <Tag color={m.color}>{m.label}</Tag>;
};
// 审核结果展示(采纳=金币+批注 / 未采纳=原因 / 待审核=-),主表与「该用户全部反馈」抽屉共用
// 反馈类型:comparison=比价反馈(比价结果页入口) / profile=普通反馈(「我的」页入口)。
// 旧数据与未识别来源按普通反馈展示。
const SOURCE_META: Record<string, { label: string; color: string }> = {
comparison: { label: '比价反馈', color: 'geekblue' },
profile: { label: '普通反馈', color: 'default' },
};
const SOURCE_OPTIONS = [
{ value: 'comparison', label: '比价反馈' },
{ value: 'profile', label: '普通反馈' },
];
// 反馈类型标签 +(比价反馈时)问题场景副标题
const renderSource = (f: Feedback) => {
const m = SOURCE_META[f.source] ?? { label: '普通反馈', color: 'default' };
return (
<Space direction="vertical" size={0}>
<Tag color={m.color}>{m.label}</Tag>
{f.scene ? (
<Text type="secondary" style={{ fontSize: 12 }}>
{f.scene}
</Text>
) : null}
</Space>
);
};
// 用户可见的运营回复留言(采纳/未采纳都可能有)
const replyLine = (f: Feedback) =>
f.admin_reply ? (
<Text style={{ fontSize: 12 }} ellipsis>
:{f.admin_reply}
</Text>
) : null;
// 审核结果展示(采纳=金币+批注 / 未采纳=原因 / 回复留言 / 待审核=-),主表与「该用户全部反馈」抽屉共用
const renderReview = (f: Feedback) => {
if (f.status === 'adopted') {
return (
@@ -60,14 +95,18 @@ const renderReview = (f: Feedback) => {
{f.review_note}
</Text>
) : null}
{replyLine(f)}
</Space>
);
}
if (f.status === 'rejected') {
return (
<Text type="secondary" style={{ fontSize: 12 }} ellipsis>
:{f.reject_reason || '-'}
</Text>
<Space direction="vertical" size={0}>
<Text type="secondary" style={{ fontSize: 12 }} ellipsis>
:{f.reject_reason || '-'}
</Text>
{replyLine(f)}
</Space>
);
}
return <Text type="secondary">-</Text>;
@@ -95,6 +134,7 @@ const renderDeviceOs = (f: Feedback) => {
const RECORD_COLUMNS: ColumnsType<Feedback> = [
{ title: '提交时间', dataIndex: 'created_at', width: 150, render: (v: string) => formatWallTime(v) },
{ title: '状态', dataIndex: 'status', width: 80, render: statusTag },
{ title: '反馈类型', key: 'source', width: 100, render: (_: unknown, f: Feedback) => renderSource(f) },
{
title: '内容',
dataIndex: 'content',
@@ -116,6 +156,7 @@ const RECORD_COLUMNS: ColumnsType<Feedback> = [
export default function FeedbacksPage() {
// 筛选草稿:点「查询」才应用(避免输入即刷新)
const [status, setStatus] = useState<string | undefined>();
const [source, setSource] = useState<string | undefined>();
const [userId, setUserId] = useState('');
const [content, setContent] = useState('');
const [createdRange, setCreatedRange] = useState<[Dayjs, Dayjs] | null>(null);
@@ -158,6 +199,7 @@ export default function FeedbacksPage() {
const search = () =>
setApplied({
status,
source,
user_id: userId.trim() ? Number(userId.trim()) : undefined,
content: content.trim() || undefined,
created_from: createdRange?.[0] ? createdRange[0].startOf('day').toISOString() : undefined,
@@ -166,6 +208,7 @@ export default function FeedbacksPage() {
const resetFilters = () => {
setStatus(undefined);
setSource(undefined);
setUserId('');
setContent('');
setCreatedRange(null);
@@ -216,6 +259,12 @@ export default function FeedbacksPage() {
width: 120,
render: (v: string | null) => v || <Text type="secondary"></Text>,
},
{
title: '反馈类型',
key: 'source',
width: 110,
render: (_: unknown, f: Feedback) => renderSource(f),
},
{
title: '提交版本号',
dataIndex: 'app_version',
@@ -325,6 +374,14 @@ export default function FeedbacksPage() {
{ value: 'rejected', label: '未采纳' },
]}
/>
<Select
placeholder="反馈类型"
value={source}
onChange={setSource}
allowClear
style={{ width: 130 }}
options={SOURCE_OPTIONS}
/>
<Input
placeholder="用户ID"
value={userId}
@@ -367,7 +424,7 @@ export default function FeedbacksPage() {
onChange: onPageChange,
}}
onChange={onTableChange}
scroll={{ x: 1610 }}
scroll={{ x: 1720 }}
/>
<FeedbackHandleDrawer
+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>
{/* 金币记录 */}
+36 -1
View File
@@ -104,6 +104,19 @@ const SORT_OPTIONS = [
{ value: 'created_at', label: '申请时间' },
{ value: 'amount_cents', label: '提现金额' },
];
// 提现类型:coin_cash=福利页提现(金币兑换现金) / invite_cash=邀请提现(邀请奖励金)
const SOURCE_LABEL: Record<string, string> = {
coin_cash: '福利页提现',
invite_cash: '邀请提现',
};
const SOURCE_COLOR: Record<string, string> = {
coin_cash: 'blue',
invite_cash: 'purple',
};
const SOURCE_OPTIONS = [
{ value: 'coin_cash', label: '福利页提现' },
{ value: 'invite_cash', label: '邀请提现' },
];
const DATE_FIELD_OPTIONS = [
{ value: 'created_at', label: '申请时间' },
{ value: 'updated_at', label: '更新时间' },
@@ -184,9 +197,11 @@ export default function WithdrawsPage() {
const [sortBy, setSortBy] = useState<'created_at' | 'amount_cents'>('created_at');
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
const [quickFilter, setQuickFilter] = useState<string | undefined>(undefined);
const [source, setSource] = useState<string | undefined>(undefined);
const filters: Record<string, unknown> = {};
if (activeStatus !== 'all') filters.status = activeStatus;
if (source) filters.source = source;
if (keyword.trim()) filters.keyword = keyword.trim();
if (dateRange?.[0]) filters.date_from = dateRange[0].startOf('day').toISOString();
if (dateRange?.[1]) filters.date_to = dateRange[1].endOf('day').toISOString();
@@ -211,6 +226,7 @@ export default function WithdrawsPage() {
setSortBy('created_at');
setSortOrder('desc');
setQuickFilter(undefined);
setSource(undefined);
};
const applyQuickFilter = (value?: string) => {
@@ -481,6 +497,12 @@ export default function WithdrawsPage() {
width: 120,
render: (v: number) => <Text strong>{yuan(v)}</Text>,
},
{
title: '提现类型',
dataIndex: 'source',
width: 110,
render: (v: string) => <Tag color={SOURCE_COLOR[v] || 'default'}>{SOURCE_LABEL[v] || v}</Tag>,
},
{
title: '累计提现',
dataIndex: 'cumulative_success_cents',
@@ -724,6 +746,14 @@ export default function WithdrawsPage() {
}}
onSearch={(value) => setKeyword(value.trim())}
/>
<Select
value={source}
allowClear
placeholder="提现类型"
style={{ width: 140 }}
options={SOURCE_OPTIONS}
onChange={(value?: string) => setSource(value)}
/>
<Select
value={quickFilter}
allowClear
@@ -849,7 +879,7 @@ export default function WithdrawsPage() {
showTotal: (t) => `${t}`,
onChange: onPageChange,
}}
scroll={{ x: 1350 }}
scroll={{ x: 1460 }}
onRow={(record) => ({
onClick: () => openDetail(record),
style: { cursor: 'pointer' },
@@ -881,6 +911,11 @@ export default function WithdrawsPage() {
<Descriptions.Item label="金额">
<Text strong>{yuan(detail.order.amount_cents)}</Text>
</Descriptions.Item>
<Descriptions.Item label="提现类型">
<Tag color={SOURCE_COLOR[detail.order.source] || 'default'}>
{SOURCE_LABEL[detail.order.source] || detail.order.source}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="提现实名">
{detail.order.user_name || '-'}
</Descriptions.Item>
+11 -1
View File
@@ -117,6 +117,8 @@ export interface WithdrawOrder {
user_id: number;
out_bill_no: string;
amount_cents: number;
// 提现类型:coin_cash(福利页提现,金币兑换现金) / invite_cash(邀请提现,邀请奖励金)
source: string;
user_name: string | null;
status: string; // reviewing / pending / success / failed / rejected
wechat_state: string | null;
@@ -239,12 +241,17 @@ export interface Feedback {
user_id: number;
content: string;
contact: string;
// 反馈来源入口:profile(「我的」页=普通反馈) / comparison(比价结果页=比价反馈)
source: string;
// 比价反馈的问题场景(找错商品/优惠不对…);普通反馈为 null
scene: string | null;
images: string[] | null;
// pending(审核中) / adopted(已采纳) / rejected(未采纳);历史数据可能为 new
status: string;
reject_reason: string | null; // 未采纳原因(用户端可见)
reward_coins: number | null; // 采纳后发放金币
review_note: string | null; // 审核批注(采纳要点 / 内部备注)
review_note: string | null; // 审核批注(采纳要点 / 内部备注,用户不可见)
admin_reply: string | null; // 运营给用户的回复留言(用户端可见)
reviewed_by_admin_id: number | null;
reviewed_at: string | null;
created_at: string;
@@ -425,6 +432,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 +442,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 {