Compare commits

..

1 Commits

Author SHA1 Message Date
linkeyu 12687bef5a fix(admin): 拆分广告发奖与播放状态 2026-07-22 11:49:26 +08:00
8 changed files with 20 additions and 289 deletions
-14
View File
@@ -32,20 +32,6 @@ server {
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 托管。
# admin 页面要展示这些图,经此同域反代过去(免跨域 + 免 https 页面引 http 图被拦)。
# 前提:App 后端与本 admin 同机;若分机,把 127.0.0.1:8770 换成 App 后端可达地址。
+7 -17
View File
@@ -76,28 +76,16 @@ const REWARD_STATUS_HINT: Record<string, string> = {
const PLAYBACK_STATUS_TAG: Record<string, { color: string; label: string }> = {
completed: { color: 'green', label: '已完成' },
too_short: { color: 'gold', label: '观看时长不足' },
too_short: { color: 'gold', label: '未满10秒' },
closed_early: { color: 'default', label: '提前关闭' },
unknown: { color: 'default', label: '未知' },
};
const ZERO_REVENUE_REWARD_VIDEO_STATUSES = new Set(['closed_early', 'too_short']);
function rewardStatuses(row: AdRevenueRow): string[] {
if (row.sub_rewards?.length) return row.sub_rewards.map((reward) => reward.status);
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) {
@@ -159,7 +147,7 @@ function playbackStatusTag(row: AdRevenueRow) {
const hint = entries
.map(([status, count]) => `${PLAYBACK_STATUS_TAG[status].label} ${count}`)
.join('');
return { color: 'purple', label: '部分完成', hint: `${hint}` };
return { color: 'purple', label: '混合状态', hint: `${hint}` };
}
const fmtFactorRange = (a: number | null, b: number | null) => {
@@ -558,8 +546,10 @@ export default function AdRevenueReportPage() {
width: 110,
align: 'right',
// 一次比价/领券聚合行用 row_revenue_yuan(该次发奖广告 eCPM 折算之和),其它行用展示侧 revenue_yuan
// 激励视频提前关闭/时长不足时防御性显示 0,与后端有效收益口径一致。
render: (_v: number, r: AdRevenueRow) => effectiveRevenueYuan(r).toFixed(4),
render: (v: number, r: AdRevenueRow) => {
const rev = r.row_revenue_yuan ?? v;
return rev.toFixed(4);
},
},
{
title: '发奖状态',
@@ -705,7 +695,7 @@ export default function AdRevenueReportPage() {
<br />
<br />
广(onAdShow) eCPM ( ÷1000
);<b> 0 </b>, eCPM 穿,
),<b>广</b>;穿/,,
<b>穿</b> 0广ID / ,
<br />
<br />
-222
View File
@@ -1,222 +0,0 @@
'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 }}>
MP4H.264100MB
</Text>
</Space>
<Button type="primary" loading={saving} disabled={!canEdit} onClick={save}>
</Button>
{!canEdit && <Text type="secondary"> operator / super_admin </Text>}
</Space>
</Space>
)}
</Card>
);
}
-2
View File
@@ -6,7 +6,6 @@ import { api, errMsg } from '@/lib/api';
import HomeMarqueeSeeds from './HomeMarqueeSeeds';
import HomeStatsConfig from './HomeStatsConfig';
import FeedbackQrConfig from './FeedbackQrConfig';
import GuideVideoConfig from './GuideVideoConfig';
interface ConfigItem {
key: string;
@@ -165,7 +164,6 @@ export default function ConfigPage() {
},
{ key: 'welfare', label: '福利页', children: welfareConfig },
{ key: 'feedback-qr', label: '反馈二维码', children: <FeedbackQrConfig /> },
{ key: 'guide-video', label: '领券引导视频', children: <GuideVideoConfig /> },
]}
/>
</div>
+2 -8
View File
@@ -149,10 +149,6 @@ function PointScorePopover({ row }: { row: CouponDataRow }) {
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);
@@ -219,9 +215,7 @@ function PointScorePopover({ row }: { row: CouponDataRow }) {
</div>
)}
>
<Button type="link" size="small" style={{ height: 'auto', padding: 0, color: scoreColor }}>
{score}
</Button>
<Button type="link" size="small" style={{ height: 'auto', padding: 0 }}>{score}</Button>
</Popover>
);
}
@@ -602,7 +596,7 @@ export default function CouponDataPage() {
render: (v: number | null) => fmtSec(v),
},
{
title: '百分比',
title: '点位成功率',
key: 'point_success_rate',
width: 110,
render: (_: unknown, r: CouponDataRow) => <PointScorePopover row={r} />,
+6 -2
View File
@@ -499,7 +499,12 @@ export default function DashboardPage() {
const tokenCostYuan = periodData?.comparison.token_cost_total_yuan ?? null;
const couponRewardCoinTotal = periodData?.coins.coupon_reward_coin_total;
const comparisonRewardCoinTotal = periodData?.coins.comparison_reward_coin_total;
const regularTaskCoinTotal = periodData?.coins.regular_task_coin_total;
const signinCoinTotal = periodData?.coins.signin_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 meituanCpsCommissionCents = data?.cps.meituan_commission_cents;
const jdCpsCommissionCents = data?.cps.jd_commission_cents;
@@ -1072,7 +1077,6 @@ export default function DashboardPage() {
value={fmtInt(regularTaskCoinTotal)}
delta={regularTaskCoinRatio.value}
deltaTone={regularTaskCoinRatio.tone}
hint="每日签到、历史签到膨胀、通知/其他任务、上报更低价和反馈采纳的实发金币之和。"
/>
<StatCard
title="本期提现金额"
+4 -11
View File
@@ -67,6 +67,8 @@ const NAV_GROUPS: NavGroup[] = [
{ key: '/comparison-records', icon: <ProfileOutlined />, label: '比价记录' },
{ key: '/coupon-data', icon: <GiftOutlined />, label: '领券记录' },
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS收益' },
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
],
},
{
@@ -90,18 +92,9 @@ const NAV_GROUPS: NavGroup[] = [
{ 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: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
];
// 导航项 key(/dashboard)→ 权限页 key(dashboard),与后端 permissions.py 目录对齐
+1 -13
View File
@@ -317,18 +317,6 @@ export interface FeedbackQrConfig {
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 {
id: number;
admin_id: number;
@@ -500,7 +488,7 @@ export interface AdRevenueRow {
has_impression: boolean; // 是否有广告展示(信息流逐条展示=true,纯发奖行=false)
impressions: number; // 本行展示条数 1/0(供日汇总、趋势图复用)
ecpm: string | null; // 分/千次;展示行取展示值,纯发奖行取发奖采用值
revenue_yuan: number; // 本次有效展示预估收益(元);纯发奖、激励视频提前关闭/时长不足=0
revenue_yuan: number; // 本次展示预估收益(元);纯发奖=0
row_revenue_yuan?: number | null; // 主表逐行显示用:一次比价/领券聚合行=该次发奖广告 eCPM 折算之和;其它行空(回退 revenue_yuan)
adn: string | null; // 实际填充 ADN;纯发奖行为空
slot_id: string | null; // 底层 mediation rit;纯发奖行为空