Compare commits

..

2 Commits

Author SHA1 Message Date
marco 98417ff8c6 feat(ad): 「广告数据」改「广告管理」,加穿山甲配置面板
- 顶部广告配置面板:app_id / 3 场景广告位ID / 激励验签密钥(Password) / 3 场景开关,
  读写 /admin/api/ad-config
- 原报表保留为下方「收益报表」;左侧菜单更名「广告管理」

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 01:35:19 +08:00
marco b7957e58c0 feat(cps): 群详情页加「群内微信用户」区块(头像/昵称/领券次数)
微信落地页授权来的用户列表:头像+昵称+领券次数(点复制)+点击次数+首次进入。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 11:44:14 +08:00
3 changed files with 167 additions and 3 deletions
+94 -1
View File
@@ -10,6 +10,8 @@ import {
Col,
DatePicker,
Divider,
Form,
Input,
InputNumber,
Modal,
Popover,
@@ -17,6 +19,7 @@ import {
Select,
Space,
Statistic,
Switch,
Table,
Tag,
Typography,
@@ -268,6 +271,95 @@ function TrendChart({ points }: { points: TrendPoint[] }) {
// 广告数据页:单表 —— 按 用户×类型×应用×代码位 聚合,一行同时给出
// 展示条数 / 收益 / 应发金币 / 实发金币 / 是否一致(发奖对账下沉到聚合级)。
// 广告配置面板:穿山甲 app_id / 各场景广告位ID / 验签密钥 / 各场景开关。
// 客户端(发版后)从 /api/v1/platform/ad-config 拉取;此处经 admin /ad-config 读写。
interface AdCfg {
app_id: string;
reward_code_id: string;
compare_feed_code_id: string;
coupon_feed_code_id: string;
reward_mkey: string;
reward_enabled: boolean;
compare_ad_enabled: boolean;
coupon_ad_enabled: boolean;
}
function AdConfigPanel() {
const { message } = App.useApp();
const [form] = Form.useForm();
const [saving, setSaving] = useState(false);
const load = useCallback(async () => {
try {
const r = await api.get<AdCfg>('/admin/api/ad-config');
form.setFieldsValue(r.data);
} catch (e) {
message.error(errMsg(e, '广告配置加载失败'));
}
}, [form, message]);
useEffect(() => {
load();
}, [load]);
const save = async () => {
const v = await form.validateFields();
setSaving(true);
try {
await api.patch('/admin/api/ad-config', v);
message.success('已保存。客户端下次拉取生效(应用ID需冷启,广告位ID即时)');
load();
} catch (e) {
message.error(errMsg(e, '保存失败'));
} finally {
setSaving(false);
}
};
return (
<Card
title="广告配置(穿山甲)"
style={{ marginBottom: 16 }}
extra={
<Button type="primary" loading={saving} onClick={save}>
</Button>
}
>
<Alert
type="info"
style={{ marginBottom: 16 }}
message="应用ID改了客户端需冷启生效,广告位ID即时;换激励位必须同步换验签密钥(m-key),否则发不出金币。这些配置需客户端发版接入后才会读取。"
/>
<Form form={form} layout="vertical">
<Form.Item name="app_id" label="穿山甲应用ID (APP_ID)" rules={[{ required: true }]}>
<Input placeholder="如 5830519" />
</Form.Item>
<Form.Item name="reward_code_id" label="福利页 · 激励视频 广告位ID" rules={[{ required: true }]}>
<Input placeholder="如 104099389" />
</Form.Item>
<Form.Item
name="reward_mkey"
label="福利激励 · 验签密钥 m-key(机密,不下发客户端;换激励位必须同步换;留空回退 .env)"
>
<Input.Password placeholder="GroMore S2S 回调验签密钥" autoComplete="off" />
</Form.Item>
<Form.Item name="compare_feed_code_id" label="比价 · 信息流 广告位ID" rules={[{ required: true }]}>
<Input placeholder="如 104090333" />
</Form.Item>
<Form.Item name="coupon_feed_code_id" label="领券 · 信息流 广告位ID" rules={[{ required: true }]}>
<Input placeholder="如 104090333" />
</Form.Item>
<Form.Item name="reward_enabled" label="福利激励视频开关" valuePropName="checked">
<Switch />
</Form.Item>
<Form.Item name="compare_ad_enabled" label="比价广告开关" valuePropName="checked">
<Switch />
</Form.Item>
<Form.Item name="coupon_ad_enabled" label="领券广告开关" valuePropName="checked">
<Switch />
</Form.Item>
</Form>
</Card>
);
}
export default function AdRevenuePage() {
const { message } = App.useApp();
const [range, setRange] = useState<[Dayjs, Dayjs]>([dayjs(), dayjs()]);
@@ -412,8 +504,9 @@ export default function AdRevenuePage() {
return (
<div>
<AdConfigPanel />
<Space align="center" style={{ display: 'flex', marginBottom: 16 }}>
<h2 style={{ margin: 0 }}>广</h2>
<h2 style={{ margin: 0 }}></h2>
<Button
type="link"
size="small"
+72 -1
View File
@@ -8,7 +8,7 @@ import dynamic from 'next/dynamic';
import type { ColumnsType } from 'antd/es/table';
import { Button, Card, Col, Empty, Row, Segmented, Space, Spin, Statistic, Table, message } from 'antd';
import { api, errMsg } from '@/lib/api';
import { yuan } from '@/lib/format';
import { formatUtcTime, yuan } from '@/lib/format';
// @ant-design/plots 依赖 DOM,关掉 SSR 仅在客户端渲染(否则 Next 预渲染报 document undefined)。
const Line = dynamic(() => import('@ant-design/plots').then((m) => m.Line), { ssr: false });
@@ -47,6 +47,16 @@ interface DailyResp {
rows: DailyRow[];
}
// 群内微信用户(落地页授权拿到;nickname/headimgurl 仅 userinfo 授权后有)
interface WxUser {
openid: string;
nickname: string | null;
headimgurl: string | null;
first_seen: string;
visit_count: number;
copy_count: number;
}
const RANGES = [
{ label: '近 3 天', value: 'd3' },
{ label: '近 7 天', value: 'd7' },
@@ -115,6 +125,20 @@ export default function GroupDetailPage() {
loadDaily();
}, [loadDaily]);
// 群内微信用户(独立于时间范围,累计画像)
const [wxUsers, setWxUsers] = useState<WxUser[]>([]);
const loadWxUsers = useCallback(async () => {
try {
const r = await api.get<{ users: WxUser[] }>(`/admin/api/cps/groups/${id}/wx-users`);
setWxUsers(r.data.users || []);
} catch (e) {
message.error(errMsg(e, '用户列表加载失败'));
}
}, [id]);
useEffect(() => {
loadWxUsers();
}, [loadWxUsers]);
const points = useMemo(() => data?.points ?? [], [data]);
// 展平成「长表」给折线图:每个 (时间桶 × 指标) 一行,colorField 按指标分 4 条线。
const chartData = useMemo(
@@ -202,6 +226,38 @@ export default function GroupDetailPage() {
},
];
const wxColumns: ColumnsType<WxUser> = [
{
title: '用户',
key: 'user',
render: (_, u) => (
<Space>
{u.headimgurl ? (
<img
src={u.headimgurl}
alt=""
style={{ width: 32, height: 32, borderRadius: '50%', objectFit: 'cover' }}
/>
) : (
<span
style={{ width: 32, height: 32, borderRadius: '50%', background: '#f0f0f0', display: 'inline-block' }}
/>
)}
<span>{u.nickname || '(未授权昵称)'}</span>
</Space>
),
},
{
title: '领券次数',
dataIndex: 'copy_count',
width: 90,
sorter: (a, b) => a.copy_count - b.copy_count,
render: (v: number) => (v ? <b style={{ color: '#ff4d4f' }}>{v}</b> : 0),
},
{ title: '点击次数', dataIndex: 'visit_count', width: 90 },
{ title: '首次进入', dataIndex: 'first_seen', width: 160, render: (v: string) => formatUtcTime(v) },
];
return (
<div>
<Space style={{ marginBottom: 16 }} align="center" wrap>
@@ -255,6 +311,21 @@ export default function GroupDetailPage() {
/>
</Card>
)}
<Card title={`群内微信用户(${wxUsers.length})`} style={{ marginTop: 16 }}>
<div style={{ fontSize: 12, color: '#999', marginBottom: 8 }}>
= ;/
</div>
<Table<WxUser>
rowKey="openid"
size="small"
columns={wxColumns}
dataSource={wxUsers}
pagination={false}
scroll={{ x: 560 }}
locale={{ emptyText: '暂无授权用户' }}
/>
</Card>
</div>
);
}
+1 -1
View File
@@ -31,7 +31,7 @@ const MENU = [
{ key: '/price-reports', icon: <FlagOutlined />, label: '上报审核' },
{ key: '/comparison-records', icon: <ProfileOutlined />, label: '比价记录' },
{ key: '/feedbacks', icon: <MessageOutlined />, label: '反馈工单' },
{ key: '/ad-revenue', icon: <BarChartOutlined />, label: '广告数据' },
{ key: '/ad-revenue', icon: <BarChartOutlined />, label: '广告管理' },
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS 分发' },
{ key: '/config', icon: <SettingOutlined />, label: '系统配置' },
{ key: '/admins', icon: <TeamOutlined />, label: '管理员', superOnly: true },