Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 16fc253926 |
@@ -9,7 +9,6 @@ import {
|
||||
Card,
|
||||
Col,
|
||||
DatePicker,
|
||||
Descriptions,
|
||||
Divider,
|
||||
InputNumber,
|
||||
Modal,
|
||||
@@ -190,7 +189,61 @@ const LT_FACTOR_ROWS = [
|
||||
{ key: '5', lt: '第 11 条及以后', factor: 1.0 },
|
||||
];
|
||||
|
||||
type AdRevenueDetailRow = AdRevenueRecord & { source_adn?: string | null };
|
||||
type AdRevenueDetailRow = AdRevenueRecord & {
|
||||
source_adn?: string | null;
|
||||
is_impression_only?: boolean;
|
||||
};
|
||||
|
||||
const FORMULA_EMPTY_STATUS_LABEL: Record<string, string> = {
|
||||
capped: '次数超限',
|
||||
ecpm_missing: 'eCPM 缺失',
|
||||
too_short: '观看时长不足',
|
||||
closed_early: '提前关闭',
|
||||
impression_only: '仅展示',
|
||||
};
|
||||
|
||||
// 未发奖记录用可读状态代替空值,避免误认为数据丢失;悬停时说明为何没有计算因子。
|
||||
function renderFormulaValue(value: string | number, row: AdRevenueDetailRow) {
|
||||
if (value !== '-') return value;
|
||||
const isGrantedButMissing = row.status === 'granted';
|
||||
const reason = isGrantedButMissing
|
||||
? '该记录标记为已发奖,但计算因子缺失,需要进一步排查'
|
||||
: row.is_impression_only
|
||||
? '该记录只有广告展示,没有对应发奖记录'
|
||||
: REWARD_STATUS_HINT[row.status] ?? `发奖状态为 ${row.status || '未知'}`;
|
||||
const statusLabel = isGrantedButMissing
|
||||
? '计算数据缺失'
|
||||
: (FORMULA_EMPTY_STATUS_LABEL[row.status] ?? row.status) || '未进入计算';
|
||||
return (
|
||||
<Tooltip
|
||||
title={isGrantedButMissing
|
||||
? reason
|
||||
: `${reason};未进入金币计算,不占用 LT 累计条数,因此不展示因子。`}
|
||||
>
|
||||
<span>{statusLabel}</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
function impressionOnlyDetail(row: AdRevenueRow): AdRevenueDetailRow {
|
||||
return {
|
||||
record_id: 0,
|
||||
created_at: row.created_at,
|
||||
status: 'impression_only',
|
||||
ecpm: row.ecpm,
|
||||
ecpm_factor: null,
|
||||
units: 0,
|
||||
lt_index_start: null,
|
||||
lt_index_end: null,
|
||||
lt_factor_start: null,
|
||||
lt_factor_end: null,
|
||||
expected_coin: 0,
|
||||
actual_coin: 0,
|
||||
matched: true,
|
||||
source_adn: row.adn,
|
||||
is_impression_only: true,
|
||||
};
|
||||
}
|
||||
|
||||
// 展开行(逐条事件展开)- 该条的发奖复算明细(还原金币审计的 eCPM/因子1/份数/LT/因子2 等列)
|
||||
const DETAIL_COLUMNS: ColumnsType<AdRevenueDetailRow> = [
|
||||
@@ -208,18 +261,25 @@ const DETAIL_COLUMNS: ColumnsType<AdRevenueDetailRow> = [
|
||||
render: (v: string | null) => (v == null || Number.isNaN(Number(v)) ? '-' : (Number(v) / 100 / 1000).toFixed(4)),
|
||||
},
|
||||
{ title: '实发金币数', dataIndex: 'actual_coin', width: 100 },
|
||||
{ title: '因子1', dataIndex: 'ecpm_factor', width: 70, render: (v: number | null) => v ?? '-' },
|
||||
{
|
||||
title: '因子1',
|
||||
dataIndex: 'ecpm_factor',
|
||||
width: 70,
|
||||
render: (v: number | null, row: AdRevenueDetailRow) => renderFormulaValue(v ?? '-', row),
|
||||
},
|
||||
{
|
||||
title: '因子2',
|
||||
key: 'lt_factor',
|
||||
width: 90,
|
||||
render: (_: unknown, r: AdRevenueDetailRow) => fmtFactorRange(r.lt_factor_start, r.lt_factor_end),
|
||||
render: (_: unknown, row: AdRevenueDetailRow) =>
|
||||
renderFormulaValue(fmtFactorRange(row.lt_factor_start, row.lt_factor_end), row),
|
||||
},
|
||||
{
|
||||
title: 'LT累计条数',
|
||||
key: 'lt_index',
|
||||
width: 100,
|
||||
render: (_: unknown, r: AdRevenueDetailRow) => fmtIndexRange(r.lt_index_start, r.lt_index_end),
|
||||
render: (_: unknown, row: AdRevenueDetailRow) =>
|
||||
renderFormulaValue(fmtIndexRange(row.lt_index_start, row.lt_index_end), row),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1126,24 +1186,19 @@ export default function AdRevenueReportPage() {
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<Typography.Text strong>展示明细</Typography.Text>{' '}
|
||||
<Typography.Text type="secondary">(纯展示事件,未单独发奖,无金币复算)</Typography.Text>
|
||||
<Descriptions size="small" column={3} bordered style={{ marginTop: 8 }}>
|
||||
<Descriptions.Item label="时间">{formatUtcTime(r.created_at)}</Descriptions.Item>
|
||||
<Descriptions.Item label="eCPM(分)">{r.ecpm ?? '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="eCPM(元)">
|
||||
{r.ecpm != null && !Number.isNaN(Number(r.ecpm))
|
||||
? (Number(r.ecpm) / 100).toFixed(2)
|
||||
: '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="预估收益(元)">
|
||||
{r.has_impression ? r.revenue_yuan.toFixed(4) : '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="底层 ADN">{r.adn ?? '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="底层代码位(rit)">{r.slot_id ?? '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="我方代码位">{r.our_code_id ?? '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="来源应用">{r.app_env ?? '-'}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Typography.Text strong>本次广告逐条明细</Typography.Text>{' '}
|
||||
<Typography.Text type="secondary">
|
||||
(共 1 条 · 应发 0 / 实发 0;仅展示,未单独发奖)
|
||||
</Typography.Text>
|
||||
<Table<AdRevenueDetailRow>
|
||||
style={{ marginTop: 8 }}
|
||||
rowKey="record_id"
|
||||
columns={DETAIL_COLUMNS}
|
||||
dataSource={[impressionOnlyDetail(r)]}
|
||||
pagination={false}
|
||||
size="small"
|
||||
scroll={{ x: 900 }}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type { SorterResult } from 'antd/es/table/interface';
|
||||
import {
|
||||
@@ -35,7 +35,6 @@ 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 || '';
|
||||
@@ -179,10 +178,6 @@ 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[]>([]);
|
||||
@@ -200,39 +195,17 @@ export default function FeedbacksPage() {
|
||||
}, [items]);
|
||||
|
||||
const [summary, setSummary] = useState<FeedbackSummary | null>(null);
|
||||
const loadSummary = useCallback(async () => {
|
||||
const loadSummary = async () => {
|
||||
try {
|
||||
const { data } = await api.get<FeedbackSummary>('/admin/api/feedbacks/summary');
|
||||
setSummary(data);
|
||||
} catch {
|
||||
/* 统计失败不阻塞列表 */
|
||||
}
|
||||
}, []);
|
||||
|
||||
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]);
|
||||
loadSummary();
|
||||
}, []);
|
||||
|
||||
// 审核/查看抽屉(采纳发金币 / 拒绝填原因 + 看该用户历史反馈)
|
||||
const [drawerFb, setDrawerFb] = useState<Feedback | null>(null);
|
||||
|
||||
@@ -37,8 +37,6 @@ import type {
|
||||
WithdrawSummary,
|
||||
} from '@/lib/types';
|
||||
|
||||
const REVIEW_BADGE_POLL_INTERVAL_MS = 60_000;
|
||||
|
||||
const { Sider, Header, Content } = Layout;
|
||||
|
||||
type NavItem = {
|
||||
@@ -146,13 +144,8 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
const version = (reviewRefreshVersion.current[key] ?? 0) + 1;
|
||||
reviewRefreshVersion.current[key] = version;
|
||||
let count: number;
|
||||
if (key === '/withdraws' || key === '/invite-withdraws') {
|
||||
const source = key === '/invite-withdraws' ? 'invite_cash' : 'coin_cash';
|
||||
count = (
|
||||
await api.get<WithdrawSummary>('/admin/api/withdraws/summary', {
|
||||
params: { source },
|
||||
})
|
||||
).data.reviewing_count;
|
||||
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 {
|
||||
@@ -163,39 +156,21 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
};
|
||||
|
||||
const refreshSafely = (key: ReviewBadgeKey) => refresh(key).catch(() => {});
|
||||
const refreshAll = () => {
|
||||
void Promise.all([
|
||||
refreshSafely('/withdraws'),
|
||||
refreshSafely('/invite-withdraws'),
|
||||
refreshSafely('/price-reports'),
|
||||
refreshSafely('/feedbacks'),
|
||||
]);
|
||||
};
|
||||
|
||||
refreshAll();
|
||||
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);
|
||||
};
|
||||
const onWindowFocus = () => refreshAll();
|
||||
const onVisibilityChange = () => {
|
||||
if (document.visibilityState === 'visible') refreshAll();
|
||||
};
|
||||
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]);
|
||||
}, [admin]);
|
||||
|
||||
if (!admin) return null; // 守卫期间不闪烁内容
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import {
|
||||
App,
|
||||
Button,
|
||||
@@ -30,7 +30,6 @@ 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)。
|
||||
@@ -151,10 +150,6 @@ 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;
|
||||
@@ -186,39 +181,17 @@ export default function PriceReportsPage() {
|
||||
setSelectedRowKeys((keys) => keys.filter((id) => visiblePendingIds.has(id)));
|
||||
}, [items]);
|
||||
|
||||
const loadSummary = useCallback(async () => {
|
||||
const loadSummary = async () => {
|
||||
try {
|
||||
const { data } = await api.get<PriceReportSummary>('/admin/api/price-reports/summary');
|
||||
setSummary(data);
|
||||
} catch {
|
||||
/* 统计失败不阻塞列表 */
|
||||
}
|
||||
}, []);
|
||||
|
||||
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]);
|
||||
loadSummary();
|
||||
}, []);
|
||||
|
||||
const refreshAfterChange = () => {
|
||||
reload();
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
export type ReviewBadgeKey =
|
||||
| '/invite-withdraws'
|
||||
| '/withdraws'
|
||||
| '/price-reports'
|
||||
| '/feedbacks';
|
||||
export type ReviewBadgeKey = '/withdraws' | '/price-reports' | '/feedbacks';
|
||||
|
||||
export const REVIEW_BADGE_REFRESH_EVENT = 'review-badge-refresh';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user