Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aff250f9fd | |||
| ecf8150cfc | |||
| 1559d4faf0 | |||
| 9d32234015 | |||
| a2a8451aec | |||
| 578819a284 | |||
| efa443ea8a | |||
| f3cfd622a7 |
@@ -66,21 +66,101 @@ const APP_TAG: Record<string, { color: string; label: string }> = {
|
||||
test: { color: 'default', label: '测试应用' },
|
||||
};
|
||||
|
||||
// 发奖状态 → 颜色 + 中文(含「不发金币的原因」:提前关闭/未满10秒/缺eCPM/次数超限)
|
||||
const STATUS_TAG: Record<string, { color: string; label: string }> = {
|
||||
granted: { color: 'green', label: '已发' },
|
||||
capped: { color: 'orange', label: '次数超限' },
|
||||
ecpm_missing: { color: 'red', label: '缺 eCPM' },
|
||||
too_short: { color: 'gold', label: '未满10秒' },
|
||||
const REWARD_STATUS_HINT: Record<string, string> = {
|
||||
granted: '已完成金币发放',
|
||||
capped: '次数超限,未发金币',
|
||||
ecpm_missing: '缺少有效 eCPM,未发金币',
|
||||
too_short: '播放时长未达到发奖条件,未发金币',
|
||||
closed_early: '用户提前关闭广告,未发金币',
|
||||
};
|
||||
|
||||
const PLAYBACK_STATUS_TAG: Record<string, { color: string; label: string }> = {
|
||||
completed: { color: 'green', label: '已完成' },
|
||||
too_short: { color: 'gold', label: '观看时长不足' },
|
||||
closed_early: { color: 'default', label: '提前关闭' },
|
||||
unknown: { color: 'default', label: '未知' },
|
||||
};
|
||||
const STATUS_HINT: Record<string, string> = {
|
||||
granted: '已满足当前客户端发奖条件并完成金币发放。',
|
||||
too_short: '旧版 Draw 信息流观看不足 10 秒,不发金币;新版按观看比例发放时会记为已发。',
|
||||
closed_early: '用户在达到发奖条件前主动关闭,不发金币。',
|
||||
capped: '已达到次数上限,不再发金币。',
|
||||
ecpm_missing: '缺少有效 eCPM,无法计算金币。',
|
||||
};
|
||||
|
||||
const ZERO_REVENUE_REWARD_VIDEO_STATUSES = new Set(['closed_early', 'too_short']);
|
||||
|
||||
function rewardStatuses(row: AdRevenueRow): string[] {
|
||||
if (row.sub_rewards?.length) return row.sub_rewards.map((reward) => reward.status);
|
||||
return row.status ? [row.status] : [];
|
||||
}
|
||||
|
||||
function effectiveRevenueYuan(row: AdRevenueRow): number {
|
||||
if (
|
||||
row.ad_type === 'reward_video'
|
||||
&& rewardStatuses(row).some((status) => ZERO_REVENUE_REWARD_VIDEO_STATUSES.has(status))
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
return row.row_revenue_yuan ?? row.revenue_yuan;
|
||||
}
|
||||
|
||||
function rewardStatusTag(row: AdRevenueRow) {
|
||||
const statuses = rewardStatuses(row);
|
||||
if (!row.has_reward || statuses.length === 0) {
|
||||
return { color: 'default', label: '无记录', hint: '仅记录到广告展示,没有对应发奖记录。' };
|
||||
}
|
||||
|
||||
const grantedCount = statuses.filter((status) => status === 'granted').length;
|
||||
const reasonSummary = Object.entries(
|
||||
statuses
|
||||
.filter((status) => status !== 'granted')
|
||||
.reduce<Record<string, number>>((counts, status) => {
|
||||
counts[status] = (counts[status] ?? 0) + 1;
|
||||
return counts;
|
||||
}, {}),
|
||||
)
|
||||
.map(([status, count]) => `${REWARD_STATUS_HINT[status] ?? status} ${count} 条`)
|
||||
.join(';');
|
||||
|
||||
if (grantedCount === statuses.length) {
|
||||
return { color: 'green', label: '已发', hint: `已完成金币发放${statuses.length > 1 ? ` ${statuses.length} 条` : ''}。` };
|
||||
}
|
||||
if (grantedCount > 0) {
|
||||
return {
|
||||
color: 'blue',
|
||||
label: '部分已发',
|
||||
hint: `已发 ${grantedCount} 条,未发 ${statuses.length - grantedCount} 条${reasonSummary ? `;${reasonSummary}` : ''}。`,
|
||||
};
|
||||
}
|
||||
return { color: 'default', label: '未发', hint: reasonSummary ? `${reasonSummary}。` : '未发放金币。' };
|
||||
}
|
||||
|
||||
function playbackStatusTag(row: AdRevenueRow) {
|
||||
const statuses = rewardStatuses(row);
|
||||
if (statuses.length === 0) {
|
||||
return row.has_impression
|
||||
? { color: 'blue', label: '仅展示', hint: '记录到广告展示,但没有对应的播放结果。' }
|
||||
: { color: 'default', label: '无记录', hint: '没有可用的广告播放记录。' };
|
||||
}
|
||||
|
||||
const playbackCounts = statuses.reduce<Record<string, number>>((counts, status) => {
|
||||
const playbackStatus =
|
||||
status === 'too_short' || status === 'closed_early'
|
||||
? status
|
||||
: status === 'granted' || status === 'capped' || status === 'ecpm_missing'
|
||||
? 'completed'
|
||||
: 'unknown';
|
||||
counts[playbackStatus] = (counts[playbackStatus] ?? 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
const entries = Object.entries(playbackCounts);
|
||||
if (entries.length === 1) {
|
||||
const [status, count] = entries[0];
|
||||
const tag = PLAYBACK_STATUS_TAG[status];
|
||||
return {
|
||||
...tag,
|
||||
hint: `${tag.label}${count > 1 ? ` ${count} 条` : ''}。`,
|
||||
};
|
||||
}
|
||||
const hint = entries
|
||||
.map(([status, count]) => `${PLAYBACK_STATUS_TAG[status].label} ${count} 条`)
|
||||
.join(';');
|
||||
return { color: 'purple', label: '部分完成', hint: `${hint}。` };
|
||||
}
|
||||
|
||||
const fmtFactorRange = (a: number | null, b: number | null) => {
|
||||
if (a == null) return '-';
|
||||
@@ -478,19 +558,25 @@ export default function AdRevenueReportPage() {
|
||||
width: 110,
|
||||
align: 'right',
|
||||
// 一次比价/领券聚合行用 row_revenue_yuan(该次发奖广告 eCPM 折算之和),其它行用展示侧 revenue_yuan
|
||||
render: (v: number, r: AdRevenueRow) => {
|
||||
const rev = r.row_revenue_yuan ?? v;
|
||||
return rev.toFixed(4);
|
||||
},
|
||||
// 激励视频提前关闭/时长不足时防御性显示 0,与后端有效收益口径一致。
|
||||
render: (_v: number, r: AdRevenueRow) => effectiveRevenueYuan(r).toFixed(4),
|
||||
},
|
||||
{
|
||||
title: '发奖状态',
|
||||
dataIndex: 'status',
|
||||
key: 'reward_status',
|
||||
width: 100,
|
||||
render: (s: string | null) => {
|
||||
if (!s) return <Tooltip title="仅记录广告展示,没有对应发奖事件。"><Tag>仅展示</Tag></Tooltip>;
|
||||
const t = STATUS_TAG[s] ?? { color: 'default', label: s };
|
||||
return <Tooltip title={STATUS_HINT[s]}><Tag color={t.color}>{t.label}</Tag></Tooltip>;
|
||||
render: (_: unknown, row: AdRevenueRow) => {
|
||||
const tag = rewardStatusTag(row);
|
||||
return <Tooltip title={tag.hint}><Tag color={tag.color}>{tag.label}</Tag></Tooltip>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '广告播放状态',
|
||||
key: 'playback_status',
|
||||
width: 120,
|
||||
render: (_: unknown, row: AdRevenueRow) => {
|
||||
const tag = playbackStatusTag(row);
|
||||
return <Tooltip title={tag.hint}><Tag color={tag.color}>{tag.label}</Tag></Tooltip>;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -532,7 +618,8 @@ export default function AdRevenueReportPage() {
|
||||
'ecpm_yuan',
|
||||
'revenue_yuan',
|
||||
'actual_coin',
|
||||
'status',
|
||||
'reward_status',
|
||||
'playback_status',
|
||||
'ad_type',
|
||||
'app_env',
|
||||
'our_code_id',
|
||||
@@ -618,7 +705,7 @@ export default function AdRevenueReportPage() {
|
||||
<br />
|
||||
<br />
|
||||
「预估收益」为客户端在广告展示(onAdShow)时上报 eCPM 折算的预估值(每千次展示 ÷1000
|
||||
累加),<b>只要广告展示就计入、不论是否看完发奖</b>;穿山甲会过滤无效/过短曝光,故预估值可能偏高,
|
||||
累加);<b>激励视频提前关闭或播放时长不足时按 0 计</b>,其他有效展示按 eCPM 折算。穿山甲仍可能过滤无效曝光,
|
||||
<b>实际收益一律以穿山甲后台结算为准</b>。测试应用多为 0。「广告位ID / 来源应用」为本期新增,历史记录留空。
|
||||
<br />
|
||||
<br />
|
||||
|
||||
@@ -10,9 +10,11 @@ import {
|
||||
DatePicker,
|
||||
Divider,
|
||||
Input,
|
||||
Popover,
|
||||
Row,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Statistic,
|
||||
Table,
|
||||
Tag,
|
||||
@@ -72,9 +74,23 @@ interface CouponDataRow {
|
||||
app_env: string | null;
|
||||
started_at: string;
|
||||
claimed_count: number | null;
|
||||
point_success_count: number | null;
|
||||
point_total_count: number | null;
|
||||
// 兼容旧后端的内嵌明细;新后端不再返回,改为点击后按 trace 加载。
|
||||
point_details?: CouponPointDetail[];
|
||||
trace_url: string | null;
|
||||
ad_revenue_yuan: number | null; // 本次领券看的信息流广告预估收益(元);未填充为 null
|
||||
}
|
||||
interface CouponPointDetail {
|
||||
coupon_id: string;
|
||||
coupon_name: string | null;
|
||||
status: string;
|
||||
reason: string | null;
|
||||
}
|
||||
interface CouponPointDetailsOut {
|
||||
trace_id: string;
|
||||
items: CouponPointDetail[];
|
||||
}
|
||||
interface CouponDataReport {
|
||||
date_from: string;
|
||||
date_to: string;
|
||||
@@ -116,6 +132,100 @@ const STATUS_TAG: Record<string, { color: string; label: string }> = {
|
||||
abandoned: { color: 'orange', label: '中途退出' },
|
||||
};
|
||||
|
||||
const POINT_STATUS_TAG: Record<string, { color: string; label: string }> = {
|
||||
success: { color: 'success', label: '成功' },
|
||||
already_claimed: { color: 'processing', label: '已领' },
|
||||
failed: { color: 'error', label: '失败' },
|
||||
skipped: { color: 'default', label: '跳过' },
|
||||
};
|
||||
|
||||
function PointScorePopover({ row }: { row: CouponDataRow }) {
|
||||
const { message } = App.useApp();
|
||||
const [details, setDetails] = useState<CouponPointDetail[] | null>(row.point_details ?? null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [loadError, setLoadError] = useState<string | null>(null);
|
||||
|
||||
if (row.point_success_count == null || row.point_total_count == null || row.point_total_count <= 0) {
|
||||
return <Typography.Text type="secondary">-</Typography.Text>;
|
||||
}
|
||||
const score = `${row.point_success_count}/${row.point_total_count}`;
|
||||
const scoreColor =
|
||||
row.point_success_count === row.point_total_count
|
||||
? STATUS_TAG.completed.color
|
||||
: STATUS_TAG.abandoned.color;
|
||||
const loadDetails = async () => {
|
||||
if (details !== null || loading) return;
|
||||
setLoading(true);
|
||||
setLoadError(null);
|
||||
try {
|
||||
const response = await api.get<CouponPointDetailsOut>('/admin/api/coupon-data/point-details', {
|
||||
params: { trace_id: row.trace_id },
|
||||
});
|
||||
setDetails(response.data.items);
|
||||
} catch (error) {
|
||||
const errorMessage = errMsg(error);
|
||||
setLoadError(errorMessage);
|
||||
message.error(errorMessage);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover
|
||||
trigger="click"
|
||||
placement="bottomLeft"
|
||||
title={`点位明细(${score})`}
|
||||
onOpenChange={(open) => {
|
||||
if (open) void loadDetails();
|
||||
}}
|
||||
content={(
|
||||
<div style={{ width: 380, maxHeight: 360, overflowY: 'auto' }}>
|
||||
{loading || (details === null && loadError === null) ? (
|
||||
<Spin size="small" style={{ display: 'block', margin: '24px auto' }} />
|
||||
) : loadError ? (
|
||||
<Typography.Text type="danger">明细加载失败,请关闭后重试</Typography.Text>
|
||||
) : details && details.length > 0 ? details.map((point, index) => {
|
||||
const status = POINT_STATUS_TAG[point.status] ?? {
|
||||
color: 'default', label: point.status,
|
||||
};
|
||||
return (
|
||||
<div
|
||||
key={`${point.coupon_id}-${index}`}
|
||||
style={{
|
||||
padding: '8px 0',
|
||||
borderBottom: index < details.length - 1 ? '1px solid #f0f0f0' : undefined,
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 12 }}>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<Typography.Text>{point.coupon_name || point.coupon_id}</Typography.Text>
|
||||
{point.coupon_name ? (
|
||||
<div><Typography.Text type="secondary">{point.coupon_id}</Typography.Text></div>
|
||||
) : null}
|
||||
</div>
|
||||
<Tag color={status.color} style={{ marginInlineEnd: 0 }}>{status.label}</Tag>
|
||||
</div>
|
||||
{point.reason ? (
|
||||
<div style={{ marginTop: 4 }}>
|
||||
<Typography.Text type="danger">原因:{point.reason}</Typography.Text>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}) : (
|
||||
<Typography.Text type="secondary">暂无点位明细</Typography.Text>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
>
|
||||
<Button type="link" size="small" style={{ height: 'auto', padding: 0, color: scoreColor }}>
|
||||
{score}
|
||||
</Button>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
// ms → "1.5s"(空值显示 -)
|
||||
const fmtSec = (ms: number | null | undefined): string =>
|
||||
ms == null ? '-' : `${(ms / 1000).toFixed(1)}s`;
|
||||
@@ -492,20 +602,10 @@ export default function CouponDataPage() {
|
||||
render: (v: number | null) => fmtSec(v),
|
||||
},
|
||||
{
|
||||
title: '点位成功率',
|
||||
title: '百分比',
|
||||
key: 'point_success_rate',
|
||||
width: 110,
|
||||
render: (_: unknown, r: CouponDataRow) => (
|
||||
<Tooltip title="当前接口未返回本场应领点位及逐点结果,前端不使用全局均值冒充本场成功率。">
|
||||
{r.trace_url ? (
|
||||
<a href={r.trace_url} target="_blank" rel="noreferrer">
|
||||
查看明细
|
||||
</a>
|
||||
) : (
|
||||
<Typography.Text type="secondary">待埋点</Typography.Text>
|
||||
)}
|
||||
</Tooltip>
|
||||
),
|
||||
render: (_: unknown, r: CouponDataRow) => <PointScorePopover row={r} />,
|
||||
},
|
||||
{
|
||||
title: '广告收益',
|
||||
|
||||
@@ -499,12 +499,7 @@ export default function DashboardPage() {
|
||||
const tokenCostYuan = periodData?.comparison.token_cost_total_yuan ?? null;
|
||||
const couponRewardCoinTotal = periodData?.coins.coupon_reward_coin_total;
|
||||
const comparisonRewardCoinTotal = periodData?.coins.comparison_reward_coin_total;
|
||||
const signinCoinTotal = periodData?.coins.signin_coin_total;
|
||||
const signinBoostCoinTotal = periodData?.coins.signin_boost_coin_total;
|
||||
const taskCoinTotal = periodData?.coins.task_coin_total;
|
||||
const regularTaskCoinTotal =
|
||||
periodData?.coins.regular_task_coin_total ??
|
||||
((signinCoinTotal ?? 0) + (signinBoostCoinTotal ?? 0) + (taskCoinTotal ?? 0));
|
||||
const regularTaskCoinTotal = periodData?.coins.regular_task_coin_total;
|
||||
const cpsAvailable = data?.cps.available === true;
|
||||
const meituanCpsCommissionCents = data?.cps.meituan_commission_cents;
|
||||
const jdCpsCommissionCents = data?.cps.jd_commission_cents;
|
||||
@@ -1077,6 +1072,7 @@ export default function DashboardPage() {
|
||||
value={fmtInt(regularTaskCoinTotal)}
|
||||
delta={regularTaskCoinRatio.value}
|
||||
deltaTone={regularTaskCoinRatio.tone}
|
||||
hint="每日签到、历史签到膨胀、通知/其他任务、上报更低价和反馈采纳的实发金币之和。"
|
||||
/>
|
||||
<StatCard
|
||||
title="本期提现金额"
|
||||
|
||||
@@ -4,11 +4,15 @@ import { useEffect, useState } from 'react';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type { SorterResult } from 'antd/es/table/interface';
|
||||
import {
|
||||
App,
|
||||
Button,
|
||||
Card,
|
||||
DatePicker,
|
||||
Form,
|
||||
Image,
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
Statistic,
|
||||
@@ -21,6 +25,8 @@ import { api } from '@/lib/api';
|
||||
import { canDo } from '@/lib/auth';
|
||||
import { formatWallTime } from '@/lib/format';
|
||||
import { refreshReviewBadge } from '@/lib/reviewBadge';
|
||||
import { failedReviewIds } from '@/lib/bulkAction';
|
||||
import type { BulkReviewResult } from '@/lib/bulkAction';
|
||||
import { usePagedList } from '@/lib/usePagedList';
|
||||
import type { Feedback, FeedbackSummary } from '@/lib/types';
|
||||
import FeedbackHandleDrawer from './FeedbackHandleDrawer';
|
||||
@@ -28,6 +34,7 @@ import UserRecordsDrawer from '@/components/UserRecordsDrawer';
|
||||
|
||||
const { Text, Paragraph } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
const REWARD_MAX = 10000;
|
||||
|
||||
// 截图是 app-server 的 /media 相对路径,本地由 :8770 提供(NEXT_PUBLIC_MEDIA_BASE);生产同域走 nginx 代理。
|
||||
const MEDIA_BASE = process.env.NEXT_PUBLIC_MEDIA_BASE || '';
|
||||
@@ -155,6 +162,8 @@ const RECORD_COLUMNS: ColumnsType<Feedback> = [
|
||||
];
|
||||
|
||||
export default function FeedbacksPage() {
|
||||
const { message } = App.useApp();
|
||||
const [bulkForm] = Form.useForm();
|
||||
// 筛选草稿:点「查询」才应用(避免输入即刷新)
|
||||
const [status, setStatus] = useState<string | undefined>();
|
||||
const [source, setSource] = useState<string | undefined>();
|
||||
@@ -171,6 +180,19 @@ export default function FeedbacksPage() {
|
||||
usePagedList<Feedback>('/admin/api/feedbacks', filters);
|
||||
|
||||
const canReview = canDo(['operator']);
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
|
||||
const [bulkAction, setBulkAction] = useState<'approve' | 'reject' | null>(null);
|
||||
const [bulkSubmitting, setBulkSubmitting] = useState(false);
|
||||
const selectedFeedbacks = items.filter(
|
||||
(item) => selectedRowKeys.includes(item.id) && isPending(item.status),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const visiblePendingIds = new Set(
|
||||
items.filter((item) => isPending(item.status)).map((item) => item.id),
|
||||
);
|
||||
setSelectedRowKeys((keys) => keys.filter((id) => visiblePendingIds.has(id)));
|
||||
}, [items]);
|
||||
|
||||
const [summary, setSummary] = useState<FeedbackSummary | null>(null);
|
||||
const loadSummary = async () => {
|
||||
@@ -236,6 +258,55 @@ export default function FeedbacksPage() {
|
||||
const sortOrderOf = (field: SortField) =>
|
||||
sortBy === field ? (sortOrder === 'asc' ? 'ascend' : 'descend') : null;
|
||||
|
||||
const openBulkModal = (action: 'approve' | 'reject') => {
|
||||
if (!selectedFeedbacks.length) return;
|
||||
bulkForm.resetFields();
|
||||
setBulkAction(action);
|
||||
};
|
||||
|
||||
const submitBulkReview = async () => {
|
||||
if (!bulkAction || !selectedFeedbacks.length) return;
|
||||
const values = await bulkForm.validateFields();
|
||||
const targets = selectedFeedbacks;
|
||||
setBulkSubmitting(true);
|
||||
try {
|
||||
const { data } = await api.post<BulkReviewResult>(
|
||||
`/admin/api/feedbacks/bulk/${bulkAction}`,
|
||||
bulkAction === 'approve'
|
||||
? {
|
||||
ids: targets.map((item) => item.id),
|
||||
reward_coins: values.reward_coins,
|
||||
note: values.note?.trim() || null,
|
||||
reply: values.reply?.trim() || null,
|
||||
}
|
||||
: {
|
||||
ids: targets.map((item) => item.id),
|
||||
reason: values.reason.trim(),
|
||||
note: values.note?.trim() || null,
|
||||
reply: values.reply?.trim() || null,
|
||||
},
|
||||
);
|
||||
const failedIds = failedReviewIds(data);
|
||||
setSelectedRowKeys(failedIds);
|
||||
setBulkAction(null);
|
||||
bulkForm.resetFields();
|
||||
if (failedIds.length) reload();
|
||||
else onPageChange(1, pageSize);
|
||||
loadSummary();
|
||||
refreshReviewBadge('/feedbacks');
|
||||
const label = bulkAction === 'approve' ? '批量采纳' : '批量拒绝';
|
||||
if (failedIds.length) {
|
||||
message.warning(
|
||||
`${label}完成:成功 ${data.success} 条,失败 ${failedIds.length} 条;失败项已保留勾选`,
|
||||
);
|
||||
} else {
|
||||
message.success(`${label}完成:成功 ${data.success} 条`);
|
||||
}
|
||||
} finally {
|
||||
setBulkSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns: ColumnsType<Feedback> = [
|
||||
{
|
||||
title: '用户ID',
|
||||
@@ -411,10 +482,45 @@ export default function FeedbacksPage() {
|
||||
<Button onClick={resetFilters}>重置</Button>
|
||||
</Space>
|
||||
|
||||
{canReview && (
|
||||
<Space wrap style={{ display: 'flex', marginBottom: 12 }}>
|
||||
<Text>已选 <Text strong>{selectedFeedbacks.length}</Text> 条待审核反馈</Text>
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!selectedFeedbacks.length}
|
||||
onClick={() => openBulkModal('approve')}
|
||||
>
|
||||
批量采纳
|
||||
</Button>
|
||||
<Button
|
||||
danger
|
||||
disabled={!selectedFeedbacks.length}
|
||||
onClick={() => openBulkModal('reject')}
|
||||
>
|
||||
批量拒绝
|
||||
</Button>
|
||||
{!!selectedFeedbacks.length && (
|
||||
<Button onClick={() => setSelectedRowKeys([])}>取消选择</Button>
|
||||
)}
|
||||
</Space>
|
||||
)}
|
||||
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={items}
|
||||
rowSelection={
|
||||
canReview
|
||||
? {
|
||||
selectedRowKeys,
|
||||
onChange: (keys) => setSelectedRowKeys(keys as number[]),
|
||||
getCheckboxProps: (record) => ({
|
||||
disabled: !isPending(record.status),
|
||||
name: `选择反馈 #${record.id}`,
|
||||
}),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
loading={loading}
|
||||
pagination={{
|
||||
current: page,
|
||||
@@ -428,6 +534,88 @@ export default function FeedbacksPage() {
|
||||
scroll={{ x: 1720 }}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title={
|
||||
bulkAction === 'approve'
|
||||
? `批量采纳 ${selectedFeedbacks.length} 条反馈`
|
||||
: `批量拒绝 ${selectedFeedbacks.length} 条反馈`
|
||||
}
|
||||
open={bulkAction != null}
|
||||
okText={bulkAction === 'approve' ? '批量采纳并发金币' : '确认批量拒绝'}
|
||||
okButtonProps={{ danger: bulkAction === 'reject' }}
|
||||
confirmLoading={bulkSubmitting}
|
||||
onOk={submitBulkReview}
|
||||
onCancel={() => {
|
||||
if (bulkSubmitting) return;
|
||||
setBulkAction(null);
|
||||
bulkForm.resetFields();
|
||||
}}
|
||||
destroyOnHidden
|
||||
>
|
||||
<Text type="secondary">
|
||||
下列设置会统一应用到已选的 {selectedFeedbacks.length}
|
||||
条反馈。批量操作前请确认每条内容适用相同处理结果。
|
||||
</Text>
|
||||
<Form form={bulkForm} layout="vertical" preserve={false} style={{ marginTop: 16 }}>
|
||||
{bulkAction === 'approve' ? (
|
||||
<Form.Item
|
||||
name="reward_coins"
|
||||
label={`每条奖励金币(必填,1 ~ ${REWARD_MAX})`}
|
||||
rules={[
|
||||
{ required: true, message: '请输入每条反馈的奖励金币' },
|
||||
{ type: 'number', min: 1, max: REWARD_MAX, message: `请输入 1 ~ ${REWARD_MAX}` },
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={1}
|
||||
max={REWARD_MAX}
|
||||
style={{ width: '100%' }}
|
||||
placeholder="每条反馈发放相同金币"
|
||||
/>
|
||||
</Form.Item>
|
||||
) : (
|
||||
<Form.Item
|
||||
name="reason"
|
||||
label="未采纳原因(必填,用户可见)"
|
||||
rules={[
|
||||
{ required: true, whitespace: true, message: '请填写未采纳原因' },
|
||||
{ max: 256, message: '最多 256 字' },
|
||||
]}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={3}
|
||||
maxLength={256}
|
||||
showCount
|
||||
placeholder="同一原因将发送给全部已选用户"
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
<Form.Item
|
||||
name="note"
|
||||
label={
|
||||
bulkAction === 'approve'
|
||||
? '采纳要点 / 审核备注(选填,内部)'
|
||||
: '内部备注(选填)'
|
||||
}
|
||||
rules={[{ max: 256, message: '最多 256 字' }]}
|
||||
>
|
||||
<Input.TextArea rows={2} maxLength={256} showCount />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="reply"
|
||||
label="给用户的回复(选填,用户可见)"
|
||||
rules={[{ max: 256, message: '最多 256 字' }]}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={2}
|
||||
maxLength={256}
|
||||
showCount
|
||||
placeholder="同一回复将发送给全部已选用户"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<FeedbackHandleDrawer
|
||||
feedback={drawerFb}
|
||||
open={drawerOpen}
|
||||
|
||||
@@ -67,8 +67,6 @@ const NAV_GROUPS: NavGroup[] = [
|
||||
{ key: '/comparison-records', icon: <ProfileOutlined />, label: '比价记录' },
|
||||
{ key: '/coupon-data', icon: <GiftOutlined />, label: '领券记录' },
|
||||
{ key: '/cps', icon: <ShareAltOutlined />, label: 'CPS收益' },
|
||||
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
|
||||
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -92,9 +90,18 @@ const NAV_GROUPS: NavGroup[] = [
|
||||
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'monitoring-audit',
|
||||
icon: <FileSearchOutlined />,
|
||||
label: '监控审计',
|
||||
children: [
|
||||
{ key: '/device-liveness', icon: <HeartOutlined />, label: '设备存活' },
|
||||
{ key: '/analytics-health', icon: <LineChartOutlined />, label: '埋点成功率' },
|
||||
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
||||
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
||||
],
|
||||
},
|
||||
{ key: '/admins', icon: <TeamOutlined />, label: '权限管理' },
|
||||
{ key: '/event-logs', icon: <DatabaseOutlined />, label: '埋点日志' },
|
||||
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
||||
];
|
||||
|
||||
// 导航项 key(/dashboard)→ 权限页 key(dashboard),与后端 permissions.py 目录对齐
|
||||
|
||||
@@ -23,6 +23,8 @@ import { api, errMsg } from '@/lib/api';
|
||||
import { canDo } from '@/lib/auth';
|
||||
import { mediaUrl } from '@/lib/media';
|
||||
import { refreshReviewBadge } from '@/lib/reviewBadge';
|
||||
import { failedReviewIds } from '@/lib/bulkAction';
|
||||
import type { BulkReviewResult } from '@/lib/bulkAction';
|
||||
import { usePagedList } from '@/lib/usePagedList';
|
||||
import type { PriceReport, PriceReportSummary } from '@/lib/types';
|
||||
import UserRecordsDrawer from '@/components/UserRecordsDrawer';
|
||||
@@ -132,7 +134,10 @@ export default function PriceReportsPage() {
|
||||
const [activeStatus, setActiveStatus] = useState('pending');
|
||||
const [summary, setSummary] = useState<PriceReportSummary | null>(null);
|
||||
const [rejecting, setRejecting] = useState<PriceReport | null>(null);
|
||||
const [bulkRejecting, setBulkRejecting] = useState<PriceReport[]>([]);
|
||||
const [rejectReason, setRejectReason] = useState('');
|
||||
const [rejectSubmitting, setRejectSubmitting] = useState(false);
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
|
||||
// 提交时间列服务端排序(默认按提交时间倒序,最新在前)
|
||||
const [sortBy, setSortBy] = useState<SortField>('created_at');
|
||||
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
|
||||
@@ -165,6 +170,16 @@ export default function PriceReportsPage() {
|
||||
};
|
||||
|
||||
const canReview = canDo(['operator']);
|
||||
const selectedReports = items.filter(
|
||||
(item) => selectedRowKeys.includes(item.id) && item.status === 'pending',
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const visiblePendingIds = new Set(
|
||||
items.filter((item) => item.status === 'pending').map((item) => item.id),
|
||||
);
|
||||
setSelectedRowKeys((keys) => keys.filter((id) => visiblePendingIds.has(id)));
|
||||
}, [items]);
|
||||
|
||||
const loadSummary = async () => {
|
||||
try {
|
||||
@@ -183,6 +198,37 @@ export default function PriceReportsPage() {
|
||||
loadSummary();
|
||||
};
|
||||
|
||||
const reportBulkResult = (label: string, succeeded: number, failedIds: number[]) => {
|
||||
setSelectedRowKeys(failedIds);
|
||||
refreshReviewBadge('/price-reports');
|
||||
loadSummary();
|
||||
if (failedIds.length) reload();
|
||||
else onPageChange(1, pageSize);
|
||||
if (failedIds.length) {
|
||||
message.warning(`${label}完成:成功 ${succeeded} 条,失败 ${failedIds.length} 条;失败项已保留勾选`);
|
||||
} else {
|
||||
message.success(`${label}完成:成功 ${succeeded} 条`);
|
||||
}
|
||||
};
|
||||
|
||||
const bulkApprove = () => {
|
||||
const targets = selectedReports;
|
||||
if (!targets.length) return;
|
||||
modal.confirm({
|
||||
title: `确认批量通过 ${targets.length} 条低价上报?`,
|
||||
icon: <CheckCircleOutlined style={{ color: '#52c41a' }} />,
|
||||
content: `通过后将向每位用户发放 1000 金币,共发放 ${targets.length * 1000} 金币。请确认已逐条核实截图。`,
|
||||
okText: '批量通过并发金币',
|
||||
onOk: async () => {
|
||||
const { data } = await api.post<BulkReviewResult>(
|
||||
'/admin/api/price-reports/bulk/approve',
|
||||
{ ids: targets.map((item) => item.id) },
|
||||
);
|
||||
reportBulkResult('批量通过', data.success, failedReviewIds(data));
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const approve = (r: PriceReport) => {
|
||||
modal.confirm({
|
||||
title: '确认通过该上报?',
|
||||
@@ -214,21 +260,34 @@ export default function PriceReportsPage() {
|
||||
};
|
||||
|
||||
const confirmReject = async () => {
|
||||
if (!rejecting) return;
|
||||
const targets = bulkRejecting.length ? bulkRejecting : rejecting ? [rejecting] : [];
|
||||
if (!targets.length) return;
|
||||
const reason = rejectReason.trim();
|
||||
if (!reason) {
|
||||
message.warning('请填写拒绝理由');
|
||||
return;
|
||||
}
|
||||
setRejectSubmitting(true);
|
||||
try {
|
||||
await api.post(`/admin/api/price-reports/${rejecting.id}/reject`, { reason });
|
||||
refreshReviewBadge('/price-reports');
|
||||
message.success('已拒绝');
|
||||
if (bulkRejecting.length) {
|
||||
const { data } = await api.post<BulkReviewResult>(
|
||||
'/admin/api/price-reports/bulk/reject',
|
||||
{ ids: targets.map((item) => item.id), reason },
|
||||
);
|
||||
reportBulkResult('批量拒绝', data.success, failedReviewIds(data));
|
||||
} else {
|
||||
await api.post(`/admin/api/price-reports/${targets[0].id}/reject`, { reason });
|
||||
refreshReviewBadge('/price-reports');
|
||||
message.success('已拒绝');
|
||||
refreshAfterChange();
|
||||
}
|
||||
setRejecting(null);
|
||||
setBulkRejecting([]);
|
||||
setRejectReason('');
|
||||
refreshAfterChange();
|
||||
} catch (e) {
|
||||
message.error(errMsg(e));
|
||||
} finally {
|
||||
setRejectSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -393,10 +452,50 @@ export default function PriceReportsPage() {
|
||||
onChange={setActiveStatus}
|
||||
items={STATUS_TABS.map((t) => ({ key: t.key, label: t.label }))}
|
||||
/>
|
||||
{canReview && (
|
||||
<Space wrap style={{ marginBottom: 16 }}>
|
||||
<Text>已选 <Text strong>{selectedReports.length}</Text> 条待审核记录</Text>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<CheckCircleOutlined />}
|
||||
disabled={!selectedReports.length}
|
||||
onClick={bulkApprove}
|
||||
>
|
||||
批量通过
|
||||
</Button>
|
||||
<Button
|
||||
danger
|
||||
icon={<CloseCircleOutlined />}
|
||||
disabled={!selectedReports.length}
|
||||
onClick={() => {
|
||||
setRejecting(null);
|
||||
setBulkRejecting(selectedReports);
|
||||
setRejectReason('');
|
||||
}}
|
||||
>
|
||||
批量拒绝
|
||||
</Button>
|
||||
{!!selectedReports.length && (
|
||||
<Button onClick={() => setSelectedRowKeys([])}>取消选择</Button>
|
||||
)}
|
||||
</Space>
|
||||
)}
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={items}
|
||||
rowSelection={
|
||||
canReview
|
||||
? {
|
||||
selectedRowKeys,
|
||||
onChange: (keys) => setSelectedRowKeys(keys as number[]),
|
||||
getCheckboxProps: (record) => ({
|
||||
disabled: record.status !== 'pending',
|
||||
name: `选择低价上报 #${record.id}`,
|
||||
}),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
loading={loading}
|
||||
onChange={onTableChange}
|
||||
pagination={{
|
||||
@@ -412,21 +511,25 @@ export default function PriceReportsPage() {
|
||||
</Card>
|
||||
|
||||
<Modal
|
||||
title="拒绝上报"
|
||||
open={!!rejecting}
|
||||
title={bulkRejecting.length ? `批量拒绝 ${bulkRejecting.length} 条低价上报` : '拒绝上报'}
|
||||
open={!!(rejecting || bulkRejecting.length)}
|
||||
okText="确认拒绝"
|
||||
confirmLoading={rejectSubmitting}
|
||||
okButtonProps={{ danger: true, icon: <CloseCircleOutlined /> }}
|
||||
onOk={confirmReject}
|
||||
onCancel={() => {
|
||||
setRejecting(null);
|
||||
setBulkRejecting([]);
|
||||
setRejectReason('');
|
||||
}}
|
||||
>
|
||||
{rejecting && (
|
||||
{(rejecting || bulkRejecting.length > 0) && (
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<Text>
|
||||
用户 #{rejecting.user_id} · {rejecting.store_name || '-'}
|
||||
</Text>
|
||||
{bulkRejecting.length ? (
|
||||
<Text type="secondary">以下原因会统一应用到已选的 {bulkRejecting.length} 条记录。</Text>
|
||||
) : rejecting ? (
|
||||
<Text>用户 #{rejecting.user_id} · {rejecting.store_name || '-'}</Text>
|
||||
) : null}
|
||||
<Space wrap>
|
||||
{REJECT_TEMPLATES.map((tpl) => (
|
||||
<Button size="small" key={tpl} onClick={() => setRejectReason(tpl)}>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export interface BulkReviewItemResult {
|
||||
id: number;
|
||||
ok: boolean;
|
||||
status: string | null;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export interface BulkReviewResult {
|
||||
total: number;
|
||||
success: number;
|
||||
failed: number;
|
||||
items: BulkReviewItemResult[];
|
||||
}
|
||||
|
||||
export function failedReviewIds(result: BulkReviewResult): number[] {
|
||||
return result.items.filter((item) => !item.ok).map((item) => item.id);
|
||||
}
|
||||
+1
-1
@@ -488,7 +488,7 @@ export interface AdRevenueRow {
|
||||
has_impression: boolean; // 是否有广告展示(信息流逐条展示=true,纯发奖行=false)
|
||||
impressions: number; // 本行展示条数 1/0(供日汇总、趋势图复用)
|
||||
ecpm: string | null; // 分/千次;展示行取展示值,纯发奖行取发奖采用值
|
||||
revenue_yuan: number; // 本次展示预估收益(元);纯发奖行=0
|
||||
revenue_yuan: number; // 本次有效展示预估收益(元);纯发奖、激励视频提前关闭/时长不足=0
|
||||
row_revenue_yuan?: number | null; // 主表逐行显示用:一次比价/领券聚合行=该次发奖广告 eCPM 折算之和;其它行空(回退 revenue_yuan)
|
||||
adn: string | null; // 实际填充 ADN;纯发奖行为空
|
||||
slot_id: string | null; // 底层 mediation rit;纯发奖行为空
|
||||
|
||||
Reference in New Issue
Block a user