Compare commits

...

4 Commits

Author SHA1 Message Date
guke 92cdc64654 Merge branch 'main' into codex/comparison-device-display 2026-07-27 16:38:27 +08:00
linkeyu 63538ddee2 修复提现审核状态汇总与列表条数不一致 (#89)
## 问题

奖励审核页面只有待审核、打款中和打款失败显示数量,已到账、已拒绝和全部没有数字;同时两个提现审核页面的页签数字及顶部“待审核/待审核金额”收到后端全局汇总后发生混合。

## 改动

- 补充已到账、已拒绝和全部三个汇总字段类型
- 六个状态页签全部展示对应的小框数字
- 页签数字及顶部待审核数量、金额均使用当前页面的提现来源参数

## 验证

- `npm run build` 通过
- Next.js 编译、类型检查及静态页面生成全部通过
- 结合线上数据库确认普通提现和邀请提现的状态、顶部待审核数量与金额应分别展示

## 后端依赖

需配合后端 PR WonderableAI/shaguabijia-app-server#185 一起合入部署:
WonderableAI/shaguabijia-app-server#185

---------

Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #89
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-27 16:26:07 +08:00
linkeyu d057f75b90 修复低价审核红点与列表数据不同步 (#84)
## 问题
低价审核记录被处理后,左侧红点可能继续显示进入后台时的旧数量;页面长时间打开时,顶部统计和列表也不会自动同步新状态。

## 改动
- 进入或切换后台页面时重新获取审核红点数量。
- 窗口重新聚焦、标签页恢复可见时立即刷新。
- 页面可见期间每 60 秒同步一次红点、低价审核统计和当前列表。
- 组件卸载时清理定时器与事件监听,隐藏标签页不发起轮询。

## 验证
- `tsc --noEmit`
- `npm run build`
- 人工 review:仅修改导航红点和低价审核页刷新逻辑,未包含其他工作区改动。

---------

Co-authored-by: guke <guke@wonderable.ai>
Co-authored-by: linkeyu <798648091@qq.com>
Reviewed-on: #84
Co-authored-by: linkeyu <linkeyu@wonderable.ai>
Co-committed-by: linkeyu <linkeyu@wonderable.ai>
2026-07-27 16:03:13 +08:00
linkeyu 4cd9c19e4d 优化:展示比价记录机型与 ROM 版本
列表和详情优先展示可读机型名,保留原始设备编码,并补充 ROM 版本。
2026-07-27 14:36:56 +08:00
6 changed files with 147 additions and 25 deletions
+46 -4
View File
@@ -46,6 +46,41 @@ const fmtTok = (inTok: number | null, outTok: number | null) =>
inTok == null && outTok == null ? '-' : `${inTok ?? 0}/${outTok ?? 0}`;
const fmtRate = (value: number | null) => (value == null ? '-' : `${(value * 100).toFixed(1)}%`);
function deviceName(record: ComparisonRecordListItem): string {
return record.device_model_name || record.device_model || '-';
}
function romName(record: ComparisonRecordListItem): string {
return [
record.rom_vendor,
record.rom_name,
record.rom_version != null ? String(record.rom_version) : null,
]
.filter(Boolean)
.join(' ') || '-';
}
function renderDevice(record: ComparisonRecordListItem): ReactNode {
const readableName = deviceName(record);
const showRawModel =
record.device_model_name
&& record.device_model
&& record.device_model_name !== record.device_model;
return (
<Space direction="vertical" size={0}>
<span>{readableName}</span>
{showRawModel ? (
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
{record.device_model}
</Typography.Text>
) : null}
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
{romName(record)}
</Typography.Text>
</Space>
);
}
// LLM 价格快照只展示 prices 里各模型的单价(元/每百万 token),忽略 mode/_source 等元字段。
function llmPriceRows(snapshot: Record<string, unknown> | null): string[] {
const prices = snapshot?.prices;
@@ -308,9 +343,9 @@ export default function ComparisonRecordsPage() {
{
title: '机型/ROM',
key: 'device',
width: 150,
width: 180,
ellipsis: true,
render: (_, r) => [r.device_model, r.rom_name].filter(Boolean).join(' / ') || '-',
render: (_, r) => renderDevice(r),
},
{
title: 'traceid',
@@ -499,8 +534,15 @@ export default function ComparisonRecordsPage() {
<Card size="small" title="设备环境">
<Descriptions size="small" column={2}>
<Descriptions.Item label="机型">{detail.device_model || '-'}{detail.device_manufacturer || '-'}</Descriptions.Item>
<Descriptions.Item label="ROM">{[detail.rom_vendor, detail.rom_name, detail.rom_version].filter(Boolean).join(' ') || '-'}</Descriptions.Item>
<Descriptions.Item label="机型">
{deviceName(detail)}
{detail.device_model_name && detail.device_model_name !== detail.device_model
? `${[detail.device_manufacturer, detail.device_model].filter(Boolean).join(' · ')}`
: detail.device_manufacturer
? `${detail.device_manufacturer}`
: ''}
</Descriptions.Item>
<Descriptions.Item label="ROM">{romName(detail)}</Descriptions.Item>
<Descriptions.Item label="Android">{detail.android_version || '-'}SDK {detail.android_sdk ?? '-'}</Descriptions.Item>
<Descriptions.Item label="App 版本">{detail.app_version || '-'}{detail.app_version_code ?? '-'}</Descriptions.Item>
<Descriptions.Item label="源 App 版本" span={2}>{detail.source_app_version || '-'}</Descriptions.Item>
+32 -5
View File
@@ -1,6 +1,6 @@
'use client';
import { useEffect, useState } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import type { ColumnsType } from 'antd/es/table';
import type { SorterResult } from 'antd/es/table/interface';
import {
@@ -35,6 +35,7 @@ import UserRecordsDrawer from '@/components/UserRecordsDrawer';
const { Text, Paragraph } = Typography;
const { RangePicker } = DatePicker;
const REWARD_MAX = 10000;
const REVIEW_PAGE_POLL_INTERVAL_MS = 60_000;
// 截图是 app-server 的 /media 相对路径,本地由 :8770 提供(NEXT_PUBLIC_MEDIA_BASE);生产同域走 nginx 代理。
const MEDIA_BASE = process.env.NEXT_PUBLIC_MEDIA_BASE || '';
@@ -196,6 +197,10 @@ export default function FeedbacksPage() {
const filters: Record<string, unknown> = { ...applied, sort_by: sortBy, sort_order: sortOrder };
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
usePagedList<Feedback>('/admin/api/feedbacks', filters);
const reloadRef = useRef(reload);
useEffect(() => {
reloadRef.current = reload;
}, [reload]);
const canReview = canDo(['operator']);
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
@@ -213,18 +218,40 @@ export default function FeedbacksPage() {
}, [items]);
const [summary, setSummary] = useState<FeedbackSummary | null>(null);
const loadSummary = async () => {
const loadSummary = useCallback(async () => {
try {
const { data } = await api.get<FeedbackSummary>('/admin/api/feedbacks/summary');
setSummary(data);
} catch {
/* 统计失败不阻塞列表 */
}
};
useEffect(() => {
loadSummary();
}, []);
const refreshPageData = useCallback(() => {
void reloadRef.current();
void loadSummary();
}, [loadSummary]);
useEffect(() => {
void loadSummary();
const onWindowFocus = () => refreshPageData();
const onVisibilityChange = () => {
if (document.visibilityState === 'visible') refreshPageData();
};
const pollTimer = window.setInterval(() => {
if (document.visibilityState === 'visible') refreshPageData();
}, REVIEW_PAGE_POLL_INTERVAL_MS);
window.addEventListener('focus', onWindowFocus);
document.addEventListener('visibilitychange', onVisibilityChange);
return () => {
window.clearInterval(pollTimer);
window.removeEventListener('focus', onWindowFocus);
document.removeEventListener('visibilitychange', onVisibilityChange);
};
}, [loadSummary, refreshPageData]);
// 审核/查看抽屉(采纳发金币 / 拒绝填原因 + 看该用户历史反馈)
const [drawerFb, setDrawerFb] = useState<Feedback | null>(null);
const [drawerOpen, setDrawerOpen] = useState(false);
+29 -10
View File
@@ -37,6 +37,8 @@ import type {
WithdrawSummary,
} from '@/lib/types';
const REVIEW_BADGE_POLL_INTERVAL_MS = 60_000;
const { Sider, Header, Content } = Layout;
type NavItem = {
@@ -162,22 +164,39 @@ export default function MainLayout({ children }: { children: React.ReactNode })
};
const refreshSafely = (key: ReviewBadgeKey) => refresh(key).catch(() => {});
void Promise.all([
refreshSafely('/withdraws'),
refreshSafely('/invite-withdraws'),
refreshSafely('/price-reports'),
refreshSafely('/feedbacks'),
]);
const refreshAll = () => {
void Promise.all([
refreshSafely('/withdraws'),
refreshSafely('/invite-withdraws'),
refreshSafely('/price-reports'),
refreshSafely('/feedbacks'),
]);
};
refreshAll();
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);
const onWindowFocus = () => refreshAll();
const onVisibilityChange = () => {
if (document.visibilityState === 'visible') refreshAll();
};
}, [admin]);
const pollTimer = window.setInterval(() => {
if (document.visibilityState === 'visible') refreshAll();
}, REVIEW_BADGE_POLL_INTERVAL_MS);
window.addEventListener(REVIEW_BADGE_REFRESH_EVENT, onReviewCompleted);
window.addEventListener('focus', onWindowFocus);
document.addEventListener('visibilitychange', onVisibilityChange);
return () => {
window.clearInterval(pollTimer);
window.removeEventListener(REVIEW_BADGE_REFRESH_EVENT, onReviewCompleted);
window.removeEventListener('focus', onWindowFocus);
document.removeEventListener('visibilitychange', onVisibilityChange);
};
}, [admin, pathname]);
if (!admin) return null; // 守卫期间不闪烁内容
+32 -5
View File
@@ -1,6 +1,6 @@
'use client';
import { useEffect, useState } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import {
App,
Button,
@@ -30,6 +30,7 @@ import type { PriceReport, PriceReportSummary } from '@/lib/types';
import UserRecordsDrawer from '@/components/UserRecordsDrawer';
const { Text } = Typography;
const REVIEW_PAGE_POLL_INTERVAL_MS = 60_000;
// 后端 created_at/reviewed_at 存的是北京 wall-clock(naive,同 savings/comparison),
// 直接本地解析、不加 Z(否则会差 8h)。
@@ -150,6 +151,10 @@ export default function PriceReportsPage() {
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
usePagedList<PriceReport>('/admin/api/price-reports', filters);
const reloadRef = useRef(reload);
useEffect(() => {
reloadRef.current = reload;
}, [reload]);
const sortOrderOf = (field: SortField) =>
sortBy === field ? (sortOrder === 'asc' ? 'ascend' : 'descend') : null;
@@ -181,18 +186,40 @@ export default function PriceReportsPage() {
setSelectedRowKeys((keys) => keys.filter((id) => visiblePendingIds.has(id)));
}, [items]);
const loadSummary = async () => {
const loadSummary = useCallback(async () => {
try {
const { data } = await api.get<PriceReportSummary>('/admin/api/price-reports/summary');
setSummary(data);
} catch {
/* 统计失败不阻塞列表 */
}
};
useEffect(() => {
loadSummary();
}, []);
const refreshPageData = useCallback(() => {
void reloadRef.current();
void loadSummary();
}, [loadSummary]);
useEffect(() => {
void loadSummary();
const onWindowFocus = () => refreshPageData();
const onVisibilityChange = () => {
if (document.visibilityState === 'visible') refreshPageData();
};
const pollTimer = window.setInterval(() => {
if (document.visibilityState === 'visible') refreshPageData();
}, REVIEW_PAGE_POLL_INTERVAL_MS);
window.addEventListener('focus', onWindowFocus);
document.addEventListener('visibilitychange', onVisibilityChange);
return () => {
window.clearInterval(pollTimer);
window.removeEventListener('focus', onWindowFocus);
document.removeEventListener('visibilitychange', onVisibilityChange);
};
}, [loadSummary, refreshPageData]);
const refreshAfterChange = () => {
reload();
loadSummary();
@@ -124,7 +124,10 @@ function summaryCount(summary: WithdrawSummary | null, key: string) {
if (!summary) return undefined;
if (key === 'reviewing') return summary.reviewing_count;
if (key === 'pending') return summary.pending_count;
if (key === 'success') return summary.success_count;
if (key === 'rejected') return summary.rejected_count;
if (key === 'failed') return summary.failed_count;
if (key === 'all') return summary.total_count;
return undefined;
}
+5 -1
View File
@@ -167,7 +167,10 @@ export interface WithdrawSummary {
reviewing_count: number;
reviewing_amount_cents: number;
pending_count: number;
success_count: number;
rejected_count: number;
failed_count: number;
total_count: number;
today_success_count: number;
today_success_amount_cents: number;
today_rejected_count: number;
@@ -462,8 +465,10 @@ export interface ComparisonRecordListItem {
output_tokens: number | null;
llm_cost_yuan: number | null; // 后端按「当时价」冻结的实际成本(元);旧记录 null → 「成本」列回退估算
device_model: string | null;
device_model_name: string | null;
rom_vendor: string | null;
rom_name: string | null;
rom_version: number | null;
android_version: string | null;
app_version: string | null;
ad_revenue_yuan: number; // 本次比价看的信息流广告预估收益(元)
@@ -514,7 +519,6 @@ export interface ComparisonRecordDetail extends ComparisonRecordListItem {
comparison_results: Record<string, unknown>[];
skipped_dish_names: string[];
device_manufacturer: string | null;
rom_version: number | null;
android_sdk: number | null;
app_version_code: number | null;
source_app_version: string | null;