Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2880a8a118 | |||
| e99c79b4d4 |
@@ -15,8 +15,6 @@ interface UserOverviewResp {
|
|||||||
id: number;
|
id: number;
|
||||||
phone: string;
|
phone: string;
|
||||||
nickname: string | null;
|
nickname: string | null;
|
||||||
is_high_risk: boolean;
|
|
||||||
high_risk_note: string | null;
|
|
||||||
status: string;
|
status: string;
|
||||||
wechat_nickname: string | null;
|
wechat_nickname: string | null;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
@@ -51,8 +49,6 @@ export default function UserAdRevenueDrawer({ open, onClose, userId, phone }: Pr
|
|||||||
id: o.user.id,
|
id: o.user.id,
|
||||||
phone: o.user.phone,
|
phone: o.user.phone,
|
||||||
nickname: o.user.nickname,
|
nickname: o.user.nickname,
|
||||||
is_high_risk: o.user.is_high_risk,
|
|
||||||
high_risk_note: o.user.high_risk_note,
|
|
||||||
status: o.user.status,
|
status: o.user.status,
|
||||||
wechat_nickname: o.user.wechat_nickname, // 概览接口已返回微信昵称
|
wechat_nickname: o.user.wechat_nickname, // 概览接口已返回微信昵称
|
||||||
wechat_avatar_url: null,
|
wechat_avatar_url: null,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
Col,
|
Col,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
|
Descriptions,
|
||||||
Divider,
|
Divider,
|
||||||
InputNumber,
|
InputNumber,
|
||||||
Modal,
|
Modal,
|
||||||
@@ -42,8 +43,6 @@ import type {
|
|||||||
import UserAdRevenueDrawer from './UserAdRevenueDrawer';
|
import UserAdRevenueDrawer from './UserAdRevenueDrawer';
|
||||||
|
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
const DEFAULT_PAGE_SIZE = 50;
|
|
||||||
const ALL_FILTER_VALUE = '__all__';
|
|
||||||
|
|
||||||
// 广告类型标签
|
// 广告类型标签
|
||||||
const TYPE_TAG: Record<string, { color: string; label: string }> = {
|
const TYPE_TAG: Record<string, { color: string; label: string }> = {
|
||||||
@@ -191,76 +190,11 @@ const LT_FACTOR_ROWS = [
|
|||||||
{ key: '5', lt: '第 11 条及以后', factor: 1.0 },
|
{ key: '5', lt: '第 11 条及以后', factor: 1.0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
type AdRevenueDetailRow = AdRevenueRecord & {
|
type AdRevenueDetailRow = AdRevenueRecord & { source_adn?: string | null };
|
||||||
source_adn?: string | null;
|
|
||||||
is_impression_only?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const FORMULA_EMPTY_STATUS_LABEL: Record<string, string> = {
|
|
||||||
capped: '次数超限',
|
|
||||||
ecpm_missing: 'eCPM 缺失',
|
|
||||||
too_short: '观看时长不足',
|
|
||||||
closed_early: '提前关闭',
|
|
||||||
impression_only: '仅展示',
|
|
||||||
};
|
|
||||||
|
|
||||||
// 未发奖记录用可读状态代替空值,避免误认为数据丢失;悬停时说明为何没有计算因子。
|
|
||||||
function renderFormulaValue(value: string | number, row: AdRevenueDetailRow) {
|
|
||||||
if (value !== '-') return value;
|
|
||||||
const isGrantedButMissing = row.status === 'granted';
|
|
||||||
const reason = isGrantedButMissing
|
|
||||||
? '该记录标记为已发奖,但计算因子缺失,需要进一步排查'
|
|
||||||
: row.is_impression_only
|
|
||||||
? '该记录只有广告展示,没有对应发奖记录'
|
|
||||||
: REWARD_STATUS_HINT[row.status] ?? `发奖状态为 ${row.status || '未知'}`;
|
|
||||||
const statusLabel = isGrantedButMissing
|
|
||||||
? '计算数据缺失'
|
|
||||||
: (FORMULA_EMPTY_STATUS_LABEL[row.status] ?? row.status) || '未进入计算';
|
|
||||||
return (
|
|
||||||
<Tooltip
|
|
||||||
title={isGrantedButMissing
|
|
||||||
? reason
|
|
||||||
: `${reason};未进入金币计算,不占用 LT 累计条数,因此不展示因子。`}
|
|
||||||
>
|
|
||||||
<span>{statusLabel}</span>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function impressionOnlyDetail(row: AdRevenueRow): AdRevenueDetailRow {
|
|
||||||
return {
|
|
||||||
record_id: 0,
|
|
||||||
created_at: row.created_at,
|
|
||||||
status: 'impression_only',
|
|
||||||
ecpm: row.ecpm,
|
|
||||||
ecpm_factor: null,
|
|
||||||
units: 0,
|
|
||||||
lt_index_start: null,
|
|
||||||
lt_index_end: null,
|
|
||||||
lt_factor_start: null,
|
|
||||||
lt_factor_end: null,
|
|
||||||
expected_coin: 0,
|
|
||||||
actual_coin: 0,
|
|
||||||
matched: true,
|
|
||||||
adn: row.adn,
|
|
||||||
slot_id: row.slot_id,
|
|
||||||
source_adn: row.adn,
|
|
||||||
is_impression_only: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 展开行(逐条事件展开)- 该条的发奖复算明细(还原金币审计的 eCPM/因子1/份数/LT/因子2 等列)
|
// 展开行(逐条事件展开)- 该条的发奖复算明细(还原金币审计的 eCPM/因子1/份数/LT/因子2 等列)
|
||||||
const DETAIL_COLUMNS: ColumnsType<AdRevenueDetailRow> = [
|
const DETAIL_COLUMNS: ColumnsType<AdRevenueDetailRow> = [
|
||||||
{
|
{ title: '来源广告网络', dataIndex: 'source_adn', width: 110, render: (value: string | null) => value || '-' },
|
||||||
title: '来源广告网络',
|
|
||||||
dataIndex: 'source_adn',
|
|
||||||
width: 110,
|
|
||||||
render: (value: string | null) => value?.trim() || (
|
|
||||||
<Tooltip title="该历史记录没有可唯一确认的 SDK 广告来源,未猜测填充。">
|
|
||||||
<span>未上报</span>
|
|
||||||
</Tooltip>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'eCPM(元)',
|
title: 'eCPM(元)',
|
||||||
dataIndex: 'ecpm',
|
dataIndex: 'ecpm',
|
||||||
@@ -274,25 +208,18 @@ const DETAIL_COLUMNS: ColumnsType<AdRevenueDetailRow> = [
|
|||||||
render: (v: string | null) => (v == null || Number.isNaN(Number(v)) ? '-' : (Number(v) / 100 / 1000).toFixed(4)),
|
render: (v: string | null) => (v == null || Number.isNaN(Number(v)) ? '-' : (Number(v) / 100 / 1000).toFixed(4)),
|
||||||
},
|
},
|
||||||
{ title: '实发金币数', dataIndex: 'actual_coin', width: 100 },
|
{ title: '实发金币数', dataIndex: 'actual_coin', width: 100 },
|
||||||
{
|
{ title: '因子1', dataIndex: 'ecpm_factor', width: 70, render: (v: number | null) => v ?? '-' },
|
||||||
title: '因子1',
|
|
||||||
dataIndex: 'ecpm_factor',
|
|
||||||
width: 70,
|
|
||||||
render: (v: number | null, row: AdRevenueDetailRow) => renderFormulaValue(v ?? '-', row),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '因子2',
|
title: '因子2',
|
||||||
key: 'lt_factor',
|
key: 'lt_factor',
|
||||||
width: 90,
|
width: 90,
|
||||||
render: (_: unknown, row: AdRevenueDetailRow) =>
|
render: (_: unknown, r: AdRevenueDetailRow) => fmtFactorRange(r.lt_factor_start, r.lt_factor_end),
|
||||||
renderFormulaValue(fmtFactorRange(row.lt_factor_start, row.lt_factor_end), row),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'LT累计条数',
|
title: 'LT累计条数',
|
||||||
key: 'lt_index',
|
key: 'lt_index',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (_: unknown, row: AdRevenueDetailRow) =>
|
render: (_: unknown, r: AdRevenueDetailRow) => fmtIndexRange(r.lt_index_start, r.lt_index_end),
|
||||||
renderFormulaValue(fmtIndexRange(row.lt_index_start, row.lt_index_end), row),
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -460,13 +387,13 @@ export default function AdRevenueReportPage() {
|
|||||||
const [scene, setScene] = useState<string | undefined>();
|
const [scene, setScene] = useState<string | undefined>();
|
||||||
const [granularity, setGranularity] = useState<'day' | 'hour'>('day');
|
const [granularity, setGranularity] = useState<'day' | 'hour'>('day');
|
||||||
const [sortBy, setSortBy] = useState<'time' | 'ecpm'>('time'); // 明细排序:time=时间倒序 / ecpm=eCPM 倒序
|
const [sortBy, setSortBy] = useState<'time' | 'ecpm'>('time'); // 明细排序:time=时间倒序 / ecpm=eCPM 倒序
|
||||||
const [limit, setLimit] = useState<number>(DEFAULT_PAGE_SIZE);
|
const [limit, setLimit] = useState<number>(1000); // 默认拉满接口单页上限,供单次流程广告数分位统计
|
||||||
const [page, setPage] = useState<number>(1); // 当前页码(后端分页;1 起)
|
const [page, setPage] = useState<number>(1); // 当前页码(后端分页;1 起)
|
||||||
const [queriedGranularity, setQueriedGranularity] = useState<'day' | 'hour'>('day'); // 本次结果对应的粒度,决定是否显示「小时」列
|
const [queriedGranularity, setQueriedGranularity] = useState<'day' | 'hour'>('day'); // 本次结果对应的粒度,决定是否显示「小时」列
|
||||||
const [queriedMultiDay, setQueriedMultiDay] = useState(false); // 本次结果是否跨多天,决定显示「日期」列 + 按天/按小时图
|
const [queriedMultiDay, setQueriedMultiDay] = useState(false); // 本次结果是否跨多天,决定显示「日期」列 + 按天/按小时图
|
||||||
const [data, setData] = useState<AdRevenueReport | null>(null);
|
const [data, setData] = useState<AdRevenueReport | null>(null);
|
||||||
const [allFlowItems, setAllFlowItems] = useState<AdRevenueRow[]>([]);
|
const [allFlowItems, setAllFlowItems] = useState<AdRevenueRow[]>([]);
|
||||||
const [queriedLimit, setQueriedLimit] = useState<number>(DEFAULT_PAGE_SIZE);
|
const [queriedLimit, setQueriedLimit] = useState<number>(1000);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [formulaOpen, setFormulaOpen] = useState(false);
|
const [formulaOpen, setFormulaOpen] = useState(false);
|
||||||
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
|
// 点用户手机号弹出的「用户广告收益详情」半屏抽屉(userId + 手机号;null=关闭)
|
||||||
@@ -734,21 +661,11 @@ export default function AdRevenueReportPage() {
|
|||||||
: data.date_from
|
: data.date_from
|
||||||
: `${data.date_from} ~ ${data.date_to}`;
|
: `${data.date_from} ~ ${data.date_to}`;
|
||||||
|
|
||||||
// 第二行大盘「分广告类型」:看视频包含福利视频与提现视频;
|
// 第二行大盘「分广告类型」:draw / 激励视频 各自 收益 / eCPM / 展示条数;eCPM = 收益÷展示×1000。
|
||||||
// eCPM 优先使用后端按真实展示加权的经营分类口径;兼容旧后端时才用合并收益÷展示数回退。
|
|
||||||
const drawStat = data?.type_stats?.draw;
|
const drawStat = data?.type_stats?.draw;
|
||||||
const rewardVideoStat = data?.type_stats?.reward_video;
|
const rvStat = data?.type_stats?.reward_video;
|
||||||
const withdrawalVideoStat = data?.type_stats?.withdrawal_video;
|
|
||||||
const videoStat: AdRevenueTypeStat = {
|
|
||||||
impressions:
|
|
||||||
(rewardVideoStat?.impressions ?? 0) + (withdrawalVideoStat?.impressions ?? 0),
|
|
||||||
revenue_yuan:
|
|
||||||
(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 ?? [];
|
||||||
@@ -858,11 +775,12 @@ export default function AdRevenueReportPage() {
|
|||||||
<Space size={6}>
|
<Space size={6}>
|
||||||
<Typography.Text type="secondary">类型</Typography.Text>
|
<Typography.Text type="secondary">类型</Typography.Text>
|
||||||
<Select
|
<Select
|
||||||
value={adType ?? ALL_FILTER_VALUE}
|
placeholder="全部"
|
||||||
onChange={(value) => setAdType(value === ALL_FILTER_VALUE ? undefined : value)}
|
value={adType}
|
||||||
|
onChange={setAdType}
|
||||||
|
allowClear
|
||||||
style={{ width: 150 }}
|
style={{ width: 150 }}
|
||||||
options={[
|
options={[
|
||||||
{ value: ALL_FILTER_VALUE, label: '全部' },
|
|
||||||
{ value: 'reward_video', label: '看视频' },
|
{ value: 'reward_video', label: '看视频' },
|
||||||
{ value: 'draw', label: 'Draw 信息流' },
|
{ value: 'draw', label: 'Draw 信息流' },
|
||||||
{ value: 'withdrawal_video', label: '提现看视频' },
|
{ value: 'withdrawal_video', label: '提现看视频' },
|
||||||
@@ -872,11 +790,12 @@ export default function AdRevenueReportPage() {
|
|||||||
<Space size={6}>
|
<Space size={6}>
|
||||||
<Typography.Text type="secondary">场景</Typography.Text>
|
<Typography.Text type="secondary">场景</Typography.Text>
|
||||||
<Select
|
<Select
|
||||||
value={scene ?? ALL_FILTER_VALUE}
|
placeholder="全部"
|
||||||
onChange={(value) => setScene(value === ALL_FILTER_VALUE ? undefined : value)}
|
value={scene}
|
||||||
|
onChange={setScene}
|
||||||
|
allowClear
|
||||||
style={{ width: 130 }}
|
style={{ width: 130 }}
|
||||||
options={[
|
options={[
|
||||||
{ value: ALL_FILTER_VALUE, label: '全部' },
|
|
||||||
{ value: 'comparison', label: '比价' },
|
{ value: 'comparison', label: '比价' },
|
||||||
{ value: 'coupon', label: '领券' },
|
{ value: 'coupon', label: '领券' },
|
||||||
{ value: 'welfare', label: '福利' },
|
{ value: 'welfare', label: '福利' },
|
||||||
@@ -1062,19 +981,19 @@ 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} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="看视频收益(元)" value={videoStat.revenue_yuan} precision={4} />
|
<Statistic title="看视频收益(元)" value={rvStat?.revenue_yuan ?? 0} precision={4} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="看视频 eCPM(元/千次)" value={ecpmOf(videoEcpmStat)} precision={2} />
|
<Statistic title="看视频 eCPM(元/千次)" value={ecpmOf(rvStat)} precision={2} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4}>
|
<Col span={4}>
|
||||||
<Statistic title="看视频条数" value={videoStat.impressions} />
|
<Statistic title="看视频条数" value={rvStat?.impressions ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
<Divider orientation="left" plain style={{ marginTop: 20, marginBottom: 16 }}>
|
||||||
@@ -1183,11 +1102,7 @@ export default function AdRevenueReportPage() {
|
|||||||
style={{ marginTop: 8 }}
|
style={{ marginTop: 8 }}
|
||||||
rowKey="record_id"
|
rowKey="record_id"
|
||||||
columns={DETAIL_COLUMNS}
|
columns={DETAIL_COLUMNS}
|
||||||
dataSource={r.sub_rewards.map((detail) => ({
|
dataSource={r.sub_rewards.map((detail) => ({ ...detail, source_adn: r.adn }))}
|
||||||
...detail,
|
|
||||||
// 一次比价/领券可能由不同 ADN 连续填充,优先显示本条发奖记录的来源。
|
|
||||||
source_adn: detail.adn ?? r.adn,
|
|
||||||
}))}
|
|
||||||
pagination={false}
|
pagination={false}
|
||||||
size="small"
|
size="small"
|
||||||
scroll={{ x: 900 }}
|
scroll={{ x: 900 }}
|
||||||
@@ -1203,10 +1118,7 @@ export default function AdRevenueReportPage() {
|
|||||||
style={{ marginTop: 8 }}
|
style={{ marginTop: 8 }}
|
||||||
rowKey="record_id"
|
rowKey="record_id"
|
||||||
columns={DETAIL_COLUMNS}
|
columns={DETAIL_COLUMNS}
|
||||||
dataSource={[{
|
dataSource={[{ ...r.reward_detail, source_adn: r.adn }]}
|
||||||
...r.reward_detail,
|
|
||||||
source_adn: r.reward_detail.adn ?? r.adn,
|
|
||||||
}]}
|
|
||||||
pagination={false}
|
pagination={false}
|
||||||
size="small"
|
size="small"
|
||||||
scroll={{ x: 900 }}
|
scroll={{ x: 900 }}
|
||||||
@@ -1214,19 +1126,24 @@ export default function AdRevenueReportPage() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<Typography.Text strong>本次广告逐条明细</Typography.Text>{' '}
|
<Typography.Text strong>展示明细</Typography.Text>{' '}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">(纯展示事件,未单独发奖,无金币复算)</Typography.Text>
|
||||||
(共 1 条 · 应发 0 / 实发 0;仅展示,未单独发奖)
|
<Descriptions size="small" column={3} bordered style={{ marginTop: 8 }}>
|
||||||
</Typography.Text>
|
<Descriptions.Item label="时间">{formatUtcTime(r.created_at)}</Descriptions.Item>
|
||||||
<Table<AdRevenueDetailRow>
|
<Descriptions.Item label="eCPM(分)">{r.ecpm ?? '-'}</Descriptions.Item>
|
||||||
style={{ marginTop: 8 }}
|
<Descriptions.Item label="eCPM(元)">
|
||||||
rowKey="record_id"
|
{r.ecpm != null && !Number.isNaN(Number(r.ecpm))
|
||||||
columns={DETAIL_COLUMNS}
|
? (Number(r.ecpm) / 100).toFixed(2)
|
||||||
dataSource={[impressionOnlyDetail(r)]}
|
: '-'}
|
||||||
pagination={false}
|
</Descriptions.Item>
|
||||||
size="small"
|
<Descriptions.Item label="预估收益(元)">
|
||||||
scroll={{ x: 900 }}
|
{r.has_impression ? r.revenue_yuan.toFixed(4) : '-'}
|
||||||
/>
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="底层 ADN">{r.adn ?? '-'}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="底层代码位(rit)">{r.slot_id ?? '-'}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="我方代码位">{r.our_code_id ?? '-'}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="来源应用">{r.app_env ?? '-'}</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -46,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;
|
||||||
@@ -343,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',
|
||||||
@@ -534,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>
|
||||||
|
|||||||
@@ -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 || '';
|
||||||
@@ -123,31 +122,13 @@ const renderReview = (f: Feedback) => {
|
|||||||
|
|
||||||
// 机型 / OS版本(提交反馈时的端环境;改版前历史反馈无 → -)
|
// 机型 / OS版本(提交反馈时的端环境;改版前历史反馈无 → -)
|
||||||
const renderDeviceOs = (f: Feedback) => {
|
const renderDeviceOs = (f: Feedback) => {
|
||||||
const modelName = f.device_model_name || f.device_model;
|
const os = [f.android_version ? `Android ${f.android_version}` : null, f.rom_name]
|
||||||
const rawModel =
|
|
||||||
f.device_model_name && f.device_model_name !== f.device_model ? f.device_model : null;
|
|
||||||
const romHasVersion = /\d/.test(f.rom_name || '');
|
|
||||||
const vendorOs = [
|
|
||||||
f.rom_name,
|
|
||||||
f.rom_version && !romHasVersion ? f.rom_version : null,
|
|
||||||
]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(' ');
|
|
||||||
const os = [
|
|
||||||
vendorOs || null,
|
|
||||||
f.android_version ? `Android ${f.android_version}` : null,
|
|
||||||
]
|
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(' · ');
|
.join(' · ');
|
||||||
if (!modelName && !os) return <Text type="secondary">-</Text>;
|
if (!f.device_model && !os) return <Text type="secondary">-</Text>;
|
||||||
return (
|
return (
|
||||||
<Space direction="vertical" size={0}>
|
<Space direction="vertical" size={0}>
|
||||||
<Text>{modelName || '-'}</Text>
|
<Text>{f.device_model || '-'}</Text>
|
||||||
{rawModel ? (
|
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
|
||||||
{[f.device_manufacturer, rawModel].filter(Boolean).join(' · ')}
|
|
||||||
</Text>
|
|
||||||
) : null}
|
|
||||||
{os ? (
|
{os ? (
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
{os}
|
{os}
|
||||||
@@ -197,10 +178,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 +195,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);
|
||||||
@@ -397,7 +352,7 @@ export default function FeedbacksPage() {
|
|||||||
{
|
{
|
||||||
title: '机型 / OS版本',
|
title: '机型 / OS版本',
|
||||||
key: 'device',
|
key: 'device',
|
||||||
width: 180,
|
width: 150,
|
||||||
render: (_: unknown, f: Feedback) => renderDeviceOs(f),
|
render: (_: unknown, f: Feedback) => renderDeviceOs(f),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
import { WithdrawReviewPage } from '../withdraws/WithdrawReviewPage';
|
|
||||||
|
|
||||||
export default function InviteWithdrawsPage() {
|
|
||||||
return <WithdrawReviewPage mode="invite" />;
|
|
||||||
}
|
|
||||||
+13
-49
@@ -37,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 = {
|
||||||
@@ -77,8 +75,7 @@ const NAV_GROUPS: NavGroup[] = [
|
|||||||
icon: <MoneyCollectOutlined />,
|
icon: <MoneyCollectOutlined />,
|
||||||
label: '奖励审核',
|
label: '奖励审核',
|
||||||
children: [
|
children: [
|
||||||
{ key: '/invite-withdraws', icon: <MoneyCollectOutlined />, label: '邀请提现审核' },
|
{ key: '/withdraws', icon: <MoneyCollectOutlined />, label: '提现审核' },
|
||||||
{ key: '/withdraws', icon: <MoneyCollectOutlined />, label: '其他提现审核' },
|
|
||||||
{ key: '/price-reports', icon: <FlagOutlined />, label: '低价审核' },
|
{ key: '/price-reports', icon: <FlagOutlined />, label: '低价审核' },
|
||||||
{ key: '/feedbacks', icon: <MessageOutlined />, label: '用户反馈' },
|
{ key: '/feedbacks', icon: <MessageOutlined />, label: '用户反馈' },
|
||||||
],
|
],
|
||||||
@@ -94,7 +91,6 @@ const NAV_GROUPS: NavGroup[] = [
|
|||||||
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ key: '/admins', icon: <TeamOutlined />, label: '权限管理' },
|
|
||||||
{
|
{
|
||||||
key: 'monitoring-audit',
|
key: 'monitoring-audit',
|
||||||
icon: <FileSearchOutlined />,
|
icon: <FileSearchOutlined />,
|
||||||
@@ -107,6 +103,7 @@ const NAV_GROUPS: NavGroup[] = [
|
|||||||
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
{ key: '/audit-logs', icon: <FileSearchOutlined />, label: '审计日志' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{ key: '/admins', icon: <TeamOutlined />, label: '权限管理' },
|
||||||
];
|
];
|
||||||
|
|
||||||
// 导航项 key(/dashboard)→ 权限页 key(dashboard),与后端 permissions.py 目录对齐
|
// 导航项 key(/dashboard)→ 权限页 key(dashboard),与后端 permissions.py 目录对齐
|
||||||
@@ -147,13 +144,8 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
const version = (reviewRefreshVersion.current[key] ?? 0) + 1;
|
const version = (reviewRefreshVersion.current[key] ?? 0) + 1;
|
||||||
reviewRefreshVersion.current[key] = version;
|
reviewRefreshVersion.current[key] = version;
|
||||||
let count: number;
|
let count: number;
|
||||||
if (key === '/withdraws' || key === '/invite-withdraws') {
|
if (key === '/withdraws') {
|
||||||
const source = key === '/invite-withdraws' ? 'invite_cash' : 'coin_cash';
|
count = (await api.get<WithdrawSummary>('/admin/api/withdraws/summary')).data.reviewing_count;
|
||||||
count = (
|
|
||||||
await api.get<WithdrawSummary>('/admin/api/withdraws/summary', {
|
|
||||||
params: { source },
|
|
||||||
})
|
|
||||||
).data.reviewing_count;
|
|
||||||
} else if (key === '/price-reports') {
|
} else if (key === '/price-reports') {
|
||||||
count = (await api.get<PriceReportSummary>('/admin/api/price-reports/summary')).data.pending;
|
count = (await api.get<PriceReportSummary>('/admin/api/price-reports/summary')).data.pending;
|
||||||
} else {
|
} else {
|
||||||
@@ -164,39 +156,21 @@ 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('/price-reports'),
|
||||||
refreshSafely('/invite-withdraws'),
|
refreshSafely('/feedbacks'),
|
||||||
refreshSafely('/price-reports'),
|
]);
|
||||||
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; // 守卫期间不闪烁内容
|
||||||
|
|
||||||
@@ -249,7 +223,8 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
position: 'sticky',
|
position: 'sticky',
|
||||||
top: 0,
|
top: 0,
|
||||||
height: '100vh',
|
height: '100vh',
|
||||||
overflow: 'hidden',
|
overflowY: 'auto',
|
||||||
|
overflowX: 'hidden',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<nav className={`side-nav${collapsed ? ' side-nav-collapsed' : ''}`} aria-label="后台导航">
|
<nav className={`side-nav${collapsed ? ' side-nav-collapsed' : ''}`} aria-label="后台导航">
|
||||||
@@ -339,19 +314,8 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
|||||||
.side-nav {
|
.side-nav {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
box-sizing: border-box;
|
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
height: calc(100vh - 48px);
|
padding: 0 10px 14px;
|
||||||
min-height: 0;
|
|
||||||
overflow-x: hidden;
|
|
||||||
overflow-y: auto;
|
|
||||||
overscroll-behavior: contain;
|
|
||||||
padding: 0 10px 20px;
|
|
||||||
scrollbar-gutter: stable;
|
|
||||||
-webkit-overflow-scrolling: touch;
|
|
||||||
}
|
|
||||||
.side-nav:focus-within {
|
|
||||||
scroll-behavior: smooth;
|
|
||||||
}
|
}
|
||||||
.nav-group {
|
.nav-group {
|
||||||
padding: 6px 0 8px;
|
padding: 6px 0 8px;
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -13,11 +13,6 @@ import { formatUtcTime } from '@/lib/format';
|
|||||||
import { usePagedList } from '@/lib/usePagedList';
|
import { usePagedList } from '@/lib/usePagedList';
|
||||||
import { AdjustCashModal, AdjustCoinModal } from '@/components/AdjustBalanceModals';
|
import { AdjustCashModal, AdjustCoinModal } from '@/components/AdjustBalanceModals';
|
||||||
import { DeleteUserModal } from '@/components/DeleteUserModal';
|
import { DeleteUserModal } from '@/components/DeleteUserModal';
|
||||||
import {
|
|
||||||
clearUserRisk,
|
|
||||||
UserRiskModal,
|
|
||||||
type RiskUser,
|
|
||||||
} from '@/components/UserRiskModal';
|
|
||||||
import type { UserListItem } from '@/lib/types';
|
import type { UserListItem } from '@/lib/types';
|
||||||
|
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
@@ -54,7 +49,6 @@ export default function UsersPage() {
|
|||||||
const [coinUser, setCoinUser] = useState<UserListItem | null>(null);
|
const [coinUser, setCoinUser] = useState<UserListItem | null>(null);
|
||||||
const [cashUser, setCashUser] = useState<UserListItem | null>(null);
|
const [cashUser, setCashUser] = useState<UserListItem | null>(null);
|
||||||
const [delUser, setDelUser] = useState<UserListItem | null>(null);
|
const [delUser, setDelUser] = useState<UserListItem | null>(null);
|
||||||
const [riskUser, setRiskUser] = useState<RiskUser | null>(null);
|
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<Key[]>([]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState<Key[]>([]);
|
||||||
|
|
||||||
// 筛选/排序变化后清空已选(避免选中项跨筛选错位)
|
// 筛选/排序变化后清空已选(避免选中项跨筛选错位)
|
||||||
@@ -140,22 +134,6 @@ export default function UsersPage() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const markNormalRisk = (u: UserListItem) => {
|
|
||||||
modal.confirm({
|
|
||||||
title: `确认将用户 ${u.phone} 标记为非高风险?`,
|
|
||||||
content: '确认后将清空当前高风险备注。',
|
|
||||||
onOk: async () => {
|
|
||||||
try {
|
|
||||||
await clearUserRisk(u.id);
|
|
||||||
message.success('已标记为非高风险');
|
|
||||||
reload();
|
|
||||||
} catch (error) {
|
|
||||||
message.error(errMsg(error));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 一次性操作:点一下把该用户标记为「未看过引导」,下次打开 App 重看一遍,看完后端自动恢复(只触发这一次)。
|
// 一次性操作:点一下把该用户标记为「未看过引导」,下次打开 App 重看一遍,看完后端自动恢复(只触发这一次)。
|
||||||
// 用户尚未重看前可「撤销」(把 force_onboarding 置回 false),纠正误点。
|
// 用户尚未重看前可「撤销」(把 force_onboarding 置回 false),纠正误点。
|
||||||
const setForceOnboarding = (u: UserListItem, enable: boolean) => {
|
const setForceOnboarding = (u: UserListItem, enable: boolean) => {
|
||||||
@@ -235,38 +213,26 @@ export default function UsersPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const columns: ColumnsType<UserListItem> = [
|
const columns: ColumnsType<UserListItem> = [
|
||||||
{ title: 'ID', dataIndex: 'id', width: 60, sorter: true, sortOrder: sortOrderOf('id') },
|
{ title: 'ID', dataIndex: 'id', width: 80, sorter: true, sortOrder: sortOrderOf('id') },
|
||||||
{ title: '手机号', dataIndex: 'phone', width: 115 },
|
{ title: '手机号', dataIndex: 'phone', width: 130 },
|
||||||
{
|
{
|
||||||
title: '昵称',
|
title: '昵称',
|
||||||
dataIndex: 'nickname',
|
dataIndex: 'nickname',
|
||||||
width: 130,
|
width: 150,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
render: (v: string | null) => v || '-',
|
render: (v: string | null) => v || '-',
|
||||||
},
|
},
|
||||||
{
|
{ title: '渠道', dataIndex: 'register_channel', width: 90 },
|
||||||
title: '用户标识',
|
|
||||||
dataIndex: 'is_high_risk',
|
|
||||||
width: 95,
|
|
||||||
render: (_: boolean, user: UserListItem) => (
|
|
||||||
<Tooltip title={user.is_high_risk ? user.high_risk_note || '暂无高风险备注' : undefined}>
|
|
||||||
<Tag color={user.is_high_risk ? 'red' : 'default'}>
|
|
||||||
{user.is_high_risk ? '高风险' : '非高风险'}
|
|
||||||
</Tag>
|
|
||||||
</Tooltip>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{ title: '渠道', dataIndex: 'register_channel', width: 70 },
|
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
width: 80,
|
width: 90,
|
||||||
render: (s: string) => <Tag color={STATUS_COLOR[s]}>{s}</Tag>,
|
render: (s: string) => <Tag color={STATUS_COLOR[s]}>{s}</Tag>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '注册时间',
|
title: '注册时间',
|
||||||
dataIndex: 'created_at',
|
dataIndex: 'created_at',
|
||||||
width: 140,
|
width: 160,
|
||||||
sorter: true,
|
sorter: true,
|
||||||
sortOrder: sortOrderOf('created_at'),
|
sortOrder: sortOrderOf('created_at'),
|
||||||
render: (v: string) => formatUtcTime(v),
|
render: (v: string) => formatUtcTime(v),
|
||||||
@@ -279,7 +245,7 @@ export default function UsersPage() {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
),
|
),
|
||||||
dataIndex: 'last_active_at',
|
dataIndex: 'last_active_at',
|
||||||
width: 140,
|
width: 160,
|
||||||
sorter: true,
|
sorter: true,
|
||||||
// 关掉 antd 默认的「点击升序/降序」表头提示,否则与上面自定义口径 Tooltip 同时弹出互相遮挡
|
// 关掉 antd 默认的「点击升序/降序」表头提示,否则与上面自定义口径 Tooltip 同时弹出互相遮挡
|
||||||
showSorterTooltip: false,
|
showSorterTooltip: false,
|
||||||
@@ -290,14 +256,9 @@ export default function UsersPage() {
|
|||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'op',
|
key: 'op',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 540,
|
width: 340,
|
||||||
render: (_: unknown, u: UserListItem) => (
|
render: (_: unknown, u: UserListItem) => (
|
||||||
<Space
|
<Space wrap={false} onClick={(e) => e.stopPropagation()}>
|
||||||
size={6}
|
|
||||||
wrap={false}
|
|
||||||
style={{ whiteSpace: 'nowrap' }}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
<a onClick={() => router.push(`/users/${u.id}`)}>详情</a>
|
<a onClick={() => router.push(`/users/${u.id}`)}>详情</a>
|
||||||
{canCoins && <a onClick={() => setCoinUser(u)}>调金币</a>}
|
{canCoins && <a onClick={() => setCoinUser(u)}>调金币</a>}
|
||||||
{canCoins && <a onClick={() => setCashUser(u)}>调现金</a>}
|
{canCoins && <a onClick={() => setCashUser(u)}>调现金</a>}
|
||||||
@@ -309,16 +270,6 @@ export default function UsersPage() {
|
|||||||
{u.debug_trace_enabled ? '关调试链接' : '开调试链接'}
|
{u.debug_trace_enabled ? '关调试链接' : '开调试链接'}
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
{canStatus &&
|
|
||||||
u.status !== 'deleted' &&
|
|
||||||
(u.is_high_risk ? (
|
|
||||||
<>
|
|
||||||
<a onClick={() => setRiskUser(u)}>修改高风险备注</a>
|
|
||||||
<a onClick={() => markNormalRisk(u)}>标记为非高风险</a>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<a onClick={() => setRiskUser(u)}>标记为高风险</a>
|
|
||||||
))}
|
|
||||||
{canStatus &&
|
{canStatus &&
|
||||||
u.status !== 'deleted' &&
|
u.status !== 'deleted' &&
|
||||||
(u.force_onboarding ? (
|
(u.force_onboarding ? (
|
||||||
@@ -441,7 +392,7 @@ export default function UsersPage() {
|
|||||||
showTotal: (t) => `共 ${t} 个用户`,
|
showTotal: (t) => `共 ${t} 个用户`,
|
||||||
onChange: onPageChange,
|
onChange: onPageChange,
|
||||||
}}
|
}}
|
||||||
scroll={{ x: 1400 }}
|
scroll={{ x: 1200 }}
|
||||||
onChange={onTableChange}
|
onChange={onTableChange}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -453,12 +404,6 @@ export default function UsersPage() {
|
|||||||
onClose={() => setDelUser(null)}
|
onClose={() => setDelUser(null)}
|
||||||
onDone={reload}
|
onDone={reload}
|
||||||
/>
|
/>
|
||||||
<UserRiskModal
|
|
||||||
user={riskUser}
|
|
||||||
open={!!riskUser}
|
|
||||||
onClose={() => setRiskUser(null)}
|
|
||||||
onDone={reload}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import { useCallback, useEffect, useState } from 'react';
|
|||||||
import {
|
import {
|
||||||
DatePicker,
|
DatePicker,
|
||||||
Descriptions,
|
Descriptions,
|
||||||
Input,
|
|
||||||
Radio,
|
Radio,
|
||||||
Space,
|
Space,
|
||||||
Table,
|
Table,
|
||||||
Tag,
|
Tag,
|
||||||
Typography,
|
Typography,
|
||||||
Tooltip,
|
|
||||||
message,
|
message,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
@@ -41,18 +39,12 @@ const PAGE_SIZE = 10; // 金币记录每页条数
|
|||||||
interface Props {
|
interface Props {
|
||||||
userId: number;
|
userId: number;
|
||||||
user: WithdrawUserSnapshot | null;
|
user: WithdrawUserSnapshot | null;
|
||||||
withdrawSource?: 'coin_cash' | 'invite_cash';
|
|
||||||
// 统计区字段集:withdraw(默认,提现详情:含提现细分) / ad(广告收益详情:只看看广告观看统计,对齐参考图 6 项)
|
// 统计区字段集:withdraw(默认,提现详情:含提现细分) / ad(广告收益详情:只看看广告观看统计,对齐参考图 6 项)
|
||||||
statsVariant?: 'withdraw' | 'ad';
|
statsVariant?: 'withdraw' | 'ad';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 用户看广告/提现详情:基本信息 + 互斥时间筛选 + 统计区(按 statsVariant 取字段集)+ 金币发放记录表。 */
|
/** 用户看广告/提现详情:基本信息 + 互斥时间筛选 + 统计区(按 statsVariant 取字段集)+ 金币发放记录表。 */
|
||||||
export default function UserRewardPanel({
|
export default function UserRewardPanel({ userId, user, statsVariant = 'withdraw' }: Props) {
|
||||||
userId,
|
|
||||||
user,
|
|
||||||
withdrawSource,
|
|
||||||
statsVariant = 'withdraw',
|
|
||||||
}: Props) {
|
|
||||||
const [mode, setMode] = useState<'all' | 'range'>('all'); // all=注册至今 / range=自定义区间
|
const [mode, setMode] = useState<'all' | 'range'>('all'); // all=注册至今 / range=自定义区间
|
||||||
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
|
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
|
||||||
const [stats, setStats] = useState<UserRewardStats | null>(null);
|
const [stats, setStats] = useState<UserRewardStats | null>(null);
|
||||||
@@ -77,10 +69,7 @@ export default function UserRewardPanel({
|
|||||||
setStatsLoading(true);
|
setStatsLoading(true);
|
||||||
try {
|
try {
|
||||||
const { data } = await api.get<UserRewardStats>(`/admin/api/users/${userId}/reward-stats`, {
|
const { data } = await api.get<UserRewardStats>(`/admin/api/users/${userId}/reward-stats`, {
|
||||||
params: {
|
params: JSON.parse(paramsKey),
|
||||||
...JSON.parse(paramsKey),
|
|
||||||
...(withdrawSource ? { withdraw_source: withdrawSource } : {}),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
setStats(data);
|
setStats(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -88,7 +77,7 @@ export default function UserRewardPanel({
|
|||||||
} finally {
|
} finally {
|
||||||
setStatsLoading(false);
|
setStatsLoading(false);
|
||||||
}
|
}
|
||||||
}, [userId, paramsKey, withdrawSource]);
|
}, [userId, paramsKey]);
|
||||||
|
|
||||||
const loadRecords = useCallback(
|
const loadRecords = useCallback(
|
||||||
async (p: number) => {
|
async (p: number) => {
|
||||||
@@ -146,13 +135,6 @@ export default function UserRewardPanel({
|
|||||||
<Space size="large" wrap>
|
<Space size="large" wrap>
|
||||||
<span>
|
<span>
|
||||||
手机号 <Text strong>{user?.phone || '-'}</Text>
|
手机号 <Text strong>{user?.phone || '-'}</Text>
|
||||||
{user && (
|
|
||||||
<Tooltip title={user.is_high_risk ? user.high_risk_note || '暂无高风险备注' : undefined}>
|
|
||||||
<Tag color={user.is_high_risk ? 'red' : 'default'} style={{ marginInlineStart: 8 }}>
|
|
||||||
{user.is_high_risk ? '高风险' : '非高风险'}
|
|
||||||
</Tag>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
昵称 <Text strong>{user?.nickname || '-'}</Text>
|
昵称 <Text strong>{user?.nickname || '-'}</Text>
|
||||||
@@ -178,7 +160,6 @@ export default function UserRewardPanel({
|
|||||||
<RangePicker
|
<RangePicker
|
||||||
size="small"
|
size="small"
|
||||||
disabled={mode !== 'range'}
|
disabled={mode !== 'range'}
|
||||||
allowEmpty={[true, true]}
|
|
||||||
value={range}
|
value={range}
|
||||||
onChange={(v) => setRange(v as [Dayjs, Dayjs] | null)}
|
onChange={(v) => setRange(v as [Dayjs, Dayjs] | null)}
|
||||||
/>
|
/>
|
||||||
@@ -187,7 +168,7 @@ export default function UserRewardPanel({
|
|||||||
|
|
||||||
{/* 统计区(受时间筛选;现金余额为当前快照)。ad 视图只保留看广告观看统计(对齐参考图 6 项) */}
|
{/* 统计区(受时间筛选;现金余额为当前快照)。ad 视图只保留看广告观看统计(对齐参考图 6 项) */}
|
||||||
<Descriptions bordered size="small" column={2} style={{ marginBottom: 8 }}>
|
<Descriptions bordered size="small" column={2} style={{ marginBottom: 8 }}>
|
||||||
<Descriptions.Item label="累计成功提现">
|
<Descriptions.Item label="累计提现">
|
||||||
{stats ? yuan(stats.withdraw_success_cents) : '-'}
|
{stats ? yuan(stats.withdraw_success_cents) : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="现金余额">
|
<Descriptions.Item label="现金余额">
|
||||||
@@ -195,40 +176,40 @@ export default function UserRewardPanel({
|
|||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
{statsVariant === 'ad' ? (
|
{statsVariant === 'ad' ? (
|
||||||
<>
|
<>
|
||||||
<Descriptions.Item label="激励视频成功发奖次数">
|
<Descriptions.Item label="激励视频观看数">
|
||||||
{stats?.reward_video_count ?? '-'}
|
{stats?.reward_video_count ?? '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
{/* eCPM 均按元展示(reward_video / feed avg_ecpm 原始为分/千次,÷100 转元) */}
|
{/* eCPM 均按元展示(reward_video / feed avg_ecpm 原始为分/千次,÷100 转元) */}
|
||||||
<Descriptions.Item label="预估平均激励视频ECPM">
|
<Descriptions.Item label="平均激励视频ECPM">
|
||||||
{stats ? `${(stats.reward_video_avg_ecpm / 100).toFixed(2)} 元/千` : '-'}
|
{stats ? `${(stats.reward_video_avg_ecpm / 100).toFixed(2)} 元/千` : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="Draw信息流奖励份数">
|
<Descriptions.Item label="draw信息流视频观看数">
|
||||||
{stats?.feed_count ?? '-'}
|
{stats?.feed_count ?? '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="预估平均Draw信息流ECPM">
|
<Descriptions.Item label="平均draw信息流ECPM">
|
||||||
{stats ? `${(stats.feed_avg_ecpm / 100).toFixed(2)} 元/千` : '-'}
|
{stats ? `${(stats.feed_avg_ecpm / 100).toFixed(2)} 元/千` : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Descriptions.Item label="提现申请总次数">{stats?.withdraw_total ?? '-'}</Descriptions.Item>
|
<Descriptions.Item label="提现总次数">{stats?.withdraw_total ?? '-'}</Descriptions.Item>
|
||||||
<Descriptions.Item label="传统任务累计收益">
|
<Descriptions.Item label="传统任务提现">
|
||||||
{stats ? yuan(stats.traditional_task_cash_cents) : '-'}
|
{stats ? yuan(stats.traditional_task_cash_cents) : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="激励视频成功发奖次数">
|
<Descriptions.Item label="累计激励视频数">
|
||||||
{stats?.reward_video_count ?? '-'}
|
{stats?.reward_video_count ?? '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="预估平均激励视频ECPM">
|
<Descriptions.Item label="平均激励视频ECPM">
|
||||||
{stats ? `${stats.reward_video_avg_ecpm} 分/千` : '-'}
|
{stats ? `${stats.reward_video_avg_ecpm} 分/千` : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="激励视频累计收益">
|
<Descriptions.Item label="激励视频提现">
|
||||||
{stats ? yuan(stats.reward_video_cash_cents) : '-'}
|
{stats ? yuan(stats.reward_video_cash_cents) : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="信息流奖励份数">{stats?.feed_count ?? '-'}</Descriptions.Item>
|
<Descriptions.Item label="累计信息流广告数">{stats?.feed_count ?? '-'}</Descriptions.Item>
|
||||||
<Descriptions.Item label="预估平均信息流广告ECPM">
|
<Descriptions.Item label="平均信息流广告ECPM">
|
||||||
{stats ? `${stats.feed_avg_ecpm} 分/千` : '-'}
|
{stats ? `${stats.feed_avg_ecpm} 分/千` : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="信息流广告累计收益">
|
<Descriptions.Item label="信息流广告提现">
|
||||||
{stats ? yuan(stats.feed_cash_cents) : '-'}
|
{stats ? yuan(stats.feed_cash_cents) : '-'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
</>
|
</>
|
||||||
@@ -236,24 +217,12 @@ export default function UserRewardPanel({
|
|||||||
</Descriptions>
|
</Descriptions>
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
{statsVariant === 'ad'
|
{statsVariant === 'ad'
|
||||||
? '统计随上方时间筛选(现金余额除外,为当前快照);次数仅统计成功发奖记录,信息流按奖励份数统计;eCPM 为预估值。'
|
? '统计随上方时间筛选(现金余额除外,为当前快照);eCPM 均按元展示(原始分/千次 ÷100)。'
|
||||||
: '统计随上方时间筛选(现金余额除外,为当前快照);提现按申请提交时间统计;累计收益为已发金币按当前汇率折算,不代表实际已提现金额;eCPM 为预估值。'}
|
: '统计随上方时间筛选(现金余额除外,为当前快照);eCPM 单位分/千次,同金币审计。'}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{user?.is_high_risk && (
|
{/* 金币记录 */}
|
||||||
<div style={{ marginTop: 16 }}>
|
<h4 style={{ margin: '16px 0 8px' }}>金币记录</h4>
|
||||||
<Text strong>高风险备注</Text>
|
|
||||||
<Input.TextArea
|
|
||||||
readOnly
|
|
||||||
value={user.high_risk_note || ''}
|
|
||||||
rows={3}
|
|
||||||
style={{ marginTop: 8 }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 主要金币发放记录 */}
|
|
||||||
<h4 style={{ margin: '16px 0 8px' }}>主要金币发放记录</h4>
|
|
||||||
<Table
|
<Table
|
||||||
rowKey={(r) => `${r.source}-${r.created_at}-${r.coin}-${r.ecpm ?? ''}`}
|
rowKey={(r) => `${r.source}-${r.created_at}-${r.coin}-${r.ecpm ?? ''}`}
|
||||||
size="small"
|
size="small"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,985 @@
|
|||||||
import { WithdrawReviewPage } from './WithdrawReviewPage';
|
'use client';
|
||||||
|
|
||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import type { Key } from 'react';
|
||||||
|
import {
|
||||||
|
App,
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Col,
|
||||||
|
DatePicker,
|
||||||
|
Descriptions,
|
||||||
|
Drawer,
|
||||||
|
Input,
|
||||||
|
Modal,
|
||||||
|
Row,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Spin,
|
||||||
|
Statistic,
|
||||||
|
Table,
|
||||||
|
Tabs,
|
||||||
|
Tag,
|
||||||
|
Timeline,
|
||||||
|
Typography,
|
||||||
|
} from 'antd';
|
||||||
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import {
|
||||||
|
CheckCircleOutlined,
|
||||||
|
ClearOutlined,
|
||||||
|
CloseCircleOutlined,
|
||||||
|
ReloadOutlined,
|
||||||
|
SearchOutlined,
|
||||||
|
SortAscendingOutlined,
|
||||||
|
SyncOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import dayjs, { type Dayjs } from 'dayjs';
|
||||||
|
import { api, errMsg } from '@/lib/api';
|
||||||
|
import { canDo } from '@/lib/auth';
|
||||||
|
import { formatUtcTime, utcDayjs, utcFromNow, yuan } from '@/lib/format';
|
||||||
|
import { refreshReviewBadge } from '@/lib/reviewBadge';
|
||||||
|
import { usePagedList } from '@/lib/usePagedList';
|
||||||
|
import type {
|
||||||
|
AuditLog,
|
||||||
|
WithdrawBulkResult,
|
||||||
|
WithdrawDetail,
|
||||||
|
WithdrawLedgerCheck,
|
||||||
|
WithdrawListItem,
|
||||||
|
WithdrawOrder,
|
||||||
|
WithdrawSummary,
|
||||||
|
WxpayHealthCheck,
|
||||||
|
} from '@/lib/types';
|
||||||
|
import UserRewardPanel from './UserRewardPanel';
|
||||||
|
|
||||||
|
const { Text } = Typography;
|
||||||
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
|
// 提现单 / 审计 / 用户均为 UTC 口径(server_default=func.now());现金流水为北京 wall-clock。
|
||||||
|
const dt = (v: string) => formatUtcTime(v);
|
||||||
|
const ago = (v: string) => utcFromNow(v);
|
||||||
|
|
||||||
|
const STATUS_COLOR: Record<string, string> = {
|
||||||
|
reviewing: 'gold',
|
||||||
|
pending: 'orange',
|
||||||
|
success: 'green',
|
||||||
|
failed: 'red',
|
||||||
|
rejected: 'default',
|
||||||
|
};
|
||||||
|
|
||||||
|
const STATUS_LABEL: Record<string, string> = {
|
||||||
|
reviewing: '待审核',
|
||||||
|
pending: '打款中',
|
||||||
|
success: '已到账',
|
||||||
|
failed: '打款失败',
|
||||||
|
rejected: '已拒绝',
|
||||||
|
};
|
||||||
|
|
||||||
|
const STATUS_TABS = [
|
||||||
|
{ key: 'reviewing', label: '待审核' },
|
||||||
|
{ key: 'pending', label: '打款中' },
|
||||||
|
{ key: 'success', label: '已到账' },
|
||||||
|
{ key: 'rejected', label: '已拒绝' },
|
||||||
|
{ key: 'failed', label: '打款失败' },
|
||||||
|
{ key: 'all', label: '全部' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const REJECT_TEMPLATES = ['账号异常', '提现金额异常', '微信实名不匹配', '风控拦截', '其他原因'];
|
||||||
|
|
||||||
|
function statusTag(status: string) {
|
||||||
|
return <Tag color={STATUS_COLOR[status]}>{STATUS_LABEL[status] || status}</Tag>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshResultText(order: WithdrawOrder) {
|
||||||
|
if (order.status === 'success') return '已查询: 微信已到账';
|
||||||
|
if (order.status === 'failed') return '已查询: 打款未成功,余额已退回';
|
||||||
|
if (order.status === 'rejected') return '已查询: 已拒绝,余额已退回';
|
||||||
|
if (order.status === 'pending') {
|
||||||
|
return order.fail_reason ? `已查询: ${order.fail_reason}` : '已查询: 仍在打款中';
|
||||||
|
}
|
||||||
|
return `已查询: ${STATUS_LABEL[order.status] || order.status}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function actionLabel(action: string) {
|
||||||
|
const labels: Record<string, string> = {
|
||||||
|
'withdraw.approve': '审核通过',
|
||||||
|
'withdraw.reject': '审核拒绝',
|
||||||
|
'withdraw.refresh': '查单刷新',
|
||||||
|
'withdraw.reconcile': '处理超时订单',
|
||||||
|
};
|
||||||
|
return labels[action] || action;
|
||||||
|
}
|
||||||
|
|
||||||
|
function summaryCount(summary: WithdrawSummary | null, key: string) {
|
||||||
|
if (!summary) return undefined;
|
||||||
|
if (key === 'reviewing') return summary.reviewing_count;
|
||||||
|
if (key === 'pending') return summary.pending_count;
|
||||||
|
if (key === 'failed') return summary.failed_count;
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function riskTags(detail: WithdrawDetail | null) {
|
||||||
|
if (!detail) return [];
|
||||||
|
if (detail.risk_flags?.length) return detail.risk_flags;
|
||||||
|
const tags: string[] = [];
|
||||||
|
if (!detail.order.user_name) tags.push('缺少提现实名');
|
||||||
|
if (detail.user?.status && detail.user.status !== 'active') tags.push(`账号状态:${detail.user.status}`);
|
||||||
|
if (detail.user && dayjs().diff(utcDayjs(detail.user.created_at), 'hour') < 24) tags.push('新注册用户');
|
||||||
|
if ((detail.user?.withdraw_total || 0) >= 3) tags.push('多次提现用户');
|
||||||
|
const rejectedN = detail.recent_withdraws.filter((o) => o.status === 'rejected').length;
|
||||||
|
const failedN = detail.recent_withdraws.filter((o) => o.status === 'failed').length;
|
||||||
|
if (rejectedN) tags.push(`提现拒绝${rejectedN}笔`);
|
||||||
|
if (failedN) tags.push(`提现失败${failedN}笔`);
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bulkResultText(action: string, result: WithdrawBulkResult) {
|
||||||
|
const firstError = result.items.find((item) => !item.ok)?.error;
|
||||||
|
return `${action}: 成功 ${result.success} / ${result.total} 笔${
|
||||||
|
result.failed ? `,失败 ${result.failed} 笔` : ''
|
||||||
|
}${firstError ? `,首个失败原因: ${firstError}` : ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
export default function WithdrawsPage() {
|
export default function WithdrawsPage() {
|
||||||
return <WithdrawReviewPage mode="other" />;
|
const { message, modal } = App.useApp();
|
||||||
|
const [activeStatus, setActiveStatus] = useState('reviewing');
|
||||||
|
const [summary, setSummary] = useState<WithdrawSummary | null>(null);
|
||||||
|
const [health, setHealth] = useState<WxpayHealthCheck | null>(null);
|
||||||
|
const [healthLoading, setHealthLoading] = useState(false);
|
||||||
|
const [healthCheckedAt, setHealthCheckedAt] = useState<number | null>(null);
|
||||||
|
const [ledger, setLedger] = useState<WithdrawLedgerCheck | null>(null);
|
||||||
|
const [ledgerLoading, setLedgerLoading] = useState(false);
|
||||||
|
const [ledgerCheckedAt, setLedgerCheckedAt] = useState<number | null>(null);
|
||||||
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
|
const [detail, setDetail] = useState<WithdrawDetail | null>(null);
|
||||||
|
const [detailLoading, setDetailLoading] = useState(false);
|
||||||
|
const [rejecting, setRejecting] = useState<WithdrawOrder | null>(null);
|
||||||
|
const [bulkRejecting, setBulkRejecting] = useState<WithdrawOrder[]>([]);
|
||||||
|
const [rejectReason, setRejectReason] = useState('');
|
||||||
|
const [selectedRowKeys, setSelectedRowKeys] = useState<Key[]>([]);
|
||||||
|
const [searchDraft, setSearchDraft] = useState('');
|
||||||
|
const [keyword, setKeyword] = useState('');
|
||||||
|
const [dateRange, setDateRange] = useState<[Dayjs, Dayjs] | null>(null);
|
||||||
|
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
|
||||||
|
|
||||||
|
const filters: Record<string, unknown> = {};
|
||||||
|
if (activeStatus !== 'all') filters.status = activeStatus;
|
||||||
|
if (keyword.trim()) filters.keyword = keyword.trim();
|
||||||
|
if (dateRange?.[0]) filters.date_from = dateRange[0].startOf('day').toISOString();
|
||||||
|
if (dateRange?.[1]) filters.date_to = dateRange[1].endOf('day').toISOString();
|
||||||
|
filters.date_field = 'created_at';
|
||||||
|
filters.sort_by = 'created_at';
|
||||||
|
filters.sort_order = sortOrder;
|
||||||
|
const filterKey = JSON.stringify(filters);
|
||||||
|
const { items, total, page, pageSize, loading, onChange: onPageChange, reload } =
|
||||||
|
usePagedList<WithdrawListItem>('/admin/api/withdraws', filters, 20);
|
||||||
|
const canManage = canDo(['finance']);
|
||||||
|
const selectedOrders = items.filter((item) => selectedRowKeys.includes(item.id));
|
||||||
|
const selectedReviewing = selectedOrders.filter((item) => item.status === 'reviewing');
|
||||||
|
const selectedPending = selectedOrders.filter((item) => item.status === 'pending');
|
||||||
|
|
||||||
|
const resetFilters = () => {
|
||||||
|
setActiveStatus('reviewing');
|
||||||
|
setSearchDraft('');
|
||||||
|
setKeyword('');
|
||||||
|
setDateRange(null);
|
||||||
|
setSortOrder('desc');
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadSummary = useCallback(async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<WithdrawSummary>('/admin/api/withdraws/summary');
|
||||||
|
setSummary(data);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const loadHealth = useCallback(async (showFeedback = false) => {
|
||||||
|
setHealthLoading(true);
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<WxpayHealthCheck>('/admin/api/withdraws/health-check');
|
||||||
|
setHealth(data);
|
||||||
|
setHealthCheckedAt(Date.now());
|
||||||
|
if (showFeedback) {
|
||||||
|
message.success(data.ok ? '检测完成,微信提现配置正常' : '检测完成,仍有配置项需要处理');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
} finally {
|
||||||
|
setHealthLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 账本校验是全表对账、相对重,故只在进页时拉一次 + 提供手动按钮,不随每次写操作重算。
|
||||||
|
const loadLedger = useCallback(async (showFeedback = false) => {
|
||||||
|
setLedgerLoading(true);
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<WithdrawLedgerCheck>('/admin/api/withdraws/ledger-check');
|
||||||
|
setLedger(data);
|
||||||
|
setLedgerCheckedAt(Date.now());
|
||||||
|
if (showFeedback) {
|
||||||
|
if (data.ok) {
|
||||||
|
message.success('校验完成,现金账本正常');
|
||||||
|
} else {
|
||||||
|
message.warning('校验完成,发现现金账本异常');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
} finally {
|
||||||
|
setLedgerLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const loadDetail = useCallback(async (outBillNo: string) => {
|
||||||
|
setDetailLoading(true);
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<WithdrawDetail>(`/admin/api/withdraws/${outBillNo}`);
|
||||||
|
setDetail(data);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
} finally {
|
||||||
|
setDetailLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void loadSummary();
|
||||||
|
void loadHealth();
|
||||||
|
void loadLedger();
|
||||||
|
}, [loadHealth, loadLedger, loadSummary]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSelectedRowKeys([]);
|
||||||
|
}, [filterKey, page, pageSize]);
|
||||||
|
|
||||||
|
const refreshAfterChange = async (outBillNo?: string) => {
|
||||||
|
setSelectedRowKeys([]);
|
||||||
|
reload();
|
||||||
|
// 账本校验偏重,写操作后不重算(只刷 summary + health);需要时点账本 Alert 上的「重新校验」。
|
||||||
|
await Promise.all([loadSummary(), loadHealth()]);
|
||||||
|
if (outBillNo && drawerOpen && detail?.order.out_bill_no === outBillNo) {
|
||||||
|
await loadDetail(outBillNo);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const openDetail = (o: WithdrawOrder) => {
|
||||||
|
setDrawerOpen(true);
|
||||||
|
setDetail(null);
|
||||||
|
void loadDetail(o.out_bill_no);
|
||||||
|
};
|
||||||
|
|
||||||
|
const approve = (o: WithdrawOrder) => {
|
||||||
|
modal.confirm({
|
||||||
|
title: `确认通过并打款 ${yuan(o.amount_cents)}?`,
|
||||||
|
content: (
|
||||||
|
<div>
|
||||||
|
<div>用户 ID: {o.user_id}</div>
|
||||||
|
<div>提现实名: {o.user_name || '-'}</div>
|
||||||
|
<div>提现单号: {o.out_bill_no}</div>
|
||||||
|
<div style={{ marginTop: 8, color: '#8c8c8c' }}>
|
||||||
|
通过后会立即发起微信转账,请确认该笔提现已经人工审核通过。
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
okText: '通过并打款',
|
||||||
|
okButtonProps: { danger: true, icon: <CheckCircleOutlined /> },
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
await api.post(`/admin/api/withdraws/${o.out_bill_no}/approve`);
|
||||||
|
refreshReviewBadge('/withdraws');
|
||||||
|
message.success('已通过审核并发起打款');
|
||||||
|
await refreshAfterChange(o.out_bill_no);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmReject = async () => {
|
||||||
|
const targets = bulkRejecting.length ? bulkRejecting : rejecting ? [rejecting] : [];
|
||||||
|
if (!targets.length) return;
|
||||||
|
const trimmed = rejectReason.trim();
|
||||||
|
if (!trimmed) {
|
||||||
|
message.warning('请填写拒绝理由');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (bulkRejecting.length) {
|
||||||
|
const { data } = await api.post<WithdrawBulkResult>('/admin/api/withdraws/bulk/reject', {
|
||||||
|
out_bill_nos: targets.map((item) => item.out_bill_no),
|
||||||
|
reason: trimmed,
|
||||||
|
});
|
||||||
|
const text = bulkResultText('批量拒绝完成', data);
|
||||||
|
if (data.failed) message.warning(text);
|
||||||
|
else message.success(text);
|
||||||
|
} else {
|
||||||
|
await api.post(`/admin/api/withdraws/${targets[0].out_bill_no}/reject`, { reason: trimmed });
|
||||||
|
message.success('已拒绝并退回余额');
|
||||||
|
}
|
||||||
|
refreshReviewBadge('/withdraws');
|
||||||
|
setRejecting(null);
|
||||||
|
setBulkRejecting([]);
|
||||||
|
setRejectReason('');
|
||||||
|
await refreshAfterChange(targets.length === 1 ? targets[0].out_bill_no : undefined);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const bulkApprove = () => {
|
||||||
|
if (!selectedReviewing.length) {
|
||||||
|
message.warning('请选择待审核的提现单');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const amount = selectedReviewing.reduce((sum, item) => sum + item.amount_cents, 0);
|
||||||
|
let confirmText = '';
|
||||||
|
modal.confirm({
|
||||||
|
title: `确认批量通过 ${selectedReviewing.length} 笔提现?`,
|
||||||
|
content: (
|
||||||
|
<Space direction="vertical" style={{ width: '100%' }}>
|
||||||
|
<Text>
|
||||||
|
合计 <Text strong>{yuan(amount)}</Text>,通过后会逐笔发起微信打款。
|
||||||
|
</Text>
|
||||||
|
<Text type="danger">这是资金操作,请输入“确认打款”后继续。</Text>
|
||||||
|
<Input placeholder="确认打款" onChange={(e) => { confirmText = e.target.value.trim(); }} />
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
okText: '批量通过并打款',
|
||||||
|
okButtonProps: { danger: true, icon: <CheckCircleOutlined /> },
|
||||||
|
onOk: async () => {
|
||||||
|
if (confirmText !== '确认打款') {
|
||||||
|
message.warning('请输入“确认打款”');
|
||||||
|
return Promise.reject(new Error('confirm required'));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const { data } = await api.post<WithdrawBulkResult>('/admin/api/withdraws/bulk/approve', {
|
||||||
|
out_bill_nos: selectedReviewing.map((item) => item.out_bill_no),
|
||||||
|
});
|
||||||
|
refreshReviewBadge('/withdraws');
|
||||||
|
const text = bulkResultText('批量通过完成', data);
|
||||||
|
if (data.failed) message.warning(text);
|
||||||
|
else message.success(text);
|
||||||
|
await refreshAfterChange();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const bulkRefresh = () => {
|
||||||
|
if (!selectedPending.length) {
|
||||||
|
message.warning('请选择打款中的提现单');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modal.confirm({
|
||||||
|
title: `确认批量刷新 ${selectedPending.length} 笔打款状态?`,
|
||||||
|
content: '会逐笔向微信查单,并按最新状态归一化。',
|
||||||
|
okText: '批量刷新查单',
|
||||||
|
okButtonProps: { icon: <SyncOutlined /> },
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await api.post<WithdrawBulkResult>('/admin/api/withdraws/bulk/refresh', {
|
||||||
|
out_bill_nos: selectedPending.map((item) => item.out_bill_no),
|
||||||
|
});
|
||||||
|
const text = bulkResultText('批量刷新完成', data);
|
||||||
|
if (data.failed) message.warning(text);
|
||||||
|
else message.success(text);
|
||||||
|
await refreshAfterChange();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const retry = (o: WithdrawOrder) => {
|
||||||
|
modal.confirm({
|
||||||
|
title: `重新查询 ${o.out_bill_no} 的微信状态?`,
|
||||||
|
content: '会按微信最新状态归一化为成功、失败退款或撤销未确认。',
|
||||||
|
okText: '刷新查单',
|
||||||
|
okButtonProps: { icon: <SyncOutlined /> },
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await api.post<WithdrawOrder>(
|
||||||
|
`/admin/api/withdraws/${o.out_bill_no}/refresh`,
|
||||||
|
);
|
||||||
|
const text = refreshResultText(data);
|
||||||
|
if (data.status === 'pending' && data.fail_reason) message.warning(text);
|
||||||
|
else message.success(text);
|
||||||
|
await refreshAfterChange(o.out_bill_no);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const reconcile = () => {
|
||||||
|
modal.confirm({
|
||||||
|
title: '处理超时打款订单?',
|
||||||
|
content:
|
||||||
|
'将检查超过 15 分钟仍处于“打款中”的订单:微信已成功则更新为“已到账”;失败则退款;仍待用户确认的老单将撤销并退款;仍在处理中则保持不变。',
|
||||||
|
okText: '开始处理',
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await api.post<{ checked: number; resolved: number }>(
|
||||||
|
'/admin/api/withdraws/reconcile',
|
||||||
|
);
|
||||||
|
message.success(`处理完成:检查 ${data.checked} 单,更新 ${data.resolved} 单`);
|
||||||
|
await refreshAfterChange();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(errMsg(e));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns: ColumnsType<WithdrawListItem> = [
|
||||||
|
{
|
||||||
|
title: '手机号',
|
||||||
|
dataIndex: 'phone',
|
||||||
|
width: 130,
|
||||||
|
render: (v: string | null) => v || <Text type="secondary">-</Text>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户昵称',
|
||||||
|
dataIndex: 'nickname',
|
||||||
|
width: 130,
|
||||||
|
render: (v: string | null) => v || <Text type="secondary">-</Text>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '提现金额',
|
||||||
|
dataIndex: 'amount_cents',
|
||||||
|
width: 120,
|
||||||
|
render: (v: number) => <Text strong>{yuan(v)}</Text>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '累计提现',
|
||||||
|
dataIndex: 'cumulative_success_cents',
|
||||||
|
width: 120,
|
||||||
|
render: (v: number) => yuan(v ?? 0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 110,
|
||||||
|
render: statusTag,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '提交时间',
|
||||||
|
dataIndex: 'created_at',
|
||||||
|
width: 180,
|
||||||
|
render: (v: string) => (
|
||||||
|
<Space direction="vertical" size={0}>
|
||||||
|
<span>{dt(v)}</span>
|
||||||
|
<Text type="secondary">{ago(v)}</Text>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '提交单号',
|
||||||
|
dataIndex: 'out_bill_no',
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '失败/拒绝原因',
|
||||||
|
dataIndex: 'fail_reason',
|
||||||
|
ellipsis: true,
|
||||||
|
render: (v: string | null) => v || <Text type="secondary">-</Text>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'op',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 210,
|
||||||
|
render: (_: unknown, o: WithdrawListItem) => {
|
||||||
|
if (!canManage) return <Text type="secondary">-</Text>;
|
||||||
|
if (o.status === 'reviewing') {
|
||||||
|
return (
|
||||||
|
<Space onClick={(e) => e.stopPropagation()}>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="link"
|
||||||
|
icon={<CheckCircleOutlined />}
|
||||||
|
onClick={() => approve(o)}
|
||||||
|
>
|
||||||
|
通过并打款
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="link"
|
||||||
|
danger
|
||||||
|
icon={<CloseCircleOutlined />}
|
||||||
|
onClick={() => {
|
||||||
|
setRejecting(o);
|
||||||
|
setBulkRejecting([]);
|
||||||
|
setRejectReason('');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
拒绝
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (o.status === 'pending') {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="link"
|
||||||
|
icon={<SyncOutlined />}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
retry(o);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
刷新查单
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <Text type="secondary">-</Text>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const auditTimeline = detail
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
children: (
|
||||||
|
<span>
|
||||||
|
用户提交提现申请 <Text type="secondary">{dt(detail.order.created_at)}</Text>
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
...[...detail.audit_logs].reverse().map((log: AuditLog) => ({
|
||||||
|
children: (
|
||||||
|
<span>
|
||||||
|
{actionLabel(log.action)} · {log.admin_username}
|
||||||
|
<Text type="secondary"> {dt(log.created_at)}</Text>
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
{
|
||||||
|
children: (
|
||||||
|
<span>
|
||||||
|
当前状态 {statusTag(detail.order.status)}
|
||||||
|
<Text type="secondary"> {dt(detail.order.updated_at)}</Text>
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [];
|
||||||
|
|
||||||
|
const risks = riskTags(detail);
|
||||||
|
const rejectTargets = bulkRejecting.length ? bulkRejecting : rejecting ? [rejecting] : [];
|
||||||
|
const rejectAmount = rejectTargets.reduce((sum, item) => sum + item.amount_cents, 0);
|
||||||
|
const ledgerIssues = ledger
|
||||||
|
? [
|
||||||
|
// 普通现金账(coin_cash)
|
||||||
|
ledger.balance_diff_cents ? `现金余额差额 ${yuan(ledger.balance_diff_cents)}` : '',
|
||||||
|
ledger.missing_withdraw_txn_count ? `现金缺扣款流水 ${ledger.missing_withdraw_txn_count} 笔` : '',
|
||||||
|
ledger.missing_refund_txn_count ? `现金缺退款流水 ${ledger.missing_refund_txn_count} 笔` : '',
|
||||||
|
ledger.duplicate_refund_txn_count ? `现金重复退款流水 ${ledger.duplicate_refund_txn_count} 类` : '',
|
||||||
|
ledger.refund_txn_on_non_terminal_count
|
||||||
|
? `现金非退款终态存在退款流水 ${ledger.refund_txn_on_non_terminal_count} 笔`
|
||||||
|
: '',
|
||||||
|
// 邀请奖励金账(invite_cash)
|
||||||
|
ledger.invite_balance_diff_cents ? `邀请金余额差额 ${yuan(ledger.invite_balance_diff_cents)}` : '',
|
||||||
|
ledger.invite_missing_withdraw_txn_count
|
||||||
|
? `邀请金缺扣款流水 ${ledger.invite_missing_withdraw_txn_count} 笔`
|
||||||
|
: '',
|
||||||
|
ledger.invite_missing_refund_txn_count
|
||||||
|
? `邀请金缺退款流水 ${ledger.invite_missing_refund_txn_count} 笔`
|
||||||
|
: '',
|
||||||
|
ledger.invite_duplicate_refund_txn_count
|
||||||
|
? `邀请金重复退款流水 ${ledger.invite_duplicate_refund_txn_count} 类`
|
||||||
|
: '',
|
||||||
|
ledger.invite_refund_txn_on_non_terminal_count
|
||||||
|
? `邀请金非退款终态存在退款流水 ${ledger.invite_refund_txn_on_non_terminal_count} 笔`
|
||||||
|
: '',
|
||||||
|
].filter(Boolean)
|
||||||
|
: [];
|
||||||
|
const payoutReady = Boolean(
|
||||||
|
health?.wxpay_configured && health.private_key_loadable && health.public_key_loadable,
|
||||||
|
);
|
||||||
|
const hasBlockingPayoutIssue = Boolean(health && !payoutReady);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Space style={{ width: '100%', justifyContent: 'space-between', marginBottom: 16 }}>
|
||||||
|
<div>
|
||||||
|
<h2 style={{ marginBottom: 4 }}>提现审核</h2>
|
||||||
|
<Text type="secondary">
|
||||||
|
针对赚钱页面的账户。审核通过会立即发起微信提现,拒绝会退回用户现金余额。
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
{canManage && (
|
||||||
|
<Button danger icon={<ReloadOutlined />} onClick={reconcile}>
|
||||||
|
处理超时订单
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
{(hasBlockingPayoutIssue || (ledger && !ledger.ok)) && (
|
||||||
|
<Space direction="vertical" style={{ width: '100%', marginBottom: 16 }}>
|
||||||
|
{health && hasBlockingPayoutIssue && (
|
||||||
|
<Alert
|
||||||
|
showIcon
|
||||||
|
type="warning"
|
||||||
|
message="当前环境无法执行微信打款"
|
||||||
|
description={
|
||||||
|
<Space direction="vertical" size={6}>
|
||||||
|
<Text>微信支付配置不完整,点击“通过并打款”将失败。请联系部署管理员处理。</Text>
|
||||||
|
{healthCheckedAt && (
|
||||||
|
<Text type="secondary">
|
||||||
|
最近检测:{dayjs(healthCheckedAt).format('HH:mm:ss')}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<details>
|
||||||
|
<summary style={{ color: '#1677ff', cursor: 'pointer' }}>查看技术详情</summary>
|
||||||
|
<ul style={{ margin: '8px 0 0', paddingInlineStart: 20 }}>
|
||||||
|
{health.issues.map((issue) => (
|
||||||
|
<li key={issue} style={{ marginBottom: 4, overflowWrap: 'anywhere' }}>
|
||||||
|
{issue}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
action={
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
icon={<ReloadOutlined />}
|
||||||
|
loading={healthLoading}
|
||||||
|
onClick={() => void loadHealth(true)}
|
||||||
|
>
|
||||||
|
重新检测
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{ledger && !ledger.ok && (
|
||||||
|
<Alert
|
||||||
|
showIcon
|
||||||
|
type="error"
|
||||||
|
message="现金账本存在异常"
|
||||||
|
description={ledgerIssues.join(';')}
|
||||||
|
action={
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
icon={<ReloadOutlined />}
|
||||||
|
loading={ledgerLoading}
|
||||||
|
onClick={() => void loadLedger(true)}
|
||||||
|
>
|
||||||
|
重新校验
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(health || ledger) && (
|
||||||
|
<Space
|
||||||
|
size={12}
|
||||||
|
wrap
|
||||||
|
style={{ width: '100%', justifyContent: 'flex-end', marginBottom: 12 }}
|
||||||
|
>
|
||||||
|
{health && payoutReady && <Tag color="success">微信打款可用</Tag>}
|
||||||
|
{ledger?.ok && (
|
||||||
|
<Space size={6}>
|
||||||
|
<CheckCircleOutlined style={{ color: '#52c41a' }} />
|
||||||
|
<Text strong>账本正常</Text>
|
||||||
|
{ledgerCheckedAt && (
|
||||||
|
<Text type="secondary">
|
||||||
|
· {dayjs(ledgerCheckedAt).format('HH:mm:ss')} 校验
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
icon={<ReloadOutlined />}
|
||||||
|
loading={ledgerLoading}
|
||||||
|
onClick={() => void loadLedger(true)}
|
||||||
|
>
|
||||||
|
重新校验
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Row gutter={12} style={{ marginBottom: 16 }}>
|
||||||
|
<Col xs={24} sm={12}>
|
||||||
|
<Card size="small">
|
||||||
|
<Statistic title="待审核" value={summary?.reviewing_count || 0} suffix="笔" />
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
<Col xs={24} sm={12}>
|
||||||
|
<Card size="small">
|
||||||
|
<Statistic title="待审核金额" value={yuan(summary?.reviewing_amount_cents || 0)} />
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<Tabs
|
||||||
|
activeKey={activeStatus}
|
||||||
|
onChange={setActiveStatus}
|
||||||
|
items={STATUS_TABS.map((tab) => {
|
||||||
|
const count = summaryCount(summary, tab.key);
|
||||||
|
return {
|
||||||
|
key: tab.key,
|
||||||
|
label:
|
||||||
|
count == null ? (
|
||||||
|
tab.label
|
||||||
|
) : (
|
||||||
|
<Space size={4}>
|
||||||
|
<span>{tab.label}</span>
|
||||||
|
<Tag>{count}</Tag>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<Space
|
||||||
|
wrap
|
||||||
|
align="start"
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
marginBottom: 12,
|
||||||
|
paddingBottom: 12,
|
||||||
|
borderBottom: '1px solid #f0f0f0',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Input.Search
|
||||||
|
allowClear
|
||||||
|
enterButton="搜索"
|
||||||
|
prefix={<SearchOutlined />}
|
||||||
|
placeholder="用户手机号"
|
||||||
|
value={searchDraft}
|
||||||
|
style={{ width: 240 }}
|
||||||
|
onChange={(e) => {
|
||||||
|
const value = e.target.value;
|
||||||
|
setSearchDraft(value);
|
||||||
|
if (!value) setKeyword('');
|
||||||
|
}}
|
||||||
|
onSearch={(value) => setKeyword(value.trim())}
|
||||||
|
/>
|
||||||
|
<RangePicker
|
||||||
|
value={dateRange}
|
||||||
|
allowClear
|
||||||
|
style={{ width: 260 }}
|
||||||
|
presets={[
|
||||||
|
{ label: '今天', value: [dayjs().startOf('day'), dayjs().endOf('day')] },
|
||||||
|
{
|
||||||
|
label: '最近7天',
|
||||||
|
value: [dayjs().subtract(6, 'day').startOf('day'), dayjs().endOf('day')],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '最近30天',
|
||||||
|
value: [dayjs().subtract(29, 'day').startOf('day'), dayjs().endOf('day')],
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
onChange={(values) => setDateRange(values as [Dayjs, Dayjs] | null)}
|
||||||
|
/>
|
||||||
|
<Select
|
||||||
|
value={sortOrder}
|
||||||
|
style={{ width: 96 }}
|
||||||
|
suffixIcon={<SortAscendingOutlined />}
|
||||||
|
options={[
|
||||||
|
{ value: 'desc', label: '倒序' },
|
||||||
|
{ value: 'asc', label: '正序' },
|
||||||
|
]}
|
||||||
|
onChange={(value: 'asc' | 'desc') => setSortOrder(value)}
|
||||||
|
/>
|
||||||
|
<Button icon={<ClearOutlined />} onClick={resetFilters}>
|
||||||
|
重置
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
{canManage && selectedOrders.length > 0 && (
|
||||||
|
<Space
|
||||||
|
wrap
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
marginBottom: 12,
|
||||||
|
padding: '8px 0',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text type="secondary">
|
||||||
|
已选 {selectedOrders.length} 笔,待审核 {selectedReviewing.length} 笔,打款中{' '}
|
||||||
|
{selectedPending.length} 笔
|
||||||
|
</Text>
|
||||||
|
<Space wrap>
|
||||||
|
<Button
|
||||||
|
icon={<CheckCircleOutlined />}
|
||||||
|
disabled={!selectedReviewing.length}
|
||||||
|
onClick={bulkApprove}
|
||||||
|
>
|
||||||
|
批量通过
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
danger
|
||||||
|
icon={<CloseCircleOutlined />}
|
||||||
|
disabled={!selectedReviewing.length}
|
||||||
|
onClick={() => {
|
||||||
|
setRejecting(null);
|
||||||
|
setBulkRejecting(selectedReviewing);
|
||||||
|
setRejectReason('');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
批量拒绝
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
icon={<SyncOutlined />}
|
||||||
|
disabled={!selectedPending.length}
|
||||||
|
onClick={bulkRefresh}
|
||||||
|
>
|
||||||
|
批量刷新查单
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => setSelectedRowKeys([])}>清空选择</Button>
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
<Table
|
||||||
|
rowKey="id"
|
||||||
|
rowSelection={
|
||||||
|
canManage
|
||||||
|
? {
|
||||||
|
selectedRowKeys,
|
||||||
|
onChange: (keys) => setSelectedRowKeys(keys),
|
||||||
|
getCheckboxProps: (record) => ({
|
||||||
|
disabled: record.status !== 'reviewing' && record.status !== 'pending',
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={items}
|
||||||
|
loading={loading}
|
||||||
|
pagination={{
|
||||||
|
current: page,
|
||||||
|
pageSize,
|
||||||
|
total,
|
||||||
|
showSizeChanger: true,
|
||||||
|
pageSizeOptions: [20, 50, 100],
|
||||||
|
showTotal: (t) => `共 ${t} 条`,
|
||||||
|
onChange: onPageChange,
|
||||||
|
}}
|
||||||
|
scroll={{ x: 1350 }}
|
||||||
|
onRow={(record) => ({
|
||||||
|
onClick: () => openDetail(record),
|
||||||
|
style: { cursor: 'pointer' },
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Drawer
|
||||||
|
title="提现详情"
|
||||||
|
width="50%"
|
||||||
|
open={drawerOpen}
|
||||||
|
onClose={() => setDrawerOpen(false)}
|
||||||
|
extra={
|
||||||
|
detail && (
|
||||||
|
<Button
|
||||||
|
icon={<SearchOutlined />}
|
||||||
|
onClick={() => void loadDetail(detail.order.out_bill_no)}
|
||||||
|
>
|
||||||
|
刷新详情
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Spin spinning={detailLoading}>
|
||||||
|
{detail && (
|
||||||
|
<Space direction="vertical" size={18} style={{ width: '100%' }}>
|
||||||
|
<Descriptions bordered size="small" column={2} title="提现单">
|
||||||
|
<Descriptions.Item label="状态">{statusTag(detail.order.status)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="金额">
|
||||||
|
<Text strong>{yuan(detail.order.amount_cents)}</Text>
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="提现实名">
|
||||||
|
{detail.order.user_name || '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="微信状态">
|
||||||
|
{detail.order.wechat_state || '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="提现单号" span={2}>
|
||||||
|
<Text copyable>{detail.order.out_bill_no}</Text>
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="微信转账单号" span={2}>
|
||||||
|
{detail.order.transfer_bill_no || '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="失败/拒绝原因" span={2}>
|
||||||
|
{detail.order.fail_reason || '-'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
|
||||||
|
<UserRewardPanel userId={detail.order.user_id} user={detail.user} />
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>风险提示</h3>
|
||||||
|
{risks.length ? (
|
||||||
|
<Space wrap>
|
||||||
|
{risks.map((risk) => (
|
||||||
|
<Tag color="orange" key={risk}>
|
||||||
|
{risk}
|
||||||
|
</Tag>
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
) : (
|
||||||
|
<Text type="secondary">暂无明显风险标签</Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>处理时间线</h3>
|
||||||
|
<Timeline items={auditTimeline} />
|
||||||
|
</div>
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
</Spin>
|
||||||
|
</Drawer>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title={bulkRejecting.length ? `批量拒绝 ${bulkRejecting.length} 笔提现` : '拒绝提现'}
|
||||||
|
open={!!rejectTargets.length}
|
||||||
|
okText="确认拒绝并退款"
|
||||||
|
okButtonProps={{ danger: true, icon: <CloseCircleOutlined /> }}
|
||||||
|
onOk={confirmReject}
|
||||||
|
onCancel={() => {
|
||||||
|
setRejecting(null);
|
||||||
|
setBulkRejecting([]);
|
||||||
|
setRejectReason('');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{!!rejectTargets.length && (
|
||||||
|
<Space direction="vertical" style={{ width: '100%' }}>
|
||||||
|
<Text>
|
||||||
|
拒绝后会把 <Text strong>{yuan(rejectAmount)}</Text> 退回用户现金余额。
|
||||||
|
</Text>
|
||||||
|
<Space wrap>
|
||||||
|
{REJECT_TEMPLATES.map((tpl) => (
|
||||||
|
<Button size="small" key={tpl} onClick={() => setRejectReason(tpl)}>
|
||||||
|
{tpl}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
<Input.TextArea
|
||||||
|
rows={4}
|
||||||
|
maxLength={200}
|
||||||
|
value={rejectReason}
|
||||||
|
placeholder="请输入拒绝理由,用户端会看到这段说明"
|
||||||
|
onChange={(e) => setRejectReason(e.target.value)}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-18
@@ -1,26 +1,13 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
import { getToken } from '@/lib/auth';
|
import { getToken } from '@/lib/auth';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const router = useRouter();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.location.replace(getToken() ? '/dashboard' : '/login');
|
router.replace(getToken() ? '/dashboard' : '/login');
|
||||||
}, []);
|
}, [router]);
|
||||||
|
return null;
|
||||||
return (
|
|
||||||
<main
|
|
||||||
style={{
|
|
||||||
minHeight: '100vh',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
background: '#f0f2f5',
|
|
||||||
color: '#595959',
|
|
||||||
fontFamily: 'system-ui, sans-serif',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
正在进入运营后台…
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { App, Input, Modal } from 'antd';
|
|
||||||
import { api, errMsg } from '@/lib/api';
|
|
||||||
|
|
||||||
export type RiskUser = {
|
|
||||||
id: number;
|
|
||||||
phone: string;
|
|
||||||
is_high_risk: boolean;
|
|
||||||
high_risk_note: string | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
user: RiskUser | null;
|
|
||||||
open: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
onDone: () => void | Promise<void>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function UserRiskModal({ user, open, onClose, onDone }: Props) {
|
|
||||||
const { message } = App.useApp();
|
|
||||||
const [note, setNote] = useState('');
|
|
||||||
const [saving, setSaving] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (open) setNote(user?.high_risk_note ?? '');
|
|
||||||
}, [open, user]);
|
|
||||||
|
|
||||||
const save = async () => {
|
|
||||||
if (!user) return;
|
|
||||||
const trimmed = note.trim();
|
|
||||||
if (!trimmed) {
|
|
||||||
message.warning('请输入标记为高风险的原因');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setSaving(true);
|
|
||||||
try {
|
|
||||||
await api.post(`/admin/api/users/${user.id}/risk`, {
|
|
||||||
is_high_risk: true,
|
|
||||||
note: trimmed,
|
|
||||||
});
|
|
||||||
message.success(user.is_high_risk ? '高风险备注已更新' : '已标记为高风险');
|
|
||||||
await onDone();
|
|
||||||
onClose();
|
|
||||||
} catch (error) {
|
|
||||||
message.error(errMsg(error));
|
|
||||||
} finally {
|
|
||||||
setSaving(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
title="高风险备注"
|
|
||||||
open={open}
|
|
||||||
okText="保存"
|
|
||||||
confirmLoading={saving}
|
|
||||||
onOk={save}
|
|
||||||
onCancel={onClose}
|
|
||||||
destroyOnHidden
|
|
||||||
>
|
|
||||||
<Input.TextArea
|
|
||||||
autoFocus
|
|
||||||
rows={5}
|
|
||||||
maxLength={500}
|
|
||||||
showCount
|
|
||||||
value={note}
|
|
||||||
placeholder="请输入标记为高风险的原因"
|
|
||||||
onChange={(event) => setNote(event.target.value)}
|
|
||||||
/>
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function clearUserRisk(userId: number) {
|
|
||||||
await api.post(`/admin/api/users/${userId}/risk`, {
|
|
||||||
is_high_risk: false,
|
|
||||||
note: null,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
export type ReviewBadgeKey =
|
export type ReviewBadgeKey = '/withdraws' | '/price-reports' | '/feedbacks';
|
||||||
| '/invite-withdraws'
|
|
||||||
| '/withdraws'
|
|
||||||
| '/price-reports'
|
|
||||||
| '/feedbacks';
|
|
||||||
|
|
||||||
export const REVIEW_BADGE_REFRESH_EVENT = 'review-badge-refresh';
|
export const REVIEW_BADGE_REFRESH_EVENT = 'review-badge-refresh';
|
||||||
|
|
||||||
|
|||||||
+22
-38
@@ -52,8 +52,6 @@ export interface UserListItem {
|
|||||||
status: string;
|
status: string;
|
||||||
// 调试链接权限:开了的用户在 App 比价结果页/记录页可复制 price.shaguabijia.com 的 trace 调试链接
|
// 调试链接权限:开了的用户在 App 比价结果页/记录页可复制 price.shaguabijia.com 的 trace 调试链接
|
||||||
debug_trace_enabled: boolean;
|
debug_trace_enabled: boolean;
|
||||||
is_high_risk: boolean;
|
|
||||||
high_risk_note: string | null;
|
|
||||||
// 运营「一键开启新手引导」:true = 该用户下次打开 App 会被强制重走新手引导,走完自动取消
|
// 运营「一键开启新手引导」:true = 该用户下次打开 App 会被强制重走新手引导,走完自动取消
|
||||||
force_onboarding: boolean;
|
force_onboarding: boolean;
|
||||||
wechat_openid: string | null;
|
wechat_openid: string | null;
|
||||||
@@ -145,6 +143,7 @@ export interface WithdrawOrder {
|
|||||||
amount_cents: number;
|
amount_cents: number;
|
||||||
// 提现类型:coin_cash(福利页提现,金币兑换现金) / invite_cash(邀请提现,邀请奖励金)
|
// 提现类型:coin_cash(福利页提现,金币兑换现金) / invite_cash(邀请提现,邀请奖励金)
|
||||||
source: string;
|
source: string;
|
||||||
|
user_name: string | null;
|
||||||
status: string; // reviewing / pending / success / failed / rejected
|
status: string; // reviewing / pending / success / failed / rejected
|
||||||
wechat_state: string | null;
|
wechat_state: string | null;
|
||||||
transfer_bill_no: string | null;
|
transfer_bill_no: string | null;
|
||||||
@@ -158,8 +157,6 @@ export interface WithdrawOrder {
|
|||||||
export interface WithdrawListItem extends WithdrawOrder {
|
export interface WithdrawListItem extends WithdrawOrder {
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
nickname: string | null;
|
nickname: string | null;
|
||||||
is_high_risk: boolean;
|
|
||||||
high_risk_note: string | null;
|
|
||||||
cumulative_success_cents: number; // 累计成功提现(分)
|
cumulative_success_cents: number; // 累计成功提现(分)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,10 +164,7 @@ export interface WithdrawSummary {
|
|||||||
reviewing_count: number;
|
reviewing_count: number;
|
||||||
reviewing_amount_cents: number;
|
reviewing_amount_cents: number;
|
||||||
pending_count: number;
|
pending_count: number;
|
||||||
success_count: number;
|
|
||||||
rejected_count: number;
|
|
||||||
failed_count: number;
|
failed_count: number;
|
||||||
total_count: number;
|
|
||||||
today_success_count: number;
|
today_success_count: number;
|
||||||
today_success_amount_cents: number;
|
today_success_amount_cents: number;
|
||||||
today_rejected_count: number;
|
today_rejected_count: number;
|
||||||
@@ -180,8 +174,6 @@ export interface WithdrawUserSnapshot {
|
|||||||
id: number;
|
id: number;
|
||||||
phone: string;
|
phone: string;
|
||||||
nickname: string | null;
|
nickname: string | null;
|
||||||
is_high_risk: boolean;
|
|
||||||
high_risk_note: string | null;
|
|
||||||
status: string;
|
status: string;
|
||||||
wechat_nickname: string | null;
|
wechat_nickname: string | null;
|
||||||
wechat_avatar_url: string | null;
|
wechat_avatar_url: string | null;
|
||||||
@@ -192,34 +184,14 @@ export interface WithdrawUserSnapshot {
|
|||||||
withdraw_success_cents: number;
|
withdraw_success_cents: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InviteeDetail {
|
|
||||||
user_id: number;
|
|
||||||
phone: string;
|
|
||||||
registered_at: string;
|
|
||||||
invite_success: boolean;
|
|
||||||
first_compare_store: string | null;
|
|
||||||
first_compare_products: string | null;
|
|
||||||
first_order_store: string | null;
|
|
||||||
first_order_products: string | null;
|
|
||||||
first_order_amount_cents: number | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface InviteOverview {
|
|
||||||
invite_total: number;
|
|
||||||
invite_success_total: number;
|
|
||||||
items: InviteeDetail[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WithdrawDetail {
|
export interface WithdrawDetail {
|
||||||
order: WithdrawOrder;
|
order: WithdrawOrder;
|
||||||
user: WithdrawUserSnapshot | null;
|
user: WithdrawUserSnapshot | null;
|
||||||
cumulative_success_cents: number;
|
|
||||||
risk_flags: string[];
|
risk_flags: string[];
|
||||||
risk_score: number;
|
risk_score: number;
|
||||||
recent_withdraws: WithdrawOrder[];
|
recent_withdraws: WithdrawOrder[];
|
||||||
recent_cash_transactions: CashTxn[];
|
recent_cash_transactions: CashTxn[];
|
||||||
audit_logs: AuditLog[];
|
audit_logs: AuditLog[];
|
||||||
invite_overview: InviteOverview | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提现详情抽屉「用户统计区」:按时间窗口算的提现 + 看广告行为统计。
|
// 提现详情抽屉「用户统计区」:按时间窗口算的提现 + 看广告行为统计。
|
||||||
@@ -346,6 +318,26 @@ export interface WithdrawBulkResult {
|
|||||||
items: WithdrawBulkItemResult[];
|
items: WithdrawBulkItemResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WithdrawLedgerCheck {
|
||||||
|
ok: boolean;
|
||||||
|
// 普通现金账(coin_cash)
|
||||||
|
cash_balance_total_cents: number;
|
||||||
|
cash_transaction_total_cents: number;
|
||||||
|
balance_diff_cents: number;
|
||||||
|
missing_withdraw_txn_count: number;
|
||||||
|
missing_refund_txn_count: number;
|
||||||
|
duplicate_refund_txn_count: number;
|
||||||
|
refund_txn_on_non_terminal_count: number;
|
||||||
|
// 邀请奖励金账(invite_cash:与普通现金物理隔离,各自对账)
|
||||||
|
invite_cash_balance_total_cents: number;
|
||||||
|
invite_cash_transaction_total_cents: number;
|
||||||
|
invite_balance_diff_cents: number;
|
||||||
|
invite_missing_withdraw_txn_count: number;
|
||||||
|
invite_missing_refund_txn_count: number;
|
||||||
|
invite_duplicate_refund_txn_count: number;
|
||||||
|
invite_refund_txn_on_non_terminal_count: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface WxpayHealthCheck {
|
export interface WxpayHealthCheck {
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
wxpay_configured: boolean;
|
wxpay_configured: boolean;
|
||||||
@@ -385,10 +377,7 @@ export interface Feedback {
|
|||||||
// 提交端环境快照:提交版本号 / 机型OS版本;改版前的历史反馈为 null
|
// 提交端环境快照:提交版本号 / 机型OS版本;改版前的历史反馈为 null
|
||||||
app_version: string | null;
|
app_version: string | null;
|
||||||
device_model: string | null;
|
device_model: string | null;
|
||||||
device_model_name: string | null;
|
|
||||||
device_manufacturer: string | null;
|
|
||||||
rom_name: string | null;
|
rom_name: string | null;
|
||||||
rom_version: number | null;
|
|
||||||
android_version: string | null;
|
android_version: string | null;
|
||||||
// 联表瞬态:展示完整手机号(点手机号查该用户全部反馈)
|
// 联表瞬态:展示完整手机号(点手机号查该用户全部反馈)
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
@@ -465,10 +454,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; // 本次比价看的信息流广告预估收益(元)
|
||||||
@@ -519,6 +506,7 @@ export interface ComparisonRecordDetail extends ComparisonRecordListItem {
|
|||||||
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;
|
||||||
@@ -554,8 +542,6 @@ export interface AdRevenueRecord {
|
|||||||
expected_coin: number;
|
expected_coin: number;
|
||||||
actual_coin: number;
|
actual_coin: number;
|
||||||
matched: boolean;
|
matched: boolean;
|
||||||
adn: string | null; // 本条发奖对应的实际填充 ADN
|
|
||||||
slot_id: string | null; // 本条发奖对应的底层 mediation rit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 广告收益报表:按日期汇总的一天(按天趋势图用;全量,不受分页影响)
|
// 广告收益报表:按日期汇总的一天(按天趋势图用;全量,不受分页影响)
|
||||||
@@ -582,7 +568,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 合并;信息流展示/发奖各自成行。
|
||||||
@@ -622,7 +607,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 现算。
|
||||||
|
|||||||
Reference in New Issue
Block a user