Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e81bab6ea |
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 3001",
|
"dev": "next dev -p 3002",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start -p 3001",
|
"start": "next start -p 3001",
|
||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
|
|||||||
@@ -19,154 +19,19 @@ import type {
|
|||||||
|
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
// 主状态只对外呈现生命周期口径;below_minimum/store_closed 是迁移前历史兼容值。
|
const STATUS_COLOR: Record<string, string> = { success: 'green', failed: 'red', cancelled: 'default' };
|
||||||
const STATUS_COLOR: Record<string, string> = {
|
const STATUS_LABEL: Record<string, string> = { success: '成功', failed: '失败', cancelled: '中途退出' };
|
||||||
success: 'green',
|
|
||||||
below_minimum: 'green',
|
// 「卡在哪一步」: platform_results[*].status 翻成人话(找店/加菜/起送/读价)
|
||||||
failed: 'red',
|
const STUCK_LABEL: Record<string, string> = {
|
||||||
store_closed: 'red',
|
|
||||||
store_not_found: 'red',
|
|
||||||
items_not_found: 'red',
|
|
||||||
no_delivery: 'red',
|
|
||||||
unsupported: 'red',
|
|
||||||
cancelled: 'default',
|
|
||||||
running: 'blue',
|
|
||||||
};
|
|
||||||
const STATUS_LABEL: Record<string, string> = {
|
|
||||||
success: '成功',
|
success: '成功',
|
||||||
below_minimum: '成功',
|
store_not_found: '没找到店',
|
||||||
|
items_not_found: '菜没匹配上',
|
||||||
|
below_minimum: '未达起送',
|
||||||
|
unsupported: '平台不支持',
|
||||||
failed: '失败',
|
failed: '失败',
|
||||||
store_closed: '失败',
|
|
||||||
store_not_found: '失败',
|
|
||||||
items_not_found: '失败',
|
|
||||||
no_delivery: '失败',
|
|
||||||
unsupported: '失败',
|
|
||||||
cancelled: '中途退出',
|
|
||||||
running: '进行中',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type PlatformResultRow = Record<string, unknown> & {
|
|
||||||
platform_id?: string;
|
|
||||||
platform_name?: string;
|
|
||||||
status?: string;
|
|
||||||
reason?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
||||||
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
function platformResultRows(
|
|
||||||
platforms: Record<string, unknown>[] | null | undefined,
|
|
||||||
rawPayload: Record<string, unknown> | null | undefined,
|
|
||||||
): PlatformResultRow[] {
|
|
||||||
if ((platforms?.length ?? 0) > 0) return platforms as PlatformResultRow[];
|
|
||||||
|
|
||||||
const rawPlatforms = rawPayload?.platforms;
|
|
||||||
if (Array.isArray(rawPlatforms)) {
|
|
||||||
const rows = rawPlatforms.filter(isRecord) as PlatformResultRow[];
|
|
||||||
if (rows.length > 0) return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 灰度期旧记录没有 platforms,才回退 platform_results。这里的 success/source 是旧枚举,
|
|
||||||
// 展示时兼容折算为逐平台成功态 ok。
|
|
||||||
const resultValue = rawPayload?.platform_results;
|
|
||||||
if (Array.isArray(resultValue)) return resultValue.filter(isRecord) as PlatformResultRow[];
|
|
||||||
if (isRecord(resultValue)) {
|
|
||||||
return Object.entries(resultValue).flatMap(([platformId, result]) => (
|
|
||||||
isRecord(result) ? [{ platform_id: platformId, ...result } as PlatformResultRow] : []
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function stringList(value: unknown): string[] {
|
|
||||||
return Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasDishDiff(row: PlatformResultRow): boolean {
|
|
||||||
if (typeof row.has_dish_diff === 'boolean') return row.has_dish_diff;
|
|
||||||
const items = Array.isArray(row.items) ? row.items.filter(isRecord) : [];
|
|
||||||
return items.some((item) => item.similar === true)
|
|
||||||
|| stringList(row.approx_dish_names).length > 0
|
|
||||||
|| stringList(row.skipped_dish_names).length > 0
|
|
||||||
|| Number(row.skipped_dish_count || 0) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
type PlatformDisplay = {
|
|
||||||
label: string;
|
|
||||||
color: string;
|
|
||||||
rawStatus: string;
|
|
||||||
category: string;
|
|
||||||
dishDiff: boolean;
|
|
||||||
fallbackReason: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
function platformDisplay(row: PlatformResultRow): PlatformDisplay {
|
|
||||||
const rawStatus = typeof row.status === 'string' && row.status ? row.status : 'unknown';
|
|
||||||
const legacySource = rawStatus === 'source';
|
|
||||||
const normalizedStatus = rawStatus === 'success' || legacySource ? 'ok' : rawStatus;
|
|
||||||
const dishDiff = hasDishDiff(row);
|
|
||||||
|
|
||||||
if (normalizedStatus === 'ok') {
|
|
||||||
const isSource = row.role === 'source' || row.is_user_original === true || legacySource;
|
|
||||||
const isLowest = row.is_best === true && !dishDiff;
|
|
||||||
return {
|
|
||||||
label: '成功',
|
|
||||||
color: 'green',
|
|
||||||
rawStatus,
|
|
||||||
category: isLowest ? '#1 全网最低赢家' : isSource ? '#2 原选择' : '#3 其他成功',
|
|
||||||
dishDiff,
|
|
||||||
fallbackReason: dishDiff ? '已比出价格,但存在菜品差异,仅供参考' : '已成功比出价格',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const known: Record<string, Omit<PlatformDisplay, 'rawStatus' | 'dishDiff'>> = {
|
|
||||||
below_minimum: { label: '未满起送', color: 'gold', category: '#5 未满起送', fallbackReason: '购物车未达到起送门槛' },
|
|
||||||
store_closed: { label: '门店打烊', color: 'orange', category: '#6 门店打烊', fallbackReason: '门店当前已打烊,无法比价' },
|
|
||||||
items_not_found: { label: '商品未找到', color: 'orange', category: '#7 没有您点的商品', fallbackReason: '该店没有找到本次所选商品' },
|
|
||||||
store_not_found: { label: '店铺未找到', color: 'orange', category: '#8 无对应商家', fallbackReason: '未找到可对应的商家' },
|
|
||||||
failed: { label: '比价失败', color: 'red', category: '#9 失败兜底', fallbackReason: '本平台比价流程未完成' },
|
|
||||||
unsupported: { label: '比价失败', color: 'red', category: '#9 失败兜底', fallbackReason: '当前版本暂不支持该平台' },
|
|
||||||
no_delivery: { label: '单点不配送', color: 'orange', category: '表外 · 单点不配送', fallbackReason: '所选商品不支持单点配送' },
|
|
||||||
not_installed: { label: '未安装', color: 'default', category: '#10 端侧本地 · 未安装', fallbackReason: '该状态仅由 App 端根据装机情况补齐' },
|
|
||||||
not_compared_this_time: { label: '本次未比', color: 'default', category: '#11 端侧本地 · 未选择', fallbackReason: '该状态仅由 App 端根据本次勾选情况补齐' },
|
|
||||||
};
|
|
||||||
const mapped = known[normalizedStatus];
|
|
||||||
if (mapped) return { ...mapped, rawStatus, dishDiff: false };
|
|
||||||
return {
|
|
||||||
label: '比价失败',
|
|
||||||
color: 'red',
|
|
||||||
rawStatus,
|
|
||||||
category: '#9 未知状态兜底',
|
|
||||||
dishDiff: false,
|
|
||||||
fallbackReason: `端侧未识别状态 ${rawStatus},按比价失败兜底`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function dishDiffSummary(row: PlatformResultRow): string | null {
|
|
||||||
if (!hasDishDiff(row)) return null;
|
|
||||||
const parts: string[] = [];
|
|
||||||
const items = Array.isArray(row.items) ? row.items.filter(isRecord) : [];
|
|
||||||
const similarPairs = items
|
|
||||||
.filter((item) => item.similar === true && typeof item.name === 'string')
|
|
||||||
.map((item) => (typeof item.orig === 'string' ? `${item.orig}→${item.name}` : String(item.name)));
|
|
||||||
if (similarPairs.length) parts.push(`近似替换:${similarPairs.join('、')}`);
|
|
||||||
const approx = stringList(row.approx_dish_names);
|
|
||||||
if (approx.length) parts.push(`规格近似:${approx.join('、')}`);
|
|
||||||
const skipped = stringList(row.skipped_dish_names);
|
|
||||||
if (skipped.length) parts.push(`完全缺失:${skipped.join('、')}`);
|
|
||||||
if (!skipped.length && Number(row.skipped_dish_count || 0) > 0) {
|
|
||||||
parts.push(`缺少 ${Number(row.skipped_dish_count)} 个菜品`);
|
|
||||||
}
|
|
||||||
return parts.join(';') || '存在菜品差异';
|
|
||||||
}
|
|
||||||
|
|
||||||
function complexSpecSummary(row: PlatformResultRow): string | null {
|
|
||||||
const names = stringList(row.complex_spec_dish_names);
|
|
||||||
return names.length > 0 ? `复杂规格需核对:${names.join('、')}` : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fmtMs = (ms: number | null) => (ms == null ? '-' : `${(ms / 1000).toFixed(1)}s`);
|
const fmtMs = (ms: number | null) => (ms == null ? '-' : `${(ms / 1000).toFixed(1)}s`);
|
||||||
const cents = (c: number | null) => (c == null ? '-' : yuan(c));
|
const cents = (c: number | null) => (c == null ? '-' : yuan(c));
|
||||||
|
|
||||||
@@ -504,7 +369,8 @@ export default function ComparisonRecordsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const platformResults = platformResultRows(detail?.platforms, detail?.raw_payload);
|
const platformResults =
|
||||||
|
(detail?.raw_payload?.platform_results as Record<string, unknown>[] | undefined) || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -557,7 +423,6 @@ export default function ComparisonRecordsPage() {
|
|||||||
{ value: 'success', label: '成功' },
|
{ value: 'success', label: '成功' },
|
||||||
{ value: 'failed', label: '失败' },
|
{ value: 'failed', label: '失败' },
|
||||||
{ value: 'cancelled', label: '中途退出' },
|
{ value: 'cancelled', label: '中途退出' },
|
||||||
{ value: 'running', label: '进行中' },
|
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<Button type="primary" onClick={search}>查询</Button>
|
<Button type="primary" onClick={search}>查询</Button>
|
||||||
@@ -714,67 +579,16 @@ export default function ComparisonRecordsPage() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{platformResults.length > 0 && (
|
{platformResults.length > 0 && (
|
||||||
<Card size="small" title="逐平台结果卡片判定">
|
<Card size="small" title="逐平台结局(卡在哪一步)">
|
||||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 12 }}>
|
|
||||||
优先按 platforms[].status=ok 及 is_best、role、has_dish_diff 判定;#10 未安装和 #11 本次未比
|
|
||||||
由 App 端本地补齐,正常情况下后台没有对应行。
|
|
||||||
</Typography.Paragraph>
|
|
||||||
<Table
|
<Table
|
||||||
size="small"
|
size="small"
|
||||||
rowKey={(_, i) => String(i)}
|
rowKey={(_, i) => String(i)}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
dataSource={platformResults}
|
dataSource={platformResults}
|
||||||
scroll={{ x: 1050 }}
|
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{ title: '平台', dataIndex: 'platform_name', render: (v, r: Record<string, unknown>) => (v as string) || (r.platform_id as string) || '-' },
|
||||||
title: '平台', dataIndex: 'platform_name', width: 150,
|
{ title: '结局', dataIndex: 'status', render: (s: string) => <Tag color={s === 'success' ? 'green' : 'orange'}>{STUCK_LABEL[s] || s || '-'}</Tag> },
|
||||||
render: (v, r: PlatformResultRow) => (v as string) || r.platform_id || '-',
|
{ title: '说明', dataIndex: 'reason', render: (v) => (v as string) || '-' },
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '逐平台状态', dataIndex: 'status', width: 135,
|
|
||||||
render: (_, r: PlatformResultRow) => {
|
|
||||||
const display = platformDisplay(r);
|
|
||||||
return (
|
|
||||||
<Space direction="vertical" size={0}>
|
|
||||||
<Tag color={display.color}>{display.label}</Tag>
|
|
||||||
<Typography.Text type="secondary" code>{display.rawStatus}</Typography.Text>
|
|
||||||
</Space>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '卡片分类', key: 'category', width: 210,
|
|
||||||
render: (_, r: PlatformResultRow) => {
|
|
||||||
const display = platformDisplay(r);
|
|
||||||
const hasComplexSpec = complexSpecSummary(r) != null;
|
|
||||||
return (
|
|
||||||
<Space size={[4, 4]} wrap>
|
|
||||||
<Tag color={display.color}>{display.category}</Tag>
|
|
||||||
{display.dishDiff ? <Tag color="gold">#4 菜品差异</Tag> : null}
|
|
||||||
{hasComplexSpec ? <Tag color="blue">复杂规格待核对</Tag> : null}
|
|
||||||
</Space>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '价格', dataIndex: 'price', width: 90,
|
|
||||||
render: (v) => (typeof v === 'number' ? `¥${v.toFixed(2)}` : '-'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '说明 / 判定字段', key: 'reason',
|
|
||||||
render: (_, r: PlatformResultRow) => {
|
|
||||||
const display = platformDisplay(r);
|
|
||||||
const diff = dishDiffSummary(r);
|
|
||||||
const complexSpec = complexSpecSummary(r);
|
|
||||||
return (
|
|
||||||
<Space direction="vertical" size={0}>
|
|
||||||
<span>{typeof r.reason === 'string' && r.reason ? r.reason : display.fallbackReason}</span>
|
|
||||||
{diff ? <Typography.Text type="warning">{diff}</Typography.Text> : null}
|
|
||||||
{complexSpec ? <Typography.Text type="secondary">{complexSpec}</Typography.Text> : null}
|
|
||||||
</Space>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
|
Alert,
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
|
Descriptions,
|
||||||
InputNumber,
|
InputNumber,
|
||||||
|
Popconfirm,
|
||||||
Space,
|
Space,
|
||||||
Spin,
|
Spin,
|
||||||
Switch,
|
Switch,
|
||||||
@@ -21,6 +24,10 @@ import type { GuideVideoConfig as GuideCfg } from '@/lib/types';
|
|||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
const MAX_BYTES = 100 * 1024 * 1024;
|
const MAX_BYTES = 100 * 1024 * 1024;
|
||||||
|
const MIN_PLAYS = 1;
|
||||||
|
const MAX_PLAYS = 50;
|
||||||
|
const MIN_REWARD_COIN = 10;
|
||||||
|
const MAX_REWARD_COIN = 10000;
|
||||||
type Scene = 'coupon' | 'comparison';
|
type Scene = 'coupon' | 'comparison';
|
||||||
|
|
||||||
const META: Record<Scene, { title: string; action: string }> = {
|
const META: Record<Scene, { title: string; action: string }> = {
|
||||||
@@ -28,16 +35,29 @@ const META: Record<Scene, { title: string; action: string }> = {
|
|||||||
comparison: { title: '开始比价引导视频', action: '开始比价' },
|
comparison: { title: '开始比价引导视频', action: '开始比价' },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function formatDuration(durationMs: number | null | undefined) {
|
||||||
|
if (durationMs == null || !Number.isFinite(durationMs)) return '—';
|
||||||
|
return `${(durationMs / 1000).toFixed(3).replace(/\.?0+$/, '')} 秒`;
|
||||||
|
}
|
||||||
|
|
||||||
function SceneConfig({ scene }: { scene: Scene }) {
|
function SceneConfig({ scene }: { scene: Scene }) {
|
||||||
const meta = META[scene];
|
const meta = META[scene];
|
||||||
const [cfg, setCfg] = useState<GuideCfg | null>(null);
|
const [cfg, setCfg] = useState<GuideCfg | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [uploading, setUploading] = useState(false);
|
const [uploading, setUploading] = useState(false);
|
||||||
const [enabled, setEnabled] = useState(true);
|
const [enabled, setEnabled] = useState(false);
|
||||||
const [maxPlays, setMaxPlays] = useState(3);
|
const [maxPlays, setMaxPlays] = useState(3);
|
||||||
const [rewardCoin, setRewardCoin] = useState(100);
|
const [rewardCoin, setRewardCoin] = useState(100);
|
||||||
const canEdit = canDo(['operator']);
|
const canEdit = canDo(['operator']);
|
||||||
|
const configValid =
|
||||||
|
Number.isInteger(maxPlays) &&
|
||||||
|
maxPlays >= MIN_PLAYS &&
|
||||||
|
maxPlays <= MAX_PLAYS &&
|
||||||
|
Number.isInteger(rewardCoin) &&
|
||||||
|
rewardCoin >= MIN_REWARD_COIN &&
|
||||||
|
rewardCoin <= MAX_REWARD_COIN &&
|
||||||
|
rewardCoin % 10 === 0;
|
||||||
|
|
||||||
const sync = (value: GuideCfg) => {
|
const sync = (value: GuideCfg) => {
|
||||||
setCfg(value);
|
setCfg(value);
|
||||||
@@ -49,9 +69,7 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
const load = async () => {
|
const load = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const { data } = await api.get<GuideCfg>('/admin/api/guide-video', {
|
const { data } = await api.get<GuideCfg>('/admin/api/guide-video', { params: { scene } });
|
||||||
params: { scene },
|
|
||||||
});
|
|
||||||
sync(data);
|
sync(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(errMsg(e));
|
message.error(errMsg(e));
|
||||||
@@ -65,15 +83,15 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
}, [scene]);
|
}, [scene]);
|
||||||
|
|
||||||
const save = async () => {
|
const save = async () => {
|
||||||
|
if (!configValid) {
|
||||||
|
message.error('请检查配置:播放次数为 1~50,每次金币为 10~10000 且必须是 10 的倍数');
|
||||||
|
return;
|
||||||
|
}
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
const { data } = await api.patch<GuideCfg>(
|
const { data } = await api.patch<GuideCfg>(
|
||||||
'/admin/api/guide-video',
|
'/admin/api/guide-video',
|
||||||
{
|
{ enabled, max_plays: maxPlays, reward_coin: rewardCoin },
|
||||||
enabled,
|
|
||||||
reward_coin: rewardCoin,
|
|
||||||
...(scene === 'comparison' ? { max_plays: maxPlays } : {}),
|
|
||||||
},
|
|
||||||
{ params: { scene } },
|
{ params: { scene } },
|
||||||
);
|
);
|
||||||
sync(data);
|
sync(data);
|
||||||
@@ -98,7 +116,7 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
sync(data);
|
sync(data);
|
||||||
message.success(`${meta.title}已更新`);
|
message.success(`${meta.title}已更新`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(errMsg(e));
|
message.error(`${errMsg(e)},原视频和配置未改变`);
|
||||||
} finally {
|
} finally {
|
||||||
setUploading(false);
|
setUploading(false);
|
||||||
}
|
}
|
||||||
@@ -106,7 +124,7 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
|
|
||||||
const beforeUpload = (file: File) => {
|
const beforeUpload = (file: File) => {
|
||||||
if (file.type !== 'video/mp4' && !/\.mp4$/i.test(file.name)) {
|
if (file.type !== 'video/mp4' && !/\.mp4$/i.test(file.name)) {
|
||||||
message.error('仅支持 MP4 视频(H.264 编码)');
|
message.error('仅支持 MP4 视频(H.264 或 HEVC/H.265 编码)');
|
||||||
return Upload.LIST_IGNORE;
|
return Upload.LIST_IGNORE;
|
||||||
}
|
}
|
||||||
if (file.size > MAX_BYTES) {
|
if (file.size > MAX_BYTES) {
|
||||||
@@ -138,20 +156,11 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
size="small"
|
size="small"
|
||||||
title={meta.title}
|
title={meta.title}
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
extra={
|
extra={cfg?.updated_at ? <Text type="secondary">更新于 {new Date(cfg.updated_at).toLocaleString('zh-CN')}</Text> : null}
|
||||||
cfg?.updated_at ? (
|
|
||||||
<Text type="secondary">
|
|
||||||
更新于 {new Date(cfg.updated_at).toLocaleString('zh-CN')}
|
|
||||||
</Text>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<p style={{ color: '#777', marginTop: 0 }}>
|
<p style={{ color: '#777', marginTop: 0 }}>
|
||||||
Android 用户点击「{meta.action}」后,前 {cfg?.max_plays ?? 3}{' '}
|
Android 用户点击「{meta.action}」后,符合次数条件时播放本视频。次数按账号、按功能分别计算,
|
||||||
次在等候浮层广告位播放本视频并奖励金币。次数按账号、按功能分别计算;
|
每完整观看 1/10 视频立即发放 1/10 金币;中途退出只保留已完成圈的奖励。
|
||||||
开播即计次,播完或中途关闭均发放当次配置的金币。
|
|
||||||
{scene === 'coupon' &&
|
|
||||||
'领券引导视频的播放次数上限请在「监控审计 → 限制策略」中调整。'}
|
|
||||||
</p>
|
</p>
|
||||||
{loading || !cfg ? (
|
{loading || !cfg ? (
|
||||||
<Spin style={{ display: 'block', margin: '24px 0' }} />
|
<Spin style={{ display: 'block', margin: '24px 0' }} />
|
||||||
@@ -163,97 +172,115 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
<video
|
<video
|
||||||
src={mediaUrl(cfg.video_url)}
|
src={mediaUrl(cfg.video_url)}
|
||||||
controls
|
controls
|
||||||
style={{
|
style={{ width: 240, maxHeight: 420, borderRadius: 12, background: '#000' }}
|
||||||
width: 240,
|
|
||||||
maxHeight: 420,
|
|
||||||
borderRadius: 12,
|
|
||||||
background: '#000',
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div style={{ height: 280, border: '1px dashed #d9d9d9', borderRadius: 12, display: 'grid', placeItems: 'center', color: '#aaa' }}>
|
||||||
style={{
|
|
||||||
height: 280,
|
|
||||||
border: '1px dashed #d9d9d9',
|
|
||||||
borderRadius: 12,
|
|
||||||
display: 'grid',
|
|
||||||
placeItems: 'center',
|
|
||||||
color: '#aaa',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
未上传视频
|
未上传视频
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Space direction="vertical" size="middle" style={{ minWidth: 390 }}>
|
<Space direction="vertical" size="middle" style={{ minWidth: 390 }}>
|
||||||
|
{cfg.analysis_status === 'invalid' || cfg.analysis_error ? (
|
||||||
|
<Alert
|
||||||
|
type="error"
|
||||||
|
showIcon
|
||||||
|
message="视频分析异常,当前场景不可启用"
|
||||||
|
description={cfg.analysis_error || '请重新上传符合要求的视频'}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
<Space>
|
<Space>
|
||||||
<span>启用:</span>
|
<span>启用:</span>
|
||||||
<Switch
|
<Switch
|
||||||
checked={enabled}
|
checked={enabled}
|
||||||
disabled={!canEdit}
|
disabled={!canEdit || (!enabled && cfg.analysis_status !== 'valid')}
|
||||||
onChange={setEnabled}
|
onChange={setEnabled}
|
||||||
/>
|
/>
|
||||||
{!enabled && <Tag color="orange">已关闭</Tag>}
|
{!enabled && <Tag color="orange">已关闭</Tag>}
|
||||||
|
{!enabled && cfg.analysis_status !== 'valid' && <Text type="secondary">请先上传并通过视频分析</Text>}
|
||||||
</Space>
|
</Space>
|
||||||
{scene === 'comparison' && (
|
|
||||||
<Space>
|
|
||||||
<span>播放次数:</span>
|
|
||||||
<InputNumber
|
|
||||||
min={0}
|
|
||||||
max={50}
|
|
||||||
precision={0}
|
|
||||||
value={maxPlays}
|
|
||||||
disabled={!canEdit}
|
|
||||||
onChange={(value) => setMaxPlays(value ?? 0)}
|
|
||||||
/>
|
|
||||||
<Text type="secondary">每个账号前 N 次(默认 3)</Text>
|
|
||||||
</Space>
|
|
||||||
)}
|
|
||||||
<Space>
|
<Space>
|
||||||
<span>每次金币:</span>
|
<span>播放次数:</span>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
min={0}
|
min={MIN_PLAYS}
|
||||||
max={10000}
|
max={MAX_PLAYS}
|
||||||
precision={0}
|
precision={0}
|
||||||
|
status={maxPlays < MIN_PLAYS || maxPlays > MAX_PLAYS ? 'error' : undefined}
|
||||||
|
value={maxPlays}
|
||||||
|
disabled={!canEdit}
|
||||||
|
onChange={(v) => setMaxPlays(v ?? MIN_PLAYS)}
|
||||||
|
/>
|
||||||
|
<Text type="secondary">每个账号 1~50 次(默认 3)</Text>
|
||||||
|
</Space>
|
||||||
|
<Space>
|
||||||
|
<span>每次金币总价:</span>
|
||||||
|
<InputNumber
|
||||||
|
min={MIN_REWARD_COIN}
|
||||||
|
max={MAX_REWARD_COIN}
|
||||||
|
step={10}
|
||||||
|
precision={0}
|
||||||
|
status={
|
||||||
|
rewardCoin < MIN_REWARD_COIN ||
|
||||||
|
rewardCoin > MAX_REWARD_COIN ||
|
||||||
|
rewardCoin % 10 !== 0
|
||||||
|
? 'error'
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
value={rewardCoin}
|
value={rewardCoin}
|
||||||
disabled={!canEdit}
|
disabled={!canEdit}
|
||||||
onChange={(value) => setRewardCoin(value ?? 0)}
|
onChange={(v) => setRewardCoin(v ?? MIN_REWARD_COIN)}
|
||||||
/>
|
/>
|
||||||
<Text type="secondary">默认 100</Text>
|
<Text type="secondary">10~10000,必须是 10 的倍数(默认 100)</Text>
|
||||||
</Space>
|
</Space>
|
||||||
|
{cfg.video_url ? (
|
||||||
|
<Descriptions size="small" bordered column={2}>
|
||||||
|
<Descriptions.Item label="总时长">{formatDuration(cfg.duration_ms)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="单圈时长">
|
||||||
|
{formatDuration(cfg.circle_duration_ms ?? (cfg.duration_ms == null ? null : cfg.duration_ms / 10))}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="单圈金币">
|
||||||
|
{rewardCoin === cfg.reward_coin ? cfg.reward_per_circle : rewardCoin / cfg.circle_count}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="编码">
|
||||||
|
视频 {cfg.video_codec || '—'} / 音频 {cfg.audio_codec || '无'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="分析状态" span={2}>
|
||||||
|
<Tag color={cfg.analysis_status === 'valid' ? 'green' : 'orange'}>
|
||||||
|
{cfg.analysis_status === 'valid'
|
||||||
|
? '分析完成'
|
||||||
|
: cfg.analysis_status === 'invalid'
|
||||||
|
? '分析异常'
|
||||||
|
: '未上传'}
|
||||||
|
</Tag>
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
) : null}
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Upload
|
<Upload accept="video/mp4,.mp4" showUploadList={false} beforeUpload={beforeUpload} disabled={!canEdit}>
|
||||||
accept="video/mp4,.mp4"
|
<Button icon={<UploadOutlined />} loading={uploading} disabled={!canEdit}>
|
||||||
showUploadList={false}
|
|
||||||
beforeUpload={beforeUpload}
|
|
||||||
disabled={!canEdit}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
icon={<UploadOutlined />}
|
|
||||||
loading={uploading}
|
|
||||||
disabled={!canEdit}
|
|
||||||
>
|
|
||||||
{cfg.video_url ? '更换视频' : '上传视频'}
|
{cfg.video_url ? '更换视频' : '上传视频'}
|
||||||
</Button>
|
</Button>
|
||||||
</Upload>
|
</Upload>
|
||||||
{cfg.video_url && (
|
{cfg.video_url && (
|
||||||
<Button icon={<DeleteOutlined />} danger loading={uploading} disabled={!canEdit} onClick={removeVideo}>
|
<Popconfirm
|
||||||
移除视频
|
title={`确认移除${meta.title}?`}
|
||||||
</Button>
|
description="移除后该场景的新播放将无法使用引导视频,已经开始的播放不受影响。"
|
||||||
|
okText="确认移除"
|
||||||
|
cancelText="取消"
|
||||||
|
okButtonProps={{ danger: true }}
|
||||||
|
onConfirm={removeVideo}
|
||||||
|
disabled={!canEdit}
|
||||||
|
>
|
||||||
|
<Button icon={<DeleteOutlined />} danger loading={uploading} disabled={!canEdit}>
|
||||||
|
移除视频
|
||||||
|
</Button>
|
||||||
|
</Popconfirm>
|
||||||
)}
|
)}
|
||||||
<Text type="secondary">MP4(H.264),≤100MB</Text>
|
<Text type="secondary">MP4(H.264 或 HEVC/H.265,可无音轨;有音轨须 AAC),30~180 秒,≤100MB</Text>
|
||||||
</Space>
|
</Space>
|
||||||
<Button
|
<Button type="primary" loading={saving} disabled={!canEdit || !configValid} onClick={save}>
|
||||||
type="primary"
|
|
||||||
loading={saving}
|
|
||||||
disabled={!canEdit}
|
|
||||||
onClick={save}
|
|
||||||
>
|
|
||||||
保存配置
|
保存配置
|
||||||
</Button>
|
</Button>
|
||||||
<Text type="secondary">
|
|
||||||
累计播放 {cfg.total_plays} 次,已发币 {cfg.granted_plays} 次
|
|
||||||
</Text>
|
|
||||||
</Space>
|
</Space>
|
||||||
</Space>
|
</Space>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ interface CouponDataRow {
|
|||||||
claimed_count: number | null;
|
claimed_count: number | null;
|
||||||
point_success_count: number | null;
|
point_success_count: number | null;
|
||||||
point_total_count: number | null;
|
point_total_count: number | null;
|
||||||
point_event_count?: number;
|
|
||||||
// 兼容旧后端的内嵌明细;新后端不再返回,改为点击后按 trace 加载。
|
// 兼容旧后端的内嵌明细;新后端不再返回,改为点击后按 trace 加载。
|
||||||
point_details?: CouponPointDetail[];
|
point_details?: CouponPointDetail[];
|
||||||
trace_url: string | null;
|
trace_url: string | null;
|
||||||
@@ -146,22 +145,15 @@ function PointScorePopover({ row }: { row: CouponDataRow }) {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [loadError, setLoadError] = useState<string | null>(null);
|
const [loadError, setLoadError] = useState<string | null>(null);
|
||||||
|
|
||||||
const abandonedWithoutScoredResult =
|
if (row.point_success_count == null || row.point_total_count == null || row.point_total_count <= 0) {
|
||||||
row.status === 'abandoned' && row.point_success_count === 0 && row.point_total_count === 0;
|
|
||||||
if (
|
|
||||||
row.point_success_count == null ||
|
|
||||||
row.point_total_count == null ||
|
|
||||||
(row.point_total_count <= 0 && !abandonedWithoutScoredResult)
|
|
||||||
) {
|
|
||||||
return <Typography.Text type="secondary">-</Typography.Text>;
|
return <Typography.Text type="secondary">-</Typography.Text>;
|
||||||
}
|
}
|
||||||
const score = `${row.point_success_count}/${row.point_total_count}`;
|
const score = `${row.point_success_count}/${row.point_total_count}`;
|
||||||
const hasPointDetails = (row.point_event_count ?? 0) > 0;
|
const scoreWithRate = `${score}(${(
|
||||||
const scoreWithRate = abandonedWithoutScoredResult
|
row.point_success_count / row.point_total_count * 100
|
||||||
? `0.0%(${hasPointDetails ? '无有效结果' : '退出前无结果'})`
|
).toFixed(1)}%)`;
|
||||||
: `${score}(${(row.point_success_count / row.point_total_count * 100).toFixed(1)}%)`;
|
|
||||||
const scoreColor =
|
const scoreColor =
|
||||||
row.point_total_count > 0 && row.point_success_count === row.point_total_count
|
row.point_success_count === row.point_total_count
|
||||||
? STATUS_TAG.completed.color
|
? STATUS_TAG.completed.color
|
||||||
: STATUS_TAG.abandoned.color;
|
: STATUS_TAG.abandoned.color;
|
||||||
const loadDetails = async () => {
|
const loadDetails = async () => {
|
||||||
@@ -182,14 +174,6 @@ function PointScorePopover({ row }: { row: CouponDataRow }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (abandonedWithoutScoredResult && !hasPointDetails) {
|
|
||||||
return (
|
|
||||||
<Tooltip title="本次在第一张券产生终态前中途退出,没有可计入成功/尝试的单券结果;按运营展示口径记为 0.0%,不虚构失败券数量。">
|
|
||||||
<Typography.Text type="warning">{scoreWithRate}</Typography.Text>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
trigger="click"
|
trigger="click"
|
||||||
|
|||||||
@@ -550,7 +550,6 @@ export default function DashboardPage() {
|
|||||||
const couponPeriod = periodData?.coupon ?? null;
|
const couponPeriod = periodData?.coupon ?? null;
|
||||||
const previousCouponPeriod = previousPeriodData?.coupon ?? null;
|
const previousCouponPeriod = previousPeriodData?.coupon ?? null;
|
||||||
const couponStartedDelta = percentDelta(couponPeriod?.started, previousCouponPeriod?.started);
|
const couponStartedDelta = percentDelta(couponPeriod?.started, previousCouponPeriod?.started);
|
||||||
const couponSuccessDenominator = couponPeriod?.success_denominator ?? null;
|
|
||||||
const couponSuccessRateValue =
|
const couponSuccessRateValue =
|
||||||
couponPeriod?.success_rate == null ? '--' : (couponPeriod.success_rate * 100).toFixed(1);
|
couponPeriod?.success_rate == null ? '--' : (couponPeriod.success_rate * 100).toFixed(1);
|
||||||
const couponSuccessRateDelta = pointDelta(couponPeriod?.success_rate, previousCouponPeriod?.success_rate);
|
const couponSuccessRateDelta = pointDelta(couponPeriod?.success_rate, previousCouponPeriod?.success_rate);
|
||||||
@@ -876,11 +875,9 @@ export default function DashboardPage() {
|
|||||||
unit="%"
|
unit="%"
|
||||||
delta={couponSuccessRateDelta.value}
|
delta={couponSuccessRateDelta.value}
|
||||||
deltaTone={couponSuccessRateDelta.tone}
|
deltaTone={couponSuccessRateDelta.tone}
|
||||||
hint={`全部点位领成功的次数 ÷(领券发起数-中途退出数);本期 ${fmtInt(
|
hint={`全部点位领成功的次数 / 领券发起数;本期 ${fmtInt(couponPeriod?.all_success)} / ${fmtInt(
|
||||||
couponPeriod?.all_success,
|
couponPeriod?.started,
|
||||||
)} ÷(${fmtInt(couponPeriod?.started)}-${fmtInt(couponPeriod?.abandoned)}),分母为 ${fmtInt(
|
)} 次。点位成功口径含「今日已领过」。`}
|
||||||
couponSuccessDenominator,
|
|
||||||
)}。中途退出不计入分母,点位成功口径含「今日已领过」。`}
|
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="点位成功率"
|
title="点位成功率"
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { useEffect, useRef, useState } from 'react';
|
|||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
import {
|
import {
|
||||||
BarChartOutlined,
|
BarChartOutlined,
|
||||||
ControlOutlined,
|
|
||||||
DashboardOutlined,
|
DashboardOutlined,
|
||||||
DatabaseOutlined,
|
DatabaseOutlined,
|
||||||
FileSearchOutlined,
|
FileSearchOutlined,
|
||||||
@@ -106,7 +105,6 @@ const NAV_GROUPS: NavGroup[] = [
|
|||||||
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
|
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
|
||||||
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
||||||
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
||||||
{ key: '/limit-whitelist', icon: <ControlOutlined />, label: '限制策略' },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -19,12 +19,10 @@ import {
|
|||||||
CopyOutlined,
|
CopyOutlined,
|
||||||
DownOutlined,
|
DownOutlined,
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
PlusCircleOutlined,
|
|
||||||
ReloadOutlined,
|
ReloadOutlined,
|
||||||
RightOutlined,
|
RightOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
import { api, errMsg } from '@/lib/api';
|
import { api, errMsg } from '@/lib/api';
|
||||||
import { formatUtcTime, utcDayjs } from '@/lib/format';
|
import { formatUtcTime, utcDayjs } from '@/lib/format';
|
||||||
import type {
|
import type {
|
||||||
@@ -71,8 +69,8 @@ type IncidentStatus = 'open' | 'blocked';
|
|||||||
const RULE_LIMITS: Record<RiskKind, { min: number; max: number; help: string }> = {
|
const RULE_LIMITS: Record<RiskKind, { min: number; max: number; help: string }> = {
|
||||||
sms: {
|
sms: {
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 100000,
|
max: 5,
|
||||||
help: '统计成功下发;告警阈值与短信硬限制分别配置。',
|
help: '统计成功下发;最高5次,与现有每设备每小时发送上限一致。',
|
||||||
},
|
},
|
||||||
oneclick: {
|
oneclick: {
|
||||||
min: 1,
|
min: 1,
|
||||||
@@ -81,8 +79,8 @@ const RULE_LIMITS: Record<RiskKind, { min: number; max: number; help: string }>
|
|||||||
},
|
},
|
||||||
compare: {
|
compare: {
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 100000,
|
max: 100,
|
||||||
help: '同一账户按北京时间自然日累计;告警阈值与比价硬限制分别配置。',
|
help: '同一账户按北京时间自然日累计;最高100次,与比价每日上限一致。',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const utcTime = (value: string | null, withDate = true) =>
|
const utcTime = (value: string | null, withDate = true) =>
|
||||||
@@ -273,7 +271,6 @@ function DetailTable({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function RiskMonitorPage() {
|
export default function RiskMonitorPage() {
|
||||||
const router = useRouter();
|
|
||||||
const { message, modal } = App.useApp();
|
const { message, modal } = App.useApp();
|
||||||
const [summary, setSummary] = useState<RiskMonitorSummary | null>(null);
|
const [summary, setSummary] = useState<RiskMonitorSummary | null>(null);
|
||||||
const [lists, setLists] = useState<Partial<Record<RiskKind, RiskIncidentPage>>>({});
|
const [lists, setLists] = useState<Partial<Record<RiskKind, RiskIncidentPage>>>({});
|
||||||
@@ -600,40 +597,6 @@ export default function RiskMonitorPage() {
|
|||||||
[lists, loadAll, message, modal],
|
[lists, loadAll, message, modal],
|
||||||
);
|
);
|
||||||
|
|
||||||
const addToWhitelist = useCallback(
|
|
||||||
(row: RiskIncidentItem) => {
|
|
||||||
const isCompare = row.kind === 'compare';
|
|
||||||
const subjectValue = isCompare ? row.phone : row.subject_id;
|
|
||||||
if (!isCompare && subjectValue?.startsWith('legacy-ip:')) {
|
|
||||||
void message.error(
|
|
||||||
'旧客户端未上报真实设备 ID,无法加入设备白名单,请升级客户端后重试',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!subjectValue) {
|
|
||||||
void message.error(
|
|
||||||
isCompare
|
|
||||||
? '该风险记录没有关联手机号,暂时无法加入白名单'
|
|
||||||
: '该风险记录没有设备 ID,暂时无法加入白名单',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const ruleCode: Record<RiskKind, string> = {
|
|
||||||
sms: 'risk.sms.hourly',
|
|
||||||
oneclick: 'risk.oneclick.daily',
|
|
||||||
compare: 'risk.compare.daily',
|
|
||||||
};
|
|
||||||
const params = new URLSearchParams({
|
|
||||||
create: '1',
|
|
||||||
subject_type: isCompare ? 'phone' : 'device',
|
|
||||||
subject_value: subjectValue,
|
|
||||||
rule_code: ruleCode[row.kind],
|
|
||||||
});
|
|
||||||
router.push(`/limit-whitelist?${params.toString()}`);
|
|
||||||
},
|
|
||||||
[message, router],
|
|
||||||
);
|
|
||||||
|
|
||||||
const columns = useCallback(
|
const columns = useCallback(
|
||||||
(kind: RiskKind): ColumnsType<RiskIncidentItem> => {
|
(kind: RiskKind): ColumnsType<RiskIncidentItem> => {
|
||||||
const actionColumn = {
|
const actionColumn = {
|
||||||
@@ -641,18 +604,9 @@ export default function RiskMonitorPage() {
|
|||||||
key: 'actions',
|
key: 'actions',
|
||||||
align: 'right' as const,
|
align: 'right' as const,
|
||||||
fixed: 'right' as const,
|
fixed: 'right' as const,
|
||||||
width: 280,
|
width: 180,
|
||||||
render: (_: unknown, row: RiskIncidentItem) => {
|
render: (_: unknown, row: RiskIncidentItem) => {
|
||||||
const open = expanded.has(row.incident_id);
|
const open = expanded.has(row.incident_id);
|
||||||
const whitelistUnavailableReason =
|
|
||||||
row.kind === 'compare'
|
|
||||||
? row.phone
|
|
||||||
? undefined
|
|
||||||
: '该风险记录没有关联手机号,暂时无法加入白名单'
|
|
||||||
: row.subject_id.startsWith('legacy-ip:')
|
|
||||||
? '旧客户端未上报真实设备 ID,无法加入设备白名单'
|
|
||||||
: undefined;
|
|
||||||
const canAddToWhitelist = !whitelistUnavailableReason;
|
|
||||||
return (
|
return (
|
||||||
<span className={styles.actionGroup}>
|
<span className={styles.actionGroup}>
|
||||||
<Button
|
<Button
|
||||||
@@ -664,20 +618,6 @@ export default function RiskMonitorPage() {
|
|||||||
>
|
>
|
||||||
{open ? '收起' : '展开'}
|
{open ? '收起' : '展开'}
|
||||||
</Button>
|
</Button>
|
||||||
<Tooltip
|
|
||||||
title={whitelistUnavailableReason}
|
|
||||||
>
|
|
||||||
<span>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
icon={<PlusCircleOutlined />}
|
|
||||||
disabled={!canAddToWhitelist}
|
|
||||||
onClick={() => addToWhitelist(row)}
|
|
||||||
>
|
|
||||||
加入白名单
|
|
||||||
</Button>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
{row.status === 'open' && (
|
{row.status === 'open' && (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
@@ -760,16 +700,7 @@ export default function RiskMonitorPage() {
|
|||||||
actionColumn,
|
actionColumn,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
[
|
[acting, copy, detailLoading, expanded, revokeRestriction, runAction, toggle],
|
||||||
acting,
|
|
||||||
addToWhitelist,
|
|
||||||
copy,
|
|
||||||
detailLoading,
|
|
||||||
expanded,
|
|
||||||
revokeRestriction,
|
|
||||||
runAction,
|
|
||||||
toggle,
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const cards = useMemo(() => {
|
const cards = useMemo(() => {
|
||||||
|
|||||||
+13
-87
@@ -414,17 +414,23 @@ export interface FeedbackQrConfig {
|
|||||||
updated_at: string | null;
|
updated_at: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 领券等候浮层的「新手引导视频」配置(前 3 次用它替代广告,默认每次固定 100 金币)。
|
/** 领券/比价等候浮层的引导视频配置。视频分析结果均由服务端 ffprobe 生成。 */
|
||||||
* 后台只开放 enabled + 换片;下面几个字段接口仍返回,但页面不展示、也不回传。 */
|
|
||||||
export interface GuideVideoConfig {
|
export interface GuideVideoConfig {
|
||||||
scene: 'coupon' | 'comparison';
|
scene: 'coupon' | 'comparison';
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
video_url: string | null; // /media/guide_video/xxx.mp4;null = 未配片(浮层照旧只放广告)
|
video_url: string | null;
|
||||||
max_plays: number; // 每个账号前 N 次浮层放引导视频(服务端默认 3,后台不开放调整)
|
max_plays: number;
|
||||||
reward_coin: number; // 每次固定金币(服务端默认 100,播完 / 中途关闭都发)
|
reward_coin: number;
|
||||||
updated_at: string | null;
|
updated_at: string | null;
|
||||||
total_plays: number; // 只读统计:全站已播次数(后台不再展示)
|
duration_ms: number | null;
|
||||||
granted_plays: number; // 只读统计:其中已发币次数(后台不再展示)
|
circle_duration_ms: number | null;
|
||||||
|
circle_count: 10;
|
||||||
|
reward_per_circle: number;
|
||||||
|
video_codec: string | null;
|
||||||
|
audio_codec: string | null;
|
||||||
|
analysis_status: 'missing' | 'valid' | 'invalid';
|
||||||
|
analysis_error: string | null;
|
||||||
|
config_version: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuditLog {
|
export interface AuditLog {
|
||||||
@@ -518,7 +524,6 @@ export interface ComparisonRecordDetail extends ComparisonRecordListItem {
|
|||||||
skipped_dish_count: number | null;
|
skipped_dish_count: number | null;
|
||||||
device_id: string | null;
|
device_id: string | null;
|
||||||
items: { name: string; qty?: number; specs?: string[] }[];
|
items: { name: string; qty?: number; specs?: string[] }[];
|
||||||
platforms: Record<string, unknown>[];
|
|
||||||
comparison_results: Record<string, unknown>[];
|
comparison_results: Record<string, unknown>[];
|
||||||
skipped_dish_names: string[];
|
skipped_dish_names: string[];
|
||||||
device_manufacturer: string | null;
|
device_manufacturer: string | null;
|
||||||
@@ -707,8 +712,6 @@ export interface DashboardOverview {
|
|||||||
// 点位=一张券;成功口径 success+already_claimed;点位成功率分母=发起数×应领点位数(未跑到视为失败)。
|
// 点位=一张券;成功口径 success+already_claimed;点位成功率分母=发起数×应领点位数(未跑到视为失败)。
|
||||||
coupon?: {
|
coupon?: {
|
||||||
started: number;
|
started: number;
|
||||||
abandoned: number;
|
|
||||||
success_denominator: number;
|
|
||||||
all_success: number; // 全部点位领成功的完成场次数
|
all_success: number; // 全部点位领成功的完成场次数
|
||||||
success_rate: number | null;
|
success_rate: number | null;
|
||||||
point_success: number;
|
point_success: number;
|
||||||
@@ -898,80 +901,3 @@ export interface HealthTrendPoint extends HealthMetrics {
|
|||||||
export interface HealthBreakdownRow extends HealthMetrics {
|
export interface HealthBreakdownRow extends HealthMetrics {
|
||||||
key: string; // 维度值(event 名 / app_ver / oem);缺失为 "(unknown)"
|
key: string; // 维度值(event 名 / app_ver / oem);缺失为 "(unknown)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 统一限制策略 / 白名单 =====
|
|
||||||
export type LimitSubjectType = 'phone' | 'device';
|
|
||||||
export type LimitPolicyMode =
|
|
||||||
| 'inherit'
|
|
||||||
| 'override'
|
|
||||||
| 'unlimited'
|
|
||||||
| 'suppress_alert';
|
|
||||||
|
|
||||||
export interface LimitRule {
|
|
||||||
code: string;
|
|
||||||
label: string;
|
|
||||||
group: string;
|
|
||||||
global_limit: number;
|
|
||||||
default_limit: number;
|
|
||||||
window_label: string;
|
|
||||||
subject_types: LimitSubjectType[];
|
|
||||||
allowed_modes: LimitPolicyMode[];
|
|
||||||
min_value: number;
|
|
||||||
max_value: number;
|
|
||||||
supports_reset: boolean;
|
|
||||||
alert_only: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LimitDeviceCandidate {
|
|
||||||
device_id: string;
|
|
||||||
source: string;
|
|
||||||
source_label: string;
|
|
||||||
user_id: number | null;
|
|
||||||
username: string | null;
|
|
||||||
phone: string | null;
|
|
||||||
nickname: string | null;
|
|
||||||
device_model: string | null;
|
|
||||||
last_active_at: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LimitOverride {
|
|
||||||
id: number;
|
|
||||||
subject_type: LimitSubjectType;
|
|
||||||
subject_value: string;
|
|
||||||
rule_code: string;
|
|
||||||
rule_label: string;
|
|
||||||
rule_group: string;
|
|
||||||
mode: LimitPolicyMode;
|
|
||||||
limit_value: number | null;
|
|
||||||
global_limit: number;
|
|
||||||
effective_limit: number | null;
|
|
||||||
enabled: boolean;
|
|
||||||
starts_at: string | null;
|
|
||||||
expires_at: string | null;
|
|
||||||
reset_at: string | null;
|
|
||||||
reason: string | null;
|
|
||||||
status: 'active' | 'scheduled' | 'expired' | 'disabled';
|
|
||||||
created_by_admin_id: number | null;
|
|
||||||
created_at: string;
|
|
||||||
updated_at: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LimitOverrideList {
|
|
||||||
items: LimitOverride[];
|
|
||||||
total: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LimitSubject {
|
|
||||||
subject_type: LimitSubjectType;
|
|
||||||
subject_value: string;
|
|
||||||
group_counts: Record<string, number>;
|
|
||||||
total_rules: number;
|
|
||||||
items: LimitOverride[];
|
|
||||||
created_at: string;
|
|
||||||
updated_at: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LimitSubjectList {
|
|
||||||
items: LimitSubject[];
|
|
||||||
total: number;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ export function usePagedList<T>(
|
|||||||
url: string,
|
url: string,
|
||||||
filters: Record<string, unknown>,
|
filters: Record<string, unknown>,
|
||||||
initialPageSize = 20,
|
initialPageSize = 20,
|
||||||
offsetParam: 'cursor' | 'offset' = 'cursor',
|
|
||||||
) {
|
) {
|
||||||
const [items, setItems] = useState<T[]>([]);
|
const [items, setItems] = useState<T[]>([]);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
@@ -32,11 +31,7 @@ export function usePagedList<T>(
|
|||||||
requestSeq.current = seq;
|
requestSeq.current = seq;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = { ...JSON.parse(filtersKey), limit: ps, cursor: (p - 1) * ps };
|
||||||
...JSON.parse(filtersKey),
|
|
||||||
limit: ps,
|
|
||||||
[offsetParam]: (p - 1) * ps,
|
|
||||||
};
|
|
||||||
const { data } = await api.get<CursorPage<T>>(url, { params });
|
const { data } = await api.get<CursorPage<T>>(url, { params });
|
||||||
if (requestSeq.current !== seq) return; // 丢弃过期响应(快速切页/筛选)
|
if (requestSeq.current !== seq) return; // 丢弃过期响应(快速切页/筛选)
|
||||||
setItems(data.items);
|
setItems(data.items);
|
||||||
@@ -45,7 +40,7 @@ export function usePagedList<T>(
|
|||||||
if (requestSeq.current === seq) setLoading(false);
|
if (requestSeq.current === seq) setLoading(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[url, filtersKey, offsetParam],
|
[url, filtersKey],
|
||||||
);
|
);
|
||||||
|
|
||||||
// 筛选变化:回第 1 页重载
|
// 筛选变化:回第 1 页重载
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# 一键启动傻瓜比价本地联调:用户侧 API(8770) + 运营后台 API(8771) + 运营后台前端(3001)。
|
# 一键启动傻瓜比价本地联调:用户侧 API(8772) + 运营后台 API(8773) + 运营后台前端(3002)。
|
||||||
# 跨平台:Windows(Git Bash)与 macOS 通用。停止用 ./stop.sh。
|
# 跨平台:Windows(Git Bash)与 macOS 通用。停止用 ./stop.sh。
|
||||||
#
|
#
|
||||||
# 路径相对本脚本推导(本脚本在 shaguabijia-admin-web 内,server 是它的同级目录),
|
# 路径相对本脚本推导(本脚本在 shaguabijia-admin-web 内,server 是它的同级目录),
|
||||||
@@ -93,19 +93,19 @@ start_uvicorn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 用户侧绑 0.0.0.0,真机/模拟器可经局域网 IP 访问;后台只本机用,绑 127.0.0.1
|
# 用户侧绑 0.0.0.0,真机/模拟器可经局域网 IP 访问;后台只本机用,绑 127.0.0.1
|
||||||
start_uvicorn "user-api" "app.main:app" 8770 "0.0.0.0"
|
start_uvicorn "user-api" "app.main:app" 8772 "0.0.0.0"
|
||||||
start_uvicorn "admin-api" "app.admin.main:admin_app" 8771 "127.0.0.1"
|
start_uvicorn "admin-api" "app.admin.main:admin_app" 8773 "127.0.0.1"
|
||||||
|
|
||||||
if port_in_use 3001; then
|
if port_in_use 3002; then
|
||||||
echo "↺ admin-web 已在 :3001(跳过)"
|
echo "↺ admin-web 已在 :3002(跳过)"
|
||||||
else
|
else
|
||||||
cd "$WEB_DIR" || exit 1
|
cd "$WEB_DIR" || exit 1
|
||||||
nohup npm run dev > "$LOG_DIR/admin-web.log" 2>&1 &
|
nohup npm run dev > "$LOG_DIR/admin-web.log" 2>&1 &
|
||||||
echo "$!" > "$LOG_DIR/admin-web.pid"
|
echo "$!" > "$LOG_DIR/admin-web.pid"
|
||||||
echo "✅ admin-web 起在 :3001 (日志 $LOG_DIR/admin-web.log)"
|
echo "✅ admin-web 起在 :3002 (日志 $LOG_DIR/admin-web.log)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "⏳ 前端首次编译要几秒,然后开 👉 http://localhost:3001 (admin / admin12345)"
|
echo "⏳ 前端首次编译要几秒,然后开 👉 http://localhost:3002 (admin / admin12345)"
|
||||||
echo " 用户侧 API: http://127.0.0.1:8770 | 后台 API: http://127.0.0.1:8771/admin/docs"
|
echo " 用户侧 API: http://127.0.0.1:8772 | 后台 API: http://127.0.0.1:8773/admin/docs"
|
||||||
echo " 看日志: tail -f $LOG_DIR/admin-web.log | 停止: bash \"$SCRIPT_DIR/stop.sh\""
|
echo " 看日志: tail -f $LOG_DIR/admin-web.log | 停止: bash \"$SCRIPT_DIR/stop.sh\""
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# 停止 start.sh 起的三个服务:用户侧 API(8770) + 后台 API(8771) + 前端(3001)。
|
# 停止 start.sh 起的三个服务:用户侧 API(8772) + 后台 API(8773) + 前端(3002)。
|
||||||
# 双保险:先按 start.sh 落的 PID 文件杀,再按端口兜底(Windows 走 PowerShell,mac 走 lsof)。
|
# 双保险:先按 start.sh 落的 PID 文件杀,再按端口兜底(Windows 走 PowerShell,mac 走 lsof)。
|
||||||
# (PG 若由 brew 自启,本脚本不停它。)
|
# (PG 若由 brew 自启,本脚本不停它。)
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
@@ -32,8 +32,8 @@ kill_port() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
for port in 8770 8771 3001; do
|
for port in 8772 8773 3002; do
|
||||||
kill_port "$port"
|
kill_port "$port"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "✅ 已停止(用户侧 8770 / 后台 8771 / 前端 3001)。"
|
echo "✅ 已停止(用户侧 8772 / 后台 8773 / 前端 3002)。"
|
||||||
|
|||||||
Reference in New Issue
Block a user