Compare commits

..

7 Commits

Author SHA1 Message Date
linkeyu 59748c7b7f fix(admin): 避免徽标刷新响应乱序 2026-07-22 09:49:54 +08:00
linkeyu c3b77479a0 fix(admin): 审核完成后刷新菜单徽标 2026-07-22 09:47:54 +08:00
linkeyu 374ac1fd90 feat(admin): 审核菜单增加未处理数量徽标 2026-07-21 16:04:29 +08:00
linkeyu 3f5356ad87 feat(admin): 领券完成率和点位成功率展示计算明细 (#53)
## 变更内容
- 将汇总卡“领券成功率”明确为“领券完成率”
- 提示中动态展示完成数、发起数、中途退出数及本期代入计算结果
- 点位成功率提示逐券展示成功数、尝试数、单券成功率和最终等权平均结果
- 展示累计成功/尝试数作为辅助核对,并明确不作为当前加权公式

## 验证
- npx tsc --noEmit
- npm run build

---------

Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #53
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-21 11:59:50 +08:00
linkeyu c90775d09c fix(admin): 领券广告收益未填充时显示明确文案 (#54)
原 MR #52 已合并到功能分支,无法修改目标分支。本 MR 将同一项“领券广告收益未填充时显示明确文案”修复独立提交到 main,不包含后台看板功能分支的其他提交。

验证:npx tsc --noEmit;npm run build。

Reviewed-on: #54
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-21 11:59:35 +08:00
zuochenyong fb91dca192 feat(huawei-review): 华为审核开关配置页 (#51)
「数据配置」组下新增「华为审核开关」页,两态单选(不能关闭 / 可关闭)+ 保存,
展示当前生效值与最后修改时间。页面文案写清生效范围,避免过审后忘记切回:
仅华为 ROM 生效(荣耀 MagicOS 不受影响)、只影响快速设置步、客户端重进 App 才变。

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

---------

Co-authored-by: 左辰勇 <exinglang@gmail.com>
Reviewed-on: #51
Co-authored-by: zuochenyong <zuochenyong@wonderable.ai>
Co-committed-by: zuochenyong <zuochenyong@wonderable.ai>
2026-07-21 10:49:10 +08:00
linkeyu 86086b1275 feat(admin): 优化后台看板及数据记录页(日期可选) (#50)
## 修改内容
- 数据大盘顶部日期改为可点击、可选择的日期范围控件
- 点击日期区域强制展开日历,选中后自动刷新看板
- 日期完整显示为 `YYYY-MM-DD`,禁选今日及未来日期
- 固定后台侧边栏并调整菜单顺序
- 优化数据大盘比价、领券、商业化核心指标及趋势
- 完善领券记录、比价记录、广告收益页面的筛选、统计口径和明细列

## 关键口径
- 比价完成次数:成功 + 失败,不包含中途退出
- 比价成功率:成功次数 /(发起次数 - 中途退出次数)
- 领券成功率:完成数 /(发起数 - 中途退出数)
- 比价耗时统计排除中途退出

## 验证
- `npm run build` 通过
- TypeScript、Lint、静态页面生成通过
- 旧合并请求 #49 已关闭且未合并

## 后端依赖
- 领券逐场点位成功率及逐点明细仍需接口返回相应字段
- 广告逐条明细的来源广告网络仍需 `sub_rewards` 返回 ADN 字段

---------

Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #50
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-21 10:11:11 +08:00
7 changed files with 267 additions and 14 deletions
+40 -9
View File
@@ -137,11 +137,6 @@ const slotRateMean = (rows: CouponSlotRow[]): number | null => {
return rates.length ? rates.reduce((a, b) => a + b, 0) / rates.length : null;
};
// 汇总卡成功率口径 tooltip 文案
const POINT_RATE_HINT =
'点位成功率(合计):当前区间内全部券成功率的算术平均(每张券等权);' +
'单券成功率=成功(含已领)÷尝试(不含跳过),源自领券每券记录。';
// 按券表:coupon_id 平台 → 中文
const SLOT_PLATFORM: Record<string, string> = {
'meituan-waimai': '美团',
@@ -597,6 +592,10 @@ export default function CouponDataPage() {
const successDenominator = summary ? Math.max(0, summary.started_count - abandonedCount) : 0;
const couponSuccessRate =
summary && successDenominator > 0 ? summary.completed_count / successDenominator : null;
const validCouponSlots = couponSlots.filter((r) => r.success_rate != null);
const pointSuccessRate = slotRateMean(validCouponSlots);
const pointSucceededTotal = validCouponSlots.reduce((total, r) => total + r.succeeded, 0);
const pointTriedTotal = validCouponSlots.reduce((total, r) => total + r.tried, 0);
const items = data?.items ?? [];
return (
@@ -714,8 +713,19 @@ export default function CouponDataPage() {
<Statistic
title={
<span>
{' '}
<Tooltip title="领券完成数 ÷(领券发起数-中途退出数)">
{' '}
<Tooltip
overlayStyle={{ maxWidth: 520 }}
title={
<div>
<div> ÷退</div>
<div style={{ marginTop: 6 }}>
{summary.completed_count} ÷{summary.started_count}{abandonedCount}
{fmtPct(couponSuccessRate)}
</div>
</div>
}
>
<InfoCircleOutlined style={{ color: '#999' }} />
</Tooltip>
</span>
@@ -728,12 +738,33 @@ export default function CouponDataPage() {
title={
<span>
{' '}
<Tooltip title={POINT_RATE_HINT}>
<Tooltip
overlayStyle={{ maxWidth: 560 }}
title={
<div>
<div></div>
<div>÷ </div>
<div style={{ marginTop: 6 }}>
{validCouponSlots.length}
</div>
{validCouponSlots.map((slot) => (
<div key={slot.coupon_id}>
{slot.coupon_name || slot.coupon_id}{slot.succeeded} ÷ {slot.tried}
{fmtPct(slot.success_rate)}
</div>
))}
<div style={{ marginTop: 6 }}>
{fmtPct(pointSuccessRate)}/
{pointSucceededTotal}/{pointTriedTotal}
</div>
</div>
}
>
<InfoCircleOutlined style={{ color: '#999' }} />
</Tooltip>
</span>
}
value={fmtPct(slotRateMean(couponSlots))}
value={fmtPct(pointSuccessRate)}
/>
</Col>
<Col flex="1 1 0">
+6 -1
View File
@@ -20,6 +20,7 @@ import type { Dayjs } from 'dayjs';
import { api } from '@/lib/api';
import { canDo } from '@/lib/auth';
import { formatWallTime } from '@/lib/format';
import { refreshReviewBadge } from '@/lib/reviewBadge';
import { usePagedList } from '@/lib/usePagedList';
import type { Feedback, FeedbackSummary } from '@/lib/types';
import FeedbackHandleDrawer from './FeedbackHandleDrawer';
@@ -431,7 +432,11 @@ export default function FeedbacksPage() {
feedback={drawerFb}
open={drawerOpen}
onClose={() => setDrawerOpen(false)}
onDone={() => { reload(); loadSummary(); }}
onDone={() => {
reload();
loadSummary();
refreshReviewBadge('/feedbacks');
}}
/>
<UserRecordsDrawer<Feedback>
+103
View File
@@ -0,0 +1,103 @@
'use client';
import { useCallback, useEffect, useState } from 'react';
import { Alert, App, Button, Card, Descriptions, Radio, Skeleton, Tag } from 'antd';
import { api, errMsg } from '@/lib/api';
import { formatUtcTime } from '@/lib/format';
// 华为审核开关:控制新手引导「快速设置」权限步能否被用户退出。
// 华为应用市场审核要求该页必须可关闭(引导视频页不在要求内),平时保持「不能关闭」以保住权限开启率,
// 送审期间切「可关闭」。落在 app_config 的 huawei_review 行,客户端经 /api/v1/platform/huawei-review 拉。
type Mode = 'default' | 'review';
interface HuaweiReview {
mode: Mode;
updated_at: string | null;
}
const MODE_LABEL: Record<Mode, string> = {
default: '不能关闭',
review: '可关闭',
};
export default function HuaweiReviewPage() {
const { message } = App.useApp();
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
// saved = 服务端当前值(用于「有没有改动」判断);mode = 编辑中的值
const [saved, setSaved] = useState<HuaweiReview | null>(null);
const [mode, setMode] = useState<Mode>('default');
const load = useCallback(async () => {
try {
const r = await api.get<HuaweiReview>('/admin/api/huawei-review');
setSaved(r.data);
setMode(r.data.mode);
} catch (e) {
message.error(errMsg(e, '华为审核开关加载失败'));
} finally {
setLoading(false);
}
}, [message]);
useEffect(() => {
load();
}, [load]);
const save = async () => {
setSaving(true);
try {
const r = await api.patch<HuaweiReview>('/admin/api/huawei-review', { mode });
setSaved(r.data);
setMode(r.data.mode);
message.success('已保存。客户端下次进新手引导时拉取生效');
} catch (e) {
message.error(errMsg(e, '保存失败'));
} finally {
setSaving(false);
}
};
const dirty = saved !== null && saved.mode !== mode;
return (
<Card
title="华为审核开关"
extra={
<Button type="primary" loading={saving} disabled={loading || !dirty} onClick={save}>
</Button>
}
>
<Alert
type="info"
style={{ marginBottom: 16 }}
message="华为应用市场审核要求「快速设置」页必须可以关闭。切到「可关闭」后,该页左上角出现退出按钮(返回键同样可退出),用户点了直接进 App 首页、本次引导视为已完成。"
description="① 只对华为机型(HarmonyOS / EMUI)生效,荣耀 MagicOS 及其它机型不受影响;② 只影响快速设置权限步,引导视频页照旧必须看完;③ 客户端在进引导前拉一次并缓存,已经停在引导页的用户要重进 App 才会变;④ 审核通过后记得切回「不能关闭」,不然会一直损失权限开启率。"
/>
{loading ? (
<Skeleton active paragraph={{ rows: 3 }} />
) : (
<>
<Descriptions column={1} style={{ marginBottom: 16 }}>
<Descriptions.Item label="当前生效">
{saved ? (
<Tag color={saved.mode === 'review' ? 'orange' : 'green'}>{MODE_LABEL[saved.mode]}</Tag>
) : (
'-'
)}
</Descriptions.Item>
<Descriptions.Item label="最后修改">
{saved?.updated_at ? formatUtcTime(saved.updated_at) : '从未修改过(默认不能关闭)'}
</Descriptions.Item>
</Descriptions>
<div style={{ marginBottom: 8 }}></div>
<Radio.Group value={mode} onChange={(e) => setMode(e.target.value as Mode)}>
<Radio.Button value="default"></Radio.Button>
<Radio.Button value="review"></Radio.Button>
</Radio.Group>
</>
)}
</Card>
);
}
+101 -4
View File
@@ -1,6 +1,6 @@
'use client';
import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import { usePathname, useRouter } from 'next/navigation';
import {
BarChartOutlined,
@@ -16,6 +16,7 @@ import {
MoneyCollectOutlined,
NotificationOutlined,
ProfileOutlined,
SafetyCertificateOutlined,
SettingOutlined,
ShareAltOutlined,
TeamOutlined,
@@ -24,7 +25,16 @@ import {
import { Avatar, Dropdown, Layout, Tooltip } from 'antd';
import { api } from '@/lib/api';
import { clearAuth, getAdmin, getToken, setAuth } from '@/lib/auth';
import type { AdminInfo } from '@/lib/types';
import {
REVIEW_BADGE_REFRESH_EVENT,
type ReviewBadgeKey,
} from '@/lib/reviewBadge';
import type {
AdminInfo,
FeedbackSummary,
PriceReportSummary,
WithdrawSummary,
} from '@/lib/types';
const { Sider, Header, Content } = Layout;
@@ -78,6 +88,7 @@ const NAV_GROUPS: NavGroup[] = [
children: [
{ key: '/config', icon: <SettingOutlined />, label: '系统配置' },
{ key: '/ad-revenue', icon: <NotificationOutlined />, label: '广告配置' },
{ key: '/huawei-review', icon: <SafetyCertificateOutlined />, label: '华为审核开关' },
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
],
},
@@ -94,6 +105,8 @@ export default function MainLayout({ children }: { children: React.ReactNode })
const pathname = usePathname();
const [admin, setAdmin] = useState<AdminInfo | null>(null);
const [collapsed, setCollapsed] = useState(false);
const [pendingReviewCounts, setPendingReviewCounts] = useState<Partial<Record<ReviewBadgeKey, number>>>({});
const reviewRefreshVersion = useRef<Partial<Record<ReviewBadgeKey, number>>>({});
useEffect(() => {
const token = getToken();
@@ -112,6 +125,44 @@ export default function MainLayout({ children }: { children: React.ReactNode })
.catch(() => {});
}, [router]);
useEffect(() => {
if (!admin) return;
const canAccess = (page: string) =>
admin.role === 'super_admin' || !admin.pages || admin.pages.includes(page);
const refresh = async (key: ReviewBadgeKey) => {
if (!canAccess(key.slice(1))) return;
const version = (reviewRefreshVersion.current[key] ?? 0) + 1;
reviewRefreshVersion.current[key] = version;
let count: number;
if (key === '/withdraws') {
count = (await api.get<WithdrawSummary>('/admin/api/withdraws/summary')).data.reviewing_count;
} else if (key === '/price-reports') {
count = (await api.get<PriceReportSummary>('/admin/api/price-reports/summary')).data.pending;
} else {
count = (await api.get<FeedbackSummary>('/admin/api/feedbacks/summary')).data.pending;
}
if (reviewRefreshVersion.current[key] !== version) return;
setPendingReviewCounts((current) => ({ ...current, [key]: count }));
};
const refreshSafely = (key: ReviewBadgeKey) => refresh(key).catch(() => {});
void Promise.all([
refreshSafely('/withdraws'),
refreshSafely('/price-reports'),
refreshSafely('/feedbacks'),
]);
const onReviewCompleted = (event: Event) => {
const key = (event as CustomEvent<ReviewBadgeKey>).detail;
if (key) void refreshSafely(key);
};
window.addEventListener(REVIEW_BADGE_REFRESH_EVENT, onReviewCompleted);
return () => {
window.removeEventListener(REVIEW_BADGE_REFRESH_EVENT, onReviewCompleted);
};
}, [admin]);
if (!admin) return null; // 守卫期间不闪烁内容
// 选中态:取路径一级(/users/123 -> /users)
@@ -130,6 +181,20 @@ export default function MainLayout({ children }: { children: React.ReactNode })
hasChildren(group) ? group.children : [group],
);
const reviewBadge = (key: string) => {
const count = pendingReviewCounts[key as ReviewBadgeKey] ?? 0;
if (count <= 0) return null;
return (
<span
className="nav-review-badge"
aria-label={`${count} 条未审核`}
title={`${count} 条未审核`}
>
{count}
</span>
);
};
const logout = () => {
clearAuth();
router.replace('/login');
@@ -164,6 +229,7 @@ export default function MainLayout({ children }: { children: React.ReactNode })
aria-label={item.label}
>
{item.icon}
{reviewBadge(item.key)}
</button>
</Tooltip>
))
@@ -181,7 +247,8 @@ export default function MainLayout({ children }: { children: React.ReactNode })
onClick={() => router.push(group.key)}
>
<span className="nav-primary-icon">{group.icon}</span>
<span>{group.label}</span>
<span className="nav-item-label">{group.label}</span>
{reviewBadge(group.key)}
</button>
);
}
@@ -200,7 +267,8 @@ export default function MainLayout({ children }: { children: React.ReactNode })
onClick={() => router.push(child.key)}
>
<span className="nav-child-icon">{child.icon}</span>
<span>{child.label}</span>
<span className="nav-item-label">{child.label}</span>
{reviewBadge(child.key)}
</button>
))}
</div>
@@ -267,6 +335,29 @@ export default function MainLayout({ children }: { children: React.ReactNode })
color: rgba(255, 255, 255, 0.72);
font-size: 16px;
}
.nav-item-label {
min-width: 0;
flex: 1;
}
.nav-review-badge {
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
flex: 0 0 auto;
min-width: 18px;
height: 18px;
padding: 0 5px;
border-radius: 9px;
background: #ff4d4f;
color: #fff;
font-size: 11px;
font-weight: 600;
line-height: 18px;
white-space: nowrap;
font-variant-numeric: tabular-nums;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.nav-direct,
.nav-child,
.nav-icon-button {
@@ -330,6 +421,7 @@ export default function MainLayout({ children }: { children: React.ReactNode })
padding: 0 8px 14px;
}
.nav-icon-button {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
@@ -340,6 +432,11 @@ export default function MainLayout({ children }: { children: React.ReactNode })
color: rgba(255, 255, 255, 0.72);
font-size: 17px;
}
.nav-icon-button .nav-review-badge {
position: absolute;
top: 1px;
right: -6px;
}
.nav-icon-button:hover,
.nav-icon-button.is-selected {
background: #1677ff;
+3
View File
@@ -22,6 +22,7 @@ import dayjs from 'dayjs';
import { api, errMsg } from '@/lib/api';
import { canDo } from '@/lib/auth';
import { mediaUrl } from '@/lib/media';
import { refreshReviewBadge } from '@/lib/reviewBadge';
import { usePagedList } from '@/lib/usePagedList';
import type { PriceReport, PriceReportSummary } from '@/lib/types';
import UserRecordsDrawer from '@/components/UserRecordsDrawer';
@@ -202,6 +203,7 @@ export default function PriceReportsPage() {
onOk: async () => {
try {
await api.post(`/admin/api/price-reports/${r.id}/approve`);
refreshReviewBadge('/price-reports');
message.success('已通过,已发放 1000 金币');
refreshAfterChange();
} catch (e) {
@@ -220,6 +222,7 @@ export default function PriceReportsPage() {
}
try {
await api.post(`/admin/api/price-reports/${rejecting.id}/reject`, { reason });
refreshReviewBadge('/price-reports');
message.success('已拒绝');
setRejecting(null);
setRejectReason('');
+4
View File
@@ -39,6 +39,7 @@ import dayjs, { type Dayjs } from 'dayjs';
import { api, errMsg } from '@/lib/api';
import { canDo } from '@/lib/auth';
import { formatUtcTime, utcDayjs, utcFromNow, yuan } from '@/lib/format';
import { refreshReviewBadge } from '@/lib/reviewBadge';
import { usePagedList } from '@/lib/usePagedList';
import type {
AuditLog,
@@ -332,6 +333,7 @@ export default function WithdrawsPage() {
onOk: async () => {
try {
await api.post(`/admin/api/withdraws/${o.out_bill_no}/approve`);
refreshReviewBadge('/withdraws');
message.success('已通过审核并发起打款');
await refreshAfterChange(o.out_bill_no);
} catch (e) {
@@ -362,6 +364,7 @@ export default function WithdrawsPage() {
await api.post(`/admin/api/withdraws/${targets[0].out_bill_no}/reject`, { reason: trimmed });
message.success('已拒绝并退回余额');
}
refreshReviewBadge('/withdraws');
setRejecting(null);
setBulkRejecting([]);
setRejectReason('');
@@ -400,6 +403,7 @@ export default function WithdrawsPage() {
const { data } = await api.post<WithdrawBulkResult>('/admin/api/withdraws/bulk/approve', {
out_bill_nos: selectedReviewing.map((item) => item.out_bill_no),
});
refreshReviewBadge('/withdraws');
const text = bulkResultText('批量通过完成', data);
if (data.failed) message.warning(text);
else message.success(text);
+10
View File
@@ -0,0 +1,10 @@
export type ReviewBadgeKey = '/withdraws' | '/price-reports' | '/feedbacks';
export const REVIEW_BADGE_REFRESH_EVENT = 'review-badge-refresh';
export function refreshReviewBadge(key: ReviewBadgeKey) {
if (typeof window === 'undefined') return;
window.dispatchEvent(
new CustomEvent<ReviewBadgeKey>(REVIEW_BADGE_REFRESH_EVENT, { detail: key }),
);
}