Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9722473974 | |||
| ecf8150cfc | |||
| 1559d4faf0 | |||
| 9d32234015 | |||
| a2a8451aec | |||
| 578819a284 | |||
| efa443ea8a | |||
| f3cfd622a7 |
@@ -32,6 +32,20 @@ server {
|
|||||||
proxy_read_timeout 60s;
|
proxy_read_timeout 60s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 新手引导视频上传:视频比图片大一个量级,单独放宽到 100MB(对齐后端
|
||||||
|
# settings.GUIDE_VIDEO_MAX_BYTES)。不放宽全站上限,避免其它接口被大 body 打。
|
||||||
|
# 上传大文件耗时长,读超时同步放宽到 300s。
|
||||||
|
location = /admin/api/guide-video/video {
|
||||||
|
client_max_body_size 100m;
|
||||||
|
proxy_pass http://127.0.0.1:8771;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_read_timeout 300s;
|
||||||
|
proxy_send_timeout 300s;
|
||||||
|
proxy_request_buffering off;
|
||||||
|
}
|
||||||
|
|
||||||
# 用户上传媒体(上报截图 / 反馈截图 / 反馈二维码)由 App 后端(:8770)的 /media 托管。
|
# 用户上传媒体(上报截图 / 反馈截图 / 反馈二维码)由 App 后端(:8770)的 /media 托管。
|
||||||
# admin 页面要展示这些图,经此同域反代过去(免跨域 + 免 https 页面引 http 图被拦)。
|
# admin 页面要展示这些图,经此同域反代过去(免跨域 + 免 https 页面引 http 图被拦)。
|
||||||
# 前提:App 后端与本 admin 同机;若分机,把 127.0.0.1:8770 换成 App 后端可达地址。
|
# 前提:App 后端与本 admin 同机;若分机,把 127.0.0.1:8770 换成 App 后端可达地址。
|
||||||
|
|||||||
@@ -66,21 +66,101 @@ const APP_TAG: Record<string, { color: string; label: string }> = {
|
|||||||
test: { color: 'default', label: '测试应用' },
|
test: { color: 'default', label: '测试应用' },
|
||||||
};
|
};
|
||||||
|
|
||||||
// 发奖状态 → 颜色 + 中文(含「不发金币的原因」:提前关闭/未满10秒/缺eCPM/次数超限)
|
const REWARD_STATUS_HINT: Record<string, string> = {
|
||||||
const STATUS_TAG: Record<string, { color: string; label: string }> = {
|
granted: '已完成金币发放',
|
||||||
granted: { color: 'green', label: '已发' },
|
capped: '次数超限,未发金币',
|
||||||
capped: { color: 'orange', label: '次数超限' },
|
ecpm_missing: '缺少有效 eCPM,未发金币',
|
||||||
ecpm_missing: { color: 'red', label: '缺 eCPM' },
|
too_short: '播放时长未达到发奖条件,未发金币',
|
||||||
too_short: { color: 'gold', label: '未满10秒' },
|
closed_early: '用户提前关闭广告,未发金币',
|
||||||
|
};
|
||||||
|
|
||||||
|
const PLAYBACK_STATUS_TAG: Record<string, { color: string; label: string }> = {
|
||||||
|
completed: { color: 'green', label: '已完成' },
|
||||||
|
too_short: { color: 'gold', label: '观看时长不足' },
|
||||||
closed_early: { color: 'default', label: '提前关闭' },
|
closed_early: { color: 'default', label: '提前关闭' },
|
||||||
|
unknown: { color: 'default', label: '未知' },
|
||||||
};
|
};
|
||||||
const STATUS_HINT: Record<string, string> = {
|
|
||||||
granted: '已满足当前客户端发奖条件并完成金币发放。',
|
const ZERO_REVENUE_REWARD_VIDEO_STATUSES = new Set(['closed_early', 'too_short']);
|
||||||
too_short: '旧版 Draw 信息流观看不足 10 秒,不发金币;新版按观看比例发放时会记为已发。',
|
|
||||||
closed_early: '用户在达到发奖条件前主动关闭,不发金币。',
|
function rewardStatuses(row: AdRevenueRow): string[] {
|
||||||
capped: '已达到次数上限,不再发金币。',
|
if (row.sub_rewards?.length) return row.sub_rewards.map((reward) => reward.status);
|
||||||
ecpm_missing: '缺少有效 eCPM,无法计算金币。',
|
return row.status ? [row.status] : [];
|
||||||
};
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rewardStatusTag(row: AdRevenueRow) {
|
||||||
|
const statuses = rewardStatuses(row);
|
||||||
|
if (!row.has_reward || statuses.length === 0) {
|
||||||
|
return { color: 'default', label: '无记录', hint: '仅记录到广告展示,没有对应发奖记录。' };
|
||||||
|
}
|
||||||
|
|
||||||
|
const grantedCount = statuses.filter((status) => status === 'granted').length;
|
||||||
|
const reasonSummary = Object.entries(
|
||||||
|
statuses
|
||||||
|
.filter((status) => status !== 'granted')
|
||||||
|
.reduce<Record<string, number>>((counts, status) => {
|
||||||
|
counts[status] = (counts[status] ?? 0) + 1;
|
||||||
|
return counts;
|
||||||
|
}, {}),
|
||||||
|
)
|
||||||
|
.map(([status, count]) => `${REWARD_STATUS_HINT[status] ?? status} ${count} 条`)
|
||||||
|
.join(';');
|
||||||
|
|
||||||
|
if (grantedCount === statuses.length) {
|
||||||
|
return { color: 'green', label: '已发', hint: `已完成金币发放${statuses.length > 1 ? ` ${statuses.length} 条` : ''}。` };
|
||||||
|
}
|
||||||
|
if (grantedCount > 0) {
|
||||||
|
return {
|
||||||
|
color: 'blue',
|
||||||
|
label: '部分已发',
|
||||||
|
hint: `已发 ${grantedCount} 条,未发 ${statuses.length - grantedCount} 条${reasonSummary ? `;${reasonSummary}` : ''}。`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return { color: 'default', label: '未发', hint: reasonSummary ? `${reasonSummary}。` : '未发放金币。' };
|
||||||
|
}
|
||||||
|
|
||||||
|
function playbackStatusTag(row: AdRevenueRow) {
|
||||||
|
const statuses = rewardStatuses(row);
|
||||||
|
if (statuses.length === 0) {
|
||||||
|
return row.has_impression
|
||||||
|
? { color: 'blue', label: '仅展示', hint: '记录到广告展示,但没有对应的播放结果。' }
|
||||||
|
: { color: 'default', label: '无记录', hint: '没有可用的广告播放记录。' };
|
||||||
|
}
|
||||||
|
|
||||||
|
const playbackCounts = statuses.reduce<Record<string, number>>((counts, status) => {
|
||||||
|
const playbackStatus =
|
||||||
|
status === 'too_short' || status === 'closed_early'
|
||||||
|
? status
|
||||||
|
: status === 'granted' || status === 'capped' || status === 'ecpm_missing'
|
||||||
|
? 'completed'
|
||||||
|
: 'unknown';
|
||||||
|
counts[playbackStatus] = (counts[playbackStatus] ?? 0) + 1;
|
||||||
|
return counts;
|
||||||
|
}, {});
|
||||||
|
const entries = Object.entries(playbackCounts);
|
||||||
|
if (entries.length === 1) {
|
||||||
|
const [status, count] = entries[0];
|
||||||
|
const tag = PLAYBACK_STATUS_TAG[status];
|
||||||
|
return {
|
||||||
|
...tag,
|
||||||
|
hint: `${tag.label}${count > 1 ? ` ${count} 条` : ''}。`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const hint = entries
|
||||||
|
.map(([status, count]) => `${PLAYBACK_STATUS_TAG[status].label} ${count} 条`)
|
||||||
|
.join(';');
|
||||||
|
return { color: 'purple', label: '部分完成', hint: `${hint}。` };
|
||||||
|
}
|
||||||
|
|
||||||
const fmtFactorRange = (a: number | null, b: number | null) => {
|
const fmtFactorRange = (a: number | null, b: number | null) => {
|
||||||
if (a == null) return '-';
|
if (a == null) return '-';
|
||||||
@@ -478,19 +558,25 @@ export default function AdRevenueReportPage() {
|
|||||||
width: 110,
|
width: 110,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
// 一次比价/领券聚合行用 row_revenue_yuan(该次发奖广告 eCPM 折算之和),其它行用展示侧 revenue_yuan
|
// 一次比价/领券聚合行用 row_revenue_yuan(该次发奖广告 eCPM 折算之和),其它行用展示侧 revenue_yuan
|
||||||
render: (v: number, r: AdRevenueRow) => {
|
// 激励视频提前关闭/时长不足时防御性显示 0,与后端有效收益口径一致。
|
||||||
const rev = r.row_revenue_yuan ?? v;
|
render: (_v: number, r: AdRevenueRow) => effectiveRevenueYuan(r).toFixed(4),
|
||||||
return rev.toFixed(4);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '发奖状态',
|
title: '发奖状态',
|
||||||
dataIndex: 'status',
|
key: 'reward_status',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (s: string | null) => {
|
render: (_: unknown, row: AdRevenueRow) => {
|
||||||
if (!s) return <Tooltip title="仅记录广告展示,没有对应发奖事件。"><Tag>仅展示</Tag></Tooltip>;
|
const tag = rewardStatusTag(row);
|
||||||
const t = STATUS_TAG[s] ?? { color: 'default', label: s };
|
return <Tooltip title={tag.hint}><Tag color={tag.color}>{tag.label}</Tag></Tooltip>;
|
||||||
return <Tooltip title={STATUS_HINT[s]}><Tag color={t.color}>{t.label}</Tag></Tooltip>;
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '广告播放状态',
|
||||||
|
key: 'playback_status',
|
||||||
|
width: 120,
|
||||||
|
render: (_: unknown, row: AdRevenueRow) => {
|
||||||
|
const tag = playbackStatusTag(row);
|
||||||
|
return <Tooltip title={tag.hint}><Tag color={tag.color}>{tag.label}</Tag></Tooltip>;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -532,7 +618,8 @@ export default function AdRevenueReportPage() {
|
|||||||
'ecpm_yuan',
|
'ecpm_yuan',
|
||||||
'revenue_yuan',
|
'revenue_yuan',
|
||||||
'actual_coin',
|
'actual_coin',
|
||||||
'status',
|
'reward_status',
|
||||||
|
'playback_status',
|
||||||
'ad_type',
|
'ad_type',
|
||||||
'app_env',
|
'app_env',
|
||||||
'our_code_id',
|
'our_code_id',
|
||||||
@@ -618,7 +705,7 @@ export default function AdRevenueReportPage() {
|
|||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
「预估收益」为客户端在广告展示(onAdShow)时上报 eCPM 折算的预估值(每千次展示 ÷1000
|
「预估收益」为客户端在广告展示(onAdShow)时上报 eCPM 折算的预估值(每千次展示 ÷1000
|
||||||
累加),<b>只要广告展示就计入、不论是否看完发奖</b>;穿山甲会过滤无效/过短曝光,故预估值可能偏高,
|
累加);<b>激励视频提前关闭或播放时长不足时按 0 计</b>,其他有效展示按 eCPM 折算。穿山甲仍可能过滤无效曝光,
|
||||||
<b>实际收益一律以穿山甲后台结算为准</b>。测试应用多为 0。「广告位ID / 来源应用」为本期新增,历史记录留空。
|
<b>实际收益一律以穿山甲后台结算为准</b>。测试应用多为 0。「广告位ID / 来源应用」为本期新增,历史记录留空。
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Button, Card, Space, Spin, Switch, Tag, Typography, Upload, message } from 'antd';
|
||||||
|
import { DeleteOutlined, UploadOutlined } from '@ant-design/icons';
|
||||||
|
import { api, errMsg } from '@/lib/api';
|
||||||
|
import { canDo } from '@/lib/auth';
|
||||||
|
import { mediaUrl } from '@/lib/media';
|
||||||
|
import type { GuideVideoConfig as GuideCfg } from '@/lib/types';
|
||||||
|
|
||||||
|
const { Text } = Typography;
|
||||||
|
|
||||||
|
/** 后端 media.save_guide_video 只认 MP4 魔数;这里先在浏览器挡一道,省得白传 100MB。 */
|
||||||
|
const MAX_BYTES = 100 * 1024 * 1024;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领券等候浮层的「新手引导视频」配置。
|
||||||
|
*
|
||||||
|
* 用户点首页「一键自动领取」→ 出等候浮层,浮层下方那块位置**前 3 次**放这支引导视频
|
||||||
|
* (而不是广告),每次固定发 120 金币;播完若浮层还开着,自动接着放广告(原逻辑)。
|
||||||
|
* 「系统配置 → 领券引导视频」tab 的一个区块。
|
||||||
|
*
|
||||||
|
* 后台只管两件事:**开关** 和 **换片**。次数(3)/ 金币(120)走服务端默认值,产品已拍板不再
|
||||||
|
* 开放配置,所以这里不渲染输入框、PATCH 也不带这两个字段(后端仍保留字段与默认值)。
|
||||||
|
*/
|
||||||
|
export default function GuideVideoConfig() {
|
||||||
|
const [cfg, setCfg] = useState<GuideCfg | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [uploading, setUploading] = useState(false);
|
||||||
|
|
||||||
|
// 本地编辑态,保存时一次性 PATCH
|
||||||
|
const [enabled, setEnabled] = useState(true);
|
||||||
|
|
||||||
|
const canEdit = canDo(['operator']);
|
||||||
|
|
||||||
|
const sync = (c: GuideCfg) => {
|
||||||
|
setCfg(c);
|
||||||
|
setEnabled(c.enabled);
|
||||||
|
};
|
||||||
|
|
||||||
|
const load = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<GuideCfg>('/admin/api/guide-video');
|
||||||
|
sync(data);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
load();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const save = async () => {
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
const { data } = await api.patch<GuideCfg>('/admin/api/guide-video', { enabled });
|
||||||
|
sync(data);
|
||||||
|
message.success('已保存,用户下一次进入领券浮层即生效');
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// antd Upload:beforeUpload 里自行 POST(multipart),返回 false 阻止其默认上传。
|
||||||
|
const beforeUpload = (file: File) => {
|
||||||
|
// 有些系统给 .mp4 的 type 是空串,不能只看 type,再兜一层扩展名。
|
||||||
|
const looksMp4 = file.type === 'video/mp4' || /\.mp4$/i.test(file.name);
|
||||||
|
if (!looksMp4) {
|
||||||
|
message.error('仅支持 MP4 视频(H.264 编码)');
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
if (file.size > MAX_BYTES) {
|
||||||
|
message.error('视频不能超过 100MB');
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
void uploadVideo(file);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const uploadVideo = async (file: File) => {
|
||||||
|
const form = new FormData();
|
||||||
|
form.append('file', file);
|
||||||
|
setUploading(true);
|
||||||
|
try {
|
||||||
|
const { data } = await api.post<GuideCfg>('/admin/api/guide-video/video', form);
|
||||||
|
sync(data);
|
||||||
|
message.success('引导视频已更新,用户下一次进入领券浮层即生效');
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
} finally {
|
||||||
|
setUploading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeVideo = async () => {
|
||||||
|
setUploading(true);
|
||||||
|
try {
|
||||||
|
const { data } = await api.delete<GuideCfg>('/admin/api/guide-video/video');
|
||||||
|
sync(data);
|
||||||
|
message.success('已移除引导视频,领券浮层恢复为只放广告');
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
} finally {
|
||||||
|
setUploading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
size="small"
|
||||||
|
title="领券引导视频(App 领券等候浮层,前 3 次替代广告)"
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
extra={
|
||||||
|
cfg?.updated_at ? (
|
||||||
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
更新于 {new Date(cfg.updated_at).toLocaleString('zh-CN')}
|
||||||
|
</Text>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<p style={{ color: '#999', marginTop: 0 }}>
|
||||||
|
用户点「一键自动领取」后出现的等候浮层,下方那块广告位<b>前 3 次</b>改放这支引导视频。
|
||||||
|
视频<b>不可快进</b>;播完或中途关闭都算看完,各发一次 <b>120 金币</b>;播完若浮层还开着,会自动接着放广告。
|
||||||
|
次数<b>按账号</b>计(换设备不重置),<b>视频一开播就算用掉一次</b>。
|
||||||
|
次数与金币走固定值、后台不开放调整;这里只管<b>开关</b>和<b>换片</b>,每次改动进审计日志。
|
||||||
|
</p>
|
||||||
|
{loading || !cfg ? (
|
||||||
|
<Spin style={{ display: 'block', margin: '24px 0' }} />
|
||||||
|
) : (
|
||||||
|
<Space align="start" size={32} wrap>
|
||||||
|
{/* 左:视频预览 */}
|
||||||
|
<div>
|
||||||
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
当前引导视频
|
||||||
|
</Text>
|
||||||
|
<div style={{ marginTop: 8, width: 240 }}>
|
||||||
|
{cfg.video_url ? (
|
||||||
|
// eslint-disable-next-line jsx-a11y/media-has-caption
|
||||||
|
<video
|
||||||
|
src={mediaUrl(cfg.video_url)}
|
||||||
|
controls
|
||||||
|
style={{
|
||||||
|
width: 240,
|
||||||
|
maxHeight: 420,
|
||||||
|
borderRadius: 12,
|
||||||
|
background: '#000',
|
||||||
|
border: '1px solid #f0f0f0',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: 240,
|
||||||
|
height: 320,
|
||||||
|
borderRadius: 12,
|
||||||
|
border: '1px dashed #d9d9d9',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
color: '#bbb',
|
||||||
|
fontSize: 13,
|
||||||
|
textAlign: 'center',
|
||||||
|
padding: 16,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
未上传视频
|
||||||
|
<br />
|
||||||
|
(领券浮层照旧只放广告)
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{!enabled && cfg.video_url && (
|
||||||
|
<div style={{ color: '#fa8c16', fontSize: 12, marginTop: 6 }}>
|
||||||
|
当前为「关闭」:浮层不放引导视频,直接放广告
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 右:编辑控件 */}
|
||||||
|
<Space direction="vertical" size="middle" style={{ minWidth: 360 }}>
|
||||||
|
<Space>
|
||||||
|
<span>启用引导视频:</span>
|
||||||
|
<Switch checked={enabled} disabled={!canEdit} onChange={setEnabled} />
|
||||||
|
{!enabled && <Tag color="orange">已关闭</Tag>}
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<Space wrap>
|
||||||
|
<Upload accept="video/mp4,.mp4" showUploadList={false} beforeUpload={beforeUpload} disabled={!canEdit}>
|
||||||
|
<Button icon={<UploadOutlined />} loading={uploading} disabled={!canEdit}>
|
||||||
|
{cfg.video_url ? '更换视频' : '上传视频'}
|
||||||
|
</Button>
|
||||||
|
</Upload>
|
||||||
|
{cfg.video_url && (
|
||||||
|
<Button
|
||||||
|
icon={<DeleteOutlined />}
|
||||||
|
danger
|
||||||
|
loading={uploading}
|
||||||
|
disabled={!canEdit}
|
||||||
|
onClick={removeVideo}
|
||||||
|
>
|
||||||
|
移除视频
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
MP4(H.264),≤100MB
|
||||||
|
</Text>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<Button type="primary" loading={saving} disabled={!canEdit} onClick={save}>
|
||||||
|
保存开关
|
||||||
|
</Button>
|
||||||
|
{!canEdit && <Text type="secondary">仅 operator / super_admin 可修改</Text>}
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import { api, errMsg } from '@/lib/api';
|
|||||||
import HomeMarqueeSeeds from './HomeMarqueeSeeds';
|
import HomeMarqueeSeeds from './HomeMarqueeSeeds';
|
||||||
import HomeStatsConfig from './HomeStatsConfig';
|
import HomeStatsConfig from './HomeStatsConfig';
|
||||||
import FeedbackQrConfig from './FeedbackQrConfig';
|
import FeedbackQrConfig from './FeedbackQrConfig';
|
||||||
|
import GuideVideoConfig from './GuideVideoConfig';
|
||||||
|
|
||||||
interface ConfigItem {
|
interface ConfigItem {
|
||||||
key: string;
|
key: string;
|
||||||
@@ -164,6 +165,7 @@ export default function ConfigPage() {
|
|||||||
},
|
},
|
||||||
{ key: 'welfare', label: '福利页', children: welfareConfig },
|
{ key: 'welfare', label: '福利页', children: welfareConfig },
|
||||||
{ key: 'feedback-qr', label: '反馈二维码', children: <FeedbackQrConfig /> },
|
{ key: 'feedback-qr', label: '反馈二维码', children: <FeedbackQrConfig /> },
|
||||||
|
{ key: 'guide-video', label: '领券引导视频', children: <GuideVideoConfig /> },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ import {
|
|||||||
DatePicker,
|
DatePicker,
|
||||||
Divider,
|
Divider,
|
||||||
Input,
|
Input,
|
||||||
|
Popover,
|
||||||
Row,
|
Row,
|
||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
|
Spin,
|
||||||
Statistic,
|
Statistic,
|
||||||
Table,
|
Table,
|
||||||
Tag,
|
Tag,
|
||||||
@@ -72,9 +74,23 @@ interface CouponDataRow {
|
|||||||
app_env: string | null;
|
app_env: string | null;
|
||||||
started_at: string;
|
started_at: string;
|
||||||
claimed_count: number | null;
|
claimed_count: number | null;
|
||||||
|
point_success_count: number | null;
|
||||||
|
point_total_count: number | null;
|
||||||
|
// 兼容旧后端的内嵌明细;新后端不再返回,改为点击后按 trace 加载。
|
||||||
|
point_details?: CouponPointDetail[];
|
||||||
trace_url: string | null;
|
trace_url: string | null;
|
||||||
ad_revenue_yuan: number | null; // 本次领券看的信息流广告预估收益(元);未填充为 null
|
ad_revenue_yuan: number | null; // 本次领券看的信息流广告预估收益(元);未填充为 null
|
||||||
}
|
}
|
||||||
|
interface CouponPointDetail {
|
||||||
|
coupon_id: string;
|
||||||
|
coupon_name: string | null;
|
||||||
|
status: string;
|
||||||
|
reason: string | null;
|
||||||
|
}
|
||||||
|
interface CouponPointDetailsOut {
|
||||||
|
trace_id: string;
|
||||||
|
items: CouponPointDetail[];
|
||||||
|
}
|
||||||
interface CouponDataReport {
|
interface CouponDataReport {
|
||||||
date_from: string;
|
date_from: string;
|
||||||
date_to: string;
|
date_to: string;
|
||||||
@@ -116,6 +132,100 @@ const STATUS_TAG: Record<string, { color: string; label: string }> = {
|
|||||||
abandoned: { color: 'orange', label: '中途退出' },
|
abandoned: { color: 'orange', label: '中途退出' },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const POINT_STATUS_TAG: Record<string, { color: string; label: string }> = {
|
||||||
|
success: { color: 'success', label: '成功' },
|
||||||
|
already_claimed: { color: 'processing', label: '已领' },
|
||||||
|
failed: { color: 'error', label: '失败' },
|
||||||
|
skipped: { color: 'default', label: '跳过' },
|
||||||
|
};
|
||||||
|
|
||||||
|
function PointScorePopover({ row }: { row: CouponDataRow }) {
|
||||||
|
const { message } = App.useApp();
|
||||||
|
const [details, setDetails] = useState<CouponPointDetail[] | null>(row.point_details ?? null);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [loadError, setLoadError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
if (row.point_success_count == null || row.point_total_count == null || row.point_total_count <= 0) {
|
||||||
|
return <Typography.Text type="secondary">-</Typography.Text>;
|
||||||
|
}
|
||||||
|
const score = `${row.point_success_count}/${row.point_total_count}`;
|
||||||
|
const scoreColor =
|
||||||
|
row.point_success_count === row.point_total_count
|
||||||
|
? STATUS_TAG.completed.color
|
||||||
|
: STATUS_TAG.abandoned.color;
|
||||||
|
const loadDetails = async () => {
|
||||||
|
if (details !== null || loading) return;
|
||||||
|
setLoading(true);
|
||||||
|
setLoadError(null);
|
||||||
|
try {
|
||||||
|
const response = await api.get<CouponPointDetailsOut>('/admin/api/coupon-data/point-details', {
|
||||||
|
params: { trace_id: row.trace_id },
|
||||||
|
});
|
||||||
|
setDetails(response.data.items);
|
||||||
|
} catch (error) {
|
||||||
|
const errorMessage = errMsg(error);
|
||||||
|
setLoadError(errorMessage);
|
||||||
|
message.error(errorMessage);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popover
|
||||||
|
trigger="click"
|
||||||
|
placement="bottomLeft"
|
||||||
|
title={`点位明细(${score})`}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (open) void loadDetails();
|
||||||
|
}}
|
||||||
|
content={(
|
||||||
|
<div style={{ width: 380, maxHeight: 360, overflowY: 'auto' }}>
|
||||||
|
{loading || (details === null && loadError === null) ? (
|
||||||
|
<Spin size="small" style={{ display: 'block', margin: '24px auto' }} />
|
||||||
|
) : loadError ? (
|
||||||
|
<Typography.Text type="danger">明细加载失败,请关闭后重试</Typography.Text>
|
||||||
|
) : details && details.length > 0 ? details.map((point, index) => {
|
||||||
|
const status = POINT_STATUS_TAG[point.status] ?? {
|
||||||
|
color: 'default', label: point.status,
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={`${point.coupon_id}-${index}`}
|
||||||
|
style={{
|
||||||
|
padding: '8px 0',
|
||||||
|
borderBottom: index < details.length - 1 ? '1px solid #f0f0f0' : undefined,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 12 }}>
|
||||||
|
<div style={{ flex: 1, minWidth: 0 }}>
|
||||||
|
<Typography.Text>{point.coupon_name || point.coupon_id}</Typography.Text>
|
||||||
|
{point.coupon_name ? (
|
||||||
|
<div><Typography.Text type="secondary">{point.coupon_id}</Typography.Text></div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
<Tag color={status.color} style={{ marginInlineEnd: 0 }}>{status.label}</Tag>
|
||||||
|
</div>
|
||||||
|
{point.reason ? (
|
||||||
|
<div style={{ marginTop: 4 }}>
|
||||||
|
<Typography.Text type="danger">原因:{point.reason}</Typography.Text>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}) : (
|
||||||
|
<Typography.Text type="secondary">暂无点位明细</Typography.Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Button type="link" size="small" style={{ height: 'auto', padding: 0, color: scoreColor }}>
|
||||||
|
{score}
|
||||||
|
</Button>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ms → "1.5s"(空值显示 -)
|
// ms → "1.5s"(空值显示 -)
|
||||||
const fmtSec = (ms: number | null | undefined): string =>
|
const fmtSec = (ms: number | null | undefined): string =>
|
||||||
ms == null ? '-' : `${(ms / 1000).toFixed(1)}s`;
|
ms == null ? '-' : `${(ms / 1000).toFixed(1)}s`;
|
||||||
@@ -492,20 +602,10 @@ export default function CouponDataPage() {
|
|||||||
render: (v: number | null) => fmtSec(v),
|
render: (v: number | null) => fmtSec(v),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '点位成功率',
|
title: '百分比',
|
||||||
key: 'point_success_rate',
|
key: 'point_success_rate',
|
||||||
width: 110,
|
width: 110,
|
||||||
render: (_: unknown, r: CouponDataRow) => (
|
render: (_: unknown, r: CouponDataRow) => <PointScorePopover row={r} />,
|
||||||
<Tooltip title="当前接口未返回本场应领点位及逐点结果,前端不使用全局均值冒充本场成功率。">
|
|
||||||
{r.trace_url ? (
|
|
||||||
<a href={r.trace_url} target="_blank" rel="noreferrer">
|
|
||||||
查看明细
|
|
||||||
</a>
|
|
||||||
) : (
|
|
||||||
<Typography.Text type="secondary">待埋点</Typography.Text>
|
|
||||||
)}
|
|
||||||
</Tooltip>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '广告收益',
|
title: '广告收益',
|
||||||
|
|||||||
@@ -499,12 +499,7 @@ export default function DashboardPage() {
|
|||||||
const tokenCostYuan = periodData?.comparison.token_cost_total_yuan ?? null;
|
const tokenCostYuan = periodData?.comparison.token_cost_total_yuan ?? null;
|
||||||
const couponRewardCoinTotal = periodData?.coins.coupon_reward_coin_total;
|
const couponRewardCoinTotal = periodData?.coins.coupon_reward_coin_total;
|
||||||
const comparisonRewardCoinTotal = periodData?.coins.comparison_reward_coin_total;
|
const comparisonRewardCoinTotal = periodData?.coins.comparison_reward_coin_total;
|
||||||
const signinCoinTotal = periodData?.coins.signin_coin_total;
|
const regularTaskCoinTotal = periodData?.coins.regular_task_coin_total;
|
||||||
const signinBoostCoinTotal = periodData?.coins.signin_boost_coin_total;
|
|
||||||
const taskCoinTotal = periodData?.coins.task_coin_total;
|
|
||||||
const regularTaskCoinTotal =
|
|
||||||
periodData?.coins.regular_task_coin_total ??
|
|
||||||
((signinCoinTotal ?? 0) + (signinBoostCoinTotal ?? 0) + (taskCoinTotal ?? 0));
|
|
||||||
const cpsAvailable = data?.cps.available === true;
|
const cpsAvailable = data?.cps.available === true;
|
||||||
const meituanCpsCommissionCents = data?.cps.meituan_commission_cents;
|
const meituanCpsCommissionCents = data?.cps.meituan_commission_cents;
|
||||||
const jdCpsCommissionCents = data?.cps.jd_commission_cents;
|
const jdCpsCommissionCents = data?.cps.jd_commission_cents;
|
||||||
@@ -1077,6 +1072,7 @@ export default function DashboardPage() {
|
|||||||
value={fmtInt(regularTaskCoinTotal)}
|
value={fmtInt(regularTaskCoinTotal)}
|
||||||
delta={regularTaskCoinRatio.value}
|
delta={regularTaskCoinRatio.value}
|
||||||
deltaTone={regularTaskCoinRatio.tone}
|
deltaTone={regularTaskCoinRatio.tone}
|
||||||
|
hint="每日签到、历史签到膨胀、通知/其他任务、上报更低价和反馈采纳的实发金币之和。"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="本期提现金额"
|
title="本期提现金额"
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ const NAV_GROUPS: NavGroup[] = [
|
|||||||
{ key: '/comparison-records', icon: <ProfileOutlined />, label: '比价记录' },
|
{ key: '/comparison-records', icon: <ProfileOutlined />, label: '比价记录' },
|
||||||
{ key: '/coupon-data', icon: <GiftOutlined />, label: '领券记录' },
|
{ key: '/coupon-data', icon: <GiftOutlined />, label: '领券记录' },
|
||||||
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS收益' },
|
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS收益' },
|
||||||
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
|
|
||||||
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -92,9 +90,18 @@ const NAV_GROUPS: NavGroup[] = [
|
|||||||
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'monitoring-audit',
|
||||||
|
icon: <FileSearchOutlined />,
|
||||||
|
label: '监控审计',
|
||||||
|
children: [
|
||||||
|
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
|
||||||
|
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
|
||||||
|
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
||||||
|
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
||||||
|
],
|
||||||
|
},
|
||||||
{ key: '/admins', icon: <TeamOutlined />, label: '权限管理' },
|
{ key: '/admins', icon: <TeamOutlined />, label: '权限管理' },
|
||||||
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
|
||||||
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// 导航项 key(/dashboard)→ 权限页 key(dashboard),与后端 permissions.py 目录对齐
|
// 导航项 key(/dashboard)→ 权限页 key(dashboard),与后端 permissions.py 目录对齐
|
||||||
|
|||||||
+13
-1
@@ -317,6 +317,18 @@ export interface FeedbackQrConfig {
|
|||||||
updated_at: string | null;
|
updated_at: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 领券等候浮层的「新手引导视频」配置(前 3 次用它替代广告,每次固定 120 金币)。
|
||||||
|
* 后台只开放 enabled + 换片;下面几个字段接口仍返回,但页面不展示、也不回传。 */
|
||||||
|
export interface GuideVideoConfig {
|
||||||
|
enabled: boolean;
|
||||||
|
video_url: string | null; // /media/guide_video/xxx.mp4;null = 未配片(浮层照旧只放广告)
|
||||||
|
max_plays: number; // 每个账号前 N 次浮层放引导视频(服务端默认 3,后台不开放调整)
|
||||||
|
reward_coin: number; // 每次固定金币(服务端默认 120,播完 / 中途关闭都发)
|
||||||
|
updated_at: string | null;
|
||||||
|
total_plays: number; // 只读统计:全站已播次数(后台不再展示)
|
||||||
|
granted_plays: number; // 只读统计:其中已发币次数(后台不再展示)
|
||||||
|
}
|
||||||
|
|
||||||
export interface AuditLog {
|
export interface AuditLog {
|
||||||
id: number;
|
id: number;
|
||||||
admin_id: number;
|
admin_id: number;
|
||||||
@@ -488,7 +500,7 @@ 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; // 本次有效展示预估收益(元);纯发奖、激励视频提前关闭/时长不足=0
|
||||||
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;纯发奖行为空
|
||||||
|
|||||||
Reference in New Issue
Block a user