用户反馈/低价审核 admin 页改版(重命名+二维码挪位+统计修复+列增强) (#28)
- 重命名:菜单与页面标题「反馈工单→用户反馈」「上报审核→低价审核」 - 反馈页「加群二维码」卡挪到系统配置页,新增「反馈二维码」tab - 修复反馈四态统计恒为 0:对接后端新增的 /admin/api/feedbacks/summary - 两页表格增强:用户列拆为 用户ID/手机号/用户昵称;新增 提交版本号、机型/OS版本 列; 点手机号弹抽屉看该用户全部记录,抽屉顶部汇总 提交/上报总计 + 奖励总计 - 低价审核:提交时间列可排序、审核结果与操作拆两列、顶部统计改卡片式、 Trace 列对齐比价记录页(有 trace_url 即可点) - 修复反馈时间显示快 8 小时:反馈时间为北京 wall-clock,改用 formatWallTime Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: zzhyyyyy <2685922758@qq.com> Reviewed-on: #28 Co-authored-by: zhuzihao <zhuzihao@wonderable.ai> Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
This commit was merged in pull request #28.
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ const { Text } = Typography;
|
||||
|
||||
const ACCEPT = ['image/jpeg', 'image/png', 'image/webp'];
|
||||
|
||||
/** 反馈页「加群二维码」卡配置。改完 App 意见反馈页下次进入即同步。「反馈工单」页的一个区块。 */
|
||||
/** 反馈页「加群二维码」卡配置。改完 App 意见反馈页下次进入即同步。「系统配置 → 反馈二维码」tab 的一个区块。 */
|
||||
export default function FeedbackQrConfig() {
|
||||
const [cfg, setCfg] = useState<QrConfig | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -5,6 +5,7 @@ import { App, Button, Card, Input, InputNumber, Space, Spin, Switch, Tabs, Tag,
|
||||
import { api, errMsg } from '@/lib/api';
|
||||
import HomeMarqueeSeeds from './HomeMarqueeSeeds';
|
||||
import HomeStatsConfig from './HomeStatsConfig';
|
||||
import FeedbackQrConfig from './FeedbackQrConfig';
|
||||
|
||||
interface ConfigItem {
|
||||
key: string;
|
||||
@@ -162,6 +163,7 @@ export default function ConfigPage() {
|
||||
),
|
||||
},
|
||||
{ key: 'welfare', label: '福利页', children: welfareConfig },
|
||||
{ key: 'feedback-qr', label: '反馈二维码', children: <FeedbackQrConfig /> },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
} from 'antd';
|
||||
import { api, errMsg } from '@/lib/api';
|
||||
import { canDo } from '@/lib/auth';
|
||||
import { formatUtcTime } from '@/lib/format';
|
||||
import { formatWallTime } from '@/lib/format';
|
||||
import { mediaUrl } from '@/lib/media';
|
||||
import type { CursorPage, Feedback } from '@/lib/types';
|
||||
|
||||
@@ -153,7 +153,7 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
|
||||
{/* 本条反馈 */}
|
||||
<div>
|
||||
<Text type="secondary">
|
||||
用户 {feedback.user_id} · {formatUtcTime(feedback.created_at)}
|
||||
用户 {feedback.user_id} · {formatWallTime(feedback.created_at)}
|
||||
</Text>
|
||||
<Paragraph style={{ whiteSpace: 'pre-wrap', marginTop: 8, marginBottom: 8 }}>
|
||||
{feedback.content || '-'}
|
||||
@@ -185,7 +185,7 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
|
||||
<div>
|
||||
状态:{statusTag(feedback.status)}
|
||||
{feedback.reviewed_at ? (
|
||||
<Text type="secondary"> · {formatUtcTime(feedback.reviewed_at)}</Text>
|
||||
<Text type="secondary"> · {formatWallTime(feedback.reviewed_at)}</Text>
|
||||
) : null}
|
||||
</div>
|
||||
{feedback.status === 'adopted' && (
|
||||
@@ -292,7 +292,7 @@ export default function FeedbackHandleDrawer({ feedback, open, onClose, onDone }
|
||||
>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
<Text type="secondary">
|
||||
#{h.id} · {formatUtcTime(h.created_at)}
|
||||
#{h.id} · {formatWallTime(h.created_at)}
|
||||
</Text>
|
||||
{statusTag(h.status)}
|
||||
</div>
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type { SorterResult } from 'antd/es/table/interface';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
DatePicker,
|
||||
Image,
|
||||
Input,
|
||||
Select,
|
||||
Space,
|
||||
Statistic,
|
||||
Table,
|
||||
Tag,
|
||||
Typography,
|
||||
} from 'antd';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import { api } from '@/lib/api';
|
||||
import { canDo } from '@/lib/auth';
|
||||
import { formatUtcTime } from '@/lib/format';
|
||||
import { formatWallTime } from '@/lib/format';
|
||||
import { usePagedList } from '@/lib/usePagedList';
|
||||
import type { Feedback } from '@/lib/types';
|
||||
import FeedbackQrConfig from './FeedbackQrConfig';
|
||||
import type { Feedback, FeedbackSummary } from '@/lib/types';
|
||||
import FeedbackHandleDrawer from './FeedbackHandleDrawer';
|
||||
import UserRecordsDrawer from '@/components/UserRecordsDrawer';
|
||||
|
||||
const { Text, Paragraph } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
@@ -41,6 +44,75 @@ const STATUS_META: Record<string, { label: string; color: string }> = {
|
||||
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>;
|
||||
};
|
||||
|
||||
// 审核结果展示(采纳=金币+批注 / 未采纳=原因 / 待审核=-),主表与「该用户全部反馈」抽屉共用
|
||||
const renderReview = (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>;
|
||||
};
|
||||
|
||||
// 机型 / OS版本(提交反馈时的端环境;改版前历史反馈无 → -)
|
||||
const renderDeviceOs = (f: Feedback) => {
|
||||
const os = [f.android_version ? `Android ${f.android_version}` : null, f.rom_name]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
if (!f.device_model && !os) return <Text type="secondary">-</Text>;
|
||||
return (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text>{f.device_model || '-'}</Text>
|
||||
{os ? (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{os}
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
|
||||
// 点手机号弹出的「该用户全部反馈」抽屉列(精简版:不含操作/手机号,避免抽屉里再套抽屉)
|
||||
const RECORD_COLUMNS: ColumnsType<Feedback> = [
|
||||
{ title: '提交时间', dataIndex: 'created_at', width: 150, render: (v: string) => formatWallTime(v) },
|
||||
{ title: '状态', dataIndex: 'status', width: 80, render: statusTag },
|
||||
{
|
||||
title: '内容',
|
||||
dataIndex: 'content',
|
||||
render: (v: string) =>
|
||||
v ? (
|
||||
<Paragraph
|
||||
style={{ marginBottom: 0, whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}
|
||||
ellipsis={{ rows: 2, expandable: true, symbol: '展开' }}
|
||||
>
|
||||
{v}
|
||||
</Paragraph>
|
||||
) : (
|
||||
<Text type="secondary">-</Text>
|
||||
),
|
||||
},
|
||||
{ title: '审核结果', key: 'review', width: 160, render: (_: unknown, f: Feedback) => renderReview(f) },
|
||||
];
|
||||
|
||||
export default function FeedbacksPage() {
|
||||
// 筛选草稿:点「查询」才应用(避免输入即刷新)
|
||||
const [status, setStatus] = useState<string | undefined>();
|
||||
@@ -58,6 +130,19 @@ export default function FeedbacksPage() {
|
||||
|
||||
const canReview = canDo(['operator']);
|
||||
|
||||
const [summary, setSummary] = useState<FeedbackSummary | null>(null);
|
||||
const loadSummary = async () => {
|
||||
try {
|
||||
const { data } = await api.get<FeedbackSummary>('/admin/api/feedbacks/summary');
|
||||
setSummary(data);
|
||||
} catch {
|
||||
/* 统计失败不阻塞列表 */
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
loadSummary();
|
||||
}, []);
|
||||
|
||||
// 审核/查看抽屉(采纳发金币 / 拒绝填原因 + 看该用户历史反馈)
|
||||
const [drawerFb, setDrawerFb] = useState<Feedback | null>(null);
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
@@ -66,6 +151,10 @@ export default function FeedbacksPage() {
|
||||
setDrawerOpen(true);
|
||||
};
|
||||
|
||||
// 点手机号:看该用户全部反馈
|
||||
const [recordsUser, setRecordsUser] = useState<{ userId: number; phone: string | null } | null>(null);
|
||||
const openUserRecords = (f: Feedback) => setRecordsUser({ userId: f.user_id, phone: f.phone });
|
||||
|
||||
const search = () =>
|
||||
setApplied({
|
||||
status,
|
||||
@@ -104,8 +193,41 @@ export default function FeedbacksPage() {
|
||||
sortBy === field ? (sortOrder === 'asc' ? 'ascend' : 'descend') : null;
|
||||
|
||||
const columns: ColumnsType<Feedback> = [
|
||||
{ title: 'ID', dataIndex: 'id', width: 70, sorter: true, sortOrder: sortOrderOf('id') },
|
||||
{ title: '用户', dataIndex: 'user_id', width: 80 },
|
||||
{
|
||||
title: '用户ID',
|
||||
dataIndex: 'user_id',
|
||||
width: 80,
|
||||
render: (v: number) => <Text strong>#{v}</Text>,
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
dataIndex: 'phone',
|
||||
width: 130,
|
||||
render: (_: unknown, f: Feedback) =>
|
||||
f.phone ? (
|
||||
<a onClick={() => openUserRecords(f)}>{f.phone}</a>
|
||||
) : (
|
||||
<Text type="secondary">无手机号</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '用户昵称',
|
||||
dataIndex: 'nickname',
|
||||
width: 120,
|
||||
render: (v: string | null) => v || <Text type="secondary">无昵称</Text>,
|
||||
},
|
||||
{
|
||||
title: '提交版本号',
|
||||
dataIndex: 'app_version',
|
||||
width: 100,
|
||||
render: (v: string | null) => v || <Text type="secondary">-</Text>,
|
||||
},
|
||||
{
|
||||
title: '机型 / OS版本',
|
||||
key: 'device',
|
||||
width: 150,
|
||||
render: (_: unknown, f: Feedback) => renderDeviceOs(f),
|
||||
},
|
||||
{
|
||||
title: '内容',
|
||||
dataIndex: 'content',
|
||||
@@ -145,49 +267,20 @@ export default function FeedbacksPage() {
|
||||
<Text type="secondary">无</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (s: string) => {
|
||||
const m = STATUS_META[s] ?? { label: s, color: 'default' };
|
||||
return <Tag color={m.color}>{m.label}</Tag>;
|
||||
},
|
||||
},
|
||||
{ title: '状态', dataIndex: 'status', width: 90, render: statusTag },
|
||||
{
|
||||
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>;
|
||||
},
|
||||
render: (_: unknown, f: Feedback) => renderReview(f),
|
||||
},
|
||||
{
|
||||
title: '时间',
|
||||
title: '提交时间',
|
||||
dataIndex: 'created_at',
|
||||
width: 170,
|
||||
sorter: true,
|
||||
sortOrder: sortOrderOf('created_at'),
|
||||
render: (v: string) => formatUtcTime(v),
|
||||
render: (v: string) => formatWallTime(v),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
@@ -204,8 +297,21 @@ export default function FeedbacksPage() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>反馈工单</h2>
|
||||
<FeedbackQrConfig />
|
||||
<h2>用户反馈</h2>
|
||||
<div style={{ display: 'flex', gap: 16, marginBottom: 16, flexWrap: 'wrap' }}>
|
||||
<Card size="small" style={{ minWidth: 120 }}>
|
||||
<Statistic title="待审核" value={summary?.pending ?? 0} valueStyle={{ color: '#fa8c16' }} />
|
||||
</Card>
|
||||
<Card size="small" style={{ minWidth: 120 }}>
|
||||
<Statistic title="已采纳" value={summary?.adopted ?? 0} valueStyle={{ color: '#52c41a' }} />
|
||||
</Card>
|
||||
<Card size="small" style={{ minWidth: 120 }}>
|
||||
<Statistic title="未采纳" value={summary?.rejected ?? 0} valueStyle={{ color: '#8c8c8c' }} />
|
||||
</Card>
|
||||
<Card size="small" style={{ minWidth: 120 }}>
|
||||
<Statistic title="合计" value={summary?.total ?? 0} />
|
||||
</Card>
|
||||
</div>
|
||||
<Space style={{ marginBottom: 16 }} wrap>
|
||||
<Select
|
||||
placeholder="状态"
|
||||
@@ -261,13 +367,27 @@ export default function FeedbacksPage() {
|
||||
onChange: onPageChange,
|
||||
}}
|
||||
onChange={onTableChange}
|
||||
scroll={{ x: 1610 }}
|
||||
/>
|
||||
|
||||
<FeedbackHandleDrawer
|
||||
feedback={drawerFb}
|
||||
open={drawerOpen}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
onDone={reload}
|
||||
onDone={() => { reload(); loadSummary(); }}
|
||||
/>
|
||||
|
||||
<UserRecordsDrawer<Feedback>
|
||||
open={recordsUser != null}
|
||||
onClose={() => setRecordsUser(null)}
|
||||
userId={recordsUser?.userId ?? null}
|
||||
phone={recordsUser?.phone ?? null}
|
||||
endpoint="/admin/api/feedbacks"
|
||||
columns={RECORD_COLUMNS}
|
||||
recordLabel="反馈"
|
||||
countLabel="提交总计"
|
||||
rewardLabel="提交奖励总计"
|
||||
rewardOf={(f) => (f.status === 'adopted' ? (f.reward_coins ?? 0) : 0)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
+27
-241
@@ -11,6 +11,7 @@ import {
|
||||
HeartOutlined,
|
||||
LogoutOutlined,
|
||||
MessageOutlined,
|
||||
MobileOutlined,
|
||||
MoneyCollectOutlined,
|
||||
NotificationOutlined,
|
||||
ProfileOutlined,
|
||||
@@ -19,65 +20,25 @@ import {
|
||||
TeamOutlined,
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { Avatar, Dropdown, Layout, Tooltip } from 'antd';
|
||||
import { Avatar, Dropdown, Layout, Menu } from 'antd';
|
||||
import { clearAuth, getAdmin, getToken } from '@/lib/auth';
|
||||
import type { AdminInfo } from '@/lib/types';
|
||||
|
||||
const { Sider, Header, Content } = Layout;
|
||||
|
||||
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: [
|
||||
const MENU = [
|
||||
{ key: '/dashboard', icon: <DashboardOutlined />, 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: '/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: '/ad-revenue', icon: <NotificationOutlined />, label: '广告配置' },
|
||||
{ key: '/ad-revenue-report', icon: <BarChartOutlined />, label: '广告收益' },
|
||||
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS 分发' },
|
||||
{ key: '/config', icon: <SettingOutlined />, label: '系统配置' },
|
||||
{ key: '/admins', icon: <TeamOutlined />, label: '管理员', superOnly: true },
|
||||
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
||||
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
||||
@@ -87,7 +48,6 @@ 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()) {
|
||||
@@ -99,19 +59,14 @@ 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)
|
||||
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();
|
||||
@@ -120,15 +75,7 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
|
||||
return (
|
||||
<Layout style={{ minHeight: '100vh' }}>
|
||||
<Sider
|
||||
theme="dark"
|
||||
breakpoint="lg"
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
collapsedWidth={72}
|
||||
width={220}
|
||||
onCollapse={setCollapsed}
|
||||
>
|
||||
<Sider theme="dark" breakpoint="lg" collapsible>
|
||||
<div
|
||||
style={{
|
||||
height: 48,
|
||||
@@ -141,61 +88,13 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
>
|
||||
运营后台
|
||||
</div>
|
||||
<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>
|
||||
<Menu
|
||||
theme="dark"
|
||||
mode="inline"
|
||||
selectedKeys={[selectedKey]}
|
||||
items={items}
|
||||
onClick={({ key }) => router.push(key)}
|
||||
/>
|
||||
</Sider>
|
||||
<Layout>
|
||||
<Header
|
||||
@@ -221,119 +120,6 @@ 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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
Typography,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type { SorterResult } from 'antd/es/table/interface';
|
||||
import { CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons';
|
||||
import dayjs from 'dayjs';
|
||||
import { api, errMsg } from '@/lib/api';
|
||||
@@ -23,6 +24,7 @@ import { canDo } from '@/lib/auth';
|
||||
import { mediaUrl } from '@/lib/media';
|
||||
import { usePagedList } from '@/lib/usePagedList';
|
||||
import type { PriceReport, PriceReportSummary } from '@/lib/types';
|
||||
import UserRecordsDrawer from '@/components/UserRecordsDrawer';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@@ -55,19 +57,112 @@ function statusTag(status: string) {
|
||||
return <Tag color={STATUS_COLOR[status]}>{STATUS_LABEL[status] || status}</Tag>;
|
||||
}
|
||||
|
||||
type SortField = 'id' | 'created_at';
|
||||
|
||||
// 门店/菜品、原价→上报价、审核结果:主表与「该用户全部上报」抽屉共用
|
||||
const renderStore = (r: PriceReport) => (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text>{r.store_name || '-'}</Text>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{r.dish_summary || '-'}
|
||||
</Text>
|
||||
</Space>
|
||||
);
|
||||
|
||||
const renderPrice = (r: PriceReport) => (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{r.original_platform_name || '原'}: {yuan(r.original_price_cents)}
|
||||
</Text>
|
||||
<Text strong style={{ color: '#fa541c' }}>
|
||||
{r.reported_platform_name}: {yuan(r.reported_price_cents)}
|
||||
</Text>
|
||||
</Space>
|
||||
);
|
||||
|
||||
// 只读审核结果(「审核结果」列 + 抽屉共用,不带操作按钮;待审核在「状态」列已显示,这里给 -)
|
||||
const renderResult = (r: PriceReport) => {
|
||||
if (r.status === 'approved') return <Text type="success">已发 {r.reward_coins ?? 0} 金币</Text>;
|
||||
if (r.status === 'rejected') return <Text type="secondary">拒绝: {r.reject_reason || '-'}</Text>;
|
||||
return <Text type="secondary">-</Text>;
|
||||
};
|
||||
|
||||
// Trace:与「比价记录」页一致 —— 有 trace_url(本地比价=localhost debug viewer,线上=公网)
|
||||
// 就给可点的「trace」链接,否则 -。
|
||||
const traceLink = (r: PriceReport) =>
|
||||
r.trace_url ? (
|
||||
<a href={r.trace_url} target="_blank" rel="noreferrer">
|
||||
trace
|
||||
</a>
|
||||
) : (
|
||||
<Text type="secondary">-</Text>
|
||||
);
|
||||
|
||||
// 机型 / OS版本(取自关联比价记录;无关联记录时为 -)
|
||||
const renderDeviceOs = (r: PriceReport) => {
|
||||
const os = [r.android_version ? `Android ${r.android_version}` : null, r.rom_name]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
if (!r.device_model && !os) return <Text type="secondary">-</Text>;
|
||||
return (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text>{r.device_model || '-'}</Text>
|
||||
{os ? (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{os}
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
|
||||
// 点手机号弹出的「该用户全部低价上报」抽屉列(精简版:不含操作/手机号)
|
||||
const RECORD_COLUMNS: ColumnsType<PriceReport> = [
|
||||
{ title: '提交时间', dataIndex: 'created_at', width: 150, render: (v: string) => dt(v) },
|
||||
{ title: '门店 / 菜品', key: 'store', width: 180, render: (_: unknown, r: PriceReport) => renderStore(r) },
|
||||
{ title: '原价 → 上报价', key: 'price', width: 200, render: (_: unknown, r: PriceReport) => renderPrice(r) },
|
||||
{ title: '状态', dataIndex: 'status', width: 90, render: statusTag },
|
||||
{ title: 'Trace', key: 'trace', width: 80, render: (_: unknown, r: PriceReport) => traceLink(r) },
|
||||
{ title: '结果', key: 'result', width: 150, render: (_: unknown, r: PriceReport) => renderResult(r) },
|
||||
];
|
||||
|
||||
export default function PriceReportsPage() {
|
||||
const { message, modal } = App.useApp();
|
||||
const [activeStatus, setActiveStatus] = useState('pending');
|
||||
const [summary, setSummary] = useState<PriceReportSummary | null>(null);
|
||||
const [rejecting, setRejecting] = useState<PriceReport | null>(null);
|
||||
const [rejectReason, setRejectReason] = useState('');
|
||||
// 提交时间列服务端排序(默认按提交时间倒序,最新在前)
|
||||
const [sortBy, setSortBy] = useState<SortField>('created_at');
|
||||
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
|
||||
// 点手机号:看该用户全部低价上报
|
||||
const [recordsUser, setRecordsUser] = useState<{ userId: number; phone: string | null } | null>(null);
|
||||
const openUserRecords = (r: PriceReport) => setRecordsUser({ userId: r.user_id, phone: r.phone });
|
||||
|
||||
const filters: Record<string, unknown> = {};
|
||||
const filters: Record<string, unknown> = { sort_by: sortBy, sort_order: sortOrder };
|
||||
if (activeStatus !== 'all') filters.status = activeStatus;
|
||||
|
||||
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
|
||||
usePagedList<PriceReport>('/admin/api/price-reports', filters);
|
||||
|
||||
const sortOrderOf = (field: SortField) =>
|
||||
sortBy === field ? (sortOrder === 'asc' ? 'ascend' : 'descend') : null;
|
||||
|
||||
const onTableChange = (
|
||||
_pagination: unknown,
|
||||
_filters: unknown,
|
||||
sorter: SorterResult<PriceReport> | SorterResult<PriceReport>[],
|
||||
) => {
|
||||
const s = Array.isArray(sorter) ? sorter[0] : sorter;
|
||||
if (s && s.order && s.field) {
|
||||
setSortBy(s.field as SortField);
|
||||
setSortOrder(s.order === 'ascend' ? 'asc' : 'desc');
|
||||
} else {
|
||||
setSortBy('created_at');
|
||||
setSortOrder('desc');
|
||||
}
|
||||
};
|
||||
|
||||
const canReview = canDo(['operator']);
|
||||
|
||||
const loadSummary = async () => {
|
||||
@@ -136,38 +231,51 @@ export default function PriceReportsPage() {
|
||||
|
||||
const columns: ColumnsType<PriceReport> = [
|
||||
{
|
||||
title: '用户',
|
||||
title: '用户ID',
|
||||
dataIndex: 'user_id',
|
||||
width: 90,
|
||||
width: 80,
|
||||
render: (v: number) => <Text strong>#{v}</Text>,
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
dataIndex: 'phone',
|
||||
width: 130,
|
||||
render: (_: unknown, r: PriceReport) =>
|
||||
r.phone ? (
|
||||
<a onClick={() => openUserRecords(r)}>{r.phone}</a>
|
||||
) : (
|
||||
<Text type="secondary">无手机号</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '用户昵称',
|
||||
dataIndex: 'nickname',
|
||||
width: 120,
|
||||
render: (v: string | null) => v || <Text type="secondary">无昵称</Text>,
|
||||
},
|
||||
{
|
||||
title: '提交版本号',
|
||||
dataIndex: 'app_version',
|
||||
width: 100,
|
||||
render: (v: string | null) => v || <Text type="secondary">-</Text>,
|
||||
},
|
||||
{
|
||||
title: '机型 / OS版本',
|
||||
key: 'device',
|
||||
width: 150,
|
||||
render: (_: unknown, r: PriceReport) => renderDeviceOs(r),
|
||||
},
|
||||
{
|
||||
title: '门店 / 菜品',
|
||||
key: 'store',
|
||||
width: 200,
|
||||
render: (_: unknown, r: PriceReport) => (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text>{r.store_name || '-'}</Text>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{r.dish_summary || '-'}
|
||||
</Text>
|
||||
</Space>
|
||||
),
|
||||
render: (_: unknown, r: PriceReport) => renderStore(r),
|
||||
},
|
||||
{
|
||||
title: '原最低价 → 上报价',
|
||||
key: 'price',
|
||||
width: 220,
|
||||
render: (_: unknown, r: PriceReport) => (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{r.original_platform_name || '原'}: {yuan(r.original_price_cents)}
|
||||
</Text>
|
||||
<Text strong style={{ color: '#fa541c' }}>
|
||||
{r.reported_platform_name}: {yuan(r.reported_price_cents)}
|
||||
</Text>
|
||||
</Space>
|
||||
),
|
||||
render: (_: unknown, r: PriceReport) => renderPrice(r),
|
||||
},
|
||||
{
|
||||
title: '截图证明',
|
||||
@@ -193,19 +301,33 @@ export default function PriceReportsPage() {
|
||||
),
|
||||
},
|
||||
{ title: '状态', dataIndex: 'status', width: 90, render: statusTag },
|
||||
{
|
||||
title: '审核结果',
|
||||
key: 'review',
|
||||
width: 160,
|
||||
render: (_: unknown, r: PriceReport) => renderResult(r),
|
||||
},
|
||||
{
|
||||
title: '提交时间',
|
||||
dataIndex: 'created_at',
|
||||
width: 150,
|
||||
sorter: true,
|
||||
sortOrder: sortOrderOf('created_at'),
|
||||
render: (v: string) => dt(v),
|
||||
},
|
||||
{
|
||||
title: '操作 / 结果',
|
||||
title: 'Trace',
|
||||
key: 'trace',
|
||||
width: 80,
|
||||
render: (_: unknown, r: PriceReport) => traceLink(r),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'op',
|
||||
fixed: 'right',
|
||||
width: 200,
|
||||
width: 150,
|
||||
render: (_: unknown, r: PriceReport) => {
|
||||
if (r.status === 'pending') {
|
||||
if (r.status !== 'pending') return <Text type="secondary">-</Text>;
|
||||
if (!canReview) return <Text type="secondary">无审核权限</Text>;
|
||||
return (
|
||||
<Space>
|
||||
@@ -231,14 +353,6 @@ export default function PriceReportsPage() {
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
if (r.status === 'approved') {
|
||||
return <Text type="success">已发 {r.reward_coins ?? 0} 金币</Text>;
|
||||
}
|
||||
if (r.status === 'rejected') {
|
||||
return <Text type="secondary">拒绝: {r.reject_reason || '-'}</Text>;
|
||||
}
|
||||
return <Text type="secondary">-</Text>;
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -247,7 +361,7 @@ export default function PriceReportsPage() {
|
||||
<div>
|
||||
<Space direction="vertical" style={{ marginBottom: 16 }}>
|
||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||
上报审核
|
||||
低价审核
|
||||
</Typography.Title>
|
||||
<Text type="secondary">
|
||||
用户上报「某平台更低价」+ 截图,人工核实后通过发放 1000 金币奖励、拒绝需填理由。用户在 app
|
||||
@@ -255,14 +369,20 @@ export default function PriceReportsPage() {
|
||||
</Text>
|
||||
</Space>
|
||||
|
||||
{summary && (
|
||||
<Space size="large" style={{ marginBottom: 16 }}>
|
||||
<Statistic title="待审核" value={summary.pending} valueStyle={{ color: '#faad14' }} />
|
||||
<Statistic title="已通过" value={summary.approved} valueStyle={{ color: '#52c41a' }} />
|
||||
<Statistic title="已拒绝" value={summary.rejected} />
|
||||
<Statistic title="合计" value={summary.total} />
|
||||
</Space>
|
||||
)}
|
||||
<div style={{ display: 'flex', gap: 16, marginBottom: 16, flexWrap: 'wrap' }}>
|
||||
<Card size="small" style={{ minWidth: 120 }}>
|
||||
<Statistic title="待审核" value={summary?.pending ?? 0} valueStyle={{ color: '#fa8c16' }} />
|
||||
</Card>
|
||||
<Card size="small" style={{ minWidth: 120 }}>
|
||||
<Statistic title="已通过" value={summary?.approved ?? 0} valueStyle={{ color: '#52c41a' }} />
|
||||
</Card>
|
||||
<Card size="small" style={{ minWidth: 120 }}>
|
||||
<Statistic title="已拒绝" value={summary?.rejected ?? 0} valueStyle={{ color: '#8c8c8c' }} />
|
||||
</Card>
|
||||
<Card size="small" style={{ minWidth: 120 }}>
|
||||
<Statistic title="合计" value={summary?.total ?? 0} />
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<Tabs
|
||||
@@ -275,6 +395,7 @@ export default function PriceReportsPage() {
|
||||
columns={columns}
|
||||
dataSource={items}
|
||||
loading={loading}
|
||||
onChange={onTableChange}
|
||||
pagination={{
|
||||
current: page,
|
||||
pageSize,
|
||||
@@ -283,7 +404,7 @@ export default function PriceReportsPage() {
|
||||
showTotal: (t) => `共 ${t} 条`,
|
||||
onChange: onPageChange,
|
||||
}}
|
||||
scroll={{ x: 1100 }}
|
||||
scroll={{ x: 1790 }}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
@@ -320,6 +441,19 @@ export default function PriceReportsPage() {
|
||||
</Space>
|
||||
)}
|
||||
</Modal>
|
||||
|
||||
<UserRecordsDrawer<PriceReport>
|
||||
open={recordsUser != null}
|
||||
onClose={() => setRecordsUser(null)}
|
||||
userId={recordsUser?.userId ?? null}
|
||||
phone={recordsUser?.phone ?? null}
|
||||
endpoint="/admin/api/price-reports"
|
||||
columns={RECORD_COLUMNS}
|
||||
recordLabel="低价上报"
|
||||
countLabel="上报总计"
|
||||
rewardLabel="上报奖励总计"
|
||||
rewardOf={(r) => (r.status === 'approved' ? (r.reward_coins ?? 0) : 0)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
'use client';
|
||||
|
||||
// 点列表里的手机号 → 抽屉列出该用户「同类型」的全部记录(反馈页=全部反馈;低价审核页=全部上报)。
|
||||
// 顶部汇总该用户的「提交/上报总计」+「奖励总计」;复用各自的 list 接口按 user_id 过滤(无需新后端接口)。
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Drawer, Empty, Space, Spin, Statistic, Table, Typography } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { api } from '@/lib/api';
|
||||
import type { CursorPage } from '@/lib/types';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
interface Props<T> {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
userId: number | null;
|
||||
phone: string | null;
|
||||
endpoint: string; // 列表接口,按 user_id 过滤,如 /admin/api/feedbacks
|
||||
columns: ColumnsType<T>;
|
||||
recordLabel: string; // 「反馈」/「低价上报」,用于标题与空态文案
|
||||
countLabel: string; // 顶部计数卡标题,如「提交总计」/「上报总计」
|
||||
rewardLabel: string; // 顶部奖励卡标题,如「提交奖励总计」/「上报奖励总计」
|
||||
rewardOf: (item: T) => number; // 单条已发奖励金币(未采纳/未通过返回 0)
|
||||
}
|
||||
|
||||
export default function UserRecordsDrawer<T extends { id: number }>({
|
||||
open,
|
||||
onClose,
|
||||
userId,
|
||||
phone,
|
||||
endpoint,
|
||||
columns,
|
||||
recordLabel,
|
||||
countLabel,
|
||||
rewardLabel,
|
||||
rewardOf,
|
||||
}: Props<T>) {
|
||||
const [items, setItems] = useState<T[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || userId == null) return;
|
||||
let alive = true;
|
||||
setLoading(true);
|
||||
api
|
||||
.get<CursorPage<T>>(endpoint, {
|
||||
params: { user_id: userId, limit: 100, sort_by: 'created_at', sort_order: 'desc' },
|
||||
})
|
||||
.then((r) => {
|
||||
if (!alive) return;
|
||||
setItems(r.data.items);
|
||||
setTotal(r.data.total ?? r.data.items.length);
|
||||
})
|
||||
.catch(() => {
|
||||
if (!alive) return;
|
||||
setItems([]);
|
||||
setTotal(0);
|
||||
})
|
||||
.finally(() => {
|
||||
if (alive) setLoading(false);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [open, userId, endpoint]);
|
||||
|
||||
// 奖励总计在已加载记录上累加(单用户记录数远小于 100 上限,够用)
|
||||
const rewardTotal = items.reduce((sum, it) => sum + rewardOf(it), 0);
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
title={
|
||||
<span>
|
||||
用户 #{userId ?? '-'} 的全部{recordLabel}
|
||||
{phone ? (
|
||||
<Text type="secondary" style={{ fontSize: 13, marginLeft: 8 }}>
|
||||
{phone}
|
||||
</Text>
|
||||
) : null}
|
||||
</span>
|
||||
}
|
||||
width={760}
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
destroyOnHidden
|
||||
>
|
||||
{loading ? (
|
||||
<Spin style={{ display: 'block', margin: '40px auto' }} />
|
||||
) : (
|
||||
<>
|
||||
<Space size={48} style={{ marginBottom: 20 }}>
|
||||
<Statistic title={countLabel} value={total} />
|
||||
<Statistic title={rewardLabel} value={rewardTotal} suffix="金币" />
|
||||
</Space>
|
||||
{items.length === 0 ? (
|
||||
<Empty description={`该用户暂无${recordLabel}`} style={{ marginTop: 24 }} />
|
||||
) : (
|
||||
<Table<T>
|
||||
rowKey="id"
|
||||
size="small"
|
||||
columns={columns}
|
||||
dataSource={items}
|
||||
pagination={false}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
+28
-76
@@ -247,6 +247,22 @@ export interface Feedback {
|
||||
reviewed_by_admin_id: number | null;
|
||||
reviewed_at: string | null;
|
||||
created_at: string;
|
||||
// 提交端环境快照:提交版本号 / 机型OS版本;改版前的历史反馈为 null
|
||||
app_version: string | null;
|
||||
device_model: string | null;
|
||||
rom_name: string | null;
|
||||
android_version: string | null;
|
||||
// 联表瞬态:展示完整手机号(点手机号查该用户全部反馈)
|
||||
phone: string | null;
|
||||
nickname: string | null;
|
||||
}
|
||||
|
||||
// 反馈审核台顶部各状态计数(pending 含历史 new 态)。后端 GET /admin/api/feedbacks/summary。
|
||||
export interface FeedbackSummary {
|
||||
pending: number;
|
||||
adopted: number;
|
||||
rejected: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
// 反馈页「加群二维码」卡配置(运营后台改 → App 意见反馈页同步)。
|
||||
@@ -391,12 +407,6 @@ export interface AdRevenueTypeStat {
|
||||
revenue_yuan: number; // 该类型预估收益合计(元)
|
||||
}
|
||||
|
||||
export interface AdRevenueTypeBreakdown extends AdRevenueTypeStat {
|
||||
ad_type: string;
|
||||
expected_coin: number;
|
||||
actual_coin: number;
|
||||
}
|
||||
|
||||
// 广告收益报表:一次广告事件(逐条一行)。激励视频展示+发奖按 ad_session_id 合并;信息流展示/发奖各自成行。
|
||||
export interface AdRevenueRow {
|
||||
event_key: string; // 事件稳定唯一键(前端 rowKey)
|
||||
@@ -442,52 +452,9 @@ export interface AdRevenueReport {
|
||||
total_expected_coin: number;
|
||||
total_actual_coin: number;
|
||||
mismatch_count: number; // 应发≠实发的发奖条数
|
||||
by_ad_type?: Record<string, AdRevenueTypeBreakdown>;
|
||||
items: AdRevenueRow[];
|
||||
}
|
||||
|
||||
export interface DashboardPeriodTrendPoint {
|
||||
date: string;
|
||||
active_users: number;
|
||||
new_users: number;
|
||||
comparisons: number;
|
||||
}
|
||||
|
||||
export interface DashboardPeriodStats {
|
||||
date_from: string;
|
||||
date_to: string;
|
||||
users: {
|
||||
new: number;
|
||||
active: number;
|
||||
retained_new_users: number;
|
||||
retention_rate: number | null;
|
||||
retention_note: string;
|
||||
};
|
||||
comparison: {
|
||||
total: number;
|
||||
success: number;
|
||||
success_rate: number;
|
||||
ordered: number;
|
||||
average_duration_ms: number | null;
|
||||
average_saved_cents: number | null;
|
||||
};
|
||||
coins: {
|
||||
granted_total: number;
|
||||
reward_video_coin_total: number;
|
||||
feed_ad_coin_total: number;
|
||||
signin_coin_total: number;
|
||||
signin_boost_coin_total: number;
|
||||
task_coin_total: number;
|
||||
coupon_reward_coin_total: number;
|
||||
comparison_reward_coin_total: number;
|
||||
regular_task_coin_total: number;
|
||||
};
|
||||
cash: {
|
||||
withdraw_success_cents: number;
|
||||
};
|
||||
trend: DashboardPeriodTrendPoint[];
|
||||
}
|
||||
|
||||
export interface DashboardOverview {
|
||||
users: {
|
||||
total: number;
|
||||
@@ -497,17 +464,7 @@ export interface DashboardOverview {
|
||||
new_today: number;
|
||||
dau: number;
|
||||
};
|
||||
coins: {
|
||||
granted_total: number;
|
||||
reward_video_coin_total?: number;
|
||||
reward_video_watch_count?: number;
|
||||
feed_ad_coin_total?: number;
|
||||
feed_ad_watch_count?: number;
|
||||
signin_coin_total?: number;
|
||||
signin_count?: number;
|
||||
signin_boost_coin_total?: number;
|
||||
signin_boost_watch_count?: number;
|
||||
};
|
||||
coins: { granted_total: number };
|
||||
cash: {
|
||||
withdraw_success_cents: number;
|
||||
withdraw_pending_count: number;
|
||||
@@ -515,23 +472,8 @@ export interface DashboardOverview {
|
||||
withdraw_failed_count: number;
|
||||
};
|
||||
comparison: { total: number; success: number; success_rate: number };
|
||||
period: DashboardPeriodStats;
|
||||
feedback: { new: number };
|
||||
cps: {
|
||||
available: boolean;
|
||||
note: string;
|
||||
meituan_order_count?: number;
|
||||
meituan_commission_cents?: number;
|
||||
meituan_hit_count?: number;
|
||||
meituan_miss_count?: number;
|
||||
meituan_unknown_rate_count?: number;
|
||||
meituan_hit_rate?: number | null;
|
||||
jd_order_count?: number;
|
||||
jd_commission_cents?: number;
|
||||
jd_actual_commission_cents?: number;
|
||||
jd_estimated_commission_cents?: number;
|
||||
jd_invalid_count?: number;
|
||||
};
|
||||
cps: { available: boolean; note: string };
|
||||
}
|
||||
|
||||
export interface PriceReport {
|
||||
@@ -552,6 +494,16 @@ export interface PriceReport {
|
||||
reward_coins: number | null;
|
||||
reviewed_at: string | null;
|
||||
created_at: string;
|
||||
// 联表瞬态:phone/nickname 展示完整手机号(点手机号查该用户全部上报);
|
||||
// 其余取自关联比价记录(无关联记录时为 null):trace 调试链接、机型OS版本、提交版本号
|
||||
phone: string | null;
|
||||
nickname: string | null;
|
||||
trace_id: string | null;
|
||||
trace_url: string | null;
|
||||
device_model: string | null; // 机型,如 PEEM00
|
||||
rom_name: string | null; // ROM/OS 名,如 ColorOS / MIUI / HarmonyOS
|
||||
android_version: string | null; // Android 版本号,如 13
|
||||
app_version: string | null; // 提交时我们 app 的 versionName,如 1.2.3
|
||||
}
|
||||
|
||||
export interface PriceReportSummary {
|
||||
|
||||
Reference in New Issue
Block a user