Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f8d9e3dc5 |
@@ -300,6 +300,8 @@ export default function AdRevenueReportPage() {
|
||||
const { message } = App.useApp();
|
||||
const [range, setRange] = useState<[Dayjs, Dayjs]>([dayjs().subtract(1, 'day'), dayjs().subtract(1, 'day')]);
|
||||
const [userId, setUserId] = useState<number | null>(null);
|
||||
const [appEnv, setAppEnv] = useState<'prod' | 'test' | 'all'>('prod');
|
||||
const [revenueScope, setRevenueScope] = useState<'business' | 'all'>('business');
|
||||
const [adType, setAdType] = useState<string | undefined>();
|
||||
// 「场景」作为后端全局筛选(feed_scene):同时影响明细 / 合计 / 趋势,与「用户 / 类型」一致,点「查询」生效。
|
||||
const [scene, setScene] = useState<string | undefined>();
|
||||
@@ -333,6 +335,8 @@ export default function AdRevenueReportPage() {
|
||||
date_from: from,
|
||||
date_to: to,
|
||||
user_id: userId ?? undefined,
|
||||
app_env: appEnv === 'all' ? undefined : appEnv,
|
||||
revenue_scope: revenueScope,
|
||||
ad_type: adType ?? undefined,
|
||||
feed_scene: scene ?? undefined,
|
||||
granularity: gran,
|
||||
@@ -374,7 +378,7 @@ export default function AdRevenueReportPage() {
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
[range, userId, adType, scene, granularity, limit, sortBy],
|
||||
[range, userId, appEnv, revenueScope, adType, scene, granularity, limit, sortBy],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -620,7 +624,8 @@ export default function AdRevenueReportPage() {
|
||||
<br />
|
||||
核心指标里的<b>「穿山甲后台收益(T+1)」</b>来自穿山甲 GroMore 数据 API(后台结算口径,次日出数):
|
||||
<b>穿山甲预估收益</b>=接口 revenue、<b>收益API</b>=各 ADN 回传更接近结算。穿山甲不提供分用户/类型/场景维度,
|
||||
故仅在<b>全量视图</b>(未按用户/类型/场景筛选)展示;逐条事件行仍是客户端预估,不受其影响。
|
||||
故仅在<b>可对账视图</b>(未按用户/类型/场景筛选)展示;环境和数据范围会同时作用于客户端与穿山甲汇总。
|
||||
默认“正式 + 业务代码位”用于同口径对账;切到“全部代码位”会包含广告测试等非业务曝光。
|
||||
</div>
|
||||
}
|
||||
>
|
||||
@@ -655,6 +660,31 @@ export default function AdRevenueReportPage() {
|
||||
style={{ width: 130 }}
|
||||
/>
|
||||
</Space>
|
||||
<Space size={6}>
|
||||
<Typography.Text type="secondary">环境</Typography.Text>
|
||||
<Select
|
||||
value={appEnv}
|
||||
onChange={setAppEnv}
|
||||
style={{ width: 130 }}
|
||||
options={[
|
||||
{ value: 'prod', label: '正式(prod)' },
|
||||
{ value: 'test', label: '测试(dev)' },
|
||||
{ value: 'all', label: '全部' },
|
||||
]}
|
||||
/>
|
||||
</Space>
|
||||
<Space size={6}>
|
||||
<Typography.Text type="secondary">数据范围</Typography.Text>
|
||||
<Select
|
||||
value={revenueScope}
|
||||
onChange={setRevenueScope}
|
||||
style={{ width: 150 }}
|
||||
options={[
|
||||
{ value: 'business', label: '业务代码位' },
|
||||
{ value: 'all', label: '全部代码位' },
|
||||
]}
|
||||
/>
|
||||
</Space>
|
||||
<Space size={6}>
|
||||
<Typography.Text type="secondary">类型</Typography.Text>
|
||||
<Select
|
||||
|
||||
+3
-100
@@ -25,12 +25,7 @@ import {
|
||||
import { Avatar, Dropdown, Layout, Tooltip } from 'antd';
|
||||
import { api } from '@/lib/api';
|
||||
import { clearAuth, getAdmin, getToken, setAuth } from '@/lib/auth';
|
||||
import type {
|
||||
AdminInfo,
|
||||
FeedbackSummary,
|
||||
PriceReportSummary,
|
||||
WithdrawSummary,
|
||||
} from '@/lib/types';
|
||||
import type { AdminInfo } from '@/lib/types';
|
||||
|
||||
const { Sider, Header, Content } = Layout;
|
||||
|
||||
@@ -40,8 +35,6 @@ type NavItem = {
|
||||
label: string;
|
||||
};
|
||||
|
||||
type ReviewNavKey = '/withdraws' | '/price-reports' | '/feedbacks';
|
||||
|
||||
type NavGroup =
|
||||
| (NavItem & { children?: never })
|
||||
| {
|
||||
@@ -103,7 +96,6 @@ 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<ReviewNavKey, number>>>({});
|
||||
|
||||
useEffect(() => {
|
||||
const token = getToken();
|
||||
@@ -122,49 +114,6 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
.catch(() => {});
|
||||
}, [router]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!admin) return;
|
||||
let cancelled = false;
|
||||
const canAccess = (page: string) =>
|
||||
admin.role === 'super_admin' || !admin.pages || admin.pages.includes(page);
|
||||
|
||||
const refresh = async () => {
|
||||
const [withdraws, priceReports, feedbacks] = await Promise.all([
|
||||
canAccess('withdraws')
|
||||
? api.get<WithdrawSummary>('/admin/api/withdraws/summary')
|
||||
.then(({ data }) => data.reviewing_count)
|
||||
.catch(() => null)
|
||||
: Promise.resolve(null),
|
||||
canAccess('price-reports')
|
||||
? api.get<PriceReportSummary>('/admin/api/price-reports/summary')
|
||||
.then(({ data }) => data.pending)
|
||||
.catch(() => null)
|
||||
: Promise.resolve(null),
|
||||
canAccess('feedbacks')
|
||||
? api.get<FeedbackSummary>('/admin/api/feedbacks/summary')
|
||||
.then(({ data }) => data.pending)
|
||||
.catch(() => null)
|
||||
: Promise.resolve(null),
|
||||
]);
|
||||
if (cancelled) return;
|
||||
setPendingReviewCounts((current) => ({
|
||||
...current,
|
||||
...(withdraws == null ? {} : { '/withdraws': withdraws }),
|
||||
...(priceReports == null ? {} : { '/price-reports': priceReports }),
|
||||
...(feedbacks == null ? {} : { '/feedbacks': feedbacks }),
|
||||
}));
|
||||
};
|
||||
|
||||
void refresh();
|
||||
const timer = window.setInterval(refresh, 30_000);
|
||||
window.addEventListener('focus', refresh);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
window.clearInterval(timer);
|
||||
window.removeEventListener('focus', refresh);
|
||||
};
|
||||
}, [admin, pathname]);
|
||||
|
||||
if (!admin) return null; // 守卫期间不闪烁内容
|
||||
|
||||
// 选中态:取路径一级(/users/123 -> /users)
|
||||
@@ -183,20 +132,6 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
hasChildren(group) ? group.children : [group],
|
||||
);
|
||||
|
||||
const reviewBadge = (key: string) => {
|
||||
const count = pendingReviewCounts[key as ReviewNavKey] ?? 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');
|
||||
@@ -231,7 +166,6 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
aria-label={item.label}
|
||||
>
|
||||
{item.icon}
|
||||
{reviewBadge(item.key)}
|
||||
</button>
|
||||
</Tooltip>
|
||||
))
|
||||
@@ -249,8 +183,7 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
onClick={() => router.push(group.key)}
|
||||
>
|
||||
<span className="nav-primary-icon">{group.icon}</span>
|
||||
<span className="nav-item-label">{group.label}</span>
|
||||
{reviewBadge(group.key)}
|
||||
<span>{group.label}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -269,8 +202,7 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
onClick={() => router.push(child.key)}
|
||||
>
|
||||
<span className="nav-child-icon">{child.icon}</span>
|
||||
<span className="nav-item-label">{child.label}</span>
|
||||
{reviewBadge(child.key)}
|
||||
<span>{child.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
@@ -337,29 +269,6 @@ 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 {
|
||||
@@ -423,7 +332,6 @@ 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;
|
||||
@@ -434,11 +342,6 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user