Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d28358f07 |
File diff suppressed because it is too large
Load Diff
@@ -1,176 +0,0 @@
|
|||||||
# admin 比价记录「技术成功/失败」口径与缺失提示设计
|
|
||||||
|
|
||||||
- **日期**:2026-08-04
|
|
||||||
- **范围**:后端 `shaguabijia-app-server`(admin 层,**方案 A**:无 schema 变更、无迁移、不碰 #209 落库与 C 端)+ 前端 `shaguabijia-admin-web`
|
|
||||||
- **涉及文件**:
|
|
||||||
- 后端:`app/admin/repositories/comparison_outcome.py`(**新建**:共享常量 + Python 派生 + SQL 判定)、`app/admin/repositories/queries.py`(列表派生 + 概览口径)、`app/admin/schemas/comparison.py`(新增两字段)、`app/admin/repositories/stats.py`(大盘成功率分子口径)
|
|
||||||
- 前端:`src/app/(main)/comparison-records/page.tsx`、`src/lib/types.ts`
|
|
||||||
- 文档:`shaguabijia-app-server/docs/guides/比价结果卡片-状态口径与交互参考.md`(补 admin 口径说明)
|
|
||||||
|
|
||||||
## 目标
|
|
||||||
|
|
||||||
比价记录页(管理员排查工具)把「流程正常跑完、只是外部原因导致结果缺失」的记录——未找到店 / 未找到菜 / 门店打烊 / 单点不配送 / 平台·场景不支持 / 未满起送——从「失败」改判为 **🟢 成功 ⚠**(hover 看具体缺失原因)。让「失败」红标签**只剩真正的技术故障**,管理员一眼定位系统问题。改动范围:**admin 后台内部统一**(比价记录页状态列 + 概览成功率 + 数据大盘),不动 C 端。
|
|
||||||
|
|
||||||
## 背景与现状冲突
|
|
||||||
|
|
||||||
- **#209** 把 `store_closed / store_not_found / items_not_found / no_delivery / unsupported` 归一化成记录级 `failed` 落库,`below_minimum` 归 `success`;成功率按此算。
|
|
||||||
- 前端 `STATUS_LABEL` 把这些细分值 + `failed` 全显示「失败」([page.tsx:35](../../src/app/(main)/comparison-records/page.tsx))。
|
|
||||||
- 问题:这些是「跑完流程、外部结果缺失」,不是系统故障。全归「失败」粒度太粗,管理员无法区分「系统的锅」vs「目标平台本来就没有这家店 / 这些菜」。
|
|
||||||
- **数据来源已坐实**:原始业务结局保存在 `raw_payload["record_status"]`(优先)或 `raw_payload["status"]`(兜底),**每条记录都有**(harvest 与 POST 两条写路径都落,见 `repositories/comparison.py:810` 注释)。admin 列表用裸 `select(ComparisonRecord)`、**本就全量加载 `raw_payload`**(C 端 `list_records` 才 `defer`),故列表派生**零额外查询**。概览/大盘用 `raw_payload["record_status"].as_string()` 在 SQL 里分类(跨方言写法,#209 迁移已验证可用)。
|
|
||||||
|
|
||||||
## admin 口径(核心)
|
|
||||||
|
|
||||||
**原始结局** `original = raw_payload["record_status"] or raw_payload["status"]`。
|
|
||||||
|
|
||||||
| original | admin_status | outcome_hint(hover) |
|
|
||||||
|---|---|---|
|
|
||||||
| success | success | (无) |
|
|
||||||
| below_minimum | success | 未满起送 |
|
|
||||||
| store_closed | success | 门店打烊 |
|
|
||||||
| store_not_found | success | 未找到店 |
|
|
||||||
| items_not_found | success | 未找到菜 |
|
|
||||||
| no_delivery | success | 单点不配送 |
|
|
||||||
| unsupported | success | 平台·场景不支持 |
|
|
||||||
| failed / 其他未知 | failed | (无,这才是要排查的技术故障) |
|
|
||||||
| (cancelled 记录,status 列) | cancelled | (无) |
|
|
||||||
| (running 记录,status 列) | running | (无) |
|
|
||||||
|
|
||||||
**派生规则**:
|
|
||||||
- 记录 `status == "cancelled"` → `admin_status=cancelled`;`status == "running"` → `admin_status=running`(生命周期状态直接取 `status`,不看 original)。
|
|
||||||
- 否则看 original:∈ **admin 成功集** `S` → `admin_status=success`,`outcome_hint=_OUTCOME_HINTS.get(original)`(`success` 本身 → `None`)。
|
|
||||||
- original 为 `failed` 或未知非 `S` → `admin_status=failed`,`outcome_hint=None`。
|
|
||||||
- **兜底**:`raw_payload` 缺 original(极老记录)→ 用 `status` 列(`success→success` / `failed→failed`),`outcome_hint=None`。
|
|
||||||
|
|
||||||
其中 `S = {success, below_minimum, store_closed, store_not_found, items_not_found, no_delivery, unsupported}`。
|
|
||||||
|
|
||||||
## 数据契约(新增两字段)
|
|
||||||
|
|
||||||
`AdminComparisonListItem`(`AdminComparisonDetail` 继承)新增:
|
|
||||||
|
|
||||||
```python
|
|
||||||
admin_status: str # success / failed / cancelled / running(admin 口径)
|
|
||||||
outcome_hint: str | None = None # 缺失提示文案;None = 无缺失
|
|
||||||
```
|
|
||||||
|
|
||||||
原 `status` 字段**保留原样下发**(排查时可看后端落库原值)。前端只认 `admin_status` + `outcome_hint`,不自己算口径。
|
|
||||||
|
|
||||||
## 后端实现(方案 A)
|
|
||||||
|
|
||||||
### 1. 新模块 `app/admin/repositories/comparison_outcome.py`(供 `queries.py` 与 `stats.py` 共用,避免循环 import)
|
|
||||||
|
|
||||||
```python
|
|
||||||
from sqlalchemy import func
|
|
||||||
from app.models.comparison import ComparisonRecord
|
|
||||||
|
|
||||||
ADMIN_SUCCESS_OUTCOMES = frozenset({
|
|
||||||
"success", "below_minimum", "store_closed",
|
|
||||||
"store_not_found", "items_not_found", "no_delivery", "unsupported",
|
|
||||||
})
|
|
||||||
OUTCOME_HINTS = {
|
|
||||||
"below_minimum": "未满起送", "store_closed": "门店打烊",
|
|
||||||
"store_not_found": "未找到店", "items_not_found": "未找到菜",
|
|
||||||
"no_delivery": "单点不配送", "unsupported": "平台·场景不支持",
|
|
||||||
}
|
|
||||||
|
|
||||||
def derive_admin_outcome(raw_payload: dict | None, status: str) -> tuple[str, str | None]:
|
|
||||||
"""Python 层派生(列表用;raw_payload 已随 ORM 加载,零额外查询)。"""
|
|
||||||
if status in ("cancelled", "running"):
|
|
||||||
return status, None
|
|
||||||
raw = raw_payload or {}
|
|
||||||
original = raw.get("record_status") or raw.get("status")
|
|
||||||
if original is None: # 极老记录兜底
|
|
||||||
return ("success" if status == "success" else "failed"), None
|
|
||||||
if original in ADMIN_SUCCESS_OUTCOMES:
|
|
||||||
return "success", OUTCOME_HINTS.get(original)
|
|
||||||
return "failed", None
|
|
||||||
|
|
||||||
def _original_expr():
|
|
||||||
return func.coalesce(
|
|
||||||
ComparisonRecord.raw_payload["record_status"].as_string(),
|
|
||||||
ComparisonRecord.raw_payload["status"].as_string(),
|
|
||||||
)
|
|
||||||
|
|
||||||
def admin_success_sql():
|
|
||||||
"""SQL 层 admin 成功判定(概览/大盘的 case/where 共用)。"""
|
|
||||||
original = _original_expr()
|
|
||||||
return original.in_(tuple(ADMIN_SUCCESS_OUTCOMES)) | (
|
|
||||||
original.is_(None) & (ComparisonRecord.status == "success")
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 列表 `list_comparison_records`
|
|
||||||
|
|
||||||
在现有瞬态挂载段(`_attach_*` / `ad_revenue_yuan` 之后)对每条 `record`:
|
|
||||||
|
|
||||||
```python
|
|
||||||
record.admin_status, record.outcome_hint = _derive_admin_outcome(record.raw_payload, record.status)
|
|
||||||
```
|
|
||||||
|
|
||||||
`raw_payload` 列表已加载,无 N+1。schema 加上述两字段(`from_attributes` 读出)。
|
|
||||||
|
|
||||||
### 3. 概览 `comparison_records_summary`
|
|
||||||
|
|
||||||
把 `success` / `completed` 的 `case` 改用 original 口径:
|
|
||||||
|
|
||||||
```python
|
|
||||||
_original_expr = func.coalesce(
|
|
||||||
ComparisonRecord.raw_payload["record_status"].as_string(),
|
|
||||||
ComparisonRecord.raw_payload["status"].as_string(),
|
|
||||||
)
|
|
||||||
# admin 成功 = original ∈ S OR (original IS NULL AND status == 'success')
|
|
||||||
# completed = admin 成功 + 纯 failed(展示字段;admin 口径)
|
|
||||||
# success_rate = admin 成功 / (started - cancelled) # 分母不变,见 queries.py:532
|
|
||||||
```
|
|
||||||
|
|
||||||
**耗时分位**(avg / p50 / p95,`_comparison_duration_aggregate*`):统计集从「`status == "success"`」改为「admin 成功集」——用户已确认**统一口径纳入**这 6 类。改动点:`_comparison_status_condition` 系的耗时过滤条件改用 `_original_expr ∈ S`(或复用一个 `_admin_success_condition()` 表达式,列表/概览/大盘共用)。
|
|
||||||
|
|
||||||
### 4. 大盘 `stats.py` `dashboard_overview`
|
|
||||||
|
|
||||||
`period_comparison_stats` 的 success 分子([stats.py:278-281](../../../shaguabijia-app-server/app/admin/repositories/stats.py) 的 `case(status=='success')`)现在**不含 below_minimum**(#209 只改了概览、没同步大盘)。改用 `admin_success_sql()`(`original ∈ S`)口径,与概览一致。
|
|
||||||
|
|
||||||
**范围界定**:两页成功率**分母都是 `total - cancelled`**(概览 [queries.py:532](../../src/../../../shaguabijia-app-server/app/admin/repositories/queries.py)、大盘 [stats.py:290](../../../shaguabijia-app-server/app/admin/repositories/stats.py)),口径一致、本次不动。真正的既有差异在**分子**:概览 success 含 `below_minimum`、大盘不含。本次把两处分子都统一为 `original ∈ S`,改完两页口径**完全一致**。副作用:大盘成功率因补上 `below_minimum` + 5 类而上升,概览因补上 5 类上升——均属口径调整、非数据异常。
|
|
||||||
|
|
||||||
## 前端实现
|
|
||||||
|
|
||||||
### 1. 状态列([page.tsx:416](../../src/app/(main)/comparison-records/page.tsx))
|
|
||||||
|
|
||||||
`render` 改用 `admin_status` 出标签(`STATUS_LABEL/COLOR`:success→绿「成功」/ failed→红「失败」/ cancelled→「中途退出」/ running→「进行中」);`outcome_hint` 非空 → 标签后跟 `<Tooltip title={outcome_hint}>` 包一个 ⚠(antd `WarningOutlined`)。
|
|
||||||
|
|
||||||
### 2. 详情页状态([page.tsx:627](../../src/app/(main)/comparison-records/page.tsx))
|
|
||||||
|
|
||||||
同步用 `admin_status` + `outcome_hint`。
|
|
||||||
|
|
||||||
### 3. `STATUS_LABEL` / `STATUS_COLOR`([page.tsx:35](../../src/app/(main)/comparison-records/page.tsx))
|
|
||||||
|
|
||||||
精简:移除把 `store_closed/store_not_found/items_not_found/no_delivery/unsupported` 直接映射「失败」的行(统一走 `admin_status`);保留 `success/failed/cancelled/running`。`below_minimum` 同理不再单列。
|
|
||||||
|
|
||||||
### 4. `types.ts`
|
|
||||||
|
|
||||||
`ComparisonRecordListItem` 加 `admin_status: string`、`outcome_hint: string | null`。
|
|
||||||
|
|
||||||
### 5. 概览成功率
|
|
||||||
|
|
||||||
前端只展示后端返回的数字,口径变化对前端透明;检查概览区有无「成功率」口径说明文案需同步。
|
|
||||||
|
|
||||||
## 不改 / 一致性
|
|
||||||
|
|
||||||
- `status` 列语义、#209 落库、完成奖励幂等、C 端「我的比价」/ 首页轮播 / 省钱战绩口径:**全不动**。
|
|
||||||
- admin 口径(跑完即成功)**刻意宽于** C 端业务口径;因大盘也一并改,**admin 后台内部自洽**。
|
|
||||||
- 在状态口径文档补一段「admin 记录页口径」:说明 admin 成功率是「技术完成率」,与 C 端业务口径不同,避免以后有人拿两者对不上而误判为 bug。
|
|
||||||
|
|
||||||
## 边界
|
|
||||||
|
|
||||||
- `raw_payload` 缺 `record_status/status`(极老记录):`admin_status` 取 `status` 列,`outcome_hint=None`,不加 ⚠。
|
|
||||||
- 多平台 `platform_results`:以记录级 `record_status` 为准(pricebot 已归纳),不逐平台判。
|
|
||||||
- 迁移未覆盖、`status` 列仍是细分值的老记录:`original` 优先,仍正确归类(细分值本身 ∈ S)。
|
|
||||||
|
|
||||||
## 测试
|
|
||||||
|
|
||||||
- 后端新增 `_derive_admin_outcome` 单测:各 original + cancelled/running + raw_payload 缺失兜底,验 `(admin_status, outcome_hint)`。
|
|
||||||
- `tests/test_comparison_admin_summary.py`:造含 6 类 + success + failed + cancelled 的记录,验 `success` / `completed` / `success_rate` / 耗时分位按新口径。
|
|
||||||
- `tests/test_admin_read.py`:列表返回 `admin_status` / `outcome_hint`(成功·有缺失、纯失败、纯成功各一条)。
|
|
||||||
|
|
||||||
## 影响面 / 风险
|
|
||||||
|
|
||||||
- 概览/大盘 SQL 读 JSONB(`raw_payload['record_status'].as_string()`):PG 上是 JSONB,跨方言 `.as_string()` #209 迁移已用;SQLite 测试走 JSON1。admin 低频、P0 量级,性能可忽略。
|
|
||||||
- **admin 成功率数字会上升**(这 6 类从失败转成功):需知会运营这是**口径调整、非数据异常**。C 端 / 大盘之外的成功率不受影响。
|
|
||||||
@@ -32,24 +32,9 @@ interface Props {
|
|||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
userId: number | null;
|
userId: number | null;
|
||||||
phone: string | null; // 报表行已有的手机号:概览拉取失败时兜底展示
|
phone: string | null; // 报表行已有的手机号:概览拉取失败时兜底展示
|
||||||
dateFrom: string | null;
|
|
||||||
dateTo: string | null;
|
|
||||||
appEnv?: 'prod' | 'test';
|
|
||||||
revenueScope: 'business' | 'all';
|
|
||||||
feedScene?: 'comparison' | 'coupon' | 'welfare';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function UserAdRevenueDrawer({
|
export default function UserAdRevenueDrawer({ open, onClose, userId, phone }: Props) {
|
||||||
open,
|
|
||||||
onClose,
|
|
||||||
userId,
|
|
||||||
phone,
|
|
||||||
dateFrom,
|
|
||||||
dateTo,
|
|
||||||
appEnv,
|
|
||||||
revenueScope,
|
|
||||||
feedScene,
|
|
||||||
}: Props) {
|
|
||||||
// UserRewardPanel 的 user 快照:它只读 phone/nickname/wechat_nickname/created_at,其余按 snapshot 形状补齐。
|
// UserRewardPanel 的 user 快照:它只读 phone/nickname/wechat_nickname/created_at,其余按 snapshot 形状补齐。
|
||||||
const [user, setUser] = useState<WithdrawUserSnapshot | null>(null);
|
const [user, setUser] = useState<WithdrawUserSnapshot | null>(null);
|
||||||
|
|
||||||
@@ -97,19 +82,7 @@ export default function UserAdRevenueDrawer({
|
|||||||
>
|
>
|
||||||
{/* userId 就绪即渲染;UserRewardPanel 内部按 userId 自行拉统计与金币记录,user 基本信息随后补上。
|
{/* userId 就绪即渲染;UserRewardPanel 内部按 userId 自行拉统计与金币记录,user 基本信息随后补上。
|
||||||
statsVariant="ad":统计区只显示 6 项看广告统计(累计提现/现金余额/激励视频观看数+eCPM/draw观看数+eCPM) */}
|
statsVariant="ad":统计区只显示 6 项看广告统计(累计提现/现金余额/激励视频观看数+eCPM/draw观看数+eCPM) */}
|
||||||
{userId != null && (
|
{userId != null && <UserRewardPanel userId={userId} user={user} statsVariant="ad" />}
|
||||||
<UserRewardPanel
|
|
||||||
key={`${userId}-${dateFrom}-${dateTo}-${appEnv}-${revenueScope}-${feedScene}`}
|
|
||||||
userId={userId}
|
|
||||||
user={user}
|
|
||||||
statsVariant="ad"
|
|
||||||
initialDateFrom={dateFrom ?? undefined}
|
|
||||||
initialDateTo={dateTo ?? undefined}
|
|
||||||
appEnv={appEnv}
|
|
||||||
revenueScope={revenueScope}
|
|
||||||
feedScene={feedScene}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Drawer>
|
</Drawer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import {
|
|||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import dayjs, { type Dayjs } from 'dayjs';
|
import dayjs, { type Dayjs } from 'dayjs';
|
||||||
import { api, errMsg } from '@/lib/api';
|
import { api, errMsg } from '@/lib/api';
|
||||||
import { formatUtcTime, nearestRankPercentile } from '@/lib/format';
|
import { formatUtcTime, percentile } from '@/lib/format';
|
||||||
import type {
|
import type {
|
||||||
AdRevenueDaily,
|
AdRevenueDaily,
|
||||||
AdRevenueHourly,
|
AdRevenueHourly,
|
||||||
@@ -470,27 +470,7 @@ export default function AdRevenueReportPage() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [formulaOpen, setFormulaOpen] = useState(false);
|
const [formulaOpen, setFormulaOpen] = useState(false);
|
||||||
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
|
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
|
||||||
const [userDrawer, setUserDrawer] = useState<{
|
const [userDrawer, setUserDrawer] = useState<{ userId: number; phone: string | null } | null>(null);
|
||||||
userId: number;
|
|
||||||
phone: string | null;
|
|
||||||
dateFrom: string;
|
|
||||||
dateTo: string;
|
|
||||||
appEnv?: 'prod' | 'test';
|
|
||||||
revenueScope: 'business' | 'all';
|
|
||||||
feedScene?: 'comparison' | 'coupon' | 'welfare';
|
|
||||||
} | null>(null);
|
|
||||||
const [queriedDetailFilters, setQueriedDetailFilters] = useState<{
|
|
||||||
dateFrom: string;
|
|
||||||
dateTo: string;
|
|
||||||
appEnv?: 'prod' | 'test';
|
|
||||||
revenueScope: 'business' | 'all';
|
|
||||||
feedScene?: 'comparison' | 'coupon' | 'welfare';
|
|
||||||
}>({
|
|
||||||
dateFrom: range[0].format('YYYY-MM-DD'),
|
|
||||||
dateTo: range[1].format('YYYY-MM-DD'),
|
|
||||||
appEnv: 'prod',
|
|
||||||
revenueScope: 'business',
|
|
||||||
});
|
|
||||||
|
|
||||||
// 当前选择是否跨多天:跨多天时「按小时」无意义,粒度强制按天
|
// 当前选择是否跨多天:跨多天时「按小时」无意义,粒度强制按天
|
||||||
const rangeMultiDay = range[0].format('YYYY-MM-DD') !== range[1].format('YYYY-MM-DD');
|
const rangeMultiDay = range[0].format('YYYY-MM-DD') !== range[1].format('YYYY-MM-DD');
|
||||||
@@ -523,13 +503,6 @@ export default function AdRevenueReportPage() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
setData(res.data);
|
setData(res.data);
|
||||||
setQueriedDetailFilters({
|
|
||||||
dateFrom: from,
|
|
||||||
dateTo: to,
|
|
||||||
appEnv: appEnv === 'all' ? undefined : appEnv,
|
|
||||||
revenueScope,
|
|
||||||
feedScene: scene as 'comparison' | 'coupon' | 'welfare' | undefined,
|
|
||||||
});
|
|
||||||
setPage(targetPage);
|
setPage(targetPage);
|
||||||
setQueriedLimit(targetLimit);
|
setQueriedLimit(targetLimit);
|
||||||
setQueriedGranularity(gran);
|
setQueriedGranularity(gran);
|
||||||
@@ -578,7 +551,7 @@ export default function AdRevenueReportPage() {
|
|||||||
width: 150,
|
width: 150,
|
||||||
render: (phone: string | null, r: AdRevenueRow) => (
|
render: (phone: string | null, r: AdRevenueRow) => (
|
||||||
// 点手机号/用户 → 打开该用户「广告收益详情」半屏抽屉(统计卡 + 金币记录)
|
// 点手机号/用户 → 打开该用户「广告收益详情」半屏抽屉(统计卡 + 金币记录)
|
||||||
<a onClick={() => setUserDrawer({ userId: r.user_id, phone, ...queriedDetailFilters })}>
|
<a onClick={() => setUserDrawer({ userId: r.user_id, phone })}>
|
||||||
{phone ? (
|
{phone ? (
|
||||||
<span>
|
<span>
|
||||||
{phone}
|
{phone}
|
||||||
@@ -762,7 +735,7 @@ export default function AdRevenueReportPage() {
|
|||||||
: `${data.date_from} ~ ${data.date_to}`;
|
: `${data.date_from} ~ ${data.date_to}`;
|
||||||
|
|
||||||
// 第二行大盘「分广告类型」:看视频包含福利视频与提现视频;
|
// 第二行大盘「分广告类型」:看视频包含福利视频与提现视频;
|
||||||
// eCPM 优先使用后端按真实展示加权的经营分类口径;兼容旧后端时才用合并收益÷展示数回退。
|
// eCPM 使用合并后的总收益 ÷ 总展示数 × 1000,避免只读取 reward_video 而漏算提现视频。
|
||||||
const drawStat = data?.type_stats?.draw;
|
const drawStat = data?.type_stats?.draw;
|
||||||
const rewardVideoStat = data?.type_stats?.reward_video;
|
const rewardVideoStat = data?.type_stats?.reward_video;
|
||||||
const withdrawalVideoStat = data?.type_stats?.withdrawal_video;
|
const withdrawalVideoStat = data?.type_stats?.withdrawal_video;
|
||||||
@@ -772,10 +745,8 @@ export default function AdRevenueReportPage() {
|
|||||||
revenue_yuan:
|
revenue_yuan:
|
||||||
(rewardVideoStat?.revenue_yuan ?? 0) + (withdrawalVideoStat?.revenue_yuan ?? 0),
|
(rewardVideoStat?.revenue_yuan ?? 0) + (withdrawalVideoStat?.revenue_yuan ?? 0),
|
||||||
};
|
};
|
||||||
const drawEcpmStat = data?.category_stats?.draw ?? drawStat;
|
|
||||||
const videoEcpmStat = data?.category_stats?.video ?? videoStat;
|
|
||||||
const ecpmOf = (s?: AdRevenueTypeStat) =>
|
const ecpmOf = (s?: AdRevenueTypeStat) =>
|
||||||
s?.ecpm_yuan ?? (s && s.impressions > 0 ? (s.revenue_yuan / s.impressions) * 1000 : 0);
|
s && s.impressions > 0 ? (s.revenue_yuan / s.impressions) * 1000 : 0;
|
||||||
|
|
||||||
// 明细直接用后端返回的当前页 items(「场景」已由后端 feed_scene 全局过滤,前端不再二次筛)。
|
// 明细直接用后端返回的当前页 items(「场景」已由后端 feed_scene 全局过滤,前端不再二次筛)。
|
||||||
const items = data?.items ?? [];
|
const items = data?.items ?? [];
|
||||||
@@ -785,9 +756,9 @@ export default function AdRevenueReportPage() {
|
|||||||
.filter((item) => item.feed_scene === sceneName)
|
.filter((item) => item.feed_scene === sceneName)
|
||||||
.map((item) => item.sub_count ?? 1);
|
.map((item) => item.sub_count ?? 1);
|
||||||
return {
|
return {
|
||||||
p5: nearestRankPercentile(counts, 0.05),
|
p5: percentile(counts, 0.05, false),
|
||||||
p50: nearestRankPercentile(counts, 0.5),
|
p50: percentile(counts, 0.5, false),
|
||||||
p95: nearestRankPercentile(counts, 0.95),
|
p95: percentile(counts, 0.95, false),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
return { coupon: summarize('coupon'), comparison: summarize('comparison') };
|
return { coupon: summarize('coupon'), comparison: summarize('comparison') };
|
||||||
@@ -1089,7 +1060,7 @@ export default function AdRevenueReportPage() {
|
|||||||
<Statistic title="Draw 信息流收益(元)" value={drawStat?.revenue_yuan ?? 0} precision={4} />
|
<Statistic title="Draw 信息流收益(元)" value={drawStat?.revenue_yuan ?? 0} precision={4} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="Draw 信息流 eCPM(元/千次)" value={ecpmOf(drawEcpmStat)} precision={2} />
|
<Statistic title="Draw 信息流 eCPM(元/千次)" value={ecpmOf(drawStat)} precision={2} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="Draw 信息流条数" value={drawStat?.impressions ?? 0} />
|
<Statistic title="Draw 信息流条数" value={drawStat?.impressions ?? 0} />
|
||||||
@@ -1098,7 +1069,7 @@ export default function AdRevenueReportPage() {
|
|||||||
<Statistic title="看视频收益(元)" value={videoStat.revenue_yuan} precision={4} />
|
<Statistic title="看视频收益(元)" value={videoStat.revenue_yuan} precision={4} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="看视频 eCPM(元/千次)" value={ecpmOf(videoEcpmStat)} precision={2} />
|
<Statistic title="看视频 eCPM(元/千次)" value={ecpmOf(videoStat)} precision={2} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="看视频条数" value={videoStat.impressions} />
|
<Statistic title="看视频条数" value={videoStat.impressions} />
|
||||||
@@ -1110,12 +1081,12 @@ export default function AdRevenueReportPage() {
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</Divider>
|
</Divider>
|
||||||
<Row gutter={[16, 12]}>
|
<Row gutter={[16, 12]}>
|
||||||
<Col span={4}><Statistic title="单次领券广告数 P5" value={sessionAdCounts.coupon.p5 ?? '-'} precision={0} /></Col>
|
<Col span={4}><Statistic title="单次领券广告数 P5" value={sessionAdCounts.coupon.p5 ?? '-'} precision={1} /></Col>
|
||||||
<Col span={4}><Statistic title="单次领券广告数 P50" value={sessionAdCounts.coupon.p50 ?? '-'} precision={0} /></Col>
|
<Col span={4}><Statistic title="单次领券广告数 P50" value={sessionAdCounts.coupon.p50 ?? '-'} precision={1} /></Col>
|
||||||
<Col span={4}><Statistic title="单次领券广告数 P95" value={sessionAdCounts.coupon.p95 ?? '-'} precision={0} /></Col>
|
<Col span={4}><Statistic title="单次领券广告数 P95" value={sessionAdCounts.coupon.p95 ?? '-'} precision={1} /></Col>
|
||||||
<Col span={4}><Statistic title="单次比价广告数 P5" value={sessionAdCounts.comparison.p5 ?? '-'} precision={0} /></Col>
|
<Col span={4}><Statistic title="单次比价广告数 P5" value={sessionAdCounts.comparison.p5 ?? '-'} precision={1} /></Col>
|
||||||
<Col span={4}><Statistic title="单次比价广告数 P50" value={sessionAdCounts.comparison.p50 ?? '-'} precision={0} /></Col>
|
<Col span={4}><Statistic title="单次比价广告数 P50" value={sessionAdCounts.comparison.p50 ?? '-'} precision={1} /></Col>
|
||||||
<Col span={4}><Statistic title="单次比价广告数 P95" value={sessionAdCounts.comparison.p95 ?? '-'} precision={0} /></Col>
|
<Col span={4}><Statistic title="单次比价广告数 P95" value={sessionAdCounts.comparison.p95 ?? '-'} precision={1} /></Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
@@ -1311,11 +1282,6 @@ export default function AdRevenueReportPage() {
|
|||||||
open={!!userDrawer}
|
open={!!userDrawer}
|
||||||
userId={userDrawer?.userId ?? null}
|
userId={userDrawer?.userId ?? null}
|
||||||
phone={userDrawer?.phone ?? null}
|
phone={userDrawer?.phone ?? null}
|
||||||
dateFrom={userDrawer?.dateFrom ?? null}
|
|
||||||
dateTo={userDrawer?.dateTo ?? null}
|
|
||||||
appEnv={userDrawer?.appEnv}
|
|
||||||
revenueScope={userDrawer?.revenueScope ?? 'all'}
|
|
||||||
feedScene={userDrawer?.feedScene}
|
|
||||||
onClose={() => setUserDrawer(null)}
|
onClose={() => setUserDrawer(null)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import { useEffect, useState } from 'react';
|
|||||||
import type { CSSProperties, ReactNode } from 'react';
|
import type { CSSProperties, ReactNode } from 'react';
|
||||||
import {
|
import {
|
||||||
App, Button, Card, Col, Collapse, DatePicker, Descriptions, Divider, Drawer, Input, InputNumber,
|
App, Button, Card, Col, Collapse, DatePicker, Descriptions, Divider, Drawer, Input, InputNumber,
|
||||||
Row, Select, Space, Spin, Statistic, Table, Tag, Tooltip, Typography,
|
Row, Select, Space, Spin, Statistic, Table, Tag, Typography,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import dayjs, { type Dayjs } from 'dayjs';
|
import dayjs, { type Dayjs } from 'dayjs';
|
||||||
import { api, errMsg } from '@/lib/api';
|
import { api, errMsg } from '@/lib/api';
|
||||||
@@ -20,142 +19,19 @@ import type {
|
|||||||
|
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
// admin_status 只有四个生命周期值;外部缺失由 outcome_hint(感叹号)承载。
|
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',
|
|
||||||
failed: 'red',
|
// 「卡在哪一步」: platform_results[*].status 翻成人话(找店/加菜/起送/读价)
|
||||||
cancelled: 'default',
|
const STUCK_LABEL: Record<string, string> = {
|
||||||
running: 'blue',
|
|
||||||
};
|
|
||||||
const STATUS_LABEL: Record<string, string> = {
|
|
||||||
success: '成功',
|
success: '成功',
|
||||||
|
store_not_found: '没找到店',
|
||||||
|
items_not_found: '菜没匹配上',
|
||||||
|
below_minimum: '未达起送',
|
||||||
|
unsupported: '平台不支持',
|
||||||
failed: '失败',
|
failed: '失败',
|
||||||
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));
|
||||||
|
|
||||||
@@ -170,41 +46,6 @@ const fmtTok = (inTok: number | null, outTok: number | null) =>
|
|||||||
inTok == null && outTok == null ? '-' : `${inTok ?? 0}/${outTok ?? 0}`;
|
inTok == null && outTok == null ? '-' : `${inTok ?? 0}/${outTok ?? 0}`;
|
||||||
const fmtRate = (value: number | null) => (value == null ? '-' : `${(value * 100).toFixed(1)}%`);
|
const fmtRate = (value: number | null) => (value == null ? '-' : `${(value * 100).toFixed(1)}%`);
|
||||||
|
|
||||||
function deviceName(record: ComparisonRecordListItem): string {
|
|
||||||
return record.device_model_name || record.device_model || '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
function romName(record: ComparisonRecordListItem): string {
|
|
||||||
return [
|
|
||||||
record.rom_vendor,
|
|
||||||
record.rom_name,
|
|
||||||
record.rom_version != null ? String(record.rom_version) : null,
|
|
||||||
]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(' ') || '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderDevice(record: ComparisonRecordListItem): ReactNode {
|
|
||||||
const readableName = deviceName(record);
|
|
||||||
const showRawModel =
|
|
||||||
record.device_model_name
|
|
||||||
&& record.device_model
|
|
||||||
&& record.device_model_name !== record.device_model;
|
|
||||||
return (
|
|
||||||
<Space direction="vertical" size={0}>
|
|
||||||
<span>{readableName}</span>
|
|
||||||
{showRawModel ? (
|
|
||||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
|
||||||
{record.device_model}
|
|
||||||
</Typography.Text>
|
|
||||||
) : null}
|
|
||||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
|
||||||
{romName(record)}
|
|
||||||
</Typography.Text>
|
|
||||||
</Space>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LLM 价格快照只展示 prices 里各模型的单价(元/每百万 token),忽略 mode/_source 等元字段。
|
// LLM 价格快照只展示 prices 里各模型的单价(元/每百万 token),忽略 mode/_source 等元字段。
|
||||||
function llmPriceRows(snapshot: Record<string, unknown> | null): string[] {
|
function llmPriceRows(snapshot: Record<string, unknown> | null): string[] {
|
||||||
const prices = snapshot?.prices;
|
const prices = snapshot?.prices;
|
||||||
@@ -397,21 +238,12 @@ export default function ComparisonRecordsPage() {
|
|||||||
width: 140,
|
width: 140,
|
||||||
render: (_, r) => (
|
render: (_, r) => (
|
||||||
<div style={{ color: '#1677ff' }}>
|
<div style={{ color: '#1677ff' }}>
|
||||||
<div>{r.phone || (r.user_id != null ? `#${r.user_id}` : '匿名')}</div>
|
<div>{r.phone || `#${r.user_id}`}</div>
|
||||||
{r.nickname && <div style={{ fontSize: 12 }}>{r.nickname}</div>}
|
{r.nickname && <div style={{ fontSize: 12 }}>{r.nickname}</div>}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '状态', dataIndex: 'admin_status', width: 108, render: (_: string, r) => (
|
{ title: '状态', dataIndex: 'status', width: 72, render: (s: string) => <Tag color={STATUS_COLOR[s]}>{STATUS_LABEL[s] || s}</Tag> },
|
||||||
<span>
|
|
||||||
<Tag color={STATUS_COLOR[r.admin_status]}>{STATUS_LABEL[r.admin_status] || r.admin_status}</Tag>
|
|
||||||
{r.outcome_hint && (
|
|
||||||
<Tooltip title={r.outcome_hint}>
|
|
||||||
<ExclamationCircleOutlined style={{ color: '#faad14', marginLeft: 2 }} />
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
) },
|
|
||||||
// 产品文档指定展示“原平台”;字段名仍沿用后端 source_platform_name。
|
// 产品文档指定展示“原平台”;字段名仍沿用后端 source_platform_name。
|
||||||
{ title: '原平台', dataIndex: 'source_platform_name', width: 90, render: (v) => v || '-' },
|
{ title: '原平台', dataIndex: 'source_platform_name', width: 90, render: (v) => v || '-' },
|
||||||
{
|
{
|
||||||
@@ -466,14 +298,6 @@ export default function ComparisonRecordsPage() {
|
|||||||
<b style={{ color: r.saved_amount_cents > 0 ? '#3f8600' : '#999' }}>{yuan(r.saved_amount_cents)}</b>
|
<b style={{ color: r.saved_amount_cents > 0 ? '#3f8600' : '#999' }}>{yuan(r.saved_amount_cents)}</b>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '是否下单',
|
|
||||||
dataIndex: 'ordered',
|
|
||||||
width: 84,
|
|
||||||
render: (ordered: boolean) => (
|
|
||||||
<Tag color={ordered ? 'green' : 'default'}>{ordered ? '已下单' : '未下单'}</Tag>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{ title: 'LLM', dataIndex: 'llm_call_count', width: 56, render: (v) => v ?? '-' },
|
{ title: 'LLM', dataIndex: 'llm_call_count', width: 56, render: (v) => v ?? '-' },
|
||||||
{
|
{
|
||||||
title: 'TOKEN',
|
title: 'TOKEN',
|
||||||
@@ -484,9 +308,9 @@ export default function ComparisonRecordsPage() {
|
|||||||
{
|
{
|
||||||
title: '机型/ROM',
|
title: '机型/ROM',
|
||||||
key: 'device',
|
key: 'device',
|
||||||
width: 180,
|
width: 150,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
render: (_, r) => renderDevice(r),
|
render: (_, r) => [r.device_model, r.rom_name].filter(Boolean).join(' / ') || '-',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'traceid',
|
title: 'traceid',
|
||||||
@@ -502,7 +326,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>
|
||||||
@@ -555,7 +380,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>
|
||||||
@@ -620,12 +444,9 @@ export default function ComparisonRecordsPage() {
|
|||||||
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
|
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
|
||||||
<Descriptions size="small" column={2} bordered>
|
<Descriptions size="small" column={2} bordered>
|
||||||
<Descriptions.Item label="用户">
|
<Descriptions.Item label="用户">
|
||||||
{detail.phone || (detail.user_id != null ? `#${detail.user_id}` : '匿名')}{detail.nickname ? `(${detail.nickname})` : ''}
|
{detail.phone || `#${detail.user_id}`}{detail.nickname ? `(${detail.nickname})` : ''}
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="状态">
|
|
||||||
<Tag color={STATUS_COLOR[detail.admin_status]}>{STATUS_LABEL[detail.admin_status] || detail.admin_status}</Tag>
|
|
||||||
{detail.outcome_hint && <Tooltip title={detail.outcome_hint}><ExclamationCircleOutlined style={{ color: '#faad14', marginLeft: 4 }} /></Tooltip>}
|
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="状态"><Tag color={STATUS_COLOR[detail.status]}>{STATUS_LABEL[detail.status] || detail.status}</Tag></Descriptions.Item>
|
||||||
<Descriptions.Item label="业务">{detail.business_type}</Descriptions.Item>
|
<Descriptions.Item label="业务">{detail.business_type}</Descriptions.Item>
|
||||||
<Descriptions.Item label="耗时">{fmtMs(detail.total_ms)}</Descriptions.Item>
|
<Descriptions.Item label="耗时">{fmtMs(detail.total_ms)}</Descriptions.Item>
|
||||||
<Descriptions.Item label="步数">{detail.step_count ?? '-'}</Descriptions.Item>
|
<Descriptions.Item label="步数">{detail.step_count ?? '-'}</Descriptions.Item>
|
||||||
@@ -678,15 +499,8 @@ export default function ComparisonRecordsPage() {
|
|||||||
|
|
||||||
<Card size="small" title="设备环境">
|
<Card size="small" title="设备环境">
|
||||||
<Descriptions size="small" column={2}>
|
<Descriptions size="small" column={2}>
|
||||||
<Descriptions.Item label="机型">
|
<Descriptions.Item label="机型">{detail.device_model || '-'}({detail.device_manufacturer || '-'})</Descriptions.Item>
|
||||||
{deviceName(detail)}
|
<Descriptions.Item label="ROM">{[detail.rom_vendor, detail.rom_name, detail.rom_version].filter(Boolean).join(' ') || '-'}</Descriptions.Item>
|
||||||
{detail.device_model_name && detail.device_model_name !== detail.device_model
|
|
||||||
? `(${[detail.device_manufacturer, detail.device_model].filter(Boolean).join(' · ')})`
|
|
||||||
: detail.device_manufacturer
|
|
||||||
? `(${detail.device_manufacturer})`
|
|
||||||
: ''}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="ROM">{romName(detail)}</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="Android">{detail.android_version || '-'}(SDK {detail.android_sdk ?? '-'})</Descriptions.Item>
|
<Descriptions.Item label="Android">{detail.android_version || '-'}(SDK {detail.android_sdk ?? '-'})</Descriptions.Item>
|
||||||
<Descriptions.Item label="App 版本">{detail.app_version || '-'}({detail.app_version_code ?? '-'})</Descriptions.Item>
|
<Descriptions.Item label="App 版本">{detail.app_version || '-'}({detail.app_version_code ?? '-'})</Descriptions.Item>
|
||||||
<Descriptions.Item label="源 App 版本" span={2}>{detail.source_app_version || '-'}</Descriptions.Item>
|
<Descriptions.Item label="源 App 版本" span={2}>{detail.source_app_version || '-'}</Descriptions.Item>
|
||||||
@@ -715,67 +529,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>
|
||||||
|
|||||||
@@ -1,18 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import {
|
import { Button, Card, Space, Spin, Switch, Tag, Typography, Upload, message } from 'antd';
|
||||||
Button,
|
|
||||||
Card,
|
|
||||||
InputNumber,
|
|
||||||
Space,
|
|
||||||
Spin,
|
|
||||||
Switch,
|
|
||||||
Tag,
|
|
||||||
Typography,
|
|
||||||
Upload,
|
|
||||||
message,
|
|
||||||
} from 'antd';
|
|
||||||
import { DeleteOutlined, UploadOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, UploadOutlined } from '@ant-design/icons';
|
||||||
import { api, errMsg } from '@/lib/api';
|
import { api, errMsg } from '@/lib/api';
|
||||||
import { canDo } from '@/lib/auth';
|
import { canDo } from '@/lib/auth';
|
||||||
@@ -20,64 +9,55 @@ import { mediaUrl } from '@/lib/media';
|
|||||||
import type { GuideVideoConfig as GuideCfg } from '@/lib/types';
|
import type { GuideVideoConfig as GuideCfg } from '@/lib/types';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
|
/** 后端 media.save_guide_video 只认 MP4 魔数;这里先在浏览器挡一道,省得白传 100MB。 */
|
||||||
const MAX_BYTES = 100 * 1024 * 1024;
|
const MAX_BYTES = 100 * 1024 * 1024;
|
||||||
type Scene = 'coupon' | 'comparison';
|
|
||||||
|
|
||||||
const META: Record<Scene, { title: string; action: string }> = {
|
/**
|
||||||
coupon: { title: '一键自动领取引导视频', action: '一键自动领取' },
|
* 领券等候浮层的「新手引导视频」配置。
|
||||||
comparison: { title: '开始比价引导视频', action: '开始比价' },
|
*
|
||||||
};
|
* 用户点首页「一键自动领取」→ 出等候浮层,浮层下方那块位置**前 3 次**放这支引导视频
|
||||||
|
* (而不是广告),每次固定发 120 金币;播完若浮层还开着,自动接着放广告(原逻辑)。
|
||||||
function SceneConfig({ scene }: { scene: Scene }) {
|
* 「系统配置 → 领券引导视频」tab 的一个区块。
|
||||||
const meta = META[scene];
|
*
|
||||||
|
* 后台只管两件事:**开关** 和 **换片**。次数(3)/ 金币(120)走服务端默认值,产品已拍板不再
|
||||||
|
* 开放配置,所以这里不渲染输入框、PATCH 也不带这两个字段(后端仍保留字段与默认值)。
|
||||||
|
*/
|
||||||
|
export default function GuideVideoConfig() {
|
||||||
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);
|
||||||
|
|
||||||
|
// 本地编辑态,保存时一次性 PATCH
|
||||||
const [enabled, setEnabled] = useState(true);
|
const [enabled, setEnabled] = useState(true);
|
||||||
const [maxPlays, setMaxPlays] = useState(3);
|
|
||||||
const [rewardCoin, setRewardCoin] = useState(100);
|
|
||||||
const canEdit = canDo(['operator']);
|
const canEdit = canDo(['operator']);
|
||||||
|
|
||||||
const sync = (value: GuideCfg) => {
|
const sync = (c: GuideCfg) => {
|
||||||
setCfg(value);
|
setCfg(c);
|
||||||
setEnabled(value.enabled);
|
setEnabled(c.enabled);
|
||||||
setMaxPlays(value.max_plays);
|
|
||||||
setRewardCoin(value.reward_coin);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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 },
|
|
||||||
});
|
|
||||||
sync(data);
|
sync(data);
|
||||||
} catch (e) {
|
|
||||||
message.error(errMsg(e));
|
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void load();
|
load();
|
||||||
}, [scene]);
|
}, []);
|
||||||
|
|
||||||
const save = async () => {
|
const save = async () => {
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
const { data } = await api.patch<GuideCfg>(
|
const { data } = await api.patch<GuideCfg>('/admin/api/guide-video', { enabled });
|
||||||
'/admin/api/guide-video',
|
|
||||||
{
|
|
||||||
enabled,
|
|
||||||
reward_coin: rewardCoin,
|
|
||||||
...(scene === 'comparison' ? { max_plays: maxPlays } : {}),
|
|
||||||
},
|
|
||||||
{ params: { scene } },
|
|
||||||
);
|
|
||||||
sync(data);
|
sync(data);
|
||||||
message.success(`${meta.title}配置已保存,下次触发即生效`);
|
message.success('已保存,用户下一次进入领券浮层即生效');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(errMsg(e));
|
message.error(errMsg(e));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -85,27 +65,11 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const uploadVideo = async (file: File) => {
|
// antd Upload:beforeUpload 里自行 POST(multipart),返回 false 阻止其默认上传。
|
||||||
const form = new FormData();
|
|
||||||
form.append('file', file);
|
|
||||||
setUploading(true);
|
|
||||||
try {
|
|
||||||
const { data } = await api.post<GuideCfg>(
|
|
||||||
'/admin/api/guide-video/video',
|
|
||||||
form,
|
|
||||||
{ params: { scene } },
|
|
||||||
);
|
|
||||||
sync(data);
|
|
||||||
message.success(`${meta.title}已更新`);
|
|
||||||
} catch (e) {
|
|
||||||
message.error(errMsg(e));
|
|
||||||
} finally {
|
|
||||||
setUploading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const beforeUpload = (file: File) => {
|
const beforeUpload = (file: File) => {
|
||||||
if (file.type !== 'video/mp4' && !/\.mp4$/i.test(file.name)) {
|
// 有些系统给 .mp4 的 type 是空串,不能只看 type,再兜一层扩展名。
|
||||||
|
const looksMp4 = file.type === 'video/mp4' || /\.mp4$/i.test(file.name);
|
||||||
|
if (!looksMp4) {
|
||||||
message.error('仅支持 MP4 视频(H.264 编码)');
|
message.error('仅支持 MP4 视频(H.264 编码)');
|
||||||
return Upload.LIST_IGNORE;
|
return Upload.LIST_IGNORE;
|
||||||
}
|
}
|
||||||
@@ -117,15 +81,27 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
return false;
|
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 () => {
|
const removeVideo = async () => {
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
try {
|
try {
|
||||||
const { data } = await api.delete<GuideCfg>(
|
const { data } = await api.delete<GuideCfg>('/admin/api/guide-video/video');
|
||||||
'/admin/api/guide-video/video',
|
|
||||||
{ params: { scene } },
|
|
||||||
);
|
|
||||||
sync(data);
|
sync(data);
|
||||||
message.success(`已移除${meta.title}`);
|
message.success('已移除引导视频,领券浮层恢复为只放广告');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(errMsg(e));
|
message.error(errMsg(e));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -136,136 +112,111 @@ function SceneConfig({ scene }: { scene: Scene }) {
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
size="small"
|
size="small"
|
||||||
title={meta.title}
|
title="领券引导视频(App 领券等候浮层,前 3 次替代广告)"
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
extra={
|
extra={
|
||||||
cfg?.updated_at ? (
|
cfg?.updated_at ? (
|
||||||
<Text type="secondary">
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
更新于 {new Date(cfg.updated_at).toLocaleString('zh-CN')}
|
更新于 {new Date(cfg.updated_at).toLocaleString('zh-CN')}
|
||||||
</Text>
|
</Text>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<p style={{ color: '#777', marginTop: 0 }}>
|
<p style={{ color: '#999', marginTop: 0 }}>
|
||||||
Android 用户点击「{meta.action}」后,前 {cfg?.max_plays ?? 3}{' '}
|
用户点「一键自动领取」后出现的等候浮层,下方那块广告位<b>前 3 次</b>改放这支引导视频。
|
||||||
次在等候浮层广告位播放本视频并奖励金币。次数按账号、按功能分别计算;
|
视频<b>不可快进</b>;播完或中途关闭都算看完,各发一次 <b>120 金币</b>;播完若浮层还开着,会自动接着放广告。
|
||||||
开播即计次,播完或中途关闭均发放当次配置的金币。
|
次数<b>按账号</b>计(换设备不重置),<b>视频一开播就算用掉一次</b>。
|
||||||
{scene === 'coupon' &&
|
次数与金币走固定值、后台不开放调整;这里只管<b>开关</b>和<b>换片</b>,每次改动进审计日志。
|
||||||
'领券引导视频的播放次数上限请在「监控审计 → 限制策略」中调整。'}
|
|
||||||
</p>
|
</p>
|
||||||
{loading || !cfg ? (
|
{loading || !cfg ? (
|
||||||
<Spin style={{ display: 'block', margin: '24px 0' }} />
|
<Spin style={{ display: 'block', margin: '24px 0' }} />
|
||||||
) : (
|
) : (
|
||||||
<Space align="start" size={32} wrap>
|
<Space align="start" size={32} wrap>
|
||||||
<div style={{ width: 240 }}>
|
{/* 左:视频预览 */}
|
||||||
{cfg.video_url ? (
|
<div>
|
||||||
// eslint-disable-next-line jsx-a11y/media-has-caption
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
<video
|
当前引导视频
|
||||||
src={mediaUrl(cfg.video_url)}
|
</Text>
|
||||||
controls
|
<div style={{ marginTop: 8, width: 240 }}>
|
||||||
style={{
|
{cfg.video_url ? (
|
||||||
width: 240,
|
// eslint-disable-next-line jsx-a11y/media-has-caption
|
||||||
maxHeight: 420,
|
<video
|
||||||
borderRadius: 12,
|
src={mediaUrl(cfg.video_url)}
|
||||||
background: '#000',
|
controls
|
||||||
}}
|
style={{
|
||||||
/>
|
width: 240,
|
||||||
) : (
|
maxHeight: 420,
|
||||||
<div
|
borderRadius: 12,
|
||||||
style={{
|
background: '#000',
|
||||||
height: 280,
|
border: '1px solid #f0f0f0',
|
||||||
border: '1px dashed #d9d9d9',
|
}}
|
||||||
borderRadius: 12,
|
/>
|
||||||
display: 'grid',
|
) : (
|
||||||
placeItems: 'center',
|
<div
|
||||||
color: '#aaa',
|
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>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Space direction="vertical" size="middle" style={{ minWidth: 390 }}>
|
|
||||||
|
{/* 右:编辑控件 */}
|
||||||
|
<Space direction="vertical" size="middle" style={{ minWidth: 360 }}>
|
||||||
<Space>
|
<Space>
|
||||||
<span>启用:</span>
|
<span>启用引导视频:</span>
|
||||||
<Switch
|
<Switch checked={enabled} disabled={!canEdit} onChange={setEnabled} />
|
||||||
checked={enabled}
|
|
||||||
disabled={!canEdit}
|
|
||||||
onChange={setEnabled}
|
|
||||||
/>
|
|
||||||
{!enabled && <Tag color="orange">已关闭</Tag>}
|
{!enabled && <Tag color="orange">已关闭</Tag>}
|
||||||
</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>
|
|
||||||
<span>每次金币:</span>
|
|
||||||
<InputNumber
|
|
||||||
min={0}
|
|
||||||
max={10000}
|
|
||||||
precision={0}
|
|
||||||
value={rewardCoin}
|
|
||||||
disabled={!canEdit}
|
|
||||||
onChange={(value) => setRewardCoin(value ?? 0)}
|
|
||||||
/>
|
|
||||||
<Text type="secondary">默认 100</Text>
|
|
||||||
</Space>
|
|
||||||
<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}>
|
<Button
|
||||||
|
icon={<DeleteOutlined />}
|
||||||
|
danger
|
||||||
|
loading={uploading}
|
||||||
|
disabled={!canEdit}
|
||||||
|
onClick={removeVideo}
|
||||||
|
>
|
||||||
移除视频
|
移除视频
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Text type="secondary">MP4(H.264),≤100MB</Text>
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
MP4(H.264),≤100MB
|
||||||
|
</Text>
|
||||||
</Space>
|
</Space>
|
||||||
<Button
|
|
||||||
type="primary"
|
<Button type="primary" loading={saving} disabled={!canEdit} onClick={save}>
|
||||||
loading={saving}
|
保存开关
|
||||||
disabled={!canEdit}
|
|
||||||
onClick={save}
|
|
||||||
>
|
|
||||||
保存配置
|
|
||||||
</Button>
|
</Button>
|
||||||
<Text type="secondary">
|
{!canEdit && <Text type="secondary">仅 operator / super_admin 可修改</Text>}
|
||||||
累计播放 {cfg.total_plays} 次,已发币 {cfg.granted_plays} 次
|
|
||||||
</Text>
|
|
||||||
</Space>
|
</Space>
|
||||||
</Space>
|
</Space>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GuideVideoConfig() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<SceneConfig scene="coupon" />
|
|
||||||
<SceneConfig scene="comparison" />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -165,7 +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 /> },
|
{ key: 'guide-video', label: '领券引导视频', children: <GuideVideoConfig /> },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -711,7 +710,7 @@ export default function DashboardPage() {
|
|||||||
<div>
|
<div>
|
||||||
<h1>数据大盘</h1>
|
<h1>数据大盘</h1>
|
||||||
<p>
|
<p>
|
||||||
数据更新于 {updatedAt ?? '--'} · 北京时间 · 日期窗口按 00:00 自然日切分,自定义日期可选择今日
|
数据更新于 {updatedAt ?? '--'} · 北京时间 · 日期窗口按 00:00 自然日切分,不包含今日
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="controls">
|
<div className="controls">
|
||||||
@@ -735,7 +734,7 @@ export default function DashboardPage() {
|
|||||||
format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
||||||
allowClear={false}
|
allowClear={false}
|
||||||
open={datePickerOpen}
|
open={datePickerOpen}
|
||||||
disabledDate={(date) => date.isAfter(dayjs(), 'day')}
|
disabledDate={(date) => date.isAfter(dayjs().subtract(1, 'day'), 'day')}
|
||||||
suffixIcon={<CalendarOutlined />}
|
suffixIcon={<CalendarOutlined />}
|
||||||
onClick={() => setDatePickerOpen(true)}
|
onClick={() => setDatePickerOpen(true)}
|
||||||
onOpenChange={setDatePickerOpen}
|
onOpenChange={setDatePickerOpen}
|
||||||
@@ -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="点位成功率"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import type { SorterResult } from 'antd/es/table/interface';
|
import type { SorterResult } from 'antd/es/table/interface';
|
||||||
import {
|
import {
|
||||||
@@ -35,7 +35,6 @@ import UserRecordsDrawer from '@/components/UserRecordsDrawer';
|
|||||||
const { Text, Paragraph } = Typography;
|
const { Text, Paragraph } = Typography;
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
const REWARD_MAX = 10000;
|
const REWARD_MAX = 10000;
|
||||||
const REVIEW_PAGE_POLL_INTERVAL_MS = 60_000;
|
|
||||||
|
|
||||||
// 截图是 app-server 的 /media 相对路径,本地由 :8770 提供(NEXT_PUBLIC_MEDIA_BASE);生产同域走 nginx 代理。
|
// 截图是 app-server 的 /media 相对路径,本地由 :8770 提供(NEXT_PUBLIC_MEDIA_BASE);生产同域走 nginx 代理。
|
||||||
const MEDIA_BASE = process.env.NEXT_PUBLIC_MEDIA_BASE || '';
|
const MEDIA_BASE = process.env.NEXT_PUBLIC_MEDIA_BASE || '';
|
||||||
@@ -197,10 +196,6 @@ export default function FeedbacksPage() {
|
|||||||
const filters: Record<string, unknown> = { ...applied, sort_by: sortBy, sort_order: sortOrder };
|
const filters: Record<string, unknown> = { ...applied, sort_by: sortBy, sort_order: sortOrder };
|
||||||
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
|
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
|
||||||
usePagedList<Feedback>('/admin/api/feedbacks', filters);
|
usePagedList<Feedback>('/admin/api/feedbacks', filters);
|
||||||
const reloadRef = useRef(reload);
|
|
||||||
useEffect(() => {
|
|
||||||
reloadRef.current = reload;
|
|
||||||
}, [reload]);
|
|
||||||
|
|
||||||
const canReview = canDo(['operator']);
|
const canReview = canDo(['operator']);
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
|
||||||
@@ -218,39 +213,17 @@ export default function FeedbacksPage() {
|
|||||||
}, [items]);
|
}, [items]);
|
||||||
|
|
||||||
const [summary, setSummary] = useState<FeedbackSummary | null>(null);
|
const [summary, setSummary] = useState<FeedbackSummary | null>(null);
|
||||||
const loadSummary = useCallback(async () => {
|
const loadSummary = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.get<FeedbackSummary>('/admin/api/feedbacks/summary');
|
const { data } = await api.get<FeedbackSummary>('/admin/api/feedbacks/summary');
|
||||||
setSummary(data);
|
setSummary(data);
|
||||||
} catch {
|
} catch {
|
||||||
/* 统计失败不阻塞列表 */
|
/* 统计失败不阻塞列表 */
|
||||||
}
|
}
|
||||||
}, []);
|
};
|
||||||
|
|
||||||
const refreshPageData = useCallback(() => {
|
|
||||||
void reloadRef.current();
|
|
||||||
void loadSummary();
|
|
||||||
}, [loadSummary]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadSummary();
|
loadSummary();
|
||||||
|
}, []);
|
||||||
const onWindowFocus = () => refreshPageData();
|
|
||||||
const onVisibilityChange = () => {
|
|
||||||
if (document.visibilityState === 'visible') refreshPageData();
|
|
||||||
};
|
|
||||||
const pollTimer = window.setInterval(() => {
|
|
||||||
if (document.visibilityState === 'visible') refreshPageData();
|
|
||||||
}, REVIEW_PAGE_POLL_INTERVAL_MS);
|
|
||||||
|
|
||||||
window.addEventListener('focus', onWindowFocus);
|
|
||||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
||||||
return () => {
|
|
||||||
window.clearInterval(pollTimer);
|
|
||||||
window.removeEventListener('focus', onWindowFocus);
|
|
||||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
||||||
};
|
|
||||||
}, [loadSummary, refreshPageData]);
|
|
||||||
|
|
||||||
// 审核/查看抽屉(采纳发金币 / 拒绝填原因 + 看该用户历史反馈)
|
// 审核/查看抽屉(采纳发金币 / 拒绝填原因 + 看该用户历史反馈)
|
||||||
const [drawerFb, setDrawerFb] = useState<Feedback | null>(null);
|
const [drawerFb, setDrawerFb] = useState<Feedback | null>(null);
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -38,8 +37,6 @@ import type {
|
|||||||
WithdrawSummary,
|
WithdrawSummary,
|
||||||
} from '@/lib/types';
|
} from '@/lib/types';
|
||||||
|
|
||||||
const REVIEW_BADGE_POLL_INTERVAL_MS = 60_000;
|
|
||||||
|
|
||||||
const { Sider, Header, Content } = Layout;
|
const { Sider, Header, Content } = Layout;
|
||||||
|
|
||||||
type NavItem = {
|
type NavItem = {
|
||||||
@@ -106,7 +103,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: '限制策略' },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -166,39 +162,22 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
};
|
};
|
||||||
|
|
||||||
const refreshSafely = (key: ReviewBadgeKey) => refresh(key).catch(() => {});
|
const refreshSafely = (key: ReviewBadgeKey) => refresh(key).catch(() => {});
|
||||||
const refreshAll = () => {
|
void Promise.all([
|
||||||
void Promise.all([
|
refreshSafely('/withdraws'),
|
||||||
refreshSafely('/withdraws'),
|
refreshSafely('/invite-withdraws'),
|
||||||
refreshSafely('/invite-withdraws'),
|
refreshSafely('/price-reports'),
|
||||||
refreshSafely('/price-reports'),
|
refreshSafely('/feedbacks'),
|
||||||
refreshSafely('/feedbacks'),
|
]);
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
refreshAll();
|
|
||||||
|
|
||||||
const onReviewCompleted = (event: Event) => {
|
const onReviewCompleted = (event: Event) => {
|
||||||
const key = (event as CustomEvent<ReviewBadgeKey>).detail;
|
const key = (event as CustomEvent<ReviewBadgeKey>).detail;
|
||||||
if (key) void refreshSafely(key);
|
if (key) void refreshSafely(key);
|
||||||
};
|
};
|
||||||
const onWindowFocus = () => refreshAll();
|
|
||||||
const onVisibilityChange = () => {
|
|
||||||
if (document.visibilityState === 'visible') refreshAll();
|
|
||||||
};
|
|
||||||
const pollTimer = window.setInterval(() => {
|
|
||||||
if (document.visibilityState === 'visible') refreshAll();
|
|
||||||
}, REVIEW_BADGE_POLL_INTERVAL_MS);
|
|
||||||
|
|
||||||
window.addEventListener(REVIEW_BADGE_REFRESH_EVENT, onReviewCompleted);
|
window.addEventListener(REVIEW_BADGE_REFRESH_EVENT, onReviewCompleted);
|
||||||
window.addEventListener('focus', onWindowFocus);
|
|
||||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
||||||
return () => {
|
return () => {
|
||||||
window.clearInterval(pollTimer);
|
|
||||||
window.removeEventListener(REVIEW_BADGE_REFRESH_EVENT, onReviewCompleted);
|
window.removeEventListener(REVIEW_BADGE_REFRESH_EVENT, onReviewCompleted);
|
||||||
window.removeEventListener('focus', onWindowFocus);
|
|
||||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
||||||
};
|
};
|
||||||
}, [admin, pathname]);
|
}, [admin]);
|
||||||
|
|
||||||
if (!admin) return null; // 守卫期间不闪烁内容
|
if (!admin) return null; // 守卫期间不闪烁内容
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
App,
|
App,
|
||||||
Button,
|
Button,
|
||||||
@@ -30,7 +30,6 @@ import type { PriceReport, PriceReportSummary } from '@/lib/types';
|
|||||||
import UserRecordsDrawer from '@/components/UserRecordsDrawer';
|
import UserRecordsDrawer from '@/components/UserRecordsDrawer';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
const REVIEW_PAGE_POLL_INTERVAL_MS = 60_000;
|
|
||||||
|
|
||||||
// 后端 created_at/reviewed_at 存的是北京 wall-clock(naive,同 savings/comparison),
|
// 后端 created_at/reviewed_at 存的是北京 wall-clock(naive,同 savings/comparison),
|
||||||
// 直接本地解析、不加 Z(否则会差 8h)。
|
// 直接本地解析、不加 Z(否则会差 8h)。
|
||||||
@@ -151,10 +150,6 @@ export default function PriceReportsPage() {
|
|||||||
|
|
||||||
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
|
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
|
||||||
usePagedList<PriceReport>('/admin/api/price-reports', filters);
|
usePagedList<PriceReport>('/admin/api/price-reports', filters);
|
||||||
const reloadRef = useRef(reload);
|
|
||||||
useEffect(() => {
|
|
||||||
reloadRef.current = reload;
|
|
||||||
}, [reload]);
|
|
||||||
|
|
||||||
const sortOrderOf = (field: SortField) =>
|
const sortOrderOf = (field: SortField) =>
|
||||||
sortBy === field ? (sortOrder === 'asc' ? 'ascend' : 'descend') : null;
|
sortBy === field ? (sortOrder === 'asc' ? 'ascend' : 'descend') : null;
|
||||||
@@ -186,39 +181,17 @@ export default function PriceReportsPage() {
|
|||||||
setSelectedRowKeys((keys) => keys.filter((id) => visiblePendingIds.has(id)));
|
setSelectedRowKeys((keys) => keys.filter((id) => visiblePendingIds.has(id)));
|
||||||
}, [items]);
|
}, [items]);
|
||||||
|
|
||||||
const loadSummary = useCallback(async () => {
|
const loadSummary = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.get<PriceReportSummary>('/admin/api/price-reports/summary');
|
const { data } = await api.get<PriceReportSummary>('/admin/api/price-reports/summary');
|
||||||
setSummary(data);
|
setSummary(data);
|
||||||
} catch {
|
} catch {
|
||||||
/* 统计失败不阻塞列表 */
|
/* 统计失败不阻塞列表 */
|
||||||
}
|
}
|
||||||
}, []);
|
};
|
||||||
|
|
||||||
const refreshPageData = useCallback(() => {
|
|
||||||
void reloadRef.current();
|
|
||||||
void loadSummary();
|
|
||||||
}, [loadSummary]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadSummary();
|
loadSummary();
|
||||||
|
}, []);
|
||||||
const onWindowFocus = () => refreshPageData();
|
|
||||||
const onVisibilityChange = () => {
|
|
||||||
if (document.visibilityState === 'visible') refreshPageData();
|
|
||||||
};
|
|
||||||
const pollTimer = window.setInterval(() => {
|
|
||||||
if (document.visibilityState === 'visible') refreshPageData();
|
|
||||||
}, REVIEW_PAGE_POLL_INTERVAL_MS);
|
|
||||||
|
|
||||||
window.addEventListener('focus', onWindowFocus);
|
|
||||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
||||||
return () => {
|
|
||||||
window.clearInterval(pollTimer);
|
|
||||||
window.removeEventListener('focus', onWindowFocus);
|
|
||||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
||||||
};
|
|
||||||
}, [loadSummary, refreshPageData]);
|
|
||||||
|
|
||||||
const refreshAfterChange = () => {
|
const refreshAfterChange = () => {
|
||||||
reload();
|
reload();
|
||||||
|
|||||||
@@ -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(() => {
|
||||||
|
|||||||
@@ -44,11 +44,6 @@ interface Props {
|
|||||||
withdrawSource?: 'coin_cash' | 'invite_cash';
|
withdrawSource?: 'coin_cash' | 'invite_cash';
|
||||||
// 统计区字段集:withdraw(默认,提现详情:含提现细分) / ad(广告收益详情:只看看广告观看统计,对齐参考图 6 项)
|
// 统计区字段集:withdraw(默认,提现详情:含提现细分) / ad(广告收益详情:只看看广告观看统计,对齐参考图 6 项)
|
||||||
statsVariant?: 'withdraw' | 'ad';
|
statsVariant?: 'withdraw' | 'ad';
|
||||||
initialDateFrom?: string;
|
|
||||||
initialDateTo?: string;
|
|
||||||
appEnv?: 'prod' | 'test';
|
|
||||||
revenueScope?: 'business' | 'all';
|
|
||||||
feedScene?: 'comparison' | 'coupon' | 'welfare';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 用户看广告/提现详情:基本信息 + 互斥时间筛选 + 统计区(按 statsVariant 取字段集)+ 金币发放记录表。 */
|
/** 用户看广告/提现详情:基本信息 + 互斥时间筛选 + 统计区(按 statsVariant 取字段集)+ 金币发放记录表。 */
|
||||||
@@ -57,17 +52,9 @@ export default function UserRewardPanel({
|
|||||||
user,
|
user,
|
||||||
withdrawSource,
|
withdrawSource,
|
||||||
statsVariant = 'withdraw',
|
statsVariant = 'withdraw',
|
||||||
initialDateFrom,
|
|
||||||
initialDateTo,
|
|
||||||
appEnv,
|
|
||||||
revenueScope = 'all',
|
|
||||||
feedScene,
|
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const hasInitialRange = Boolean(initialDateFrom && initialDateTo);
|
const [mode, setMode] = useState<'all' | 'range'>('all'); // all=注册至今 / range=自定义区间
|
||||||
const [mode, setMode] = useState<'all' | 'range'>(hasInitialRange ? 'range' : 'all');
|
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
|
||||||
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(() =>
|
|
||||||
hasInitialRange ? [dayjs(initialDateFrom), dayjs(initialDateTo)] : null,
|
|
||||||
);
|
|
||||||
const [stats, setStats] = useState<UserRewardStats | null>(null);
|
const [stats, setStats] = useState<UserRewardStats | null>(null);
|
||||||
const [statsLoading, setStatsLoading] = useState(false);
|
const [statsLoading, setStatsLoading] = useState(false);
|
||||||
|
|
||||||
@@ -93,9 +80,6 @@ export default function UserRewardPanel({
|
|||||||
params: {
|
params: {
|
||||||
...JSON.parse(paramsKey),
|
...JSON.parse(paramsKey),
|
||||||
...(withdrawSource ? { withdraw_source: withdrawSource } : {}),
|
...(withdrawSource ? { withdraw_source: withdrawSource } : {}),
|
||||||
...(appEnv ? { app_env: appEnv } : {}),
|
|
||||||
revenue_scope: revenueScope,
|
|
||||||
...(feedScene ? { feed_scene: feedScene } : {}),
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setStats(data);
|
setStats(data);
|
||||||
@@ -104,7 +88,7 @@ export default function UserRewardPanel({
|
|||||||
} finally {
|
} finally {
|
||||||
setStatsLoading(false);
|
setStatsLoading(false);
|
||||||
}
|
}
|
||||||
}, [userId, paramsKey, withdrawSource, appEnv, revenueScope, feedScene]);
|
}, [userId, paramsKey, withdrawSource]);
|
||||||
|
|
||||||
const loadRecords = useCallback(
|
const loadRecords = useCallback(
|
||||||
async (p: number) => {
|
async (p: number) => {
|
||||||
@@ -252,7 +236,7 @@ export default function UserRewardPanel({
|
|||||||
</Descriptions>
|
</Descriptions>
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
{statsVariant === 'ad'
|
{statsVariant === 'ad'
|
||||||
? '统计继承广告收益页已查询的日期、环境、业务代码位和场景;次数仅统计成功发奖记录,信息流按奖励份数统计;Draw eCPM 按全部实际展示统计(含未发奖)。'
|
? '统计随上方时间筛选(现金余额除外,为当前快照);次数仅统计成功发奖记录,信息流按奖励份数统计;eCPM 为预估值。'
|
||||||
: '统计随上方时间筛选(现金余额除外,为当前快照);提现按申请提交时间统计;累计收益为已发金币按当前汇率折算,不代表实际已提现金额;eCPM 为预估值。'}
|
: '统计随上方时间筛选(现金余额除外,为当前快照);提现按申请提交时间统计;累计收益为已发金币按当前汇率折算,不代表实际已提现金额;eCPM 为预估值。'}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
|
|||||||
@@ -570,7 +570,6 @@ export function WithdrawReviewPage({ mode = 'other' }: { mode?: WithdrawReviewMo
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '失败/拒绝原因',
|
title: '失败/拒绝原因',
|
||||||
key: 'fail_reason',
|
|
||||||
dataIndex: 'fail_reason',
|
dataIndex: 'fail_reason',
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
render: (v: string | null) => v || <Text type="secondary">-</Text>,
|
render: (v: string | null) => v || <Text type="secondary">-</Text>,
|
||||||
@@ -648,10 +647,6 @@ export function WithdrawReviewPage({ mode = 'other' }: { mode?: WithdrawReviewMo
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const visibleColumns =
|
|
||||||
activeStatus === 'pending' || activeStatus === 'success'
|
|
||||||
? columns.filter((column) => column.key !== 'fail_reason')
|
|
||||||
: columns;
|
|
||||||
|
|
||||||
const inviteeColumns: ColumnsType<InviteeDetail> = [
|
const inviteeColumns: ColumnsType<InviteeDetail> = [
|
||||||
{ title: '手机号', dataIndex: 'phone', width: 130 },
|
{ title: '手机号', dataIndex: 'phone', width: 130 },
|
||||||
@@ -950,7 +945,7 @@ export function WithdrawReviewPage({ mode = 'other' }: { mode?: WithdrawReviewMo
|
|||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
columns={visibleColumns}
|
columns={columns}
|
||||||
dataSource={items}
|
dataSource={items}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
pagination={{
|
pagination={{
|
||||||
@@ -994,6 +989,12 @@ export function WithdrawReviewPage({ mode = 'other' }: { mode?: WithdrawReviewMo
|
|||||||
<Descriptions.Item label="金额">
|
<Descriptions.Item label="金额">
|
||||||
<Text strong>{yuan(detail.order.amount_cents)}</Text>
|
<Text strong>{yuan(detail.order.amount_cents)}</Text>
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="提现类型">
|
||||||
|
{detail.order.source === 'invite_cash' ? '邀请奖励提现' : '福利页提现'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="累计成功提现">
|
||||||
|
{yuan(detail.cumulative_success_cents)}
|
||||||
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="提交时间">
|
<Descriptions.Item label="提交时间">
|
||||||
{dt(detail.order.created_at)}
|
{dt(detail.order.created_at)}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
|||||||
@@ -37,18 +37,6 @@ export function percentile(values: readonly number[], q: number, round = true):
|
|||||||
return round ? Math.round(result) : result;
|
return round ? Math.round(result) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 离散计数分位数(nearest-rank)。
|
|
||||||
* 广告条数等不可拆分的计数不做线性插值,结果始终取自真实样本。
|
|
||||||
*/
|
|
||||||
export function nearestRankPercentile(values: readonly number[], q: number): number | null {
|
|
||||||
if (!values.length) return null;
|
|
||||||
const sorted = [...values].sort((a, b) => a - b);
|
|
||||||
const quantile = Math.min(1, Math.max(0, q));
|
|
||||||
const rank = Math.max(1, Math.ceil(quantile * sorted.length));
|
|
||||||
return sorted[rank - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasTz = (v: string) => /(?:Z|[+-]\d{2}:?\d{2})$/i.test(v);
|
const hasTz = (v: string) => /(?:Z|[+-]\d{2}:?\d{2})$/i.test(v);
|
||||||
|
|
||||||
/** 把 UTC 口径字符串解析为带时区的 dayjs(无时区后缀的补 Z 当 UTC)。 */
|
/** 把 UTC 口径字符串解析为带时区的 dayjs(无时区后缀的补 Z 当 UTC)。 */
|
||||||
|
|||||||
+5
-92
@@ -233,7 +233,7 @@ export interface UserRewardStats {
|
|||||||
reward_video_avg_ecpm: number; // 平均激励视频 eCPM(分/千次)
|
reward_video_avg_ecpm: number; // 平均激励视频 eCPM(分/千次)
|
||||||
reward_video_cash_cents: number; // 激励视频提现
|
reward_video_cash_cents: number; // 激励视频提现
|
||||||
feed_count: number; // 累计信息流广告数(份)
|
feed_count: number; // 累计信息流广告数(份)
|
||||||
feed_avg_ecpm: number; // 全部 Draw/feed 实际展示的平均 eCPM(分/千次,含未发奖展示)
|
feed_avg_ecpm: number; // 平均信息流广告 eCPM(分/千次)
|
||||||
feed_cash_cents: number; // 信息流广告提现
|
feed_cash_cents: number; // 信息流广告提现
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,14 +414,13 @@ export interface FeedbackQrConfig {
|
|||||||
updated_at: string | null;
|
updated_at: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 领券等候浮层的「新手引导视频」配置(前 3 次用它替代广告,默认每次固定 100 金币)。
|
/** 领券等候浮层的「新手引导视频」配置(前 3 次用它替代广告,每次固定 120 金币)。
|
||||||
* 后台只开放 enabled + 换片;下面几个字段接口仍返回,但页面不展示、也不回传。 */
|
* 后台只开放 enabled + 换片;下面几个字段接口仍返回,但页面不展示、也不回传。 */
|
||||||
export interface GuideVideoConfig {
|
export interface GuideVideoConfig {
|
||||||
scene: 'coupon' | 'comparison';
|
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
video_url: string | null; // /media/guide_video/xxx.mp4;null = 未配片(浮层照旧只放广告)
|
video_url: string | null; // /media/guide_video/xxx.mp4;null = 未配片(浮层照旧只放广告)
|
||||||
max_plays: number; // 每个账号前 N 次浮层放引导视频(服务端默认 3,后台不开放调整)
|
max_plays: number; // 每个账号前 N 次浮层放引导视频(服务端默认 3,后台不开放调整)
|
||||||
reward_coin: number; // 每次固定金币(服务端默认 100,播完 / 中途关闭都发)
|
reward_coin: number; // 每次固定金币(服务端默认 120,播完 / 中途关闭都发)
|
||||||
updated_at: string | null;
|
updated_at: string | null;
|
||||||
total_plays: number; // 只读统计:全站已播次数(后台不再展示)
|
total_plays: number; // 只读统计:全站已播次数(后台不再展示)
|
||||||
granted_plays: number; // 只读统计:其中已发币次数(后台不再展示)
|
granted_plays: number; // 只读统计:其中已发币次数(后台不再展示)
|
||||||
@@ -443,15 +442,13 @@ export interface AuditLog {
|
|||||||
// ===== 比价记录(admin debug 页)=====
|
// ===== 比价记录(admin debug 页)=====
|
||||||
export interface ComparisonRecordListItem {
|
export interface ComparisonRecordListItem {
|
||||||
id: number;
|
id: number;
|
||||||
user_id: number | null; // 软鉴权/匿名下帧0 建行时可能暂缺,admin 全看含孤儿行
|
user_id: number;
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
nickname: string | null;
|
nickname: string | null;
|
||||||
business_type: string;
|
business_type: string;
|
||||||
trace_id: string;
|
trace_id: string;
|
||||||
trace_url: string | null;
|
trace_url: string | null;
|
||||||
status: string;
|
status: string;
|
||||||
admin_status: string; // admin 展示口径:success/failed/cancelled/running
|
|
||||||
outcome_hint: string | null; // 有缺失的成功提示(未找到店/未满起送...);null=无缺失
|
|
||||||
information: string | null;
|
information: string | null;
|
||||||
store_name: string | null;
|
store_name: string | null;
|
||||||
product_names: string | null; // 下单商品名派生串(顿号分隔),「商品」列展示
|
product_names: string | null; // 下单商品名派生串(顿号分隔),「商品」列展示
|
||||||
@@ -460,7 +457,6 @@ export interface ComparisonRecordListItem {
|
|||||||
source_price_cents: number | null;
|
source_price_cents: number | null;
|
||||||
best_price_cents: number | null;
|
best_price_cents: number | null;
|
||||||
saved_amount_cents: number | null;
|
saved_amount_cents: number | null;
|
||||||
ordered: boolean;
|
|
||||||
total_ms: number | null;
|
total_ms: number | null;
|
||||||
step_count: number | null;
|
step_count: number | null;
|
||||||
llm_call_count: number | null;
|
llm_call_count: number | null;
|
||||||
@@ -469,10 +465,8 @@ export interface ComparisonRecordListItem {
|
|||||||
output_tokens: number | null;
|
output_tokens: number | null;
|
||||||
llm_cost_yuan: number | null; // 后端按「当时价」冻结的实际成本(元);旧记录 null → 「成本」列回退估算
|
llm_cost_yuan: number | null; // 后端按「当时价」冻结的实际成本(元);旧记录 null → 「成本」列回退估算
|
||||||
device_model: string | null;
|
device_model: string | null;
|
||||||
device_model_name: string | null;
|
|
||||||
rom_vendor: string | null;
|
rom_vendor: string | null;
|
||||||
rom_name: string | null;
|
rom_name: string | null;
|
||||||
rom_version: number | null;
|
|
||||||
android_version: string | null;
|
android_version: string | null;
|
||||||
app_version: string | null;
|
app_version: string | null;
|
||||||
ad_revenue_yuan: number; // 本次比价看的信息流广告预估收益(元)
|
ad_revenue_yuan: number; // 本次比价看的信息流广告预估收益(元)
|
||||||
@@ -520,10 +514,10 @@ 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;
|
||||||
|
rom_version: number | null;
|
||||||
android_sdk: number | null;
|
android_sdk: number | null;
|
||||||
app_version_code: number | null;
|
app_version_code: number | null;
|
||||||
source_app_version: string | null;
|
source_app_version: string | null;
|
||||||
@@ -587,7 +581,6 @@ export interface AdRevenueHourly {
|
|||||||
export interface AdRevenueTypeStat {
|
export interface AdRevenueTypeStat {
|
||||||
impressions: number; // 该类型展示条数合计
|
impressions: number; // 该类型展示条数合计
|
||||||
revenue_yuan: number; // 该类型预估收益合计(元)
|
revenue_yuan: number; // 该类型预估收益合计(元)
|
||||||
ecpm_yuan?: number; // 按真实展示次数加权的 SDK eCPM(元/千次)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 广告收益报表:一次广告事件(逐条一行)。激励视频展示+发奖按 ad_session_id 合并;信息流展示/发奖各自成行。
|
// 广告收益报表:一次广告事件(逐条一行)。激励视频展示+发奖按 ad_session_id 合并;信息流展示/发奖各自成行。
|
||||||
@@ -627,7 +620,6 @@ export interface AdRevenueReport {
|
|||||||
daily: AdRevenueDaily[]; // 按日期汇总序列(全量,供按天趋势图)
|
daily: AdRevenueDaily[]; // 按日期汇总序列(全量,供按天趋势图)
|
||||||
hourly: AdRevenueHourly[]; // 按小时汇总序列(全量,供按小时趋势图;按天查询时为空)
|
hourly: AdRevenueHourly[]; // 按小时汇总序列(全量,供按小时趋势图;按天查询时为空)
|
||||||
type_stats: Record<string, AdRevenueTypeStat>; // 按广告类型小计;前端取 draw / reward_video
|
type_stats: Record<string, AdRevenueTypeStat>; // 按广告类型小计;前端取 draw / reward_video
|
||||||
category_stats?: Record<string, AdRevenueTypeStat>; // draw=draw+历史feed;video=福利视频+提现视频
|
|
||||||
// 按信息流场景小计(comparison/coupon/welfare;全量,不受分页截断)。数据大盘「领券广告/比价广告」卡
|
// 按信息流场景小计(comparison/coupon/welfare;全量,不受分页截断)。数据大盘「领券广告/比价广告」卡
|
||||||
// 优先读它:2026-07-02 后端起 items 不再含信息流逐条展示行(唯一带收益+场景的行),按 items 现算恒 0。
|
// 优先读它:2026-07-02 后端起 items 不再含信息流逐条展示行(唯一带收益+场景的行),按 items 现算恒 0。
|
||||||
// 可选(`?.` 探测)以兼容未升级后端,缺失时回退 items 现算。
|
// 可选(`?.` 探测)以兼容未升级后端,缺失时回退 items 现算。
|
||||||
@@ -709,8 +701,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;
|
||||||
@@ -900,80 +890,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 页重载
|
||||||
|
|||||||
Reference in New Issue
Block a user