Compare commits

..

5 Commits

Author SHA1 Message Date
zzhyyyyy 1250de8b21 feat(feedback): 反馈工单接入审核采纳/拒绝 + 历史反馈
对接后端 approve/reject 接口,admin 反馈工单从单一「处理」改为审核双动作:
- FeedbackHandleDrawer: Segmented 采纳/拒绝 —— 采纳(发金币 1~10000 + 采纳备注)、
  拒绝(填用户端可见原因 + 内部备注);抽屉内联展示该用户历史反馈辅助审核
- 列表页: 状态筛选改 审核中/已采纳/未采纳、新增「审核结果」列、操作改 审核/查看,移除旧批量标记
- types.ts: Feedback 字段对齐后端(reject_reason/reward_coins/review_note/reviewed_by_admin_id/reviewed_at)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 21:35:45 +08:00
zhuzihao bd0bacb836 feat(withdraw-detail): 抽屉占屏一半 + 金币记录页码分页 + 风险提示去分数 (#15)
- 详情抽屉宽度 720→50%
- 金币记录改 antd 页码分页(10/页,显示「共N条」)
- 风险提示去掉不可解释的分数;历史异常拆成「提现拒绝/提现失败」两类

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

---------

Co-authored-by: zzhyyyyy <2685922758@qq.com>
Reviewed-on: #15
Co-authored-by: zhuzihao <zhuzihao@wonderable.ai>
Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
2026-06-21 23:41:33 +08:00
zhuzihao 12cc6f7aa6 fix(media): 后台图片指向 App 后端,修线上图片 404 (#14)
线上 admin(admin-web.shaguabijia.com)的「上报审核截图 / 反馈截图 / 反馈二维码」
全部 404:NEXT_PUBLIC_MEDIA_BASE 为空时,图片被拼到不 serve /media 的 admin 域。
媒体实际由 App 后端托管,故让前端指向它:

- .env.production: NEXT_PUBLIC_MEDIA_BASE=https://app-api.shaguabijia.com
- lib/media.ts: base 去末尾斜杠,防拼出 //media

注:NEXT_PUBLIC_* 为编译期常量,合并后服务器需 npm run build + 重启服务才生效。

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

---------

Co-authored-by: zzhyyyyy <2685922758@qq.com>
Reviewed-on: #14
Co-authored-by: zhuzihao <zhuzihao@wonderable.ai>
Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
2026-06-21 12:09:45 +08:00
zhuzihao 36d00a9d68 feat(force-onboarding): 用户列表加「开启新手引导」一次性操作 (#13)
Co-authored-by: zzhyyyyy <2685922758@qq.com>
Reviewed-on: #13
Co-authored-by: zhuzihao <zhuzihao@wonderable.ai>
Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
2026-06-21 00:15:17 +08:00
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
15 changed files with 1151 additions and 291 deletions
+8 -2
View File
@@ -1,3 +1,9 @@
# 生产:前端与 admin API 同域(admin.shaguabijia.com),nginx 把 /admin/api 反代到后端 8771。
# 留空 = axios 用相对路径,请求落到当前域名,由 nginx 转发。
# 生产:前端与 admin API 同域(admin-web.shaguabijia.com),nginx 把 /admin/api 反代到后端 8771。
# 留空 = axios 用相对路径,请求落到当前域名,由 nginx 转发。(已验证线上 /admin/api 走通、操作 200)
NEXT_PUBLIC_API_BASE=
# 媒体(反馈二维码 / 上报截图 / 头像)由 App 后端托管在 app-api.shaguabijia.com/media,【不在 admin 域】。
# 必须指到 App 后端的公开域名,否则 admin 里所有 /media 图片都会 404(被拼到 admin 域而非 App 域)。
# 都是 https → 无混合内容;<img> 跨域加载不受 CORS 限制,无需后端配 CORS。
# ⚠️ NEXT_PUBLIC_* 是编译期常量:改这里后必须重新 `npm run build` 再部署,前端才会带上新值。
NEXT_PUBLIC_MEDIA_BASE=https://app-api.shaguabijia.com
+12 -4
View File
@@ -5,10 +5,12 @@ Next.js 15 + Ant Design 5,对接 `shaguabijia-app-server` 的 admin API(`app/adm
鉴权用独立 JWT)。本仓只是前端。
## 功能(P0)
数据大盘 / 用户管理(列表+360详情+封禁+调金币) / 提现管理(列表+重试+对账) /
反馈工单 / 管理员账号(super) / 审计日志。按角色显示操作:finance=钱、operator=用户+反馈、super=全部。
## 本地开发
```bash
# 1. 起 admin 后端(在 shaguabijia-app-server 目录)
conda activate price && uvicorn app.admin.main:admin_app --port 8771
@@ -17,11 +19,13 @@ python scripts/create_admin.py --username admin --role super_admin
# 3. 起前端
npm install && npm run dev # → http://localhost:3001
```
`.env.local` 已指向 `http://localhost:8771`
## 生产部署(阿里云,域名 admin.shaguabijia.com)
### ① 后端 admin(在 app-server 机器,复用同一 codebase)
```bash
scp deploy/shaguabijia-admin.service server:/etc/systemd/system/ # 文件在 app-server/deploy/
ssh server "systemctl daemon-reload && systemctl enable --now shaguabijia-admin"
@@ -29,6 +33,7 @@ ssh server "cd /opt/shaguabijia-app-server && .venv/bin/python scripts/create_ad
```
### ② 前端
```bash
npm run build
rsync -avz --exclude node_modules --exclude .next/cache ./ server:/opt/shaguabijia-admin-web/
@@ -36,13 +41,16 @@ ssh server "cd /opt/shaguabijia-admin-web && npm install --omit=dev && npm run b
```
### ③ nginx
```bash
scp deploy/nginx/admin.shaguabijia.com.conf server:/etc/nginx/conf.d/
ssh server "nginx -t && systemctl reload nginx"
```
## ⚠️ 上线必查
- [ ] app-server 的 `.env``ADMIN_JWT_SECRET` 改成 ≥32 字节强随机串(默认 `change-me-admin` 可伪造 token)
- [ ] nginx 打开 IP 白名单(运营出口 IP)+ HTTPS 证书就位
- [ ] `.env.production``NEXT_PUBLIC_API_BASE` 留空(同域,nginx 反代 /admin/api)
- [ ] 首个 super_admin 已建、能登录
- app-server 的 `.env``ADMIN_JWT_SECRET` 改成 ≥32 字节强随机串(默认 `change-me-admin` 可伪造 token)
- nginx 打开 IP 白名单(运营出口 IP)+ HTTPS 证书就位
- `.env.production``NEXT_PUBLIC_API_BASE` 留空(同域,nginx 反代 /admin/api)
- 首个 super_admin 已建、能登录
+12
View File
@@ -32,6 +32,18 @@ server {
proxy_read_timeout 60s;
}
# 用户上传媒体(上报截图 / 反馈截图 / 反馈二维码)由 App 后端(:8770)的 /media 托管。
# admin 页面要展示这些图,经此同域反代过去(免跨域 + 免 https 页面引 http 图被拦)。
# 前提:App 后端与本 admin 同机;若分机,把 127.0.0.1:8770 换成 App 后端可达地址。
# 配好此段后,前端 .env.production 的 NEXT_PUBLIC_MEDIA_BASE 留空即走同域。
location /media/ {
proxy_pass http://127.0.0.1:8770;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 60s;
}
# 其余 → Next.js 前端
location / {
proxy_pass http://127.0.0.1:3001;
-60
View File
@@ -551,9 +551,6 @@
"cpu": [
"arm"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -570,9 +567,6 @@
"cpu": [
"arm64"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -589,9 +583,6 @@
"cpu": [
"ppc64"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -608,9 +599,6 @@
"cpu": [
"riscv64"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -627,9 +615,6 @@
"cpu": [
"s390x"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -646,9 +631,6 @@
"cpu": [
"x64"
],
"libc": [
"glibc"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -665,9 +647,6 @@
"cpu": [
"arm64"
],
"libc": [
"musl"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -684,9 +663,6 @@
"cpu": [
"x64"
],
"libc": [
"musl"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -703,9 +679,6 @@
"cpu": [
"arm"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -728,9 +701,6 @@
"cpu": [
"arm64"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -753,9 +723,6 @@
"cpu": [
"ppc64"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -778,9 +745,6 @@
"cpu": [
"riscv64"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -803,9 +767,6 @@
"cpu": [
"s390x"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -828,9 +789,6 @@
"cpu": [
"x64"
],
"libc": [
"glibc"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -853,9 +811,6 @@
"cpu": [
"arm64"
],
"libc": [
"musl"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -878,9 +833,6 @@
"cpu": [
"x64"
],
"libc": [
"musl"
],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -1017,9 +969,6 @@
"cpu": [
"arm64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1036,9 +985,6 @@
"cpu": [
"arm64"
],
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1055,9 +1001,6 @@
"cpu": [
"x64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1074,9 +1017,6 @@
"cpu": [
"x64"
],
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
+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"
@@ -0,0 +1,325 @@
'use client';
// 反馈审核抽屉:展示本条反馈 + 该用户历史反馈(就近参考),待审核态可采纳(发金币)或拒绝(填用户可见原因)。
// 已审核态只读回显。对接同事 PR#66 接口:POST .../approve、POST .../reject(.../handle 已废弃)。
import { useEffect, useState } from 'react';
import {
App,
Button,
Drawer,
Form,
Image,
Input,
InputNumber,
Segmented,
Space,
Spin,
Tag,
Typography,
} from 'antd';
import { api, errMsg } from '@/lib/api';
import { canDo } from '@/lib/auth';
import { formatUtcTime } from '@/lib/format';
import { mediaUrl } from '@/lib/media';
import type { CursorPage, Feedback } from '@/lib/types';
const { Text, Paragraph } = Typography;
const REWARD_MAX = 10000; // 对齐后端 FEEDBACK_REWARD_MAX_COINS
interface Props {
feedback: Feedback | null;
open: boolean;
onClose: () => void;
onDone: () => void; // 审核成功后刷新列表
}
// 待审核(同事后端初始态 pending;兼容历史 new 数据)
const isPending = (s: string) => s === 'pending' || s === 'new';
const STATUS_META: Record<string, { label: string; color: string }> = {
pending: { label: '审核中', color: 'orange' },
new: { label: '待审核', color: 'orange' },
adopted: { label: '已采纳', color: 'green' },
rejected: { label: '未采纳', color: 'red' },
};
const statusTag = (s: string) => {
const m = STATUS_META[s] ?? { label: s, 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 (
<Image.PreviewGroup>
<Space size={4} wrap>
{images.map((src, i) => (
<Image
key={i}
src={mediaUrl(src)}
width={48}
height={48}
style={{ objectFit: 'cover', borderRadius: 4 }}
/>
))}
</Space>
</Image.PreviewGroup>
);
}
export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }: Props) {
const { message } = App.useApp();
const [form] = Form.useForm();
const [action, setAction] = useState<'approve' | 'reject'>('approve');
const [submitting, setSubmitting] = useState(false);
const [history, setHistory] = useState<Feedback[]>([]);
const [loadingHistory, setLoadingHistory] = useState(false);
const editable = feedback != null && isPending(feedback.status) && canDo(['operator']);
// 打开时:重置表单 + 拉该用户全部历史反馈(含本条,渲染时滤掉本条)
useEffect(() => {
if (!open || !feedback) return;
setAction('approve');
form.resetFields();
let alive = true;
setLoadingHistory(true);
api
.get<CursorPage<Feedback>>('/admin/api/feedbacks', {
params: { user_id: feedback.user_id, limit: 50, sort_by: 'id', sort_order: 'desc' },
})
.then((r) => {
if (alive) setHistory(r.data.items);
})
.catch(() => {
if (alive) setHistory([]);
})
.finally(() => {
if (alive) setLoadingHistory(false);
});
return () => {
alive = false;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open, feedback?.id]);
const submit = async () => {
if (!feedback) return;
const v = await form.validateFields();
setSubmitting(true);
try {
if (action === 'approve') {
await api.post(`/admin/api/feedbacks/${feedback.id}/approve`, {
reward_coins: v.reward_coins,
note: v.note?.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,
});
message.success('已拒绝');
}
onClose();
onDone();
} catch (e) {
message.error(errMsg(e));
} finally {
setSubmitting(false);
}
};
const others = feedback ? history.filter((h) => h.id !== feedback.id) : [];
return (
<Drawer
title={feedback ? (editable ? `审核反馈 #${feedback.id}` : `反馈详情 #${feedback.id}`) : ''}
width={560}
open={open}
onClose={onClose}
destroyOnHidden
extra={
editable ? (
<Button type="primary" danger={action === 'reject'} loading={submitting} onClick={submit}>
{action === 'approve' ? '采纳并发金币' : '确认拒绝'}
</Button>
) : null
}
>
{feedback && (
<Space direction="vertical" size="large" style={{ width: '100%' }}>
{/* 本条反馈 */}
<div>
<Text type="secondary">
{feedback.user_id} · {formatUtcTime(feedback.created_at)}
</Text>
<Paragraph style={{ whiteSpace: 'pre-wrap', marginTop: 8, marginBottom: 8 }}>
{feedback.content || '-'}
</Paragraph>
<FeedbackImages images={feedback.images} />
</div>
{/* 已审核(或无权限):只读回显 */}
{!editable && (
<div
style={{
background:
feedback.status === 'adopted'
? '#f6ffed'
: feedback.status === 'rejected'
? '#fff1f0'
: '#fafafa',
border: `1px solid ${
feedback.status === 'adopted'
? '#b7eb8f'
: feedback.status === 'rejected'
? '#ffccc7'
: '#f0f0f0'
}`,
borderRadius: 8,
padding: 12,
}}
>
<div>
:{statusTag(feedback.status)}
{feedback.reviewed_at ? (
<Text type="secondary"> · {formatUtcTime(feedback.reviewed_at)}</Text>
) : null}
</div>
{feedback.status === 'adopted' && (
<div style={{ marginTop: 6 }}>
:<b>{feedback.reward_coins ?? 0}</b>
</div>
)}
{feedback.status === 'rejected' && (
<div style={{ marginTop: 6 }}>
():
{feedback.reject_reason || <Text type="secondary"></Text>}
</div>
)}
<div style={{ marginTop: 6 }}>
:{feedback.review_note || <Text type="secondary"></Text>}
</div>
{isPending(feedback.status) && (
<div style={{ marginTop: 6 }}>
<Text type="secondary"> operator / super_admin </Text>
</div>
)}
</div>
)}
{/* 待审核:采纳 / 拒绝表单 */}
{editable && (
<div>
<Segmented
value={action}
onChange={(v) => setAction(v as 'approve' | 'reject')}
options={[
{ label: '采纳(发金币)', value: 'approve' },
{ label: '拒绝', value: 'reject' },
]}
style={{ marginBottom: 16 }}
/>
{/* preserve=false:切换采纳/拒绝时卸载的字段从 store 移除,validateFields 不误校验另一侧 */}
<Form form={form} layout="vertical" preserve={false}>
{action === 'approve' ? (
<>
<Form.Item
name="reward_coins"
label={`奖励金币(必填,1 ~ ${REWARD_MAX})`}
rules={[
{ required: true, message: '请输入奖励金币' },
{ type: 'number', min: 1, max: REWARD_MAX, message: `1 ~ ${REWARD_MAX}` },
]}
>
<InputNumber
style={{ width: '100%' }}
min={1}
max={REWARD_MAX}
placeholder="采纳后发放给用户的金币"
/>
</Form.Item>
<Form.Item
name="note"
label="采纳要点 / 审核备注(选填)"
rules={[{ max: 256, message: '最多 256 字' }]}
>
<Input.TextArea rows={3} maxLength={256} showCount placeholder="如:建议已采纳,将在下个版本上线" />
</Form.Item>
</>
) : (
<>
<Form.Item
name="reason"
label="未采纳原因(必填,用户端可见)"
rules={[
{ required: true, message: '请填写未采纳原因' },
{ max: 256, message: '最多 256 字' },
]}
>
<Input.TextArea rows={3} maxLength={256} showCount placeholder="向用户说明为何未采纳" />
</Form.Item>
<Form.Item
name="note"
label="内部备注(选填,用户不可见)"
rules={[{ max: 256, message: '最多 256 字' }]}
>
<Input.TextArea rows={2} maxLength={256} showCount placeholder="运营内部备注" />
</Form.Item>
</>
)}
</Form>
</div>
)}
{/* 该用户历史反馈 */}
<div>
<Text strong>{others.length ? `${others.length}` : ''}</Text>
{loadingHistory ? (
<Spin style={{ display: 'block', margin: '16px 0' }} />
) : others.length === 0 ? (
<div style={{ marginTop: 8 }}>
<Text type="secondary"></Text>
</div>
) : (
<Space direction="vertical" size={8} style={{ width: '100%', marginTop: 8 }}>
{others.map((h) => (
<div
key={h.id}
style={{ border: '1px solid #f0f0f0', borderRadius: 8, padding: 10 }}
>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<Text type="secondary">
#{h.id} · {formatUtcTime(h.created_at)}
</Text>
{statusTag(h.status)}
</div>
<Paragraph
style={{ whiteSpace: 'pre-wrap', margin: '6px 0 0' }}
ellipsis={{ rows: 2, expandable: true, symbol: '展开' }}
>
{h.content || '-'}
</Paragraph>
{h.status === 'adopted' && (
<Text type="secondary" style={{ fontSize: 12 }}>
· {h.reward_coins ?? 0}
{h.review_note ? ` · ${h.review_note}` : ''}
</Text>
)}
{h.status === 'rejected' && (
<Text type="secondary" style={{ fontSize: 12 }}>
:{h.reject_reason || '-'}
</Text>
)}
</div>
))}
</Space>
)}
</div>
</Space>
)}
</Drawer>
);
}
@@ -0,0 +1,273 @@
'use client';
import { useEffect, useState } from 'react';
import { Button, Card, Image, Input, Space, Spin, Switch, Tag, Typography, Upload, message } from 'antd';
import { DeleteOutlined, UploadOutlined } from '@ant-design/icons';
import { api, errMsg } from '@/lib/api';
import { canDo } from '@/lib/auth';
import { mediaUrl } from '@/lib/media';
import type { FeedbackQrConfig as QrConfig } from '@/lib/types';
const { Text } = Typography;
const ACCEPT = ['image/jpeg', 'image/png', 'image/webp'];
/** 反馈页「加群二维码」卡配置。改完 App 意见反馈页下次进入即同步。「反馈工单」页的一个区块。 */
export default function FeedbackQrConfig() {
const [cfg, setCfg] = useState<QrConfig | null>(null);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [uploading, setUploading] = useState(false);
// 本地编辑态(文案 + 开关),保存时一次性 PATCH
const [enabled, setEnabled] = useState(true);
const [title, setTitle] = useState('');
const [groupName, setGroupName] = useState('');
const [subtitle, setSubtitle] = useState('');
const canEdit = canDo(['operator']);
const sync = (c: QrConfig) => {
setCfg(c);
setEnabled(c.enabled);
setTitle(c.title);
setGroupName(c.group_name);
setSubtitle(c.subtitle);
};
const load = async () => {
setLoading(true);
try {
const { data } = await api.get<QrConfig>('/admin/api/feedback-config');
sync(data);
} finally {
setLoading(false);
}
};
useEffect(() => {
load();
}, []);
const save = async () => {
if (!title.trim() || !groupName.trim() || !subtitle.trim()) {
message.warning('三行文案都需填写');
return;
}
setSaving(true);
try {
const { data } = await api.patch<QrConfig>('/admin/api/feedback-config', {
enabled,
title: title.trim(),
group_name: groupName.trim(),
subtitle: subtitle.trim(),
});
sync(data);
message.success('已保存,App 反馈页下次进入即可见');
} catch (e) {
message.error(errMsg(e));
} finally {
setSaving(false);
}
};
// antd Upload:beforeUpload 里自行 POST(multipart),返回 false 阻止其默认上传。
const beforeUpload = (file: File) => {
if (!ACCEPT.includes(file.type)) {
message.error('仅支持 JPEG / PNG / WebP 图片');
return Upload.LIST_IGNORE;
}
if (file.size > 5 * 1024 * 1024) {
message.error('图片不能超过 5MB');
return Upload.LIST_IGNORE;
}
void uploadImage(file);
return false;
};
const uploadImage = async (file: File) => {
const form = new FormData();
form.append('file', file);
setUploading(true);
try {
const { data } = await api.post<QrConfig>('/admin/api/feedback-config/image', form);
sync(data);
message.success('二维码已更新,App 反馈页下次进入即可见');
} catch (e) {
message.error(errMsg(e));
} finally {
setUploading(false);
}
};
const removeImage = async () => {
setUploading(true);
try {
const { data } = await api.delete<QrConfig>('/admin/api/feedback-config/image');
sync(data);
message.success('已移除二维码,App 将显示本地兜底图');
} catch (e) {
message.error(errMsg(e));
} finally {
setUploading(false);
}
};
return (
<Card
size="small"
title="反馈页二维码卡(App 意见反馈页底部)"
style={{ marginBottom: 16 }}
extra={
cfg?.updated_at ? (
<Text type="secondary" style={{ fontSize: 12 }}>
{new Date(cfg.updated_at).toLocaleString('zh-CN')}
</Text>
) : null
}
>
<p style={{ color: '#999', marginTop: 0 }}>
App
</p>
{loading || !cfg ? (
<Spin style={{ display: 'block', margin: '24px 0' }} />
) : (
<Space align="start" size={32} wrap>
{/* 左:所见即所得预览(对齐 App 卡片布局) */}
<div>
<Text type="secondary" style={{ fontSize: 12 }}>
App
</Text>
<div
style={{
marginTop: 8,
width: 320,
display: 'flex',
gap: 14,
alignItems: 'center',
padding: 14,
border: '1px solid #f0f0f0',
borderRadius: 14,
boxShadow: '0 1px 4px rgba(0,0,0,0.06)',
opacity: enabled ? 1 : 0.4,
}}
>
{cfg.image_url ? (
<Image
src={mediaUrl(cfg.image_url)}
width={88}
height={88}
style={{ objectFit: 'cover', borderRadius: 8, border: '1px solid #f0f0f0' }}
/>
) : (
<div
style={{
width: 88,
height: 88,
borderRadius: 8,
border: '1px dashed #d9d9d9',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: '#bbb',
fontSize: 12,
textAlign: 'center',
flexShrink: 0,
}}
>
</div>
)}
<div style={{ fontSize: 13, color: '#1a1a1a', lineHeight: '21px' }}>
<div>{title || '(标题)'}</div>
<div>
<b>{groupName || '群名'}</b>
</div>
<div>{subtitle || '(标语)'}</div>
</div>
</div>
{!enabled && (
<div style={{ color: '#fa8c16', fontSize: 12, marginTop: 6 }}>
App
</div>
)}
</div>
{/* 右:编辑控件 */}
<Space direction="vertical" size="middle" style={{ minWidth: 320 }}>
<Space>
<span></span>
<Switch checked={enabled} disabled={!canEdit} onChange={setEnabled} />
{!enabled && <Tag color="orange"></Tag>}
</Space>
<Space wrap>
<Upload accept="image/*" showUploadList={false} beforeUpload={beforeUpload} disabled={!canEdit}>
<Button icon={<UploadOutlined />} loading={uploading} disabled={!canEdit}>
{cfg.image_url ? '更换二维码' : '上传二维码'}
</Button>
</Upload>
{cfg.image_url && (
<Button
icon={<DeleteOutlined />}
danger
loading={uploading}
disabled={!canEdit}
onClick={removeImage}
>
</Button>
)}
<Text type="secondary" style={{ fontSize: 12 }}>
JPEG/PNG/WebP5MB
</Text>
</Space>
<div>
<Text type="secondary" style={{ fontSize: 12 }}>
</Text>
<Input
value={title}
maxLength={40}
disabled={!canEdit}
onChange={(e) => setTitle(e.target.value)}
placeholder="如:长按图片保存二维码"
/>
</div>
<div>
<Text type="secondary" style={{ fontSize: 12 }}>
App
</Text>
<Input
value={groupName}
maxLength={40}
disabled={!canEdit}
onChange={(e) => setGroupName(e.target.value)}
placeholder="如:傻瓜比价官方群"
/>
</div>
<div>
<Text type="secondary" style={{ fontSize: 12 }}>
</Text>
<Input
value={subtitle}
maxLength={60}
disabled={!canEdit}
onChange={(e) => setSubtitle(e.target.value)}
placeholder="如:一起唠嗑共创、解锁新玩法"
/>
</div>
<Button type="primary" loading={saving} disabled={!canEdit} onClick={save}>
/
</Button>
{!canEdit && <Text type="secondary"> operator / super_admin </Text>}
</Space>
</Space>
)}
</Card>
);
}
+70 -81
View File
@@ -1,11 +1,9 @@
'use client';
import { useEffect, useState } from 'react';
import type { Key } from 'react';
import { useState } from 'react';
import type { ColumnsType } from 'antd/es/table';
import type { SorterResult } from 'antd/es/table/interface';
import {
App,
Button,
DatePicker,
Image,
@@ -17,11 +15,12 @@ import {
Typography,
} from 'antd';
import type { Dayjs } from 'dayjs';
import { api, errMsg } from '@/lib/api';
import { canDo } from '@/lib/auth';
import { formatUtcTime } from '@/lib/format';
import { usePagedList } from '@/lib/usePagedList';
import type { Feedback } from '@/lib/types';
import FeedbackQrConfig from './FeedbackQrConfig';
import FeedbackHandleDrawer from './FeedbackHandleDrawer';
const { Text, Paragraph } = Typography;
const { RangePicker } = DatePicker;
@@ -32,8 +31,17 @@ const mediaUrl = (p: string) => (p.startsWith('http') ? p : MEDIA_BASE + p);
type SortField = 'id' | 'created_at';
// 待审核(同事后端初始态 pending;兼容历史 new 数据)
const isPending = (s: string) => s === 'pending' || s === 'new';
const STATUS_META: Record<string, { label: string; color: string }> = {
pending: { label: '审核中', color: 'orange' },
new: { label: '待审核', color: 'orange' },
adopted: { label: '已采纳', color: 'green' },
rejected: { label: '未采纳', color: 'red' },
};
export default function FeedbacksPage() {
const { message, modal } = App.useApp();
// 筛选草稿:点「查询」才应用(避免输入即刷新)
const [status, setStatus] = useState<string | undefined>();
const [userId, setUserId] = useState('');
@@ -45,17 +53,18 @@ export default function FeedbacksPage() {
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
const filters: Record<string, unknown> = { ...applied, sort_by: sortBy, sort_order: sortOrder };
const filterKey = JSON.stringify(filters);
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
usePagedList<Feedback>('/admin/api/feedbacks', filters);
const canHandle = canDo(['operator']);
const [selectedRowKeys, setSelectedRowKeys] = useState<Key[]>([]);
const canReview = canDo(['operator']);
// 筛选/排序变化后清空已选(避免选中项跨筛选错位)
useEffect(() => {
setSelectedRowKeys([]);
}, [filterKey]);
// 审核/查看抽屉(采纳发金币 / 拒绝填原因 + 看该用户历史反馈)
const [drawerFb, setDrawerFb] = useState<Feedback | null>(null);
const [drawerOpen, setDrawerOpen] = useState(false);
const openDrawer = (f: Feedback) => {
setDrawerFb(f);
setDrawerOpen(true);
};
const search = () =>
setApplied({
@@ -94,50 +103,13 @@ export default function FeedbacksPage() {
const sortOrderOf = (field: SortField) =>
sortBy === field ? (sortOrder === 'asc' ? 'ascend' : 'descend') : null;
const handle = async (f: Feedback) => {
try {
await api.post(`/admin/api/feedbacks/${f.id}/handle`);
message.success('已标记处理');
reload();
} catch (e) {
message.error(errMsg(e));
}
};
const selectedNew = items.filter(
(f) => selectedRowKeys.includes(f.id) && f.status === 'new',
);
// 批量:循环调现有逐条 /handle 接口(各自已带审计),Promise.allSettled 汇总成败,不新增 bulk 端点
const bulkHandle = () => {
if (!selectedNew.length) {
message.warning('没有可处理的选中项(仅待处理 new 态生效)');
return;
}
modal.confirm({
title: `确认批量标记处理 ${selectedNew.length} 条反馈?`,
content: '仅对选中的待处理(new)反馈生效',
onOk: async () => {
const results = await Promise.allSettled(
selectedNew.map((f) => api.post(`/admin/api/feedbacks/${f.id}/handle`)),
);
const ok = results.filter((r) => r.status === 'fulfilled').length;
const fail = results.length - ok;
if (fail) message.warning(`批量标记处理完成:成功 ${ok}/${results.length},失败 ${fail}`);
else message.success(`批量标记处理完成:${ok}`);
setSelectedRowKeys([]);
reload();
},
});
};
const columns: ColumnsType<Feedback> = [
{ title: 'ID', dataIndex: 'id', width: 70, sorter: true, sortOrder: sortOrderOf('id') },
{ title: '用户', dataIndex: 'user_id', width: 80 },
{
title: '内容',
dataIndex: 'content',
width: 360,
width: 340,
render: (v: string) =>
v ? (
<Paragraph
@@ -153,7 +125,7 @@ export default function FeedbacksPage() {
{
title: '截图',
dataIndex: 'images',
width: 180,
width: 160,
render: (imgs: string[] | null) =>
imgs && imgs.length ? (
<Image.PreviewGroup>
@@ -173,17 +145,46 @@ export default function FeedbacksPage() {
<Text type="secondary"></Text>
),
},
{ title: '联系方式', dataIndex: 'contact', width: 140, render: (v: string) => v || '-' },
{
title: '状态',
dataIndex: 'status',
width: 90,
render: (s: string) => <Tag color={s === 'new' ? 'orange' : 'green'}>{s}</Tag>,
render: (s: string) => {
const m = STATUS_META[s] ?? { label: s, color: 'default' };
return <Tag color={m.color}>{m.label}</Tag>;
},
},
{
title: '审核结果',
key: 'review',
width: 170,
render: (_: unknown, f: Feedback) => {
if (f.status === 'adopted') {
return (
<Space direction="vertical" size={0}>
<Tag color="gold">+{f.reward_coins ?? 0} </Tag>
{f.review_note ? (
<Text type="secondary" style={{ fontSize: 12 }} ellipsis>
{f.review_note}
</Text>
) : null}
</Space>
);
}
if (f.status === 'rejected') {
return (
<Text type="secondary" style={{ fontSize: 12 }} ellipsis>
:{f.reject_reason || '-'}
</Text>
);
}
return <Text type="secondary">-</Text>;
},
},
{
title: '时间',
dataIndex: 'created_at',
width: 180,
width: 170,
sorter: true,
sortOrder: sortOrderOf('created_at'),
render: (v: string) => formatUtcTime(v),
@@ -191,12 +192,12 @@ export default function FeedbacksPage() {
{
title: '操作',
key: 'op',
width: 100,
width: 90,
render: (_: unknown, f: Feedback) =>
canHandle && f.status === 'new' ? (
<a onClick={() => handle(f)}></a>
canReview && isPending(f.status) ? (
<a onClick={() => openDrawer(f)}></a>
) : (
<span style={{ color: '#ccc' }}>-</span>
<a onClick={() => openDrawer(f)}></a>
),
},
];
@@ -204,6 +205,7 @@ export default function FeedbacksPage() {
return (
<div>
<h2></h2>
<FeedbackQrConfig />
<Space style={{ marginBottom: 16 }} wrap>
<Select
placeholder="状态"
@@ -212,8 +214,9 @@ export default function FeedbacksPage() {
allowClear
style={{ width: 120 }}
options={[
{ value: 'new', label: '待处理' },
{ value: 'handled', label: '已处理' },
{ value: 'pending', label: '审核中' },
{ value: 'adopted', label: '已采纳' },
{ value: 'rejected', label: '未采纳' },
]}
/>
<Input
@@ -244,29 +247,8 @@ export default function FeedbacksPage() {
<Button onClick={resetFilters}></Button>
</Space>
{canHandle && selectedNew.length > 0 && (
<Space style={{ marginBottom: 12, width: '100%' }} wrap>
<span style={{ color: '#888' }}> {selectedNew.length} </span>
<Button type="primary" onClick={bulkHandle}>
</Button>
<Button type="link" onClick={() => setSelectedRowKeys([])}>
</Button>
</Space>
)}
<Table
rowKey="id"
rowSelection={
canHandle
? {
selectedRowKeys,
onChange: setSelectedRowKeys,
getCheckboxProps: (f) => ({ disabled: f.status !== 'new' }),
}
: undefined
}
columns={columns}
dataSource={items}
loading={loading}
@@ -280,6 +262,13 @@ export default function FeedbacksPage() {
}}
onChange={onTableChange}
/>
<FeedbackHandleDrawer
feedback={drawerFb}
open={drawerOpen}
onClose={() => setDrawerOpen(false)}
onDone={reload}
/>
</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 },
+2 -3
View File
@@ -20,6 +20,7 @@ import { CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons';
import dayjs from 'dayjs';
import { api, errMsg } from '@/lib/api';
import { canDo } from '@/lib/auth';
import { mediaUrl } from '@/lib/media';
import { usePagedList } from '@/lib/usePagedList';
import type { PriceReport, PriceReportSummary } from '@/lib/types';
@@ -30,9 +31,7 @@ const { Text } = Typography;
const dt = (v: string | null) => (v ? dayjs(v).format('YYYY-MM-DD HH:mm') : '-');
const yuan = (c: number | null) => (c == null ? '-' : `¥${(c / 100).toFixed(2)}`);
// 截图是 app-server 的 /media 相对路径,本地由 :8770 提供(NEXT_PUBLIC_MEDIA_BASE);生产同域走 nginx 代理
const MEDIA_BASE = process.env.NEXT_PUBLIC_MEDIA_BASE || '';
const mediaUrl = (p: string) => (p.startsWith('http') ? p : MEDIA_BASE + p);
// 截图 URL 解析见 @/lib/media(dev 指向 :8770,生产走 nginx /media 同域反代)
const STATUS_COLOR: Record<string, string> = {
pending: 'gold',
+31
View File
@@ -131,6 +131,28 @@ export default function UsersPage() {
});
};
// 一次性操作:点一下把该用户标记为「未看过引导」,下次打开 App 重看一遍,看完后端自动恢复(只触发这一次)。
// 用户尚未重看前可「撤销」(把 force_onboarding 置回 false),纠正误点。
const setForceOnboarding = (u: UserListItem, enable: boolean) => {
modal.confirm({
title: enable
? `确认让用户 ${u.phone} 重看一次新手引导?`
: `撤销用户 ${u.phone} 的「重看新手引导」?`,
content: enable
? '点一下即把该用户标记为「未看过引导」:Ta 下次打开 App 会重走一遍新手引导,看完自动恢复——只触发这一次。仅对已支持该功能的 App 版本生效。'
: '该用户尚未重看,撤销后下次打开 App 不再触发。',
onOk: async () => {
try {
await api.post(`/admin/api/users/${u.id}/force-onboarding`, { enabled: enable });
message.success(enable ? '已开启:该用户下次打开 App 会重看一次' : '已撤销');
reload();
} catch (e) {
message.error(errMsg(e));
}
},
});
};
const selectedUsers = items.filter((u) => selectedRowKeys.includes(u.id));
const selectedActive = selectedUsers.filter((u) => u.status === 'active');
const selectedDisabled = selectedUsers.filter((u) => u.status === 'disabled');
@@ -238,6 +260,15 @@ export default function UsersPage() {
{u.debug_trace_enabled ? '关调试链接' : '开调试链接'}
</a>
)}
{canStatus &&
u.status !== 'deleted' &&
(u.force_onboarding ? (
<span style={{ color: '#fa8c16' }}>
<a onClick={() => setForceOnboarding(u, false)}></a>
</span>
) : (
<a onClick={() => setForceOnboarding(u, true)}></a>
))}
</Space>
),
},
@@ -0,0 +1,222 @@
'use client';
import { useCallback, useEffect, useState } from 'react';
import {
DatePicker,
Descriptions,
Radio,
Space,
Table,
Tag,
Typography,
message,
} from 'antd';
import type { ColumnsType } from 'antd/es/table';
import dayjs, { type Dayjs } from 'dayjs';
import type { CursorPage, UserCoinRecord, UserRewardStats, WithdrawUserSnapshot } from '@/lib/types';
import { api, errMsg } from '@/lib/api';
const { Text } = Typography;
const { RangePicker } = DatePicker;
const yuan = (c: number) => `¥${(c / 100).toFixed(2)}`;
// 后端时间为 UTC(无时区串补 Z),按北京时区展示(与提现列表口径一致)
const apiTime = (v: string) => {
const hasTz = /(?:Z|[+-]\d{2}:?\d{2})$/i.test(v);
return dayjs(hasTz ? v : `${v}Z`);
};
const dt = (v: string) => apiTime(v).format('YYYY-MM-DD HH:mm');
const SOURCE_COLOR: Record<string, string> = {
reward_video: 'blue',
signin_boost: 'cyan',
feed: 'purple',
signin: 'green',
};
const PAGE_SIZE = 10; // 金币记录每页条数
interface Props {
userId: number;
user: WithdrawUserSnapshot | null;
}
/** 提现详情抽屉:用户基本信息 + 互斥时间筛选 + 看广告/提现统计区 + 金币发放记录表。 */
export default function UserRewardPanel({ userId, user }: 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);
const [statsLoading, setStatsLoading] = useState(false);
const [records, setRecords] = useState<UserCoinRecord[]>([]);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [recordsLoading, setRecordsLoading] = useState(false);
// 时间窗口参数:注册至今=不传;自定义区间(选齐两端)=date_from/date_to。
const params =
mode === 'range' && range?.[0] && range?.[1]
? {
date_from: range[0].startOf('day').toISOString(),
date_to: range[1].endOf('day').toISOString(),
}
: {};
const paramsKey = JSON.stringify(params);
const loadStats = useCallback(async () => {
setStatsLoading(true);
try {
const { data } = await api.get<UserRewardStats>(`/admin/api/users/${userId}/reward-stats`, {
params: JSON.parse(paramsKey),
});
setStats(data);
} catch (e) {
message.error(errMsg(e));
} finally {
setStatsLoading(false);
}
}, [userId, paramsKey]);
const loadRecords = useCallback(
async (p: number) => {
setRecordsLoading(true);
try {
const { data } = await api.get<CursorPage<UserCoinRecord>>(
`/admin/api/users/${userId}/coin-records`,
{ params: { ...JSON.parse(paramsKey), limit: PAGE_SIZE, cursor: (p - 1) * PAGE_SIZE } },
);
setRecords(data.items);
setTotal(data.total ?? 0);
} catch (e) {
message.error(errMsg(e));
} finally {
setRecordsLoading(false);
}
},
[userId, paramsKey],
);
// 用户或时间筛选变化:回到第 1 页重新拉取
useEffect(() => {
loadStats();
setPage(1);
loadRecords(1);
}, [loadStats, loadRecords]);
const regDays = user?.created_at ? dayjs().diff(apiTime(user.created_at), 'day') : null;
const columns: ColumnsType<UserCoinRecord> = [
{ title: '日期时间', dataIndex: 'created_at', width: 150, render: dt },
{
title: '赚取途径',
dataIndex: 'source_label',
width: 120,
render: (label: string, r) => <Tag color={SOURCE_COLOR[r.source] ?? 'default'}>{label}</Tag>,
},
{
title: 'ECPM',
dataIndex: 'ecpm',
width: 100,
render: (v: string | null) => v ?? <Text type="secondary">-</Text>,
},
{ title: '发放金币数', dataIndex: 'coin', width: 100, render: (v: number) => <b>{v}</b> },
];
return (
<div>
{/* 用户基本信息 + 互斥时间筛选(同一行) */}
<Space
wrap
align="center"
style={{ width: '100%', justifyContent: 'space-between', marginBottom: 12 }}
>
<Space size="large" wrap>
<span>
<Text strong>{user?.phone || '-'}</Text>
</span>
<span>
<Text strong>{user?.nickname || '-'}</Text>
</span>
<span>
<Text strong>{user?.wechat_nickname || '-'}</Text>
</span>
<span>
<Text strong>{regDays != null ? `${regDays}` : '-'}</Text>
</span>
</Space>
<Space wrap>
<Radio.Group
size="small"
value={mode}
onChange={(e) => setMode(e.target.value)}
optionType="button"
buttonStyle="solid"
>
<Radio.Button value="all"></Radio.Button>
<Radio.Button value="range"></Radio.Button>
</Radio.Group>
<RangePicker
size="small"
disabled={mode !== 'range'}
value={range}
onChange={(v) => setRange(v as [Dayjs, Dayjs] | null)}
/>
</Space>
</Space>
{/* 统计区(受时间筛选;现金余额为当前快照) */}
<Descriptions bordered size="small" column={2} style={{ marginBottom: 8 }}>
<Descriptions.Item label="累计提现">
{stats ? yuan(stats.withdraw_success_cents) : '-'}
</Descriptions.Item>
<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>
</Descriptions>
<Text type="secondary" style={{ fontSize: 12 }}>
(,);eCPM /,
</Text>
{/* 金币记录 */}
<h4 style={{ margin: '16px 0 8px' }}></h4>
<Table
rowKey={(r) => `${r.source}-${r.created_at}-${r.coin}-${r.ecpm ?? ''}`}
size="small"
columns={columns}
dataSource={records}
loading={recordsLoading || statsLoading}
pagination={{
current: page,
pageSize: PAGE_SIZE,
total,
showSizeChanger: false,
onChange: (p) => {
setPage(p);
loadRecords(p);
},
showTotal: (t) => `${t}`,
}}
/>
</div>
);
}
+37 -138
View File
@@ -38,18 +38,19 @@ import {
import dayjs, { type Dayjs } from 'dayjs';
import { api, errMsg } from '@/lib/api';
import { canDo } from '@/lib/auth';
import { formatUtcTime, formatWallTime, utcDayjs, utcFromNow, yuan } from '@/lib/format';
import { formatUtcTime, utcDayjs, utcFromNow, yuan } from '@/lib/format';
import { usePagedList } from '@/lib/usePagedList';
import type {
AuditLog,
CashTxn,
WithdrawBulkResult,
WithdrawDetail,
WithdrawLedgerCheck,
WithdrawListItem,
WithdrawOrder,
WithdrawSummary,
WxpayHealthCheck,
} from '@/lib/types';
import UserRewardPanel from './UserRewardPanel';
const { Text } = Typography;
const { RangePicker } = DatePicker;
@@ -101,19 +102,12 @@ const QUICK_FILTER_STATUS: Record<string, string> = {
};
const SORT_OPTIONS = [
{ value: 'created_at', label: '申请时间' },
{ value: 'updated_at', label: '更新时间' },
{ value: 'amount_cents', label: '提现金额' },
{ value: 'id', label: '记录 ID' },
];
const DATE_FIELD_OPTIONS = [
{ value: 'created_at', label: '申请时间' },
{ value: 'updated_at', label: '更新时间' },
];
const CASH_BIZ_LABEL: Record<string, string> = {
exchange_in: '金币兑入',
withdraw: '提现扣款',
withdraw_refund: '提现退款',
};
function statusTag(status: string) {
return <Tag color={STATUS_COLOR[status]}>{STATUS_LABEL[status] || status}</Tag>;
@@ -155,9 +149,10 @@ function riskTags(detail: WithdrawDetail | null) {
if (detail.user?.status && detail.user.status !== 'active') tags.push(`账号状态:${detail.user.status}`);
if (detail.user && dayjs().diff(utcDayjs(detail.user.created_at), 'hour') < 24) tags.push('新注册用户');
if ((detail.user?.withdraw_total || 0) >= 3) tags.push('多次提现用户');
if (detail.recent_withdraws.some((o) => o.status === 'rejected' || o.status === 'failed')) {
tags.push('历史异常单');
}
const rejectedN = detail.recent_withdraws.filter((o) => o.status === 'rejected').length;
const failedN = detail.recent_withdraws.filter((o) => o.status === 'failed').length;
if (rejectedN) tags.push(`提现拒绝${rejectedN}`);
if (failedN) tags.push(`提现失败${failedN}`);
return tags;
}
@@ -186,9 +181,7 @@ export default function WithdrawsPage() {
const [keyword, setKeyword] = useState('');
const [dateRange, setDateRange] = useState<[Dayjs, Dayjs] | null>(null);
const [dateField, setDateField] = useState<'created_at' | 'updated_at'>('created_at');
const [sortBy, setSortBy] = useState<'created_at' | 'updated_at' | 'amount_cents' | 'id'>(
'created_at',
);
const [sortBy, setSortBy] = useState<'created_at' | 'amount_cents'>('created_at');
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
const [quickFilter, setQuickFilter] = useState<string | undefined>(undefined);
@@ -203,7 +196,7 @@ export default function WithdrawsPage() {
filters.sort_order = sortOrder;
const filterKey = JSON.stringify(filters);
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
usePagedList<WithdrawOrder>('/admin/api/withdraws', filters, 20);
usePagedList<WithdrawListItem>('/admin/api/withdraws', filters, 20);
const canManage = canDo(['finance']);
const selectedOrders = items.filter((item) => selectedRowKeys.includes(item.id));
const selectedReviewing = selectedOrders.filter((item) => item.status === 'reviewing');
@@ -469,37 +462,37 @@ export default function WithdrawsPage() {
});
};
const columns: ColumnsType<WithdrawOrder> = [
const columns: ColumnsType<WithdrawListItem> = [
{
title: '用户',
dataIndex: 'user_id',
width: 110,
render: (v: number) => <Text strong>#{v}</Text>,
},
{
title: '提现实名',
dataIndex: 'user_name',
title: '手机号',
dataIndex: 'phone',
width: 130,
render: (v: string | null) => v || <Text type="secondary"></Text>,
render: (v: string | null) => v || <Text type="secondary">-</Text>,
},
{
title: '金额',
title: '用户昵称',
dataIndex: 'nickname',
width: 130,
render: (v: string | null) => v || <Text type="secondary">-</Text>,
},
{
title: '提现金额',
dataIndex: 'amount_cents',
width: 120,
render: (v: number) => <Text strong>{yuan(v)}</Text>,
},
{
title: '累计提现',
dataIndex: 'cumulative_success_cents',
width: 120,
render: (v: number) => yuan(v ?? 0),
},
{
title: '状态',
dataIndex: 'status',
width: 110,
render: statusTag,
},
{
title: '微信状态',
dataIndex: 'wechat_state',
width: 150,
render: (v: string | null) => v || <Text type="secondary">-</Text>,
},
{
title: '提交时间',
dataIndex: 'created_at',
@@ -512,7 +505,7 @@ export default function WithdrawsPage() {
),
},
{
title: '提单号',
title: '提单号',
dataIndex: 'out_bill_no',
ellipsis: true,
},
@@ -527,7 +520,7 @@ export default function WithdrawsPage() {
key: 'op',
fixed: 'right',
width: 210,
render: (_: unknown, o: WithdrawOrder) => {
render: (_: unknown, o: WithdrawListItem) => {
if (!canManage) return <Text type="secondary">-</Text>;
if (o.status === 'reviewing') {
return (
@@ -576,37 +569,6 @@ export default function WithdrawsPage() {
},
];
const cashColumns: ColumnsType<CashTxn> = [
{
title: '类型',
dataIndex: 'biz_type',
width: 130,
render: (v: string) => CASH_BIZ_LABEL[v] || v,
},
{
title: '金额',
dataIndex: 'amount_cents',
width: 100,
render: (v: number) => (
<Text style={{ color: v < 0 ? '#cf1322' : '#389e0d' }}>
{v > 0 ? '+' : ''}
{yuan(v)}
</Text>
),
},
{ title: '余额', dataIndex: 'balance_after_cents', width: 100, render: yuan },
{ title: '备注', dataIndex: 'remark', render: (v: string | null) => v || '-' },
// 现金流水是北京 wall-clock 口径,原样显示,不能当 UTC 再 +8
{ title: '时间', dataIndex: 'created_at', width: 150, render: (v: string) => formatWallTime(v) },
];
const recentWithdrawColumns: ColumnsType<WithdrawOrder> = [
{ title: '单号', dataIndex: 'out_bill_no', ellipsis: true },
{ title: '金额', dataIndex: 'amount_cents', width: 90, render: yuan },
{ title: '状态', dataIndex: 'status', width: 90, render: statusTag },
{ title: '时间', dataIndex: 'created_at', width: 150, render: dt },
];
const auditTimeline = detail
? [
{
@@ -704,34 +666,14 @@ export default function WithdrawsPage() {
)}
<Row gutter={12} style={{ marginBottom: 16 }}>
<Col xs={24} sm={12} xl={5}>
<Col xs={24} sm={12}>
<Card size="small">
<Statistic title="待审核" value={summary?.reviewing_count || 0} suffix="笔" />
<Text type="secondary"> {yuan(summary?.reviewing_amount_cents || 0)}</Text>
</Card>
</Col>
<Col xs={24} sm={12} xl={5}>
<Col xs={24} sm={12}>
<Card size="small">
<Statistic title="今日拒绝" value={summary?.today_rejected_count || 0} suffix="笔" />
<Text type="secondary"></Text>
</Card>
</Col>
<Col xs={24} sm={12} xl={5}>
<Card size="small">
<Statistic title="打款中" value={summary?.pending_count || 0} suffix="笔" />
<Text type="secondary"></Text>
</Card>
</Col>
<Col xs={24} sm={12} xl={4}>
<Card size="small">
<Statistic title="失败待处理" value={summary?.failed_count || 0} suffix="笔" />
<Text type="secondary">退</Text>
</Card>
</Col>
<Col xs={24} sm={12} xl={5}>
<Card size="small">
<Statistic title="今日到账" value={summary?.today_success_count || 0} suffix="笔" />
<Text type="secondary"> {yuan(summary?.today_success_amount_cents || 0)}</Text>
<Statistic title="待审核金额" value={yuan(summary?.reviewing_amount_cents || 0)} />
</Card>
</Col>
</Row>
@@ -772,9 +714,9 @@ export default function WithdrawsPage() {
allowClear
enterButton="搜索"
prefix={<SearchOutlined />}
placeholder="用户ID / 手机号 / 单号 / 原因"
placeholder="用户手机号"
value={searchDraft}
style={{ width: 320 }}
style={{ width: 240 }}
onChange={(e) => {
const value = e.target.value;
setSearchDraft(value);
@@ -821,9 +763,7 @@ export default function WithdrawsPage() {
style={{ width: 130 }}
suffixIcon={<SortAscendingOutlined />}
options={SORT_OPTIONS}
onChange={(value: 'created_at' | 'updated_at' | 'amount_cents' | 'id') =>
setSortBy(value)
}
onChange={(value: 'created_at' | 'amount_cents') => setSortBy(value)}
/>
<Select
value={sortOrder}
@@ -919,7 +859,7 @@ export default function WithdrawsPage() {
<Drawer
title="提现详情"
width={720}
width="50%"
open={drawerOpen}
onClose={() => setDrawerOpen(false)}
extra={
@@ -958,29 +898,10 @@ export default function WithdrawsPage() {
</Descriptions.Item>
</Descriptions>
<Descriptions bordered size="small" column={2} title="用户与钱包">
<Descriptions.Item label="用户 ID">#{detail.order.user_id}</Descriptions.Item>
<Descriptions.Item label="账号状态">
{detail.user ? <Tag>{detail.user.status}</Tag> : '-'}
</Descriptions.Item>
<Descriptions.Item label="手机号">{detail.user?.phone || '-'}</Descriptions.Item>
<Descriptions.Item label="昵称">{detail.user?.nickname || '-'}</Descriptions.Item>
<Descriptions.Item label="微信昵称">
{detail.user?.wechat_nickname || '-'}
</Descriptions.Item>
<Descriptions.Item label="现金余额">
{yuan(detail.user?.cash_balance_cents || 0)}
</Descriptions.Item>
<Descriptions.Item label="提现总次数">
{detail.user?.withdraw_total ?? '-'}
</Descriptions.Item>
<Descriptions.Item label="成功提现">
{yuan(detail.user?.withdraw_success_cents || 0)}
</Descriptions.Item>
</Descriptions>
<UserRewardPanel userId={detail.order.user_id} user={detail.user} />
<div>
<h3> {detail.risk_score ? <Tag color="red">{detail.risk_score}</Tag> : null}</h3>
<h3></h3>
{risks.length ? (
<Space wrap>
{risks.map((risk) => (
@@ -998,28 +919,6 @@ export default function WithdrawsPage() {
<h3>线</h3>
<Timeline items={auditTimeline} />
</div>
<div>
<h3></h3>
<Table
rowKey="id"
size="small"
columns={recentWithdrawColumns}
dataSource={detail.recent_withdraws}
pagination={false}
/>
</div>
<div>
<h3></h3>
<Table
rowKey="id"
size="small"
columns={cashColumns}
dataSource={detail.recent_cash_transactions}
pagination={false}
/>
</div>
</Space>
)}
</Spin>
+12
View File
@@ -0,0 +1,12 @@
// 媒体(上报截图 / 反馈截图 / 反馈二维码等)由 App 后端的 /media 静态服务托管,与 admin 不同域:
// - dev :NEXT_PUBLIC_MEDIA_BASE = http://localhost:8770(本地 App 后端)。
// - 生产:NEXT_PUBLIC_MEDIA_BASE = https://app-api.shaguabijia.com(线上 App 后端,/media 真正的家)。
// 留空则退化为同域相对路径——而 admin 域(admin-web.shaguabijia.com)并不 serve /media,会 404,
// 这正是线上后台图片打不开的根因。NEXT_PUBLIC_* 是编译期常量,改完需重新 build 才生效。
const MEDIA_BASE = (process.env.NEXT_PUBLIC_MEDIA_BASE || '').replace(/\/+$/, ''); // 去末尾斜杠,防拼出 //media
/** 把后端返回的相对媒体路径(/media/...)拼成可加载的 URL;已是 http(s) 绝对地址的原样返回。 */
export function mediaUrl(p: string): string {
if (!p) return p;
return p.startsWith('http') ? p : MEDIA_BASE + p;
}
+52 -1
View File
@@ -30,6 +30,8 @@ export interface UserListItem {
status: string;
// 调试链接权限:开了的用户在 App 比价结果页/记录页可复制 price.shaguabijia.com 的 trace 调试链接
debug_trace_enabled: boolean;
// 运营「一键开启新手引导」:true = 该用户下次打开 App 会被强制重走新手引导,走完自动取消
force_onboarding: boolean;
wechat_openid: string | null;
created_at: string;
last_login_at: string;
@@ -90,6 +92,14 @@ export interface WithdrawOrder {
updated_at: string;
}
// 提现列表项:WithdrawOrder + 列表接口联表带出的用户字段。
// 详情抽屉的 recent_withdraws 仍是裸 WithdrawOrder(无这些字段)。
export interface WithdrawListItem extends WithdrawOrder {
phone: string | null;
nickname: string | null;
cumulative_success_cents: number; // 累计成功提现(分)
}
export interface WithdrawSummary {
reviewing_count: number;
reviewing_amount_cents: number;
@@ -124,6 +134,30 @@ export interface WithdrawDetail {
audit_logs: AuditLog[];
}
// 提现详情抽屉「用户统计区」:按时间窗口算的提现 + 看广告行为统计。
// *_cash_cents = 该来源累计金币折算成可提现现金(分);现金余额是当前快照不随窗口。
export interface UserRewardStats {
withdraw_success_cents: number; // 累计提现
cash_balance_cents: number; // 现金余额(快照)
withdraw_total: number; // 提现总次数(全部状态)
traditional_task_cash_cents: number; // 传统任务提现
reward_video_count: number; // 累计激励视频数
reward_video_avg_ecpm: number; // 平均激励视频 eCPM(分/千次)
reward_video_cash_cents: number; // 激励视频提现
feed_count: number; // 累计信息流广告数(份)
feed_avg_ecpm: number; // 平均信息流广告 eCPM(分/千次)
feed_cash_cents: number; // 信息流广告提现
}
// 金币发放记录(提现详情底部表)。ecpm 为原始分/千次,非广告来源为 null。
export interface UserCoinRecord {
source: string; // reward_video / signin_boost / feed / signin
source_label: string; // 激励视频 / 签到膨胀 / 信息流广告 / 签到
created_at: string;
ecpm: string | null;
coin: number;
}
export interface WithdrawBulkItemResult {
out_bill_no: string;
ok: boolean;
@@ -172,10 +206,27 @@ export interface Feedback {
content: string;
contact: string;
images: string[] | null;
status: string; // new / handled
// pending(审核中) / adopted(已采纳) / rejected(未采纳);历史数据可能为 new
status: string;
reject_reason: string | null; // 未采纳原因(用户端可见)
reward_coins: number | null; // 采纳后发放金币
review_note: string | null; // 审核批注(采纳要点 / 内部备注)
reviewed_by_admin_id: number | null;
reviewed_at: string | null;
created_at: string;
}
// 反馈页「加群二维码」卡配置(运营后台改 → App 意见反馈页同步)。
// image_url 为后端 /media 相对路径(留空=App 走本地兜底图);其余为卡片三行文案与显隐开关。
export interface FeedbackQrConfig {
enabled: boolean;
image_url: string | null;
title: string; // 第一行(操作提示),如「长按图片保存二维码」
group_name: string; // 第二行加粗群名,App 渲染为 直通「{group_name}」
subtitle: string; // 第三行(标语)
updated_at: string | null;
}
export interface AuditLog {
id: number;
admin_id: number;