feat: 增加管理端多语言与风控/报表/奖池操作能力

This commit is contained in:
2026-05-18 15:08:34 +08:00
parent afffa4e508
commit 49a4caf01e
31 changed files with 918 additions and 115 deletions

View File

@@ -3,7 +3,11 @@
import { useCallback, useEffect, useState } from "react";
import { toast } from "sonner";
import { getAdminReportJobs, postAdminReportJob } from "@/api/admin-reports";
import {
downloadAdminReportJob,
getAdminReportJobs,
postAdminReportJob,
} from "@/api/admin-reports";
import { AdminListPaginationFooter } from "@/components/admin/admin-list-pagination-footer";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -30,6 +34,15 @@ import { LotteryApiBizError } from "@/types/api/errors";
import type { AdminReportJobListData } from "@/types/api/admin-reports";
const REPORT_TYPES = [
{ value: "draw_profit_summary", label: "期号盈亏" },
{ value: "daily_profit_summary", label: "每日盈亏汇总" },
{ value: "player_win_loss", label: "玩家输赢报表" },
{ value: "wallet_transfer_report", label: "玩家转入转出报表" },
{ value: "hot_number_risk_report", label: "热门号码风险报表" },
{ value: "play_dimension_report", label: "玩法维度报表" },
{ value: "sold_out_number_report", label: "售罄号码报表" },
{ value: "rebate_commission_report", label: "佣金回水报表" },
{ value: "audit_operation_report", label: "后台操作审计报表" },
{ value: "wallet_txns_daily", label: "钱包流水日报" },
{ value: "transfer_orders_daily", label: "转账单日报" },
] as const;
@@ -83,6 +96,7 @@ export function ReportsConsole(): React.ReactElement {
await postAdminReportJob({
report_type: reportType,
export_format: exportFormat,
parameters: filter_json,
filter_json,
});
toast.success("已创建导出任务");
@@ -95,6 +109,20 @@ export function ReportsConsole(): React.ReactElement {
}
}
async function onDownload(rowId: number): Promise<void> {
try {
const blob = await downloadAdminReportJob(rowId);
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "";
a.click();
URL.revokeObjectURL(url);
} catch {
toast.error("下载失败");
}
}
const meta = data?.meta;
const lastPage = meta
? Math.max(1, meta.last_page)
@@ -194,13 +222,14 @@ export function ReportsConsole(): React.ReactElement {
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
</TableRow>
</TableHeader>
<TableBody>
{data.items.length === 0 ? (
<TableRow>
<TableCell colSpan={7} className="text-muted-foreground">
<TableCell colSpan={8} className="text-muted-foreground">
</TableCell>
</TableRow>
@@ -217,6 +246,16 @@ export function ReportsConsole(): React.ReactElement {
<TableCell className="max-w-[12rem] truncate text-xs text-muted-foreground">
{row.output_path ?? "—"}
</TableCell>
<TableCell>
<Button
type="button"
variant="secondary"
size="sm"
onClick={() => void onDownload(row.id)}
>
</Button>
</TableCell>
<TableCell className="whitespace-nowrap font-mono text-[11px] text-muted-foreground">
{formatTs(row.created_at)}
</TableCell>