Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee9e75d702 | |||
| 694944cb5e | |||
| 27ff7936a5 | |||
| 47a7960100 |
@@ -9,7 +9,6 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
Col,
|
Col,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
Descriptions,
|
|
||||||
Divider,
|
Divider,
|
||||||
InputNumber,
|
InputNumber,
|
||||||
Modal,
|
Modal,
|
||||||
@@ -43,6 +42,8 @@ import type {
|
|||||||
import UserAdRevenueDrawer from './UserAdRevenueDrawer';
|
import UserAdRevenueDrawer from './UserAdRevenueDrawer';
|
||||||
|
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
|
const DEFAULT_PAGE_SIZE = 50;
|
||||||
|
const ALL_FILTER_VALUE = '__all__';
|
||||||
|
|
||||||
// 广告类型标签
|
// 广告类型标签
|
||||||
const TYPE_TAG: Record<string, { color: string; label: string }> = {
|
const TYPE_TAG: Record<string, { color: string; label: string }> = {
|
||||||
@@ -81,20 +82,12 @@ const PLAYBACK_STATUS_TAG: Record<string, { color: string; label: string }> = {
|
|||||||
unknown: { color: 'default', label: '未知' },
|
unknown: { color: 'default', label: '未知' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const ZERO_REVENUE_REWARD_VIDEO_STATUSES = new Set(['closed_early', 'too_short']);
|
|
||||||
|
|
||||||
function rewardStatuses(row: AdRevenueRow): string[] {
|
function rewardStatuses(row: AdRevenueRow): string[] {
|
||||||
if (row.sub_rewards?.length) return row.sub_rewards.map((reward) => reward.status);
|
if (row.sub_rewards?.length) return row.sub_rewards.map((reward) => reward.status);
|
||||||
return row.status ? [row.status] : [];
|
return row.status ? [row.status] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function effectiveRevenueYuan(row: AdRevenueRow): number {
|
function effectiveRevenueYuan(row: AdRevenueRow): number {
|
||||||
if (
|
|
||||||
row.ad_type === 'reward_video'
|
|
||||||
&& rewardStatuses(row).some((status) => ZERO_REVENUE_REWARD_VIDEO_STATUSES.has(status))
|
|
||||||
) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return row.row_revenue_yuan ?? row.revenue_yuan;
|
return row.row_revenue_yuan ?? row.revenue_yuan;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,11 +183,59 @@ const LT_FACTOR_ROWS = [
|
|||||||
{ key: '5', lt: '第 11 条及以后', factor: 1.0 },
|
{ 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 未发奖记录保留「-」以避免把潜在奖励误读为实际计算结果;悬停时说明为何没有因子。
|
||||||
|
function renderFormulaValue(value: string | number, row: AdRevenueDetailRow) {
|
||||||
|
if (value !== '-' || row.status === 'granted') return value;
|
||||||
|
const reason = row.is_impression_only
|
||||||
|
? '该记录只有广告展示,没有对应发奖记录'
|
||||||
|
: REWARD_STATUS_HINT[row.status] ?? `发奖状态为 ${row.status}`;
|
||||||
|
return (
|
||||||
|
<Tooltip title={`${reason};未进入金币计算,不占用 LT 累计条数,因此不展示因子。`}>
|
||||||
|
<span>-</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,
|
||||||
|
adn: row.adn,
|
||||||
|
slot_id: row.slot_id,
|
||||||
|
source_adn: row.adn,
|
||||||
|
is_impression_only: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// 展开行(逐条事件展开)- 该条的发奖复算明细(还原金币审计的 eCPM/因子1/份数/LT/因子2 等列)
|
// 展开行(逐条事件展开)- 该条的发奖复算明细(还原金币审计的 eCPM/因子1/份数/LT/因子2 等列)
|
||||||
const DETAIL_COLUMNS: ColumnsType<AdRevenueDetailRow> = [
|
const DETAIL_COLUMNS: ColumnsType<AdRevenueDetailRow> = [
|
||||||
{ title: '来源广告网络', dataIndex: 'source_adn', width: 110, render: (value: string | null) => value || '-' },
|
{
|
||||||
|
title: '来源广告网络',
|
||||||
|
dataIndex: 'source_adn',
|
||||||
|
width: 110,
|
||||||
|
render: (value: string | null) => value?.trim() || (
|
||||||
|
<Tooltip title="该历史记录没有可唯一确认的 SDK 广告来源,未猜测填充。">
|
||||||
|
<span>未上报</span>
|
||||||
|
</Tooltip>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'eCPM(元)',
|
title: 'eCPM(元)',
|
||||||
dataIndex: 'ecpm',
|
dataIndex: 'ecpm',
|
||||||
@@ -208,33 +249,40 @@ const DETAIL_COLUMNS: ColumnsType<AdRevenueDetailRow> = [
|
|||||||
render: (v: string | null) => (v == null || Number.isNaN(Number(v)) ? '-' : (Number(v) / 100 / 1000).toFixed(4)),
|
render: (v: string | null) => (v == null || Number.isNaN(Number(v)) ? '-' : (Number(v) / 100 / 1000).toFixed(4)),
|
||||||
},
|
},
|
||||||
{ title: '实发金币数', dataIndex: 'actual_coin', width: 100 },
|
{ 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, r: AdRevenueDetailRow) => renderFormulaValue(v ?? '-', r),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '因子2',
|
title: '因子2',
|
||||||
key: 'lt_factor',
|
key: 'lt_factor',
|
||||||
width: 90,
|
width: 90,
|
||||||
render: (_: unknown, r: AdRevenueDetailRow) => fmtFactorRange(r.lt_factor_start, r.lt_factor_end),
|
render: (_: unknown, r: AdRevenueDetailRow) =>
|
||||||
|
renderFormulaValue(fmtFactorRange(r.lt_factor_start, r.lt_factor_end), r),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'LT累计条数',
|
title: 'LT累计条数',
|
||||||
key: 'lt_index',
|
key: 'lt_index',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (_: unknown, r: AdRevenueDetailRow) => fmtIndexRange(r.lt_index_start, r.lt_index_end),
|
render: (_: unknown, r: AdRevenueDetailRow) =>
|
||||||
|
renderFormulaValue(fmtIndexRange(r.lt_index_start, r.lt_index_end), r),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// 趋势图(纯 SVG,零依赖):柱=展示条数(左轴),橙线=客户端预估收益元(右轴),
|
// 趋势图(纯 SVG,零依赖):柱=展示条数(左轴),橙线=客户端预估收益元(右轴),
|
||||||
// 绿线=穿山甲后台预估收益元(右轴,仅按天且有数据时出现)。x 轴按传入点序。
|
// 绿线=GroMore 排序价预估元(右轴,仅按天且有数据时出现)。x 轴按传入点序。
|
||||||
const CHART_BAR = '#69b1ff';
|
const CHART_BAR = '#69b1ff';
|
||||||
const CHART_LINE = '#fa8c16';
|
const CHART_LINE = '#fa8c16';
|
||||||
const CHART_LINE2 = '#52c41a'; // 穿山甲后台收益线
|
const CHART_LINE2 = '#52c41a'; // GroMore 排序价预估线
|
||||||
|
|
||||||
interface TrendPoint {
|
interface TrendPoint {
|
||||||
label: string; // x 轴刻度文案(小时数 / MM-DD)
|
label: string; // x 轴刻度文案(小时数 / MM-DD)
|
||||||
tip: string; // hover 原生 tooltip 全文
|
tip: string; // hover 原生 tooltip 全文
|
||||||
impressions: number;
|
impressions: number;
|
||||||
revenue: number;
|
revenue: number;
|
||||||
pangleRevenue: number | null; // 穿山甲后台预估收益(元);无则 null(不画绿线点)
|
pangleRevenue: number | null; // GroMore 排序价预估(元);无则 null(不画绿线点)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按小时聚合(0–23),数据源是 hourly(后端全量聚合,不受分页影响)。穿山甲为天级,小时视图无该线。
|
// 按小时聚合(0–23),数据源是 hourly(后端全量聚合,不受分页影响)。穿山甲为天级,小时视图无该线。
|
||||||
@@ -255,7 +303,7 @@ function aggregateHourly(rows: AdRevenueHourly[]): TrendPoint[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 按天聚合,数据源是 daily(全量,不受 limit 影响);用 from..to 补齐空缺日为 0,轴连续。
|
// 按天聚合,数据源是 daily(全量,不受 limit 影响);用 from..to 补齐空缺日为 0,轴连续。
|
||||||
// 穿山甲收益(pangle_revenue_yuan)为 null 时该日不画绿线点(T+1 未出/非全量视图)。
|
// GroMore 排序价预估(pangle_revenue_yuan)为 null 时该日不画绿线点(T+1 未出/非全量视图)。
|
||||||
function aggregateDaily(dateFrom: string, dateTo: string, daily: AdRevenueDaily[]): TrendPoint[] {
|
function aggregateDaily(dateFrom: string, dateTo: string, daily: AdRevenueDaily[]): TrendPoint[] {
|
||||||
const map = new Map(daily.map((d) => [d.date, d]));
|
const map = new Map(daily.map((d) => [d.date, d]));
|
||||||
const out: TrendPoint[] = [];
|
const out: TrendPoint[] = [];
|
||||||
@@ -344,7 +392,7 @@ function TrendChart({ points }: { points: TrendPoint[] }) {
|
|||||||
<title>{p.tip}</title>
|
<title>{p.tip}</title>
|
||||||
</circle>
|
</circle>
|
||||||
))}
|
))}
|
||||||
{/* 穿山甲后台收益线(绿,仅非 null 的天画;按天且已同步 T+1 数据时出现) */}
|
{/* GroMore 排序价预估线(绿,仅非 null 的天画;按天且已同步 T+1 数据时出现) */}
|
||||||
{(() => {
|
{(() => {
|
||||||
const pp = points
|
const pp = points
|
||||||
.map((p, i) => ({ i, v: p.pangleRevenue, tip: p.tip }))
|
.map((p, i) => ({ i, v: p.pangleRevenue, tip: p.tip }))
|
||||||
@@ -387,13 +435,13 @@ export default function AdRevenueReportPage() {
|
|||||||
const [scene, setScene] = useState<string | undefined>();
|
const [scene, setScene] = useState<string | undefined>();
|
||||||
const [granularity, setGranularity] = useState<'day' | 'hour'>('day');
|
const [granularity, setGranularity] = useState<'day' | 'hour'>('day');
|
||||||
const [sortBy, setSortBy] = useState<'time' | 'ecpm'>('time'); // 明细排序:time=时间倒序 / ecpm=eCPM 倒序
|
const [sortBy, setSortBy] = useState<'time' | 'ecpm'>('time'); // 明细排序:time=时间倒序 / ecpm=eCPM 倒序
|
||||||
const [limit, setLimit] = useState<number>(1000); // 默认拉满接口单页上限,供单次流程广告数分位统计
|
const [limit, setLimit] = useState<number>(DEFAULT_PAGE_SIZE);
|
||||||
const [page, setPage] = useState<number>(1); // 当前页码(后端分页;1 起)
|
const [page, setPage] = useState<number>(1); // 当前页码(后端分页;1 起)
|
||||||
const [queriedGranularity, setQueriedGranularity] = useState<'day' | 'hour'>('day'); // 本次结果对应的粒度,决定是否显示「小时」列
|
const [queriedGranularity, setQueriedGranularity] = useState<'day' | 'hour'>('day'); // 本次结果对应的粒度,决定是否显示「小时」列
|
||||||
const [queriedMultiDay, setQueriedMultiDay] = useState(false); // 本次结果是否跨多天,决定显示「日期」列 + 按天/按小时图
|
const [queriedMultiDay, setQueriedMultiDay] = useState(false); // 本次结果是否跨多天,决定显示「日期」列 + 按天/按小时图
|
||||||
const [data, setData] = useState<AdRevenueReport | null>(null);
|
const [data, setData] = useState<AdRevenueReport | null>(null);
|
||||||
const [allFlowItems, setAllFlowItems] = useState<AdRevenueRow[]>([]);
|
const [allFlowItems, setAllFlowItems] = useState<AdRevenueRow[]>([]);
|
||||||
const [queriedLimit, setQueriedLimit] = useState<number>(1000);
|
const [queriedLimit, setQueriedLimit] = useState<number>(DEFAULT_PAGE_SIZE);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [formulaOpen, setFormulaOpen] = useState(false);
|
const [formulaOpen, setFormulaOpen] = useState(false);
|
||||||
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
|
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
|
||||||
@@ -558,7 +606,6 @@ export default function AdRevenueReportPage() {
|
|||||||
width: 110,
|
width: 110,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
// 一次比价/领券聚合行用 row_revenue_yuan(该次发奖广告 eCPM 折算之和),其它行用展示侧 revenue_yuan
|
// 一次比价/领券聚合行用 row_revenue_yuan(该次发奖广告 eCPM 折算之和),其它行用展示侧 revenue_yuan
|
||||||
// 激励视频提前关闭/时长不足时防御性显示 0,与后端有效收益口径一致。
|
|
||||||
render: (_v: number, r: AdRevenueRow) => effectiveRevenueYuan(r).toFixed(4),
|
render: (_v: number, r: AdRevenueRow) => effectiveRevenueYuan(r).toFixed(4),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -637,6 +684,8 @@ export default function AdRevenueReportPage() {
|
|||||||
// 应发实发差额(金币)= 应发−实发(正=少发/负=多发);ARPU = 区间预估收益÷区间活跃用户(见 dau)。
|
// 应发实发差额(金币)= 应发−实发(正=少发/负=多发);ARPU = 区间预估收益÷区间活跃用户(见 dau)。
|
||||||
const derived = data
|
const derived = data
|
||||||
? {
|
? {
|
||||||
|
// ADN Reporting API 只覆盖已配置回传的广告源,不能据此推导全量 ARPU / 毛利。
|
||||||
|
// 在接入最终结算单前,核心经营指标始终使用 SDK 展示预估,并明确标注其性质。
|
||||||
payoutYuan: data.total_actual_coin / COIN_PER_YUAN,
|
payoutYuan: data.total_actual_coin / COIN_PER_YUAN,
|
||||||
grossProfit: data.total_revenue_yuan - data.total_actual_coin / COIN_PER_YUAN,
|
grossProfit: data.total_revenue_yuan - data.total_actual_coin / COIN_PER_YUAN,
|
||||||
payoutRatioPct:
|
payoutRatioPct:
|
||||||
@@ -644,7 +693,6 @@ export default function AdRevenueReportPage() {
|
|||||||
? (data.total_actual_coin / COIN_PER_YUAN / data.total_revenue_yuan) * 100
|
? (data.total_actual_coin / COIN_PER_YUAN / data.total_revenue_yuan) * 100
|
||||||
: null,
|
: null,
|
||||||
coinGap: data.total_expected_coin - data.total_actual_coin,
|
coinGap: data.total_expected_coin - data.total_actual_coin,
|
||||||
// ARPU = 区间预估广告收益 ÷ 区间去重活跃用户(dau,口径同数据大盘);dau 为 0 时不可算 → null,显示「-」。
|
|
||||||
arpu: data.dau && data.dau > 0 ? data.total_revenue_yuan / data.dau : null,
|
arpu: data.dau && data.dau > 0 ? data.total_revenue_yuan / data.dau : null,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
@@ -661,11 +709,15 @@ export default function AdRevenueReportPage() {
|
|||||||
: data.date_from
|
: data.date_from
|
||||||
: `${data.date_from} ~ ${data.date_to}`;
|
: `${data.date_from} ~ ${data.date_to}`;
|
||||||
|
|
||||||
// 第二行大盘「分广告类型」:draw / 激励视频 各自 收益 / eCPM / 展示条数;eCPM = 收益÷展示×1000。
|
// 经营分类由后端统一:Draw = draw + 历史 feed;看视频 = 福利视频 + 提现视频。
|
||||||
const drawStat = data?.type_stats?.draw;
|
// eCPM 同时按每次展示的 SDK 原始值加权,不能从前端漏项后再临时平均。
|
||||||
const rvStat = data?.type_stats?.reward_video;
|
const drawStat = data?.category_stats?.draw;
|
||||||
const ecpmOf = (s?: AdRevenueTypeStat) =>
|
const videoStat = data?.category_stats?.video;
|
||||||
s && s.impressions > 0 ? (s.revenue_yuan / s.impressions) * 1000 : 0;
|
const videoLabel = adType === 'withdrawal_video'
|
||||||
|
? '提现看视频'
|
||||||
|
: adType === 'reward_video'
|
||||||
|
? '福利看视频'
|
||||||
|
: '看视频(福利+提现)';
|
||||||
|
|
||||||
// 明细直接用后端返回的当前页 items(「场景」已由后端 feed_scene 全局过滤,前端不再二次筛)。
|
// 明细直接用后端返回的当前页 items(「场景」已由后端 feed_scene 全局过滤,前端不再二次筛)。
|
||||||
const items = data?.items ?? [];
|
const items = data?.items ?? [];
|
||||||
@@ -704,14 +756,19 @@ export default function AdRevenueReportPage() {
|
|||||||
逐条展示不单独占行(其展示数 / eCPM / 预估收益已计入上方合计与大盘),点行左侧「+」展开看该次金币复算。
|
逐条展示不单独占行(其展示数 / eCPM / 预估收益已计入上方合计与大盘),点行左侧「+」展开看该次金币复算。
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
「预估收益」为客户端在广告展示(onAdShow)时上报 eCPM 折算的预估值(每千次展示 ÷1000
|
「客户端 SDK 展示预估」按广告展示(onAdShow)后端留存的 eCPM 折算(每千次展示 ÷1000
|
||||||
累加);<b>激励视频提前关闭或播放时长不足时按 0 计</b>,其他有效展示按 eCPM 折算。穿山甲仍可能过滤无效曝光,
|
累加;不足 1 秒的异常曝光沿用采集规则记 0)。是否看满只影响金币发放;发奖防作弊的 eCPM 上限不参与收入计算。
|
||||||
<b>实际收益一律以穿山甲后台结算为准</b>。测试应用多为 0。「广告位ID / 来源应用」为本期新增,历史记录留空。
|
<b>最终收入仍以各 ADN 结算单为准</b>。
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
核心指标里的<b>「穿山甲后台收益(T+1)」</b>来自穿山甲 GroMore 数据 API(后台结算口径,次日出数):
|
<b>GroMore 排序价预估</b>来自接口 revenue,只是排序价/竞价实时价估算,不是结算收入;
|
||||||
<b>穿山甲预估收益</b>=接口 revenue、<b>收益API</b>=各 ADN 回传更接近结算。穿山甲不提供分用户/类型/场景维度,
|
<b>ADN Reporting API 收益</b>来自已配置广告源的 api_revenue 回传;每天 14:00 后仅代表同步窗口完成,
|
||||||
故仅在<b>可对账视图</b>(未按用户/类型/场景筛选)展示;环境和数据范围会同时作用于客户端与穿山甲汇总。
|
不代表覆盖全部广告源或最终结算,因此不用于自动计算全量毛利和 ARPU。
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
分类卡口径:<b>Draw 信息流 = draw + 历史 feed</b>;<b>看视频 = 福利视频 + 提现视频</b>。
|
||||||
|
两者的 eCPM 都由后端按每次展示的 SDK eCPM 加权计算(eCPM 总和 ÷ 展示次数),不从分页明细或单一子类型取值。
|
||||||
|
GroMore 不提供分用户/类型/场景维度,故仅在<b>可对账视图</b>(未按用户/类型/场景筛选)展示。
|
||||||
默认“正式 + 业务代码位”用于同口径对账;切到“全部代码位”会包含广告测试等非业务曝光。
|
默认“正式 + 业务代码位”用于同口径对账;切到“全部代码位”会包含广告测试等非业务曝光。
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -775,12 +832,11 @@ export default function AdRevenueReportPage() {
|
|||||||
<Space size={6}>
|
<Space size={6}>
|
||||||
<Typography.Text type="secondary">类型</Typography.Text>
|
<Typography.Text type="secondary">类型</Typography.Text>
|
||||||
<Select
|
<Select
|
||||||
placeholder="全部"
|
value={adType ?? ALL_FILTER_VALUE}
|
||||||
value={adType}
|
onChange={(value) => setAdType(value === ALL_FILTER_VALUE ? undefined : value)}
|
||||||
onChange={setAdType}
|
|
||||||
allowClear
|
|
||||||
style={{ width: 150 }}
|
style={{ width: 150 }}
|
||||||
options={[
|
options={[
|
||||||
|
{ value: ALL_FILTER_VALUE, label: '全部' },
|
||||||
{ value: 'reward_video', label: '看视频' },
|
{ value: 'reward_video', label: '看视频' },
|
||||||
{ value: 'draw', label: 'Draw 信息流' },
|
{ value: 'draw', label: 'Draw 信息流' },
|
||||||
{ value: 'withdrawal_video', label: '提现看视频' },
|
{ value: 'withdrawal_video', label: '提现看视频' },
|
||||||
@@ -790,12 +846,11 @@ export default function AdRevenueReportPage() {
|
|||||||
<Space size={6}>
|
<Space size={6}>
|
||||||
<Typography.Text type="secondary">场景</Typography.Text>
|
<Typography.Text type="secondary">场景</Typography.Text>
|
||||||
<Select
|
<Select
|
||||||
placeholder="全部"
|
value={scene ?? ALL_FILTER_VALUE}
|
||||||
value={scene}
|
onChange={(value) => setScene(value === ALL_FILTER_VALUE ? undefined : value)}
|
||||||
onChange={setScene}
|
|
||||||
allowClear
|
|
||||||
style={{ width: 130 }}
|
style={{ width: 130 }}
|
||||||
options={[
|
options={[
|
||||||
|
{ value: ALL_FILTER_VALUE, label: '全部' },
|
||||||
{ value: 'comparison', label: '比价' },
|
{ value: 'comparison', label: '比价' },
|
||||||
{ value: 'coupon', label: '领券' },
|
{ value: 'coupon', label: '领券' },
|
||||||
{ value: 'welfare', label: '福利' },
|
{ value: 'welfare', label: '福利' },
|
||||||
@@ -858,16 +913,16 @@ export default function AdRevenueReportPage() {
|
|||||||
</Divider>
|
</Divider>
|
||||||
<Row gutter={[16, 12]}>
|
<Row gutter={[16, 12]}>
|
||||||
<Col flex="1 1 0">
|
<Col flex="1 1 0">
|
||||||
<Statistic title="预估收益合计(元)" value={data.total_revenue_yuan} precision={4} />
|
<Statistic title="客户端 SDK 展示预估(元)" value={data.total_revenue_yuan} precision={4} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col flex="1 1 0">
|
<Col flex="1 1 0">
|
||||||
<Statistic
|
<Statistic
|
||||||
title={
|
title={
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={`每活跃用户广告预估收入 = 区间预估收益 ÷ 区间去重活跃用户(口径同数据大盘)。统计区间:${dauRangeLabel || '—'}`}
|
title={`客户端 SDK 展示预估 ÷ 区间去重活跃用户。ADN Reporting API 可能只覆盖已配置回传的广告源,不能作为全量 ARPU。统计区间:${dauRangeLabel || '—'}`}
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
{dauRangeIsToday ? 'ARPU(今日)' : 'ARPU'}
|
SDK 预估 ARPU
|
||||||
<InfoCircleOutlined style={{ marginLeft: 4 }} />
|
<InfoCircleOutlined style={{ marginLeft: 4 }} />
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -896,7 +951,7 @@ export default function AdRevenueReportPage() {
|
|||||||
</Col>
|
</Col>
|
||||||
<Col flex="1 1 0">
|
<Col flex="1 1 0">
|
||||||
<Statistic
|
<Statistic
|
||||||
title="预估广告毛利(元)"
|
title="SDK 预估广告毛利(元)"
|
||||||
value={derived.grossProfit}
|
value={derived.grossProfit}
|
||||||
precision={4}
|
precision={4}
|
||||||
prefix={derived.grossProfit >= 0 ? <RiseOutlined /> : <FallOutlined />}
|
prefix={derived.grossProfit >= 0 ? <RiseOutlined /> : <FallOutlined />}
|
||||||
@@ -909,9 +964,9 @@ export default function AdRevenueReportPage() {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
||||||
<Tooltip title="来自穿山甲 GroMore 数据 API(后台结算口径,T+1 次日出数)。穿山甲不提供分用户/类型/场景维度,故仅在「全量视图」(未按用户/类型/场景筛选)展示;按代码位×应用×日期汇总。revenue=预估收益、收益API=各 ADN 回传更接近结算。">
|
<Tooltip title="来自 GroMore 天级数据 API。revenue 是排序价/竞价实时价预估;api_revenue 是已配置 ADN 的 Reporting 回传收益。D+1 14:00 后仅表示 API 同步窗口完成,不代表全部广告源或最终结算。">
|
||||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
穿山甲后台收益(T+1)
|
GroMore / ADN 收益对账(T+1)
|
||||||
<InfoCircleOutlined style={{ marginLeft: 4 }} />
|
<InfoCircleOutlined style={{ marginLeft: 4 }} />
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -920,29 +975,41 @@ export default function AdRevenueReportPage() {
|
|||||||
<Row gutter={[16, 12]}>
|
<Row gutter={[16, 12]}>
|
||||||
<Col flex="1 1 0">
|
<Col flex="1 1 0">
|
||||||
<Statistic
|
<Statistic
|
||||||
title="穿山甲预估收益(元)"
|
title="GroMore 排序价预估(元)"
|
||||||
value={data.total_pangle_revenue_yuan ?? 0}
|
value={data.total_pangle_revenue_yuan ?? 0}
|
||||||
precision={4}
|
precision={4}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col flex="1 1 0">
|
<Col flex="1 1 0">
|
||||||
<Statistic
|
<Statistic
|
||||||
title="穿山甲收益API(元)"
|
title="ADN Reporting API 收益(元)"
|
||||||
value={data.total_pangle_api_revenue_yuan ?? '-'}
|
value={data.total_pangle_api_revenue_yuan ?? '-'}
|
||||||
precision={data.total_pangle_api_revenue_yuan == null ? undefined : 4}
|
precision={data.total_pangle_api_revenue_yuan == null ? undefined : 4}
|
||||||
/>
|
/>
|
||||||
{data.total_pangle_api_revenue_yuan == null && (
|
{data.total_pangle_api_revenue_yuan == null ? (
|
||||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
未配 Reporting / 当天无
|
未配置 Reporting、当天未出数或所选维度不可对账
|
||||||
|
</Typography.Text>
|
||||||
|
) : (
|
||||||
|
<Typography.Text
|
||||||
|
type={data.pangle_api_revenue_complete ? 'success' : 'warning'}
|
||||||
|
style={{ fontSize: 12 }}
|
||||||
|
>
|
||||||
|
{data.pangle_api_revenue_complete
|
||||||
|
? '已完成 API 同步(不代表全量结算)'
|
||||||
|
: '暂估,等待 14:30 API 同步'}
|
||||||
|
{data.pangle_latest_synced_at
|
||||||
|
? ` · 同步于 ${formatUtcTime(data.pangle_latest_synced_at)}`
|
||||||
|
: ''}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
<Col flex="1 1 0">
|
<Col flex="1 1 0">
|
||||||
<Statistic
|
<Statistic
|
||||||
title={
|
title={
|
||||||
<Tooltip title="客户端预估相对穿山甲预估的高估幅度 =(客户端预估 − 穿山甲预估)÷ 穿山甲预估;客户端按 onAdShow 计、不滤无效曝光,通常偏高">
|
<Tooltip title="客户端 SDK 展示预估相对 GroMore 排序价预估的差异;两者都是估算,只用于检查埋点和排序价口径,不代表结算差异">
|
||||||
<span>
|
<span>
|
||||||
客户端预估偏差
|
SDK / GroMore 预估差
|
||||||
<InfoCircleOutlined style={{ marginLeft: 4 }} />
|
<InfoCircleOutlined style={{ marginLeft: 4 }} />
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -967,8 +1034,7 @@ export default function AdRevenueReportPage() {
|
|||||||
</Row>
|
</Row>
|
||||||
) : (
|
) : (
|
||||||
<Typography.Text type="secondary" style={{ fontSize: 13 }}>
|
<Typography.Text type="secondary" style={{ fontSize: 13 }}>
|
||||||
本视图无穿山甲后台收益:仅「全量视图」(未按用户/类型/场景筛选)且对应日期已同步到数据时展示。
|
本视图无 GroMore/ADN 对账收益:仅未按用户、类型、场景筛选且对应日期已同步时展示。
|
||||||
穿山甲 T+1 出数,可由 <Typography.Text code>scripts/sync_pangle_revenue</Typography.Text> 每日拉取入库。
|
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
)}
|
)}
|
||||||
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
||||||
@@ -981,19 +1047,19 @@ export default function AdRevenueReportPage() {
|
|||||||
<Statistic title="Draw 信息流收益(元)" value={drawStat?.revenue_yuan ?? 0} precision={4} />
|
<Statistic title="Draw 信息流收益(元)" value={drawStat?.revenue_yuan ?? 0} precision={4} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="Draw 信息流 eCPM(元/千次)" value={ecpmOf(drawStat)} precision={2} />
|
<Statistic title="Draw 信息流 eCPM(元/千次)" value={drawStat?.ecpm_yuan ?? 0} precision={2} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="Draw 信息流条数" value={drawStat?.impressions ?? 0} />
|
<Statistic title="Draw 信息流条数" value={drawStat?.impressions ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="看视频收益(元)" value={rvStat?.revenue_yuan ?? 0} precision={4} />
|
<Statistic title={`${videoLabel}收益(元)`} value={videoStat?.revenue_yuan ?? 0} precision={4} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="看视频 eCPM(元/千次)" value={ecpmOf(rvStat)} precision={2} />
|
<Statistic title={`${videoLabel} eCPM(元/千次)`} value={videoStat?.ecpm_yuan ?? 0} precision={2} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="看视频条数" value={rvStat?.impressions ?? 0} />
|
<Statistic title={`${videoLabel}条数`} value={videoStat?.impressions ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
||||||
@@ -1058,7 +1124,7 @@ export default function AdRevenueReportPage() {
|
|||||||
verticalAlign: 'middle',
|
verticalAlign: 'middle',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
穿山甲后台收益(元)
|
GroMore 排序价预估(元)
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
@@ -1102,7 +1168,11 @@ export default function AdRevenueReportPage() {
|
|||||||
style={{ marginTop: 8 }}
|
style={{ marginTop: 8 }}
|
||||||
rowKey="record_id"
|
rowKey="record_id"
|
||||||
columns={DETAIL_COLUMNS}
|
columns={DETAIL_COLUMNS}
|
||||||
dataSource={r.sub_rewards.map((detail) => ({ ...detail, source_adn: r.adn }))}
|
dataSource={r.sub_rewards.map((detail) => ({
|
||||||
|
...detail,
|
||||||
|
// 一次比价/领券可能由不同 ADN 连续填充,必须优先显示本条发奖记录的来源。
|
||||||
|
source_adn: detail.adn ?? r.adn,
|
||||||
|
}))}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
size="small"
|
size="small"
|
||||||
scroll={{ x: 900 }}
|
scroll={{ x: 900 }}
|
||||||
@@ -1110,15 +1180,18 @@ export default function AdRevenueReportPage() {
|
|||||||
</div>
|
</div>
|
||||||
) : r.reward_detail ? (
|
) : r.reward_detail ? (
|
||||||
<div>
|
<div>
|
||||||
<Typography.Text strong>金币复算明细</Typography.Text>{' '}
|
<Typography.Text strong>本次广告逐条明细</Typography.Text>{' '}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
(本条广告 应发 {r.reward_detail.expected_coin} / 实发 {r.reward_detail.actual_coin})
|
(共 1 条 · 应发 {r.reward_detail.expected_coin} / 实发 {r.reward_detail.actual_coin})
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
<Table<AdRevenueDetailRow>
|
<Table<AdRevenueDetailRow>
|
||||||
style={{ marginTop: 8 }}
|
style={{ marginTop: 8 }}
|
||||||
rowKey="record_id"
|
rowKey="record_id"
|
||||||
columns={DETAIL_COLUMNS}
|
columns={DETAIL_COLUMNS}
|
||||||
dataSource={[{ ...r.reward_detail, source_adn: r.adn }]}
|
dataSource={[{
|
||||||
|
...r.reward_detail,
|
||||||
|
source_adn: r.reward_detail.adn ?? r.adn,
|
||||||
|
}]}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
size="small"
|
size="small"
|
||||||
scroll={{ x: 900 }}
|
scroll={{ x: 900 }}
|
||||||
@@ -1126,24 +1199,17 @@ export default function AdRevenueReportPage() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<Typography.Text strong>展示明细</Typography.Text>{' '}
|
<Typography.Text strong>本次广告逐条明细</Typography.Text>{' '}
|
||||||
<Typography.Text type="secondary">(纯展示事件,未单独发奖,无金币复算)</Typography.Text>
|
<Typography.Text type="secondary">(共 1 条 · 应发 0 / 实发 0;仅展示,未单独发奖)</Typography.Text>
|
||||||
<Descriptions size="small" column={3} bordered style={{ marginTop: 8 }}>
|
<Table<AdRevenueDetailRow>
|
||||||
<Descriptions.Item label="时间">{formatUtcTime(r.created_at)}</Descriptions.Item>
|
style={{ marginTop: 8 }}
|
||||||
<Descriptions.Item label="eCPM(分)">{r.ecpm ?? '-'}</Descriptions.Item>
|
rowKey="record_id"
|
||||||
<Descriptions.Item label="eCPM(元)">
|
columns={DETAIL_COLUMNS}
|
||||||
{r.ecpm != null && !Number.isNaN(Number(r.ecpm))
|
dataSource={[impressionOnlyDetail(r)]}
|
||||||
? (Number(r.ecpm) / 100).toFixed(2)
|
pagination={false}
|
||||||
: '-'}
|
size="small"
|
||||||
</Descriptions.Item>
|
scroll={{ x: 900 }}
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
NotificationOutlined,
|
NotificationOutlined,
|
||||||
ProfileOutlined,
|
ProfileOutlined,
|
||||||
SafetyCertificateOutlined,
|
SafetyCertificateOutlined,
|
||||||
|
SecurityScanOutlined,
|
||||||
SettingOutlined,
|
SettingOutlined,
|
||||||
ShareAltOutlined,
|
ShareAltOutlined,
|
||||||
TeamOutlined,
|
TeamOutlined,
|
||||||
@@ -95,6 +96,7 @@ const NAV_GROUPS: NavGroup[] = [
|
|||||||
icon: <FileSearchOutlined />,
|
icon: <FileSearchOutlined />,
|
||||||
label: '监控审计',
|
label: '监控审计',
|
||||||
children: [
|
children: [
|
||||||
|
{ key: '/risk-monitor', icon: <SecurityScanOutlined />, label: '风控监控' },
|
||||||
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
|
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
|
||||||
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
|
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
|
||||||
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
||||||
|
|||||||
@@ -0,0 +1,356 @@
|
|||||||
|
.page {
|
||||||
|
min-height: calc(100vh - 112px);
|
||||||
|
margin: -24px;
|
||||||
|
padding: 0 16px 28px;
|
||||||
|
background: #f5f5f3;
|
||||||
|
color: #171717;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
min-height: 72px;
|
||||||
|
margin: 0 -16px 18px;
|
||||||
|
padding: 0 24px;
|
||||||
|
border-bottom: 1px solid #e8e8e6;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titleCluster,
|
||||||
|
.brandLine,
|
||||||
|
.updated,
|
||||||
|
.rule,
|
||||||
|
.deviceCell,
|
||||||
|
.actionGroup,
|
||||||
|
.factRow {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back {
|
||||||
|
margin-right: 18px;
|
||||||
|
color: #555;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brandMark {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
margin-right: 12px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #ffd400;
|
||||||
|
color: #111;
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
margin-top: 3px;
|
||||||
|
color: #929292;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.updated {
|
||||||
|
gap: 7px;
|
||||||
|
color: #898989;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.updatedMeta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #9b9b9b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryGrid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 14px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusToolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border: 1px solid #ecece8;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusToolbar > div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusToolbar strong {
|
||||||
|
color: #222;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusToolbar span {
|
||||||
|
color: #888;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryCard {
|
||||||
|
min-height: 148px;
|
||||||
|
padding: 26px 24px 20px;
|
||||||
|
border: 1px solid #eeeeeb;
|
||||||
|
border-radius: 16px;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryTitle {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
color: #111;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryValue {
|
||||||
|
color: #ee3737;
|
||||||
|
font-size: 38px;
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.08;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryUnit {
|
||||||
|
margin-left: 5px;
|
||||||
|
color: #202020;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summarySub {
|
||||||
|
margin: 8px 0 8px;
|
||||||
|
color: #969696;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule {
|
||||||
|
width: fit-content;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #f6f6f4;
|
||||||
|
color: #111;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: background 0.18s ease, box-shadow 0.18s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule:hover,
|
||||||
|
.rule:focus-visible {
|
||||||
|
background: #fff3bf;
|
||||||
|
box-shadow: 0 0 0 2px rgba(255, 212, 0, 0.3);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule strong {
|
||||||
|
margin-left: 4px;
|
||||||
|
color: #df2727;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleEditIcon {
|
||||||
|
margin-left: 7px;
|
||||||
|
color: #777;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleDialogIntro {
|
||||||
|
margin: 0 0 16px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #faf8ef;
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleSettings {
|
||||||
|
border-top: 1px solid #f0f0ed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleSettingRow {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) 140px;
|
||||||
|
gap: 20px;
|
||||||
|
align-items: center;
|
||||||
|
padding: 16px 0;
|
||||||
|
border-bottom: 1px solid #f0f0ed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleSettingCopy {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleSettingCopy strong {
|
||||||
|
color: #222;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleSettingCopy span {
|
||||||
|
color: #888;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleValueEditor {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ruleValueEditor :global(.ant-input-number) {
|
||||||
|
width: 110px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
margin-top: 14px;
|
||||||
|
padding: 20px 20px 16px;
|
||||||
|
border: 1px solid #ecece8;
|
||||||
|
border-radius: 16px;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sectionTitle {
|
||||||
|
margin: 0 0 10px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deviceCell {
|
||||||
|
gap: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mono {
|
||||||
|
max-width: 210px;
|
||||||
|
overflow: hidden;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copyButton {
|
||||||
|
height: 25px !important;
|
||||||
|
padding: 0 7px !important;
|
||||||
|
color: #777 !important;
|
||||||
|
font-size: 12px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionGroup {
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 6px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expandButton {
|
||||||
|
border-color: #ffd400 !important;
|
||||||
|
background: #ffd400 !important;
|
||||||
|
color: #111 !important;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detailWrap {
|
||||||
|
padding: 12px 16px 6px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #fafaf8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.factRow {
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fact {
|
||||||
|
padding: 6px 10px;
|
||||||
|
border: 1px solid #ecece7;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #fff;
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fact strong {
|
||||||
|
margin: 0 3px;
|
||||||
|
color: #111;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.price {
|
||||||
|
white-space: nowrap;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.na {
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerNote {
|
||||||
|
margin-top: 16px;
|
||||||
|
padding: 16px 20px;
|
||||||
|
border: 1px dashed #dcdcd8;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: rgba(255, 255, 255, 0.42);
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerNote strong {
|
||||||
|
color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.summaryGrid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
align-items: flex-start;
|
||||||
|
padding-top: 16px;
|
||||||
|
padding-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.updatedMeta {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusToolbar {
|
||||||
|
align-items: flex-start;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,902 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import {
|
||||||
|
App,
|
||||||
|
Button,
|
||||||
|
Empty,
|
||||||
|
InputNumber,
|
||||||
|
Modal,
|
||||||
|
Segmented,
|
||||||
|
Skeleton,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
Tooltip,
|
||||||
|
} from 'antd';
|
||||||
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import {
|
||||||
|
ClearOutlined,
|
||||||
|
CopyOutlined,
|
||||||
|
DownOutlined,
|
||||||
|
EditOutlined,
|
||||||
|
ReloadOutlined,
|
||||||
|
RightOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import { api, errMsg } from '@/lib/api';
|
||||||
|
import { formatUtcTime, utcDayjs } from '@/lib/format';
|
||||||
|
import type {
|
||||||
|
RiskDetailItem,
|
||||||
|
RiskDetailPage,
|
||||||
|
RiskIncidentItem,
|
||||||
|
RiskIncidentPage,
|
||||||
|
RiskKind,
|
||||||
|
RiskMonitorSummary,
|
||||||
|
RiskResetResponse,
|
||||||
|
RiskRuleConfig,
|
||||||
|
RiskSummaryCard,
|
||||||
|
} from '@/lib/types';
|
||||||
|
import styles from './page.module.css';
|
||||||
|
|
||||||
|
const KIND_META: Record<
|
||||||
|
RiskKind,
|
||||||
|
{ title: string; summaryTitle: string; totalLabel: string; unit: string }
|
||||||
|
> = {
|
||||||
|
sms: {
|
||||||
|
title: '短信',
|
||||||
|
summaryTitle: '触发短信报警的设备',
|
||||||
|
totalLabel: '今日短信下发共',
|
||||||
|
unit: '台',
|
||||||
|
},
|
||||||
|
oneclick: {
|
||||||
|
title: '一键登录',
|
||||||
|
summaryTitle: '触发一键登录报警的设备',
|
||||||
|
totalLabel: '今日一键登录共',
|
||||||
|
unit: '台',
|
||||||
|
},
|
||||||
|
compare: {
|
||||||
|
title: '比价',
|
||||||
|
summaryTitle: '触发比价报警的账户',
|
||||||
|
totalLabel: '今日比价共',
|
||||||
|
unit: '个',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const integer = (value: number) => new Intl.NumberFormat('zh-CN').format(value);
|
||||||
|
const LIST_PAGE_SIZE = 20;
|
||||||
|
const RISK_KINDS: RiskKind[] = ['sms', 'oneclick', 'compare'];
|
||||||
|
type IncidentStatus = 'open' | 'blocked';
|
||||||
|
const RULE_LIMITS: Record<RiskKind, { min: number; max: number; help: string }> = {
|
||||||
|
sms: {
|
||||||
|
min: 1,
|
||||||
|
max: 5,
|
||||||
|
help: '统计成功下发;最高5次,与现有每设备每小时发送上限一致。',
|
||||||
|
},
|
||||||
|
oneclick: {
|
||||||
|
min: 1,
|
||||||
|
max: 100000,
|
||||||
|
help: '成功和失败均计入,同一设备按北京时间自然日累计。',
|
||||||
|
},
|
||||||
|
compare: {
|
||||||
|
min: 1,
|
||||||
|
max: 100,
|
||||||
|
help: '同一账户按北京时间自然日累计;最高100次,与比价每日上限一致。',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const utcTime = (value: string | null, withDate = true) =>
|
||||||
|
formatUtcTime(value, withDate ? 'MM-DD HH:mm' : 'HH:mm');
|
||||||
|
const eventMoment = (value: string, kind: RiskKind) =>
|
||||||
|
kind === 'compare' ? dayjs(value) : utcDayjs(value).tz('Asia/Shanghai');
|
||||||
|
const eventTime = (value: string | null, kind: RiskKind, withDate = true) =>
|
||||||
|
value ? eventMoment(value, kind).format(withDate ? 'MM-DD HH:mm' : 'HH:mm') : '-';
|
||||||
|
|
||||||
|
function period(item: RiskIncidentItem): string {
|
||||||
|
const start = eventMoment(item.first_event_at, item.kind);
|
||||||
|
const end = eventMoment(item.last_event_at, item.kind);
|
||||||
|
if (start.isSame(end, 'day')) {
|
||||||
|
return `${start.format('YYYY-MM-DD HH:mm')}–${end.format('HH:mm')}`;
|
||||||
|
}
|
||||||
|
return `${start.format('YYYY-MM-DD HH:mm')}–${end.format('YYYY-MM-DD HH:mm')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function DeviceId({
|
||||||
|
value,
|
||||||
|
onCopy,
|
||||||
|
}: {
|
||||||
|
value: string | null;
|
||||||
|
onCopy: (value: string) => void;
|
||||||
|
}) {
|
||||||
|
if (!value) return <span className={styles.na}>-</span>;
|
||||||
|
return (
|
||||||
|
<span className={styles.deviceCell}>
|
||||||
|
<Tooltip title={value}>
|
||||||
|
<span className={styles.mono}>{value}</span>
|
||||||
|
</Tooltip>
|
||||||
|
<Button
|
||||||
|
className={styles.copyButton}
|
||||||
|
size="small"
|
||||||
|
icon={<CopyOutlined />}
|
||||||
|
onClick={() => onCopy(value)}
|
||||||
|
>
|
||||||
|
复制
|
||||||
|
</Button>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DetailTable({
|
||||||
|
detail,
|
||||||
|
loading,
|
||||||
|
page,
|
||||||
|
onPage,
|
||||||
|
}: {
|
||||||
|
detail?: RiskDetailPage;
|
||||||
|
loading: boolean;
|
||||||
|
page: number;
|
||||||
|
onPage: (page: number) => void;
|
||||||
|
}) {
|
||||||
|
if (loading || !detail) return <Skeleton active paragraph={{ rows: 4 }} />;
|
||||||
|
let columns: ColumnsType<RiskDetailItem>;
|
||||||
|
if (detail.kind === 'sms') {
|
||||||
|
columns = [
|
||||||
|
{
|
||||||
|
title: '发送时间',
|
||||||
|
dataIndex: 'occurred_at',
|
||||||
|
width: 150,
|
||||||
|
render: (v) => eventTime(v, detail.kind),
|
||||||
|
},
|
||||||
|
{ title: '手机号', dataIndex: 'phone', width: 140, render: (v) => v || '-' },
|
||||||
|
{
|
||||||
|
title: '完成验证',
|
||||||
|
dataIndex: 'verified',
|
||||||
|
width: 100,
|
||||||
|
render: (v) => (v ? <Tag color="success">是</Tag> : <Tag>否</Tag>),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '登录账号',
|
||||||
|
key: 'account',
|
||||||
|
render: (_, row) => row.username || (row.user_id ? `U${row.user_id}` : '-'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '账号注册时间',
|
||||||
|
dataIndex: 'account_registered_at',
|
||||||
|
width: 150,
|
||||||
|
render: (v) => utcTime(v),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else if (detail.kind === 'oneclick') {
|
||||||
|
columns = [
|
||||||
|
{
|
||||||
|
title: '登录时间',
|
||||||
|
dataIndex: 'occurred_at',
|
||||||
|
width: 150,
|
||||||
|
render: (v) => eventTime(v, detail.kind),
|
||||||
|
},
|
||||||
|
{ title: '手机号', dataIndex: 'phone', width: 140, render: (v) => v || '-' },
|
||||||
|
{
|
||||||
|
title: '登录账号',
|
||||||
|
key: 'account',
|
||||||
|
render: (_, row) => row.username || (row.user_id ? `U${row.user_id}` : '-'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '账号注册时间',
|
||||||
|
dataIndex: 'account_registered_at',
|
||||||
|
width: 150,
|
||||||
|
render: (v) => utcTime(v),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '结果',
|
||||||
|
dataIndex: 'outcome',
|
||||||
|
width: 100,
|
||||||
|
render: (v) =>
|
||||||
|
v === 'success' ? <Tag color="success">成功</Tag> : <Tag color="error">失败</Tag>,
|
||||||
|
},
|
||||||
|
{ title: '失败原因', dataIndex: 'reason', render: (v) => v || '-' },
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
const priceColumn = (platform: string) => ({
|
||||||
|
title: platform,
|
||||||
|
key: platform,
|
||||||
|
width: 100,
|
||||||
|
render: (_: unknown, row: RiskDetailItem) => {
|
||||||
|
const value = row.prices?.[platform];
|
||||||
|
return value == null ? (
|
||||||
|
<span className={styles.na}>未参与</span>
|
||||||
|
) : (
|
||||||
|
<span className={styles.price}>¥{value.toFixed(2)}</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
columns = [
|
||||||
|
{
|
||||||
|
title: '触发时间',
|
||||||
|
dataIndex: 'occurred_at',
|
||||||
|
width: 150,
|
||||||
|
render: (v) => eventTime(v, detail.kind),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '店铺 / 菜品',
|
||||||
|
key: 'shop',
|
||||||
|
render: (_, row) => (
|
||||||
|
<span>{[row.store_name, row.product_names].filter(Boolean).join(' · ') || '-'}</span>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
priceColumn('美团'),
|
||||||
|
priceColumn('淘宝'),
|
||||||
|
priceColumn('京东'),
|
||||||
|
{
|
||||||
|
title: '节省',
|
||||||
|
dataIndex: 'saved_amount_yuan',
|
||||||
|
width: 90,
|
||||||
|
render: (v) => (v == null ? '-' : <span className={styles.price}>{v.toFixed(2)} 元</span>),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 90,
|
||||||
|
render: (v) =>
|
||||||
|
v === 'success' ? <Tag color="success">已完成</Tag> : <Tag color="error">失败</Tag>,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className={styles.detailWrap}>
|
||||||
|
<div className={styles.factRow}>
|
||||||
|
<span className={styles.fact}>
|
||||||
|
当期{KIND_META[detail.kind].title}
|
||||||
|
<strong>{integer(detail.event_count)}</strong>次
|
||||||
|
</span>
|
||||||
|
{detail.distinct_accounts != null && (
|
||||||
|
<span className={styles.fact}>
|
||||||
|
登录<strong>{integer(detail.distinct_accounts)}</strong>个不同账号
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<Table
|
||||||
|
rowKey="id"
|
||||||
|
size="small"
|
||||||
|
columns={columns}
|
||||||
|
dataSource={detail.items}
|
||||||
|
scroll={{ x: detail.kind === 'compare' ? 1000 : 720 }}
|
||||||
|
pagination={{
|
||||||
|
current: page,
|
||||||
|
pageSize: 20,
|
||||||
|
total: detail.total,
|
||||||
|
showSizeChanger: false,
|
||||||
|
onChange: onPage,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function RiskMonitorPage() {
|
||||||
|
const { message, modal } = App.useApp();
|
||||||
|
const [summary, setSummary] = useState<RiskMonitorSummary | null>(null);
|
||||||
|
const [lists, setLists] = useState<Partial<Record<RiskKind, RiskIncidentPage>>>({});
|
||||||
|
const [listPage, setListPage] = useState<Record<RiskKind, number>>({
|
||||||
|
sms: 1,
|
||||||
|
oneclick: 1,
|
||||||
|
compare: 1,
|
||||||
|
});
|
||||||
|
const [incidentStatus, setIncidentStatus] = useState<IncidentStatus>('open');
|
||||||
|
const listPageRef = useRef(listPage);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [expanded, setExpanded] = useState<Set<number>>(new Set());
|
||||||
|
const [details, setDetails] = useState<Record<number, RiskDetailPage>>({});
|
||||||
|
const [detailLoading, setDetailLoading] = useState<Set<number>>(new Set());
|
||||||
|
const [detailPage, setDetailPage] = useState<Record<number, number>>({});
|
||||||
|
const [acting, setActing] = useState<number | null>(null);
|
||||||
|
const [ruleOpen, setRuleOpen] = useState(false);
|
||||||
|
const [ruleSaving, setRuleSaving] = useState(false);
|
||||||
|
const [resetting, setResetting] = useState(false);
|
||||||
|
const [ruleDraft, setRuleDraft] = useState<Record<RiskKind, number>>({
|
||||||
|
sms: 5,
|
||||||
|
oneclick: 20,
|
||||||
|
compare: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadAll = useCallback(async (quiet = false) => {
|
||||||
|
if (!quiet) setLoading(true);
|
||||||
|
try {
|
||||||
|
const pages = listPageRef.current;
|
||||||
|
const [summaryRes, smsRes, oneclickRes, compareRes] = await Promise.all([
|
||||||
|
api.get<RiskMonitorSummary>('/admin/api/risk-monitor/summary'),
|
||||||
|
api.get<RiskIncidentPage>('/admin/api/risk-monitor/incidents/sms', {
|
||||||
|
params: {
|
||||||
|
status: incidentStatus,
|
||||||
|
cursor: (pages.sms - 1) * LIST_PAGE_SIZE,
|
||||||
|
limit: LIST_PAGE_SIZE,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
api.get<RiskIncidentPage>('/admin/api/risk-monitor/incidents/oneclick', {
|
||||||
|
params: {
|
||||||
|
status: incidentStatus,
|
||||||
|
cursor: (pages.oneclick - 1) * LIST_PAGE_SIZE,
|
||||||
|
limit: LIST_PAGE_SIZE,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
api.get<RiskIncidentPage>('/admin/api/risk-monitor/incidents/compare', {
|
||||||
|
params: {
|
||||||
|
status: incidentStatus,
|
||||||
|
cursor: (pages.compare - 1) * LIST_PAGE_SIZE,
|
||||||
|
limit: LIST_PAGE_SIZE,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
setSummary(summaryRes.data);
|
||||||
|
setLists({
|
||||||
|
sms: smsRes.data,
|
||||||
|
oneclick: oneclickRes.data,
|
||||||
|
compare: compareRes.data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
void message.error(errMsg(error, '风控数据加载失败'));
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [incidentStatus, message]);
|
||||||
|
|
||||||
|
const changeListPage = useCallback(
|
||||||
|
async (kind: RiskKind, page: number) => {
|
||||||
|
const nextPages = { ...listPageRef.current, [kind]: page };
|
||||||
|
listPageRef.current = nextPages;
|
||||||
|
setListPage(nextPages);
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<RiskIncidentPage>(
|
||||||
|
`/admin/api/risk-monitor/incidents/${kind}`,
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
status: incidentStatus,
|
||||||
|
cursor: (page - 1) * LIST_PAGE_SIZE,
|
||||||
|
limit: LIST_PAGE_SIZE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
setLists((current) => ({ ...current, [kind]: data }));
|
||||||
|
} catch (error) {
|
||||||
|
void message.error(errMsg(error, '风险列表加载失败'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[incidentStatus, message],
|
||||||
|
);
|
||||||
|
|
||||||
|
const changeIncidentStatus = useCallback((status: IncidentStatus) => {
|
||||||
|
const firstPage = { sms: 1, oneclick: 1, compare: 1 };
|
||||||
|
listPageRef.current = firstPage;
|
||||||
|
setListPage(firstPage);
|
||||||
|
setLists({});
|
||||||
|
setExpanded(new Set());
|
||||||
|
setDetails({});
|
||||||
|
setDetailLoading(new Set());
|
||||||
|
setDetailPage({});
|
||||||
|
setIncidentStatus(status);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void loadAll();
|
||||||
|
const timer = window.setInterval(() => void loadAll(true), 60 * 60 * 1000);
|
||||||
|
const onFocus = () => void loadAll(true);
|
||||||
|
window.addEventListener('focus', onFocus);
|
||||||
|
return () => {
|
||||||
|
window.clearInterval(timer);
|
||||||
|
window.removeEventListener('focus', onFocus);
|
||||||
|
};
|
||||||
|
}, [loadAll]);
|
||||||
|
|
||||||
|
const copy = useCallback(
|
||||||
|
async (value: string) => {
|
||||||
|
await navigator.clipboard.writeText(value);
|
||||||
|
void message.success('设备 ID 已复制');
|
||||||
|
},
|
||||||
|
[message],
|
||||||
|
);
|
||||||
|
|
||||||
|
const openRuleSettings = useCallback(() => {
|
||||||
|
if (summary) {
|
||||||
|
const current = Object.fromEntries(
|
||||||
|
summary.cards.map((card) => [card.kind, card.threshold]),
|
||||||
|
) as Record<RiskKind, number>;
|
||||||
|
setRuleDraft(current);
|
||||||
|
}
|
||||||
|
setRuleOpen(true);
|
||||||
|
}, [summary]);
|
||||||
|
|
||||||
|
const saveRules = useCallback(async () => {
|
||||||
|
setRuleSaving(true);
|
||||||
|
try {
|
||||||
|
const payload: RiskRuleConfig = {
|
||||||
|
sms_hourly_threshold: ruleDraft.sms,
|
||||||
|
oneclick_daily_threshold: ruleDraft.oneclick,
|
||||||
|
compare_daily_threshold: ruleDraft.compare,
|
||||||
|
};
|
||||||
|
await api.patch<RiskRuleConfig>('/admin/api/risk-monitor/rules', payload);
|
||||||
|
setRuleOpen(false);
|
||||||
|
void message.success('规则已保存,并已重新核算当前时段');
|
||||||
|
await loadAll(true);
|
||||||
|
} catch (error) {
|
||||||
|
void message.error(errMsg(error, '规则保存失败'));
|
||||||
|
} finally {
|
||||||
|
setRuleSaving(false);
|
||||||
|
}
|
||||||
|
}, [loadAll, message, ruleDraft]);
|
||||||
|
|
||||||
|
const resetAlerts = useCallback(() => {
|
||||||
|
modal.confirm({
|
||||||
|
title: '确认重置全部报警?',
|
||||||
|
content:
|
||||||
|
'短信、一键登录、比价三类待处理报警将归零,并从确认时刻重新累计。历史流水会保留,已封禁的设备和账户不会解封。',
|
||||||
|
okText: '确认重置',
|
||||||
|
okButtonProps: { danger: true },
|
||||||
|
cancelText: '取消',
|
||||||
|
async onOk() {
|
||||||
|
setResetting(true);
|
||||||
|
try {
|
||||||
|
const { data } = await api.post<RiskResetResponse>(
|
||||||
|
'/admin/api/risk-monitor/reset',
|
||||||
|
);
|
||||||
|
listPageRef.current = { sms: 1, oneclick: 1, compare: 1 };
|
||||||
|
setListPage({ sms: 1, oneclick: 1, compare: 1 });
|
||||||
|
setExpanded(new Set());
|
||||||
|
setDetails({});
|
||||||
|
setDetailPage({});
|
||||||
|
if (data.reset_incident_count > 0) {
|
||||||
|
void message.success(
|
||||||
|
`已重置 ${integer(data.reset_incident_count)} 条报警,并从 0 重新累计`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
void message.success('当前无待处理报警,新的累计基线已生效');
|
||||||
|
}
|
||||||
|
await loadAll(true);
|
||||||
|
} catch (error) {
|
||||||
|
void message.error(errMsg(error, '报警重置失败'));
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
setResetting(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, [loadAll, message, modal]);
|
||||||
|
|
||||||
|
const loadDetail = useCallback(
|
||||||
|
async (kind: RiskKind, incidentId: number, page = 1) => {
|
||||||
|
setDetailLoading((current) => new Set(current).add(incidentId));
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<RiskDetailPage>(
|
||||||
|
`/admin/api/risk-monitor/incidents/${kind}/${incidentId}/details`,
|
||||||
|
{ params: { cursor: (page - 1) * 20, limit: 20 } },
|
||||||
|
);
|
||||||
|
setDetails((current) => ({ ...current, [incidentId]: data }));
|
||||||
|
setDetailPage((current) => ({ ...current, [incidentId]: page }));
|
||||||
|
} catch (error) {
|
||||||
|
void message.error(errMsg(error, '风险明细加载失败'));
|
||||||
|
} finally {
|
||||||
|
setDetailLoading((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
next.delete(incidentId);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[message],
|
||||||
|
);
|
||||||
|
|
||||||
|
const toggle = useCallback(
|
||||||
|
(row: RiskIncidentItem) => {
|
||||||
|
const willOpen = !expanded.has(row.incident_id);
|
||||||
|
setExpanded((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
if (willOpen) next.add(row.incident_id);
|
||||||
|
else next.delete(row.incident_id);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
if (willOpen && !details[row.incident_id]) {
|
||||||
|
void loadDetail(row.kind, row.incident_id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[details, expanded, loadDetail],
|
||||||
|
);
|
||||||
|
|
||||||
|
const runAction = useCallback(
|
||||||
|
(row: RiskIncidentItem, action: 'ignore' | 'block') => {
|
||||||
|
const verb = action === 'block' ? '封禁' : '忽略';
|
||||||
|
modal.confirm({
|
||||||
|
title: `确认${verb}该${row.subject_type === 'device' ? '设备' : '账户'}?`,
|
||||||
|
content:
|
||||||
|
action === 'block'
|
||||||
|
? row.subject_type === 'device'
|
||||||
|
? '封禁后,该设备发送短信和一键登录会被直接拒绝,不影响它登录过的账户。'
|
||||||
|
: '封禁后,该账户不能发起比价、领取任务奖励或提现,现有金币和现金不会清零。'
|
||||||
|
: '忽略后,本风险事件会移出待处理列表,事实流水仍会保留。',
|
||||||
|
okText: verb,
|
||||||
|
okButtonProps: { danger: action === 'block' },
|
||||||
|
cancelText: '取消',
|
||||||
|
async onOk() {
|
||||||
|
setActing(row.incident_id);
|
||||||
|
try {
|
||||||
|
await api.post(`/admin/api/risk-monitor/incidents/${row.incident_id}/${action}`, {
|
||||||
|
reason: `风控监控页人工${verb}`,
|
||||||
|
});
|
||||||
|
void message.success(`${verb}成功`);
|
||||||
|
setExpanded((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
next.delete(row.incident_id);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
if (
|
||||||
|
(lists[row.kind]?.items.length ?? 0) === 1
|
||||||
|
&& listPageRef.current[row.kind] > 1
|
||||||
|
) {
|
||||||
|
const nextPages = {
|
||||||
|
...listPageRef.current,
|
||||||
|
[row.kind]: listPageRef.current[row.kind] - 1,
|
||||||
|
};
|
||||||
|
listPageRef.current = nextPages;
|
||||||
|
setListPage(nextPages);
|
||||||
|
}
|
||||||
|
await loadAll(true);
|
||||||
|
} catch (error) {
|
||||||
|
void message.error(errMsg(error));
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
setActing(null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[lists, loadAll, message, modal],
|
||||||
|
);
|
||||||
|
|
||||||
|
const revokeRestriction = useCallback(
|
||||||
|
(row: RiskIncidentItem) => {
|
||||||
|
if (!row.restriction_id) {
|
||||||
|
void message.error('未找到有效的封禁记录,请刷新后重试');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modal.confirm({
|
||||||
|
title: `确认解除该${row.subject_type === 'device' ? '设备' : '账户'}的封禁?`,
|
||||||
|
content:
|
||||||
|
row.subject_type === 'device'
|
||||||
|
? '解除后,该设备可以重新发送短信验证码和使用一键登录。'
|
||||||
|
: '解除后,该账户可以重新发起比价、领取任务奖励和提现。',
|
||||||
|
okText: '解除封禁',
|
||||||
|
cancelText: '取消',
|
||||||
|
async onOk() {
|
||||||
|
setActing(row.incident_id);
|
||||||
|
try {
|
||||||
|
await api.post(
|
||||||
|
`/admin/api/risk-monitor/restrictions/${row.restriction_id}/revoke`,
|
||||||
|
);
|
||||||
|
void message.success('解除封禁成功');
|
||||||
|
setExpanded((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
next.delete(row.incident_id);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
if (
|
||||||
|
(lists[row.kind]?.items.length ?? 0) === 1
|
||||||
|
&& listPageRef.current[row.kind] > 1
|
||||||
|
) {
|
||||||
|
const nextPages = {
|
||||||
|
...listPageRef.current,
|
||||||
|
[row.kind]: listPageRef.current[row.kind] - 1,
|
||||||
|
};
|
||||||
|
listPageRef.current = nextPages;
|
||||||
|
setListPage(nextPages);
|
||||||
|
}
|
||||||
|
await loadAll(true);
|
||||||
|
} catch (error) {
|
||||||
|
void message.error(errMsg(error, '解除封禁失败'));
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
setActing(null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[lists, loadAll, message, modal],
|
||||||
|
);
|
||||||
|
|
||||||
|
const columns = useCallback(
|
||||||
|
(kind: RiskKind): ColumnsType<RiskIncidentItem> => {
|
||||||
|
const actionColumn = {
|
||||||
|
title: '操作',
|
||||||
|
key: 'actions',
|
||||||
|
align: 'right' as const,
|
||||||
|
fixed: 'right' as const,
|
||||||
|
width: 180,
|
||||||
|
render: (_: unknown, row: RiskIncidentItem) => {
|
||||||
|
const open = expanded.has(row.incident_id);
|
||||||
|
return (
|
||||||
|
<span className={styles.actionGroup}>
|
||||||
|
<Button
|
||||||
|
className={styles.expandButton}
|
||||||
|
size="small"
|
||||||
|
loading={detailLoading.has(row.incident_id)}
|
||||||
|
icon={open ? <DownOutlined /> : <RightOutlined />}
|
||||||
|
onClick={() => toggle(row)}
|
||||||
|
>
|
||||||
|
{open ? '收起' : '展开'}
|
||||||
|
</Button>
|
||||||
|
{row.status === 'open' && (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
danger
|
||||||
|
loading={acting === row.incident_id}
|
||||||
|
onClick={() => runAction(row, 'block')}
|
||||||
|
>
|
||||||
|
封禁
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
loading={acting === row.incident_id}
|
||||||
|
onClick={() => runAction(row, 'ignore')}
|
||||||
|
>
|
||||||
|
忽略
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{row.status === 'blocked' && (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
loading={acting === row.incident_id}
|
||||||
|
disabled={!row.restriction_id}
|
||||||
|
onClick={() => revokeRestriction(row)}
|
||||||
|
>
|
||||||
|
解除封禁
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (kind === 'compare') {
|
||||||
|
return [
|
||||||
|
{ title: '账户手机号', dataIndex: 'phone', width: 130, render: (v) => v || '-' },
|
||||||
|
{
|
||||||
|
title: '注册时间',
|
||||||
|
dataIndex: 'registered_at',
|
||||||
|
width: 105,
|
||||||
|
render: (v) => utcTime(v),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '常用设备',
|
||||||
|
dataIndex: 'common_device_id',
|
||||||
|
width: 180,
|
||||||
|
render: (v) => <DeviceId value={v} onCopy={copy} />,
|
||||||
|
},
|
||||||
|
{ title: '触发时段', key: 'period', width: 180, render: (_, row) => period(row) },
|
||||||
|
{
|
||||||
|
title: '首次触发',
|
||||||
|
dataIndex: 'triggered_at',
|
||||||
|
width: 125,
|
||||||
|
render: (v) => eventTime(v, kind),
|
||||||
|
},
|
||||||
|
actionColumn,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
{ title: '设备型号', dataIndex: 'device_model', width: 120, render: (v) => v || '-' },
|
||||||
|
{
|
||||||
|
title: '设备 ID',
|
||||||
|
dataIndex: 'subject_id',
|
||||||
|
width: 190,
|
||||||
|
render: (v) => <DeviceId value={v} onCopy={copy} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '首次使用',
|
||||||
|
dataIndex: 'first_used_at',
|
||||||
|
width: 110,
|
||||||
|
render: (v) => eventTime(v, kind),
|
||||||
|
},
|
||||||
|
{ title: '触发时段', key: 'period', width: 180, render: (_, row) => period(row) },
|
||||||
|
{
|
||||||
|
title: '首次触发',
|
||||||
|
dataIndex: 'triggered_at',
|
||||||
|
width: 110,
|
||||||
|
render: (v) => eventTime(v, kind),
|
||||||
|
},
|
||||||
|
actionColumn,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
[acting, copy, detailLoading, expanded, revokeRestriction, runAction, toggle],
|
||||||
|
);
|
||||||
|
|
||||||
|
const cards = useMemo(() => {
|
||||||
|
if (!summary) return [];
|
||||||
|
const byKind = Object.fromEntries(summary.cards.map((card) => [card.kind, card]));
|
||||||
|
return RISK_KINDS
|
||||||
|
.map((kind) => byKind[kind])
|
||||||
|
.filter(Boolean) as RiskSummaryCard[];
|
||||||
|
}, [summary]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className={styles.page}>
|
||||||
|
<header className={styles.hero}>
|
||||||
|
<div className={styles.titleCluster}>
|
||||||
|
<span className={styles.back}>‹ 运营后台</span>
|
||||||
|
<span className={styles.brandMark}>傻</span>
|
||||||
|
<div>
|
||||||
|
<h1 className={styles.title}>风控监控</h1>
|
||||||
|
<div className={styles.subtitle}>短信 / 一键登录 / 比价</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.updated}>
|
||||||
|
<span className={styles.updatedMeta}>
|
||||||
|
<span>{summary ? dayjs(summary.date).format('YYYY-MM-DD') : '---- -- --'}</span>
|
||||||
|
<span>•</span>
|
||||||
|
<span className={styles.dot} />
|
||||||
|
<span>每小时更新</span>
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
icon={<ReloadOutlined />}
|
||||||
|
loading={loading}
|
||||||
|
aria-label="刷新风控数据"
|
||||||
|
onClick={() => void loadAll()}
|
||||||
|
/>
|
||||||
|
<Tooltip title="三类待处理报警归零,历史流水和封禁状态不变">
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
icon={<ClearOutlined />}
|
||||||
|
loading={resetting}
|
||||||
|
onClick={resetAlerts}
|
||||||
|
>
|
||||||
|
重置报警
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{loading && !summary ? (
|
||||||
|
<Skeleton active paragraph={{ rows: 10 }} />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<section className={styles.summaryGrid}>
|
||||||
|
{cards.map((card) => {
|
||||||
|
const meta = KIND_META[card.kind];
|
||||||
|
return (
|
||||||
|
<article key={card.kind} className={styles.summaryCard}>
|
||||||
|
<div className={styles.summaryTitle}>{meta.summaryTitle}</div>
|
||||||
|
<div>
|
||||||
|
<span className={styles.summaryValue}>{card.alert_subject_count}</span>
|
||||||
|
<span className={styles.summaryUnit}>{meta.unit}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.summarySub}>
|
||||||
|
{meta.totalLabel} {integer(card.today_total)} 次
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={styles.rule}
|
||||||
|
onClick={openRuleSettings}
|
||||||
|
aria-label={`编辑${meta.title}告警规则`}
|
||||||
|
>
|
||||||
|
规则:
|
||||||
|
<span>{card.rule_text.replace(/≥.*$/, '')}</span>
|
||||||
|
<strong>≥ {card.threshold} 次</strong>
|
||||||
|
<EditOutlined className={styles.ruleEditIcon} />
|
||||||
|
</button>
|
||||||
|
</article>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div className={styles.statusToolbar}>
|
||||||
|
<div>
|
||||||
|
<strong>风险处置</strong>
|
||||||
|
<span>
|
||||||
|
{incidentStatus === 'open'
|
||||||
|
? '查看待处理报警,可执行封禁或忽略'
|
||||||
|
: '查看当前已封禁主体,可恢复其业务权限'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<Segmented
|
||||||
|
value={incidentStatus}
|
||||||
|
options={[
|
||||||
|
{ label: '待处理', value: 'open' },
|
||||||
|
{ label: '已封禁', value: 'blocked' },
|
||||||
|
]}
|
||||||
|
onChange={(value) => changeIncidentStatus(value as IncidentStatus)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{RISK_KINDS.map((kind) => {
|
||||||
|
const data = lists[kind]?.items ?? [];
|
||||||
|
return (
|
||||||
|
<section key={kind} className={styles.section}>
|
||||||
|
<h2 className={styles.sectionTitle}>{KIND_META[kind].title}</h2>
|
||||||
|
<Table
|
||||||
|
rowKey="incident_id"
|
||||||
|
size="middle"
|
||||||
|
columns={columns(kind)}
|
||||||
|
dataSource={data}
|
||||||
|
tableLayout="fixed"
|
||||||
|
scroll={{ x: kind === 'compare' ? 900 : 890 }}
|
||||||
|
locale={{
|
||||||
|
emptyText: (
|
||||||
|
<Empty
|
||||||
|
description={
|
||||||
|
incidentStatus === 'open'
|
||||||
|
? '当前没有待处理风险'
|
||||||
|
: '当前没有已封禁主体'
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
pagination={{
|
||||||
|
current: listPage[kind],
|
||||||
|
pageSize: LIST_PAGE_SIZE,
|
||||||
|
total: lists[kind]?.total ?? 0,
|
||||||
|
hideOnSinglePage: true,
|
||||||
|
showSizeChanger: false,
|
||||||
|
onChange: (page) => void changeListPage(kind, page),
|
||||||
|
}}
|
||||||
|
expandable={{
|
||||||
|
expandedRowKeys: [...expanded],
|
||||||
|
showExpandColumn: false,
|
||||||
|
expandedRowRender: (row) => (
|
||||||
|
<DetailTable
|
||||||
|
detail={details[row.incident_id]}
|
||||||
|
loading={detailLoading.has(row.incident_id)}
|
||||||
|
page={detailPage[row.incident_id] || 1}
|
||||||
|
onPage={(page) => void loadDetail(row.kind, row.incident_id, page)}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
|
<footer className={styles.footerNote}>
|
||||||
|
<strong>处理口径:</strong>
|
||||||
|
封禁设备只拦截该设备发送短信和一键登录,不影响它登录过的账户;封禁账户只拦截该账户的比价、任务奖励和提现,不连坐设备。误封可在“已封禁”视图解除。重置报警只清空待处理计数并建立新的累计基线,不删除历史流水、不解除封禁。所有处置均写入管理员审计日志。
|
||||||
|
</footer>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<Modal
|
||||||
|
title="风控规则设置"
|
||||||
|
open={ruleOpen}
|
||||||
|
okText="保存并立即生效"
|
||||||
|
cancelText="取消"
|
||||||
|
confirmLoading={ruleSaving}
|
||||||
|
onOk={() => void saveRules()}
|
||||||
|
onCancel={() => setRuleOpen(false)}
|
||||||
|
destroyOnHidden
|
||||||
|
>
|
||||||
|
<p className={styles.ruleDialogIntro}>
|
||||||
|
修改后会立即重算北京时间当前小时或当天的数据。提高阈值时,不再命中的待处理告警会自动收起;已忽略和已封禁记录不会改变。
|
||||||
|
</p>
|
||||||
|
<div className={styles.ruleSettings}>
|
||||||
|
{RISK_KINDS.map((kind) => {
|
||||||
|
const meta = KIND_META[kind];
|
||||||
|
const limits = RULE_LIMITS[kind];
|
||||||
|
return (
|
||||||
|
<div key={kind} className={styles.ruleSettingRow}>
|
||||||
|
<div className={styles.ruleSettingCopy}>
|
||||||
|
<strong>{meta.summaryTitle}</strong>
|
||||||
|
<span>{limits.help}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.ruleValueEditor}>
|
||||||
|
<InputNumber
|
||||||
|
min={limits.min}
|
||||||
|
max={limits.max}
|
||||||
|
precision={0}
|
||||||
|
value={ruleDraft[kind]}
|
||||||
|
onChange={(value) => {
|
||||||
|
if (value == null) return;
|
||||||
|
setRuleDraft((current) => ({ ...current, [kind]: value }));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span>次</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -29,7 +29,6 @@ import {
|
|||||||
CheckCircleOutlined,
|
CheckCircleOutlined,
|
||||||
ClearOutlined,
|
ClearOutlined,
|
||||||
CloseCircleOutlined,
|
CloseCircleOutlined,
|
||||||
FilterOutlined,
|
|
||||||
ReloadOutlined,
|
ReloadOutlined,
|
||||||
SearchOutlined,
|
SearchOutlined,
|
||||||
SortAscendingOutlined,
|
SortAscendingOutlined,
|
||||||
@@ -86,42 +85,6 @@ const STATUS_TABS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const REJECT_TEMPLATES = ['账号异常', '提现金额异常', '微信实名不匹配', '风控拦截', '其他原因'];
|
const REJECT_TEMPLATES = ['账号异常', '提现金额异常', '微信实名不匹配', '风控拦截', '其他原因'];
|
||||||
const QUICK_FILTER_OPTIONS = [
|
|
||||||
{ value: 'abnormal', label: '异常单' },
|
|
||||||
{ value: 'failed', label: '打款失败' },
|
|
||||||
{ value: 'overdue_reviewing', label: '待审核超30分钟' },
|
|
||||||
{ value: 'pending_overdue', label: '打款中超15分钟' },
|
|
||||||
{ value: 'today', label: '今日申请' },
|
|
||||||
{ value: 'high_risk', label: '高风险用户' },
|
|
||||||
];
|
|
||||||
const QUICK_FILTER_STATUS: Record<string, string> = {
|
|
||||||
abnormal: 'all',
|
|
||||||
failed: 'failed',
|
|
||||||
overdue_reviewing: 'reviewing',
|
|
||||||
pending_overdue: 'pending',
|
|
||||||
high_risk: 'all',
|
|
||||||
};
|
|
||||||
const SORT_OPTIONS = [
|
|
||||||
{ value: 'created_at', label: '申请时间' },
|
|
||||||
{ value: 'amount_cents', label: '提现金额' },
|
|
||||||
];
|
|
||||||
// 提现类型:coin_cash=福利页提现(金币兑换现金) / invite_cash=邀请提现(邀请奖励金)
|
|
||||||
const SOURCE_LABEL: Record<string, string> = {
|
|
||||||
coin_cash: '福利页提现',
|
|
||||||
invite_cash: '邀请提现',
|
|
||||||
};
|
|
||||||
const SOURCE_COLOR: Record<string, string> = {
|
|
||||||
coin_cash: 'blue',
|
|
||||||
invite_cash: 'purple',
|
|
||||||
};
|
|
||||||
const SOURCE_OPTIONS = [
|
|
||||||
{ value: 'coin_cash', label: '福利页提现' },
|
|
||||||
{ value: 'invite_cash', label: '邀请提现' },
|
|
||||||
];
|
|
||||||
const DATE_FIELD_OPTIONS = [
|
|
||||||
{ value: 'created_at', label: '申请时间' },
|
|
||||||
{ value: 'updated_at', label: '更新时间' },
|
|
||||||
];
|
|
||||||
|
|
||||||
function statusTag(status: string) {
|
function statusTag(status: string) {
|
||||||
return <Tag color={STATUS_COLOR[status]}>{STATUS_LABEL[status] || status}</Tag>;
|
return <Tag color={STATUS_COLOR[status]}>{STATUS_LABEL[status] || status}</Tag>;
|
||||||
@@ -197,21 +160,15 @@ export default function WithdrawsPage() {
|
|||||||
const [searchDraft, setSearchDraft] = useState('');
|
const [searchDraft, setSearchDraft] = useState('');
|
||||||
const [keyword, setKeyword] = useState('');
|
const [keyword, setKeyword] = useState('');
|
||||||
const [dateRange, setDateRange] = useState<[Dayjs, Dayjs] | null>(null);
|
const [dateRange, setDateRange] = useState<[Dayjs, Dayjs] | null>(null);
|
||||||
const [dateField, setDateField] = useState<'created_at' | 'updated_at'>('created_at');
|
|
||||||
const [sortBy, setSortBy] = useState<'created_at' | 'amount_cents'>('created_at');
|
|
||||||
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
|
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
|
||||||
const [quickFilter, setQuickFilter] = useState<string | undefined>(undefined);
|
|
||||||
const [source, setSource] = useState<string | undefined>(undefined);
|
|
||||||
|
|
||||||
const filters: Record<string, unknown> = {};
|
const filters: Record<string, unknown> = {};
|
||||||
if (activeStatus !== 'all') filters.status = activeStatus;
|
if (activeStatus !== 'all') filters.status = activeStatus;
|
||||||
if (source) filters.source = source;
|
|
||||||
if (keyword.trim()) filters.keyword = keyword.trim();
|
if (keyword.trim()) filters.keyword = keyword.trim();
|
||||||
if (dateRange?.[0]) filters.date_from = dateRange[0].startOf('day').toISOString();
|
if (dateRange?.[0]) filters.date_from = dateRange[0].startOf('day').toISOString();
|
||||||
if (dateRange?.[1]) filters.date_to = dateRange[1].endOf('day').toISOString();
|
if (dateRange?.[1]) filters.date_to = dateRange[1].endOf('day').toISOString();
|
||||||
if (quickFilter) filters.quick_filter = quickFilter;
|
filters.date_field = 'created_at';
|
||||||
filters.date_field = dateField;
|
filters.sort_by = 'created_at';
|
||||||
filters.sort_by = sortBy;
|
|
||||||
filters.sort_order = sortOrder;
|
filters.sort_order = sortOrder;
|
||||||
const filterKey = JSON.stringify(filters);
|
const filterKey = JSON.stringify(filters);
|
||||||
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
|
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
|
||||||
@@ -226,27 +183,7 @@ export default function WithdrawsPage() {
|
|||||||
setSearchDraft('');
|
setSearchDraft('');
|
||||||
setKeyword('');
|
setKeyword('');
|
||||||
setDateRange(null);
|
setDateRange(null);
|
||||||
setDateField('created_at');
|
|
||||||
setSortBy('created_at');
|
|
||||||
setSortOrder('desc');
|
setSortOrder('desc');
|
||||||
setQuickFilter(undefined);
|
|
||||||
setSource(undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
const applyQuickFilter = (value?: string) => {
|
|
||||||
setQuickFilter(value);
|
|
||||||
const targetStatus = value ? QUICK_FILTER_STATUS[value] : undefined;
|
|
||||||
if (targetStatus) setActiveStatus(targetStatus);
|
|
||||||
};
|
|
||||||
|
|
||||||
const changeStatus = (status: string) => {
|
|
||||||
setActiveStatus(status);
|
|
||||||
setQuickFilter((current) => {
|
|
||||||
if (!current) return current;
|
|
||||||
const targetStatus = QUICK_FILTER_STATUS[current];
|
|
||||||
if (!targetStatus || status === targetStatus) return current;
|
|
||||||
return undefined;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadSummary = useCallback(async () => {
|
const loadSummary = useCallback(async () => {
|
||||||
@@ -520,12 +457,6 @@ export default function WithdrawsPage() {
|
|||||||
width: 120,
|
width: 120,
|
||||||
render: (v: number) => <Text strong>{yuan(v)}</Text>,
|
render: (v: number) => <Text strong>{yuan(v)}</Text>,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '提现类型',
|
|
||||||
dataIndex: 'source',
|
|
||||||
width: 110,
|
|
||||||
render: (v: string) => <Tag color={SOURCE_COLOR[v] || 'default'}>{SOURCE_LABEL[v] || v}</Tag>,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '累计提现',
|
title: '累计提现',
|
||||||
dataIndex: 'cumulative_success_cents',
|
dataIndex: 'cumulative_success_cents',
|
||||||
@@ -681,7 +612,9 @@ export default function WithdrawsPage() {
|
|||||||
<Space style={{ width: '100%', justifyContent: 'space-between', marginBottom: 16 }}>
|
<Space style={{ width: '100%', justifyContent: 'space-between', marginBottom: 16 }}>
|
||||||
<div>
|
<div>
|
||||||
<h2 style={{ marginBottom: 4 }}>提现审核</h2>
|
<h2 style={{ marginBottom: 4 }}>提现审核</h2>
|
||||||
<Text type="secondary">审核通过会立即发起微信打款,拒绝会退回用户现金余额。</Text>
|
<Text type="secondary">
|
||||||
|
针对赚钱页面的账户。审核通过会立即发起微信提现,拒绝会退回用户现金余额。
|
||||||
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
{canManage && (
|
{canManage && (
|
||||||
<Button danger icon={<ReloadOutlined />} onClick={reconcile}>
|
<Button danger icon={<ReloadOutlined />} onClick={reconcile}>
|
||||||
@@ -796,7 +729,7 @@ export default function WithdrawsPage() {
|
|||||||
<Card>
|
<Card>
|
||||||
<Tabs
|
<Tabs
|
||||||
activeKey={activeStatus}
|
activeKey={activeStatus}
|
||||||
onChange={changeStatus}
|
onChange={setActiveStatus}
|
||||||
items={STATUS_TABS.map((tab) => {
|
items={STATUS_TABS.map((tab) => {
|
||||||
const count = summaryCount(summary, tab.key);
|
const count = summaryCount(summary, tab.key);
|
||||||
return {
|
return {
|
||||||
@@ -818,89 +751,55 @@ export default function WithdrawsPage() {
|
|||||||
align="start"
|
align="start"
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
justifyContent: 'space-between',
|
|
||||||
marginBottom: 12,
|
marginBottom: 12,
|
||||||
paddingBottom: 12,
|
paddingBottom: 12,
|
||||||
borderBottom: '1px solid #f0f0f0',
|
borderBottom: '1px solid #f0f0f0',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Space wrap>
|
<Input.Search
|
||||||
<Input.Search
|
allowClear
|
||||||
allowClear
|
enterButton="搜索"
|
||||||
enterButton="搜索"
|
prefix={<SearchOutlined />}
|
||||||
prefix={<SearchOutlined />}
|
placeholder="用户手机号"
|
||||||
placeholder="用户手机号"
|
value={searchDraft}
|
||||||
value={searchDraft}
|
style={{ width: 240 }}
|
||||||
style={{ width: 240 }}
|
onChange={(e) => {
|
||||||
onChange={(e) => {
|
const value = e.target.value;
|
||||||
const value = e.target.value;
|
setSearchDraft(value);
|
||||||
setSearchDraft(value);
|
if (!value) setKeyword('');
|
||||||
if (!value) setKeyword('');
|
}}
|
||||||
}}
|
onSearch={(value) => setKeyword(value.trim())}
|
||||||
onSearch={(value) => setKeyword(value.trim())}
|
/>
|
||||||
/>
|
<RangePicker
|
||||||
<Select
|
value={dateRange}
|
||||||
value={source}
|
allowClear
|
||||||
allowClear
|
style={{ width: 260 }}
|
||||||
placeholder="提现类型"
|
presets={[
|
||||||
style={{ width: 140 }}
|
{ label: '今天', value: [dayjs().startOf('day'), dayjs().endOf('day')] },
|
||||||
options={SOURCE_OPTIONS}
|
{
|
||||||
onChange={(value?: string) => setSource(value)}
|
label: '最近7天',
|
||||||
/>
|
value: [dayjs().subtract(6, 'day').startOf('day'), dayjs().endOf('day')],
|
||||||
<Select
|
},
|
||||||
value={quickFilter}
|
{
|
||||||
allowClear
|
label: '最近30天',
|
||||||
placeholder="快捷筛选"
|
value: [dayjs().subtract(29, 'day').startOf('day'), dayjs().endOf('day')],
|
||||||
style={{ width: 170 }}
|
},
|
||||||
suffixIcon={<FilterOutlined />}
|
]}
|
||||||
options={QUICK_FILTER_OPTIONS}
|
onChange={(values) => setDateRange(values as [Dayjs, Dayjs] | null)}
|
||||||
onChange={applyQuickFilter}
|
/>
|
||||||
/>
|
<Select
|
||||||
<Select
|
value={sortOrder}
|
||||||
value={dateField}
|
style={{ width: 96 }}
|
||||||
style={{ width: 120 }}
|
suffixIcon={<SortAscendingOutlined />}
|
||||||
options={DATE_FIELD_OPTIONS}
|
options={[
|
||||||
onChange={(value: 'created_at' | 'updated_at') => setDateField(value)}
|
{ value: 'desc', label: '倒序' },
|
||||||
/>
|
{ value: 'asc', label: '正序' },
|
||||||
<RangePicker
|
]}
|
||||||
value={dateRange}
|
onChange={(value: 'asc' | 'desc') => setSortOrder(value)}
|
||||||
allowClear
|
/>
|
||||||
style={{ width: 260 }}
|
<Button icon={<ClearOutlined />} onClick={resetFilters}>
|
||||||
presets={[
|
重置
|
||||||
{ label: '今天', value: [dayjs().startOf('day'), dayjs().endOf('day')] },
|
</Button>
|
||||||
{
|
|
||||||
label: '最近7天',
|
|
||||||
value: [dayjs().subtract(6, 'day').startOf('day'), dayjs().endOf('day')],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '最近30天',
|
|
||||||
value: [dayjs().subtract(29, 'day').startOf('day'), dayjs().endOf('day')],
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
onChange={(values) => setDateRange(values as [Dayjs, Dayjs] | null)}
|
|
||||||
/>
|
|
||||||
</Space>
|
|
||||||
<Space wrap>
|
|
||||||
<Select
|
|
||||||
value={sortBy}
|
|
||||||
style={{ width: 130 }}
|
|
||||||
suffixIcon={<SortAscendingOutlined />}
|
|
||||||
options={SORT_OPTIONS}
|
|
||||||
onChange={(value: 'created_at' | 'amount_cents') => setSortBy(value)}
|
|
||||||
/>
|
|
||||||
<Select
|
|
||||||
value={sortOrder}
|
|
||||||
style={{ width: 96 }}
|
|
||||||
options={[
|
|
||||||
{ value: 'desc', label: '倒序' },
|
|
||||||
{ value: 'asc', label: '正序' },
|
|
||||||
]}
|
|
||||||
onChange={(value: 'asc' | 'desc') => setSortOrder(value)}
|
|
||||||
/>
|
|
||||||
<Button icon={<ClearOutlined />} onClick={resetFilters}>
|
|
||||||
重置
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
</Space>
|
</Space>
|
||||||
{canManage && selectedOrders.length > 0 && (
|
{canManage && selectedOrders.length > 0 && (
|
||||||
<Space
|
<Space
|
||||||
@@ -972,7 +871,7 @@ export default function WithdrawsPage() {
|
|||||||
showTotal: (t) => `共 ${t} 条`,
|
showTotal: (t) => `共 ${t} 条`,
|
||||||
onChange: onPageChange,
|
onChange: onPageChange,
|
||||||
}}
|
}}
|
||||||
scroll={{ x: 1460 }}
|
scroll={{ x: 1350 }}
|
||||||
onRow={(record) => ({
|
onRow={(record) => ({
|
||||||
onClick: () => openDetail(record),
|
onClick: () => openDetail(record),
|
||||||
style: { cursor: 'pointer' },
|
style: { cursor: 'pointer' },
|
||||||
@@ -1004,11 +903,6 @@ export default function WithdrawsPage() {
|
|||||||
<Descriptions.Item label="金额">
|
<Descriptions.Item label="金额">
|
||||||
<Text strong>{yuan(detail.order.amount_cents)}</Text>
|
<Text strong>{yuan(detail.order.amount_cents)}</Text>
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="提现类型">
|
|
||||||
<Tag color={SOURCE_COLOR[detail.order.source] || 'default'}>
|
|
||||||
{SOURCE_LABEL[detail.order.source] || detail.order.source}
|
|
||||||
</Tag>
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="提现实名">
|
<Descriptions.Item label="提现实名">
|
||||||
{detail.order.user_name || '-'}
|
{detail.order.user_name || '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
|||||||
+103
-11
@@ -218,6 +218,92 @@ export interface UserCoinRecord {
|
|||||||
coin: number;
|
coin: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== 风控监控 =====
|
||||||
|
|
||||||
|
export type RiskKind = 'sms' | 'oneclick' | 'compare';
|
||||||
|
|
||||||
|
export interface RiskSummaryCard {
|
||||||
|
kind: RiskKind;
|
||||||
|
alert_subject_count: number;
|
||||||
|
today_total: number;
|
||||||
|
threshold: number;
|
||||||
|
rule_text: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RiskMonitorSummary {
|
||||||
|
date: string;
|
||||||
|
updated_at: string;
|
||||||
|
cards: RiskSummaryCard[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RiskRuleConfig {
|
||||||
|
sms_hourly_threshold: number;
|
||||||
|
oneclick_daily_threshold: number;
|
||||||
|
compare_daily_threshold: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RiskResetResponse {
|
||||||
|
ok: boolean;
|
||||||
|
reset_at: string;
|
||||||
|
reset_incident_count: number;
|
||||||
|
reset_counts: Record<RiskKind, number>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RiskIncidentItem {
|
||||||
|
incident_id: number;
|
||||||
|
kind: RiskKind;
|
||||||
|
subject_type: 'device' | 'user';
|
||||||
|
subject_id: string;
|
||||||
|
device_model: string | null;
|
||||||
|
first_used_at: string | null;
|
||||||
|
phone: string | null;
|
||||||
|
user_id: number | null;
|
||||||
|
registered_at: string | null;
|
||||||
|
common_device_id: string | null;
|
||||||
|
window_start: string;
|
||||||
|
window_end: string;
|
||||||
|
first_event_at: string;
|
||||||
|
triggered_at: string;
|
||||||
|
last_event_at: string;
|
||||||
|
event_count: number;
|
||||||
|
status: 'open' | 'ignored' | 'blocked' | 'resolved';
|
||||||
|
restricted: boolean;
|
||||||
|
restriction_id: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RiskIncidentPage {
|
||||||
|
items: RiskIncidentItem[];
|
||||||
|
next_cursor: number | null;
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RiskDetailItem {
|
||||||
|
id: number;
|
||||||
|
occurred_at: string;
|
||||||
|
outcome: string;
|
||||||
|
phone: string | null;
|
||||||
|
user_id: number | null;
|
||||||
|
username: string | null;
|
||||||
|
account_registered_at: string | null;
|
||||||
|
verified: boolean | null;
|
||||||
|
reason: string | null;
|
||||||
|
store_name: string | null;
|
||||||
|
product_names: string | null;
|
||||||
|
prices: Record<string, number | null> | null;
|
||||||
|
saved_amount_yuan: number | null;
|
||||||
|
status: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RiskDetailPage {
|
||||||
|
kind: RiskKind;
|
||||||
|
incident_id: number;
|
||||||
|
event_count: number;
|
||||||
|
distinct_accounts: number | null;
|
||||||
|
items: RiskDetailItem[];
|
||||||
|
next_cursor: number | null;
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface WithdrawBulkItemResult {
|
export interface WithdrawBulkItemResult {
|
||||||
out_bill_no: string;
|
out_bill_no: string;
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
@@ -456,6 +542,8 @@ export interface AdRevenueRecord {
|
|||||||
expected_coin: number;
|
expected_coin: number;
|
||||||
actual_coin: number;
|
actual_coin: number;
|
||||||
matched: boolean;
|
matched: boolean;
|
||||||
|
adn: string | null; // 本条发奖的实际填充 ADN(不能只取整场聚合父行)
|
||||||
|
slot_id: string | null; // 本条发奖的底层 mediation rit
|
||||||
}
|
}
|
||||||
|
|
||||||
// 广告收益报表:按日期汇总的一天(按天趋势图用;全量,不受分页影响)
|
// 广告收益报表:按日期汇总的一天(按天趋势图用;全量,不受分页影响)
|
||||||
@@ -463,8 +551,8 @@ export interface AdRevenueDaily {
|
|||||||
date: string; // 北京时间 YYYY-MM-DD
|
date: string; // 北京时间 YYYY-MM-DD
|
||||||
impressions: number;
|
impressions: number;
|
||||||
revenue_yuan: number; // 客户端预估收益(eCPM 折算)
|
revenue_yuan: number; // 客户端预估收益(eCPM 折算)
|
||||||
pangle_revenue_yuan: number | null; // 穿山甲后台预估收益(GroMore revenue);非全量视图/无数据为 null
|
pangle_revenue_yuan: number | null; // GroMore 排序价预估(revenue);非全量视图/无数据为 null
|
||||||
pangle_api_revenue_yuan: number | null; // 穿山甲收益API(更接近结算);未配/当天/无数据为 null
|
pangle_api_revenue_yuan: number | null; // ADN Reporting API 收益;未配/当天/无数据为 null
|
||||||
expected_coin: number;
|
expected_coin: number;
|
||||||
actual_coin: number;
|
actual_coin: number;
|
||||||
}
|
}
|
||||||
@@ -478,10 +566,11 @@ export interface AdRevenueHourly {
|
|||||||
actual_coin: number;
|
actual_coin: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 广告收益报表:按广告类型(ad_type)的小计(展示条数 + 预估收益;eCPM 前端用 收益÷展示×1000 算)
|
// 广告收益报表:展示条数、SDK 展示预估收益与按展示次数加权的 SDK eCPM。
|
||||||
export interface AdRevenueTypeStat {
|
export interface AdRevenueTypeStat {
|
||||||
impressions: number; // 该类型展示条数合计
|
impressions: number; // 该类型展示条数合计
|
||||||
revenue_yuan: number; // 该类型预估收益合计(元)
|
revenue_yuan: number; // 该类型预估收益合计(元)
|
||||||
|
ecpm_yuan: number; // 加权 SDK eCPM(元/千次)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 广告收益报表:一次广告事件(逐条一行)。激励视频展示+发奖按 ad_session_id 合并;信息流展示/发奖各自成行。
|
// 广告收益报表:一次广告事件(逐条一行)。激励视频展示+发奖按 ad_session_id 合并;信息流展示/发奖各自成行。
|
||||||
@@ -500,10 +589,10 @@ export interface AdRevenueRow {
|
|||||||
has_impression: boolean; // 是否有广告展示(信息流逐条展示=true,纯发奖行=false)
|
has_impression: boolean; // 是否有广告展示(信息流逐条展示=true,纯发奖行=false)
|
||||||
impressions: number; // 本行展示条数 1/0(供日汇总、趋势图复用)
|
impressions: number; // 本行展示条数 1/0(供日汇总、趋势图复用)
|
||||||
ecpm: string | null; // 分/千次;展示行取展示值,纯发奖行取发奖采用值
|
ecpm: string | null; // 分/千次;展示行取展示值,纯发奖行取发奖采用值
|
||||||
revenue_yuan: number; // 本次有效展示预估收益(元);纯发奖、激励视频提前关闭/时长不足=0
|
revenue_yuan: number; // 本次 SDK 展示预估收益(元);是否满足发奖条件不改变已产生的展示收入预估
|
||||||
row_revenue_yuan?: number | null; // 主表逐行显示用:一次比价/领券聚合行=该次发奖广告 eCPM 折算之和;其它行空(回退 revenue_yuan)
|
row_revenue_yuan?: number | null; // 主表逐行显示用:一次比价/领券聚合行=该次发奖广告 eCPM 折算之和;其它行空(回退 revenue_yuan)
|
||||||
adn: string | null; // 实际填充 ADN;纯发奖行为空
|
adn: string | null; // 实际填充 ADN;历史或未上报展示来源为空
|
||||||
slot_id: string | null; // 底层 mediation rit;纯发奖行为空
|
slot_id: string | null; // 底层 mediation rit;历史或未上报展示来源为空
|
||||||
// ── 发奖侧 ──
|
// ── 发奖侧 ──
|
||||||
has_reward: boolean; // 是否有发奖(激励视频合并行/信息流整场发奖行=true;纯展示=false)
|
has_reward: boolean; // 是否有发奖(激励视频合并行/信息流整场发奖行=true;纯展示=false)
|
||||||
status: string | null; // 发奖状态 granted/closed_early/…;纯展示为空
|
status: string | null; // 发奖状态 granted/closed_early/…;纯展示为空
|
||||||
@@ -520,7 +609,8 @@ export interface AdRevenueReport {
|
|||||||
date_to: string; // 结束日 北京时间 YYYY-MM-DD(闭区间;单日时与 date_from 相同)
|
date_to: string; // 结束日 北京时间 YYYY-MM-DD(闭区间;单日时与 date_from 相同)
|
||||||
daily: AdRevenueDaily[]; // 按日期汇总序列(全量,供按天趋势图)
|
daily: AdRevenueDaily[]; // 按日期汇总序列(全量,供按天趋势图)
|
||||||
hourly: AdRevenueHourly[]; // 按小时汇总序列(全量,供按小时趋势图;按天查询时为空)
|
hourly: AdRevenueHourly[]; // 按小时汇总序列(全量,供按小时趋势图;按天查询时为空)
|
||||||
type_stats: Record<string, AdRevenueTypeStat>; // 按广告类型小计;前端取 draw / reward_video
|
type_stats: Record<string, AdRevenueTypeStat>; // 按原始广告类型小计
|
||||||
|
category_stats?: Record<string, AdRevenueTypeStat>; // draw=draw+历史feed;video=福利视频+提现视频(兼容后端滚动发布)
|
||||||
// 按信息流场景小计(comparison/coupon/welfare;全量,不受分页截断)。数据大盘「领券广告/比价广告」卡
|
// 按信息流场景小计(comparison/coupon/welfare;全量,不受分页截断)。数据大盘「领券广告/比价广告」卡
|
||||||
// 优先读它:2026-07-02 后端起 items 不再含信息流逐条展示行(唯一带收益+场景的行),按 items 现算恒 0。
|
// 优先读它:2026-07-02 后端起 items 不再含信息流逐条展示行(唯一带收益+场景的行),按 items 现算恒 0。
|
||||||
// 可选(`?.` 探测)以兼容未升级后端,缺失时回退 items 现算。
|
// 可选(`?.` 探测)以兼容未升级后端,缺失时回退 items 现算。
|
||||||
@@ -535,10 +625,12 @@ export interface AdRevenueReport {
|
|||||||
total: number; // 当前筛选下的分页总条数(全量,不受分页影响)
|
total: number; // 当前筛选下的分页总条数(全量,不受分页影响)
|
||||||
truncated: boolean; // 当前页之后是否还有更多事件(分页后前端不再据此报警)
|
truncated: boolean; // 当前页之后是否还有更多事件(分页后前端不再据此报警)
|
||||||
total_impressions: number;
|
total_impressions: number;
|
||||||
total_revenue_yuan: number; // 客户端预估收益合计(eCPM 折算)
|
total_revenue_yuan: number; // 客户端 SDK 展示预估合计(后端留存 eCPM 折算)
|
||||||
total_pangle_revenue_yuan: number | null; // 穿山甲后台预估收益合计(GroMore revenue);非全量视图/无数据为 null
|
total_pangle_revenue_yuan: number | null; // GroMore 排序价预估合计(revenue);非全量视图/无数据为 null
|
||||||
total_pangle_api_revenue_yuan: number | null; // 穿山甲收益API合计(更接近结算);未配/当天/非全量视图为 null
|
total_pangle_api_revenue_yuan: number | null; // ADN Reporting API 收益合计;未配/当天/非全量视图为 null
|
||||||
pangle_revenue_available: boolean; // 本次结果是否带穿山甲后台收益(全量视图且已同步到数据)
|
pangle_api_revenue_complete: boolean; // 每一天均在 D+1 14:00 后完成 API 同步窗口,不代表全量结算
|
||||||
|
pangle_latest_synced_at: string | null; // GroMore 日报最近同步时间
|
||||||
|
pangle_revenue_available: boolean; // 本次结果是否带 GroMore/ADN 收益(全量视图且已同步到数据)
|
||||||
total_expected_coin: number;
|
total_expected_coin: number;
|
||||||
total_actual_coin: number;
|
total_actual_coin: number;
|
||||||
mismatch_count: number; // 应发≠实发的发奖条数
|
mismatch_count: number; // 应发≠实发的发奖条数
|
||||||
|
|||||||
Reference in New Issue
Block a user