|
|
|
@@ -43,6 +43,8 @@ import type {
|
|
|
|
|
import UserAdRevenueDrawer from './UserAdRevenueDrawer';
|
|
|
|
|
|
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
|
const DEFAULT_PAGE_SIZE = 50;
|
|
|
|
|
const ALL_FILTER_VALUE = '__all__';
|
|
|
|
|
|
|
|
|
|
// 广告类型标签
|
|
|
|
|
const TYPE_TAG: Record<string, { color: string; label: string }> = {
|
|
|
|
@@ -194,7 +196,16 @@ type AdRevenueDetailRow = AdRevenueRecord & { source_adn?: string | null };
|
|
|
|
|
|
|
|
|
|
// 展开行(逐条事件展开)- 该条的发奖复算明细(还原金币审计的 eCPM/因子1/份数/LT/因子2 等列)
|
|
|
|
|
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(元)',
|
|
|
|
|
dataIndex: 'ecpm',
|
|
|
|
@@ -387,13 +398,13 @@ export default function AdRevenueReportPage() {
|
|
|
|
|
const [scene, setScene] = useState<string | undefined>();
|
|
|
|
|
const [granularity, setGranularity] = useState<'day' | 'hour'>('day');
|
|
|
|
|
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 [queriedGranularity, setQueriedGranularity] = useState<'day' | 'hour'>('day'); // 本次结果对应的粒度,决定是否显示「小时」列
|
|
|
|
|
const [queriedMultiDay, setQueriedMultiDay] = useState(false); // 本次结果是否跨多天,决定显示「日期」列 + 按天/按小时图
|
|
|
|
|
const [data, setData] = useState<AdRevenueReport | null>(null);
|
|
|
|
|
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 [formulaOpen, setFormulaOpen] = useState(false);
|
|
|
|
|
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
|
|
|
|
@@ -661,9 +672,17 @@ export default function AdRevenueReportPage() {
|
|
|
|
|
: data.date_from
|
|
|
|
|
: `${data.date_from} ~ ${data.date_to}`;
|
|
|
|
|
|
|
|
|
|
// 第二行大盘「分广告类型」:draw / 激励视频 各自 收益 / eCPM / 展示条数;eCPM = 收益÷展示×1000。
|
|
|
|
|
// 第二行大盘「分广告类型」:看视频包含福利视频与提现视频;
|
|
|
|
|
// eCPM 使用合并后的总收益 ÷ 总展示数 × 1000,避免只读取 reward_video 而漏算提现视频。
|
|
|
|
|
const drawStat = data?.type_stats?.draw;
|
|
|
|
|
const rvStat = data?.type_stats?.reward_video;
|
|
|
|
|
const rewardVideoStat = data?.type_stats?.reward_video;
|
|
|
|
|
const withdrawalVideoStat = data?.type_stats?.withdrawal_video;
|
|
|
|
|
const videoStat: AdRevenueTypeStat = {
|
|
|
|
|
impressions:
|
|
|
|
|
(rewardVideoStat?.impressions ?? 0) + (withdrawalVideoStat?.impressions ?? 0),
|
|
|
|
|
revenue_yuan:
|
|
|
|
|
(rewardVideoStat?.revenue_yuan ?? 0) + (withdrawalVideoStat?.revenue_yuan ?? 0),
|
|
|
|
|
};
|
|
|
|
|
const ecpmOf = (s?: AdRevenueTypeStat) =>
|
|
|
|
|
s && s.impressions > 0 ? (s.revenue_yuan / s.impressions) * 1000 : 0;
|
|
|
|
|
|
|
|
|
@@ -775,12 +794,11 @@ export default function AdRevenueReportPage() {
|
|
|
|
|
<Space size={6}>
|
|
|
|
|
<Typography.Text type="secondary">类型</Typography.Text>
|
|
|
|
|
<Select
|
|
|
|
|
placeholder="全部"
|
|
|
|
|
value={adType}
|
|
|
|
|
onChange={setAdType}
|
|
|
|
|
allowClear
|
|
|
|
|
value={adType ?? ALL_FILTER_VALUE}
|
|
|
|
|
onChange={(value) => setAdType(value === ALL_FILTER_VALUE ? undefined : value)}
|
|
|
|
|
style={{ width: 150 }}
|
|
|
|
|
options={[
|
|
|
|
|
{ value: ALL_FILTER_VALUE, label: '全部' },
|
|
|
|
|
{ value: 'reward_video', label: '看视频' },
|
|
|
|
|
{ value: 'draw', label: 'Draw 信息流' },
|
|
|
|
|
{ value: 'withdrawal_video', label: '提现看视频' },
|
|
|
|
@@ -790,12 +808,11 @@ export default function AdRevenueReportPage() {
|
|
|
|
|
<Space size={6}>
|
|
|
|
|
<Typography.Text type="secondary">场景</Typography.Text>
|
|
|
|
|
<Select
|
|
|
|
|
placeholder="全部"
|
|
|
|
|
value={scene}
|
|
|
|
|
onChange={setScene}
|
|
|
|
|
allowClear
|
|
|
|
|
value={scene ?? ALL_FILTER_VALUE}
|
|
|
|
|
onChange={(value) => setScene(value === ALL_FILTER_VALUE ? undefined : value)}
|
|
|
|
|
style={{ width: 130 }}
|
|
|
|
|
options={[
|
|
|
|
|
{ value: ALL_FILTER_VALUE, label: '全部' },
|
|
|
|
|
{ value: 'comparison', label: '比价' },
|
|
|
|
|
{ value: 'coupon', label: '领券' },
|
|
|
|
|
{ value: 'welfare', label: '福利' },
|
|
|
|
@@ -987,13 +1004,13 @@ export default function AdRevenueReportPage() {
|
|
|
|
|
<Statistic title="Draw 信息流条数" value={drawStat?.impressions ?? 0} />
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={4}>
|
|
|
|
|
<Statistic title="看视频收益(元)" value={rvStat?.revenue_yuan ?? 0} precision={4} />
|
|
|
|
|
<Statistic title="看视频收益(元)" value={videoStat.revenue_yuan} precision={4} />
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={4}>
|
|
|
|
|
<Statistic title="看视频 eCPM(元/千次)" value={ecpmOf(rvStat)} precision={2} />
|
|
|
|
|
<Statistic title="看视频 eCPM(元/千次)" value={ecpmOf(videoStat)} precision={2} />
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={4}>
|
|
|
|
|
<Statistic title="看视频条数" value={rvStat?.impressions ?? 0} />
|
|
|
|
|
<Statistic title="看视频条数" value={videoStat.impressions} />
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
|
|
|
@@ -1102,7 +1119,11 @@ export default function AdRevenueReportPage() {
|
|
|
|
|
style={{ marginTop: 8 }}
|
|
|
|
|
rowKey="record_id"
|
|
|
|
|
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}
|
|
|
|
|
size="small"
|
|
|
|
|
scroll={{ x: 900 }}
|
|
|
|
@@ -1118,7 +1139,10 @@ export default function AdRevenueReportPage() {
|
|
|
|
|
style={{ marginTop: 8 }}
|
|
|
|
|
rowKey="record_id"
|
|
|
|
|
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}
|
|
|
|
|
size="small"
|
|
|
|
|
scroll={{ x: 900 }}
|
|
|
|
|