feat: 更新管理员导航,添加结算和奖池模块,并优化活动匹配逻辑
This commit is contained in:
51
src/api/admin-jackpot.ts
Normal file
51
src/api/admin-jackpot.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { adminRequest } from "@/lib/admin-http";
|
||||
|
||||
import { API_V1_PREFIX } from "./paths";
|
||||
|
||||
import type {
|
||||
AdminJackpotContributionsData,
|
||||
AdminJackpotPoolsData,
|
||||
AdminJackpotPayoutLogsData,
|
||||
AdminJackpotPoolRow,
|
||||
} from "@/types/api/admin-jackpot";
|
||||
|
||||
const A = `${API_V1_PREFIX}/admin`;
|
||||
|
||||
export async function getAdminJackpotPools(): Promise<AdminJackpotPoolsData> {
|
||||
return adminRequest.get<AdminJackpotPoolsData>(`${A}/jackpot/pools`);
|
||||
}
|
||||
|
||||
export type AdminJackpotPoolUpdateBody = Partial<{
|
||||
current_amount: number;
|
||||
contribution_rate: number;
|
||||
trigger_threshold: number;
|
||||
payout_rate: number;
|
||||
force_trigger_draw_gap: number;
|
||||
min_bet_amount: number;
|
||||
status: number;
|
||||
}>;
|
||||
|
||||
export async function putAdminJackpotPool(
|
||||
poolId: number,
|
||||
body: AdminJackpotPoolUpdateBody,
|
||||
): Promise<AdminJackpotPoolRow> {
|
||||
return adminRequest.put<AdminJackpotPoolRow>(`${A}/jackpot/pools/${poolId}`, body);
|
||||
}
|
||||
|
||||
export type AdminJackpotLogsQuery = {
|
||||
page?: number;
|
||||
per_page?: number;
|
||||
draw_no?: string;
|
||||
};
|
||||
|
||||
export async function getAdminJackpotPayoutLogs(
|
||||
q: AdminJackpotLogsQuery = {},
|
||||
): Promise<AdminJackpotPayoutLogsData> {
|
||||
return adminRequest.get<AdminJackpotPayoutLogsData>(`${A}/jackpot/payout-logs`, { params: q });
|
||||
}
|
||||
|
||||
export async function getAdminJackpotContributions(
|
||||
q: AdminJackpotLogsQuery = {},
|
||||
): Promise<AdminJackpotContributionsData> {
|
||||
return adminRequest.get<AdminJackpotContributionsData>(`${A}/jackpot/contributions`, { params: q });
|
||||
}
|
||||
43
src/api/admin-settlement.ts
Normal file
43
src/api/admin-settlement.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { adminRequest } from "@/lib/admin-http";
|
||||
|
||||
import { API_V1_PREFIX } from "./paths";
|
||||
|
||||
import type {
|
||||
AdminSettlementBatchDetailsData,
|
||||
AdminSettlementBatchListData,
|
||||
AdminSettlementBatchShowData,
|
||||
} from "@/types/api/admin-settlement";
|
||||
|
||||
const A = `${API_V1_PREFIX}/admin`;
|
||||
|
||||
export type AdminSettlementBatchListQuery = {
|
||||
page?: number;
|
||||
per_page?: number;
|
||||
draw_no?: string;
|
||||
status?: string;
|
||||
};
|
||||
|
||||
export async function getAdminSettlementBatches(
|
||||
q: AdminSettlementBatchListQuery = {},
|
||||
): Promise<AdminSettlementBatchListData> {
|
||||
return adminRequest.get<AdminSettlementBatchListData>(`${A}/settlement-batches`, { params: q });
|
||||
}
|
||||
|
||||
export async function getAdminSettlementBatch(batchId: number): Promise<AdminSettlementBatchShowData> {
|
||||
return adminRequest.get<AdminSettlementBatchShowData>(`${A}/settlement-batches/${batchId}`);
|
||||
}
|
||||
|
||||
export type AdminSettlementBatchDetailsQuery = {
|
||||
page?: number;
|
||||
per_page?: number;
|
||||
};
|
||||
|
||||
export async function getAdminSettlementBatchDetails(
|
||||
batchId: number,
|
||||
q: AdminSettlementBatchDetailsQuery = {},
|
||||
): Promise<AdminSettlementBatchDetailsData> {
|
||||
return adminRequest.get<AdminSettlementBatchDetailsData>(
|
||||
`${A}/settlement-batches/${batchId}/details`,
|
||||
{ params: q },
|
||||
);
|
||||
}
|
||||
10
src/app/admin/(shell)/jackpot/layout.tsx
Normal file
10
src/app/admin/(shell)/jackpot/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { JackpotSubNav } from "@/modules/jackpot/jackpot-subnav";
|
||||
|
||||
export default function AdminJackpotLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="w-full max-w-none px-1">
|
||||
<JackpotSubNav />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
19
src/app/admin/(shell)/jackpot/pools/page.tsx
Normal file
19
src/app/admin/(shell)/jackpot/pools/page.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { JackpotPoolsConsole } from "@/modules/jackpot/jackpot-pools-console";
|
||||
import { jackpotModuleMeta } from "@/modules/jackpot/meta";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `奖池配置 · ${jackpotModuleMeta.title}`,
|
||||
};
|
||||
|
||||
export default function AdminJackpotPoolsPage() {
|
||||
return (
|
||||
<>
|
||||
<div className="mx-auto mb-6 max-w-5xl">
|
||||
<h1 className="text-lg font-semibold tracking-tight">{jackpotModuleMeta.title}</h1>
|
||||
<p className="text-muted-foreground mt-1 text-sm">{jackpotModuleMeta.description}</p>
|
||||
</div>
|
||||
<JackpotPoolsConsole />
|
||||
</>
|
||||
);
|
||||
}
|
||||
19
src/app/admin/(shell)/jackpot/records/page.tsx
Normal file
19
src/app/admin/(shell)/jackpot/records/page.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { JackpotRecordsConsole } from "@/modules/jackpot/jackpot-records-console";
|
||||
import { jackpotModuleMeta } from "@/modules/jackpot/meta";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `Jackpot 记录 · ${jackpotModuleMeta.title}`,
|
||||
};
|
||||
|
||||
export default function AdminJackpotRecordsPage() {
|
||||
return (
|
||||
<>
|
||||
<div className="mx-auto mb-6 max-w-5xl">
|
||||
<h1 className="text-lg font-semibold tracking-tight">Jackpot 记录</h1>
|
||||
<p className="text-muted-foreground mt-1 text-sm">派彩与蓄水流水</p>
|
||||
</div>
|
||||
<JackpotRecordsConsole />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { SettlementBatchDetailsConsole } from "@/modules/settlement/settlement-batch-details-console";
|
||||
import { settlementModuleMeta } from "@/modules/settlement/meta";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `结算明细 · ${settlementModuleMeta.title}`,
|
||||
};
|
||||
|
||||
export default async function AdminSettlementBatchDetailsPage(props: {
|
||||
params: Promise<{ batchId: string }>;
|
||||
}) {
|
||||
const { batchId } = await props.params;
|
||||
const id = Number.parseInt(batchId, 10);
|
||||
if (!Number.isFinite(id) || id < 1) {
|
||||
return <p className="text-destructive text-sm">无效的批次 ID</p>;
|
||||
}
|
||||
|
||||
return <SettlementBatchDetailsConsole batchId={id} />;
|
||||
}
|
||||
11
src/app/admin/(shell)/settlement-batches/page.tsx
Normal file
11
src/app/admin/(shell)/settlement-batches/page.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { SettlementBatchesConsole } from "@/modules/settlement/settlement-batches-console";
|
||||
import { settlementModuleMeta } from "@/modules/settlement/meta";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: settlementModuleMeta.title,
|
||||
};
|
||||
|
||||
export default function AdminSettlementBatchesPage() {
|
||||
return <SettlementBatchesConsole />;
|
||||
}
|
||||
@@ -24,11 +24,13 @@ import {
|
||||
} from "@/modules/_config/admin-nav-icons";
|
||||
import { adminShellNavItems, ADMIN_BASE } from "@/modules/_config/admin-nav";
|
||||
|
||||
function isActive(pathname: string, href: string): boolean {
|
||||
if (href === ADMIN_BASE || href === `${ADMIN_BASE}/`) {
|
||||
function isActive(pathname: string, item: { href: string; activeMatchPrefix?: string }): boolean {
|
||||
const { href, activeMatchPrefix } = item;
|
||||
const prefix = activeMatchPrefix ?? href;
|
||||
if (prefix === ADMIN_BASE || prefix === `${ADMIN_BASE}/`) {
|
||||
return pathname === ADMIN_BASE || pathname === `${ADMIN_BASE}/`;
|
||||
}
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
return pathname === prefix || pathname.startsWith(`${prefix}/`);
|
||||
}
|
||||
|
||||
export function AdminAppSidebar() {
|
||||
@@ -67,7 +69,7 @@ export function AdminAppSidebar() {
|
||||
<SidebarMenuItem key={item.segment}>
|
||||
<SidebarMenuButton
|
||||
tooltip={item.label}
|
||||
isActive={isActive(pathname, item.href)}
|
||||
isActive={isActive(pathname, item)}
|
||||
render={<Link href={item.href} />}
|
||||
>
|
||||
<Icon data-icon="inline-start" aria-hidden />
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
import {
|
||||
CalendarClock,
|
||||
CircleDollarSign,
|
||||
Landmark,
|
||||
LayoutDashboard,
|
||||
LogIn,
|
||||
Settings,
|
||||
@@ -23,6 +25,8 @@ export const adminNavIconBySegment: Record<AdminNavItem["segment"], LucideIcon>
|
||||
tickets: Ticket,
|
||||
wallet: Wallet,
|
||||
risk: ShieldAlert,
|
||||
settlement: Landmark,
|
||||
jackpot: CircleDollarSign,
|
||||
settings: Settings,
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,11 @@ export type AdminNavItem = {
|
||||
| "tickets"
|
||||
| "wallet"
|
||||
| "risk"
|
||||
| "settings";
|
||||
| "settings"
|
||||
| "settlement"
|
||||
| "jackpot";
|
||||
/** 高亮匹配:默认用 `href`;Jackpot 多子页时传公共前缀如 `/admin/jackpot` */
|
||||
activeMatchPrefix?: string;
|
||||
};
|
||||
|
||||
export const adminShellNavItems: AdminNavItem[] = [
|
||||
@@ -27,5 +31,12 @@ export const adminShellNavItems: AdminNavItem[] = [
|
||||
{ segment: "tickets", label: "注单 / 票务", href: "/admin/tickets" },
|
||||
{ segment: "wallet", label: "钱包", href: "/admin/wallet" },
|
||||
{ segment: "risk", label: "风控", href: "/admin/risk" },
|
||||
{ segment: "settlement", label: "结算", href: "/admin/settlement-batches" },
|
||||
{
|
||||
segment: "jackpot",
|
||||
label: "Jackpot",
|
||||
href: "/admin/jackpot/pools",
|
||||
activeMatchPrefix: "/admin/jackpot",
|
||||
},
|
||||
{ segment: "settings", label: "系统设置", href: "/admin/settings" },
|
||||
];
|
||||
|
||||
209
src/modules/jackpot/jackpot-pools-console.tsx
Normal file
209
src/modules/jackpot/jackpot-pools-console.tsx
Normal file
@@ -0,0 +1,209 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getAdminJackpotPools, putAdminJackpotPool } from "@/api/admin-jackpot";
|
||||
import { ModuleScaffold } from "@/components/admin/module-scaffold";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { formatAdminMinorUnits } from "@/lib/money";
|
||||
import { toast } from "sonner";
|
||||
import { LotteryApiBizError } from "@/types/api/errors";
|
||||
import type { AdminJackpotPoolRow } from "@/types/api/admin-jackpot";
|
||||
|
||||
type Draft = {
|
||||
current_amount: string;
|
||||
contribution_rate: string;
|
||||
trigger_threshold: string;
|
||||
payout_rate: string;
|
||||
force_trigger_draw_gap: string;
|
||||
min_bet_amount: string;
|
||||
status: string;
|
||||
};
|
||||
|
||||
function toDraft(p: AdminJackpotPoolRow): Draft {
|
||||
return {
|
||||
current_amount: String(p.current_amount),
|
||||
contribution_rate: String(p.contribution_rate),
|
||||
trigger_threshold: String(p.trigger_threshold),
|
||||
payout_rate: String(p.payout_rate),
|
||||
force_trigger_draw_gap: String(p.force_trigger_draw_gap),
|
||||
min_bet_amount: String(p.min_bet_amount),
|
||||
status: String(p.status),
|
||||
};
|
||||
}
|
||||
|
||||
export function JackpotPoolsConsole() {
|
||||
const [items, setItems] = useState<AdminJackpotPoolRow[]>([]);
|
||||
const [drafts, setDrafts] = useState<Record<number, Draft>>({});
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [savingId, setSavingId] = useState<number | null>(null);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await getAdminJackpotPools();
|
||||
setItems(res.items);
|
||||
const d: Record<number, Draft> = {};
|
||||
for (const p of res.items) {
|
||||
d[p.id] = toDraft(p);
|
||||
}
|
||||
setDrafts(d);
|
||||
} catch (e) {
|
||||
toast.error(e instanceof LotteryApiBizError ? e.message : "加载失败");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
queueMicrotask(() => {
|
||||
void load();
|
||||
});
|
||||
}, [load]);
|
||||
|
||||
const updateDraft = (id: number, patch: Partial<Draft>) => {
|
||||
setDrafts((prev) => ({
|
||||
...prev,
|
||||
[id]: { ...prev[id], ...patch },
|
||||
}));
|
||||
};
|
||||
|
||||
const save = async (p: AdminJackpotPoolRow) => {
|
||||
const d = drafts[p.id];
|
||||
if (!d) return;
|
||||
setSavingId(p.id);
|
||||
try {
|
||||
await putAdminJackpotPool(p.id, {
|
||||
current_amount: Number.parseInt(d.current_amount, 10),
|
||||
contribution_rate: Number(d.contribution_rate),
|
||||
trigger_threshold: Number.parseInt(d.trigger_threshold, 10),
|
||||
payout_rate: Number(d.payout_rate),
|
||||
force_trigger_draw_gap: Number.parseInt(d.force_trigger_draw_gap, 10),
|
||||
min_bet_amount: Number.parseInt(d.min_bet_amount, 10),
|
||||
status: Number.parseInt(d.status, 10),
|
||||
});
|
||||
toast.success("已保存");
|
||||
await load();
|
||||
} catch (e) {
|
||||
toast.error(e instanceof LotteryApiBizError ? e.message : "保存失败");
|
||||
} finally {
|
||||
setSavingId(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ModuleScaffold>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Jackpot 奖池配置</CardTitle>
|
||||
<CardDescription>蓄水比例、爆池阈值、派彩比例等;修改后保存生效</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-8">
|
||||
{loading ? <p className="text-muted-foreground text-sm">加载中…</p> : null}
|
||||
{!loading && items.length === 0 ? (
|
||||
<p className="text-muted-foreground text-sm">暂无奖池数据</p>
|
||||
) : null}
|
||||
{items.map((p) => {
|
||||
const d = drafts[p.id] ?? toDraft(p);
|
||||
return (
|
||||
<div key={p.id} className="space-y-4 rounded-lg border border-border p-4">
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<h3 className="font-mono text-sm font-semibold">{p.currency_code}</h3>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
展示余额 {formatAdminMinorUnits(p.current_amount, p.currency_code)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor={`amt-${p.id}`}>当前池余额(最小单位)</Label>
|
||||
<Input
|
||||
id={`amt-${p.id}`}
|
||||
className="font-mono"
|
||||
value={d.current_amount}
|
||||
onChange={(e) => updateDraft(p.id, { current_amount: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor={`cr-${p.id}`}>蓄水比例 0–1</Label>
|
||||
<Input
|
||||
id={`cr-${p.id}`}
|
||||
className="font-mono"
|
||||
value={d.contribution_rate}
|
||||
onChange={(e) => updateDraft(p.id, { contribution_rate: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor={`th-${p.id}`}>爆池阈值(最小单位)</Label>
|
||||
<Input
|
||||
id={`th-${p.id}`}
|
||||
className="font-mono"
|
||||
value={d.trigger_threshold}
|
||||
onChange={(e) => updateDraft(p.id, { trigger_threshold: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor={`pr-${p.id}`}>爆池派彩比例 0–1</Label>
|
||||
<Input
|
||||
id={`pr-${p.id}`}
|
||||
className="font-mono"
|
||||
value={d.payout_rate}
|
||||
onChange={(e) => updateDraft(p.id, { payout_rate: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor={`gap-${p.id}`}>强制爆池间隔(已结算期数)</Label>
|
||||
<Input
|
||||
id={`gap-${p.id}`}
|
||||
className="font-mono"
|
||||
value={d.force_trigger_draw_gap}
|
||||
onChange={(e) => updateDraft(p.id, { force_trigger_draw_gap: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor={`min-${p.id}`}>最低下注额(最小单位)</Label>
|
||||
<Input
|
||||
id={`min-${p.id}`}
|
||||
className="font-mono"
|
||||
value={d.min_bet_amount}
|
||||
onChange={(e) => updateDraft(p.id, { min_bet_amount: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label>开关</Label>
|
||||
<Select
|
||||
value={d.status}
|
||||
onValueChange={(v) => updateDraft(p.id, { status: v ?? "0" })}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="0">关闭</SelectItem>
|
||||
<SelectItem value="1">开启</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end">
|
||||
<Button type="button" disabled={savingId === p.id} onClick={() => void save(p)}>
|
||||
{savingId === p.id ? "保存中…" : "保存"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</ModuleScaffold>
|
||||
);
|
||||
}
|
||||
236
src/modules/jackpot/jackpot-records-console.tsx
Normal file
236
src/modules/jackpot/jackpot-records-console.tsx
Normal file
@@ -0,0 +1,236 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getAdminJackpotContributions, getAdminJackpotPayoutLogs } from "@/api/admin-jackpot";
|
||||
import { AdminListPaginationFooter } from "@/components/admin/admin-list-pagination-footer";
|
||||
import { ModuleScaffold } from "@/components/admin/module-scaffold";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
|
||||
import { formatAdminMinorUnits } from "@/lib/money";
|
||||
import { LotteryApiBizError } from "@/types/api/errors";
|
||||
import type {
|
||||
AdminJackpotContributionsData,
|
||||
AdminJackpotPayoutLogsData,
|
||||
} from "@/types/api/admin-jackpot";
|
||||
|
||||
export function JackpotRecordsConsole() {
|
||||
const formatDt = useAdminDateTimeFormatter();
|
||||
const [drawNo, setDrawNo] = useState("");
|
||||
const [appliedDrawNo, setAppliedDrawNo] = useState("");
|
||||
|
||||
const [payouts, setPayouts] = useState<AdminJackpotPayoutLogsData | null>(null);
|
||||
const [pPage, setPPage] = useState(1);
|
||||
const [pPer, setPPer] = useState(15);
|
||||
|
||||
const [contribs, setContribs] = useState<AdminJackpotContributionsData | null>(null);
|
||||
const [cPage, setCPage] = useState(1);
|
||||
const [cPer, setCPer] = useState(15);
|
||||
|
||||
const [loadingP, setLoadingP] = useState(true);
|
||||
const [loadingC, setLoadingC] = useState(true);
|
||||
const [err, setErr] = useState<string | null>(null);
|
||||
|
||||
const loadPayouts = useCallback(async () => {
|
||||
setLoadingP(true);
|
||||
try {
|
||||
const d = await getAdminJackpotPayoutLogs({
|
||||
page: pPage,
|
||||
per_page: pPer,
|
||||
draw_no: appliedDrawNo.trim() || undefined,
|
||||
});
|
||||
setPayouts(d);
|
||||
} catch (e) {
|
||||
setErr(e instanceof LotteryApiBizError ? e.message : "派彩记录加载失败");
|
||||
} finally {
|
||||
setLoadingP(false);
|
||||
}
|
||||
}, [pPage, pPer, appliedDrawNo]);
|
||||
|
||||
const loadContribs = useCallback(async () => {
|
||||
setLoadingC(true);
|
||||
try {
|
||||
const d = await getAdminJackpotContributions({
|
||||
page: cPage,
|
||||
per_page: cPer,
|
||||
draw_no: appliedDrawNo.trim() || undefined,
|
||||
});
|
||||
setContribs(d);
|
||||
} catch (e) {
|
||||
setErr(e instanceof LotteryApiBizError ? e.message : "蓄水记录加载失败");
|
||||
} finally {
|
||||
setLoadingC(false);
|
||||
}
|
||||
}, [cPage, cPer, appliedDrawNo]);
|
||||
|
||||
useEffect(() => {
|
||||
queueMicrotask(() => {
|
||||
void loadPayouts();
|
||||
});
|
||||
}, [loadPayouts]);
|
||||
|
||||
useEffect(() => {
|
||||
queueMicrotask(() => {
|
||||
void loadContribs();
|
||||
});
|
||||
}, [loadContribs]);
|
||||
|
||||
const applyDraw = () => {
|
||||
setAppliedDrawNo(drawNo);
|
||||
setPPage(1);
|
||||
setCPage(1);
|
||||
};
|
||||
|
||||
return (
|
||||
<ModuleScaffold>
|
||||
<Card className="mb-6">
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-base">筛选</CardTitle>
|
||||
<CardDescription>按期号模糊过滤两类记录</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-3 sm:flex-row sm:items-end">
|
||||
<div className="flex max-w-xs flex-1 flex-col gap-1.5">
|
||||
<Label htmlFor="jk-draw">期号</Label>
|
||||
<Input
|
||||
id="jk-draw"
|
||||
className="font-mono"
|
||||
value={drawNo}
|
||||
onChange={(e) => setDrawNo(e.target.value)}
|
||||
placeholder="可选"
|
||||
/>
|
||||
</div>
|
||||
<Button type="button" onClick={applyDraw}>
|
||||
应用
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{err ? <p className="text-destructive mb-4 text-sm">{err}</p> : null}
|
||||
|
||||
<Card className="mb-8">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Jackpot 派彩记录</CardTitle>
|
||||
<CardDescription>爆池触发与划出总额</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{loadingP && !payouts ? (
|
||||
<p className="text-muted-foreground text-sm">加载中…</p>
|
||||
) : (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>ID</TableHead>
|
||||
<TableHead>期号</TableHead>
|
||||
<TableHead>触发</TableHead>
|
||||
<TableHead className="text-right">派彩额</TableHead>
|
||||
<TableHead className="text-right">中奖人数</TableHead>
|
||||
<TableHead>时间</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{(payouts?.items ?? []).map((r) => (
|
||||
<TableRow key={r.id}>
|
||||
<TableCell className="font-mono text-xs">{r.id}</TableCell>
|
||||
<TableCell className="font-mono text-xs">{r.draw_no ?? "—"}</TableCell>
|
||||
<TableCell className="text-xs">{r.trigger_type}</TableCell>
|
||||
<TableCell className="text-right font-mono text-xs tabular-nums">
|
||||
{formatAdminMinorUnits(r.total_payout_amount, r.currency_code ?? "NPR")}
|
||||
</TableCell>
|
||||
<TableCell className="text-right tabular-nums">{r.winner_count}</TableCell>
|
||||
<TableCell className="text-xs text-muted-foreground whitespace-nowrap">
|
||||
{formatDt(r.created_at)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
{payouts ? (
|
||||
<AdminListPaginationFooter
|
||||
selectId="jk-payout-per"
|
||||
total={payouts.meta.total}
|
||||
page={payouts.meta.current_page}
|
||||
lastPage={payouts.meta.last_page}
|
||||
perPage={payouts.meta.per_page}
|
||||
loading={loadingP}
|
||||
onPerPageChange={(n) => {
|
||||
setPPer(n);
|
||||
setPPage(1);
|
||||
}}
|
||||
onPageChange={setPPage}
|
||||
/>
|
||||
) : null}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Jackpot 蓄水记录</CardTitle>
|
||||
<CardDescription>每笔注单蓄水入账流水</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{loadingC && !contribs ? (
|
||||
<p className="text-muted-foreground text-sm">加载中…</p>
|
||||
) : (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>ID</TableHead>
|
||||
<TableHead>期号</TableHead>
|
||||
<TableHead>注单</TableHead>
|
||||
<TableHead>玩家</TableHead>
|
||||
<TableHead className="text-right">蓄水额</TableHead>
|
||||
<TableHead>时间</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{(contribs?.items ?? []).map((r) => (
|
||||
<TableRow key={r.id}>
|
||||
<TableCell className="font-mono text-xs">{r.id}</TableCell>
|
||||
<TableCell className="font-mono text-xs">{r.draw_no ?? "—"}</TableCell>
|
||||
<TableCell className="font-mono text-xs">{r.ticket_no ?? "—"}</TableCell>
|
||||
<TableCell className="max-w-[10rem] truncate text-xs">
|
||||
{r.player_username ?? "—"}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-mono text-xs tabular-nums">
|
||||
{formatAdminMinorUnits(r.contribution_amount, r.currency_code ?? "NPR")}
|
||||
</TableCell>
|
||||
<TableCell className="text-xs text-muted-foreground whitespace-nowrap">
|
||||
{formatDt(r.created_at)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
{contribs ? (
|
||||
<AdminListPaginationFooter
|
||||
selectId="jk-contrib-per"
|
||||
total={contribs.meta.total}
|
||||
page={contribs.meta.current_page}
|
||||
lastPage={contribs.meta.last_page}
|
||||
perPage={contribs.meta.per_page}
|
||||
loading={loadingC}
|
||||
onPerPageChange={(n) => {
|
||||
setCPer(n);
|
||||
setCPage(1);
|
||||
}}
|
||||
onPageChange={setCPage}
|
||||
/>
|
||||
) : null}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</ModuleScaffold>
|
||||
);
|
||||
}
|
||||
37
src/modules/jackpot/jackpot-subnav.tsx
Normal file
37
src/modules/jackpot/jackpot-subnav.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const LINKS: { href: string; label: string }[] = [
|
||||
{ href: "/admin/jackpot/pools", label: "奖池配置" },
|
||||
{ href: "/admin/jackpot/records", label: "记录" },
|
||||
];
|
||||
|
||||
export function JackpotSubNav() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<nav className="mb-6 flex flex-wrap gap-2 border-b border-border pb-3" aria-label="Jackpot 子导航">
|
||||
{LINKS.map(({ href, label }) => {
|
||||
const active = pathname === href || pathname.startsWith(`${href}/`);
|
||||
return (
|
||||
<Link
|
||||
key={href}
|
||||
href={href}
|
||||
className={cn(
|
||||
"rounded-md px-3 py-1.5 text-sm transition-colors",
|
||||
active
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
4
src/modules/jackpot/meta.ts
Normal file
4
src/modules/jackpot/meta.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const jackpotModuleMeta = {
|
||||
title: "Jackpot",
|
||||
description: "奖池配置与蓄水 / 派彩记录",
|
||||
} as const;
|
||||
4
src/modules/settlement/meta.ts
Normal file
4
src/modules/settlement/meta.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const settlementModuleMeta = {
|
||||
title: "结算批次",
|
||||
description: "按期查看结算批次与注单结算明细",
|
||||
} as const;
|
||||
190
src/modules/settlement/settlement-batch-details-console.tsx
Normal file
190
src/modules/settlement/settlement-batch-details-console.tsx
Normal file
@@ -0,0 +1,190 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getAdminSettlementBatch, getAdminSettlementBatchDetails } from "@/api/admin-settlement";
|
||||
import { AdminListPaginationFooter } from "@/components/admin/admin-list-pagination-footer";
|
||||
import { ModuleScaffold } from "@/components/admin/module-scaffold";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
|
||||
import { formatAdminMinorUnits } from "@/lib/money";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { LotteryApiBizError } from "@/types/api/errors";
|
||||
import type {
|
||||
AdminSettlementBatchDetailsData,
|
||||
AdminSettlementBatchShowData,
|
||||
} from "@/types/api/admin-settlement";
|
||||
|
||||
type Props = {
|
||||
batchId: number;
|
||||
};
|
||||
|
||||
export function SettlementBatchDetailsConsole({ batchId }: Props) {
|
||||
const formatDt = useAdminDateTimeFormatter();
|
||||
const [summary, setSummary] = useState<AdminSettlementBatchShowData | null>(null);
|
||||
const [details, setDetails] = useState<AdminSettlementBatchDetailsData | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [err, setErr] = useState<string | null>(null);
|
||||
const [page, setPage] = useState(1);
|
||||
const [perPage, setPerPage] = useState(25);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setErr(null);
|
||||
try {
|
||||
const [s, d] = await Promise.all([
|
||||
getAdminSettlementBatch(batchId),
|
||||
getAdminSettlementBatchDetails(batchId, { page, per_page: perPage }),
|
||||
]);
|
||||
setSummary(s);
|
||||
setDetails(d);
|
||||
} catch (e) {
|
||||
setErr(e instanceof LotteryApiBizError ? e.message : "加载失败");
|
||||
setSummary(null);
|
||||
setDetails(null);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [batchId, page, perPage]);
|
||||
|
||||
useEffect(() => {
|
||||
const t = window.setTimeout(() => void load(), 0);
|
||||
return () => window.clearTimeout(t);
|
||||
}, [load]);
|
||||
|
||||
return (
|
||||
<ModuleScaffold>
|
||||
<div className="mb-4">
|
||||
<Link href="/admin/settlement-batches" className={cn(buttonVariants({ variant: "ghost", size: "sm" }), "px-0")}>
|
||||
← 返回批次列表
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{err ? (
|
||||
<Card className="border-destructive/40">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">错误</CardTitle>
|
||||
<CardDescription>{err}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Button type="button" size="sm" variant="secondary" onClick={() => void load()}>
|
||||
重试
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{summary ? (
|
||||
<Card className="mb-6">
|
||||
<CardHeader>
|
||||
<CardTitle className="font-mono text-base">批次 #{summary.id}</CardTitle>
|
||||
<CardDescription>
|
||||
期号 {summary.draw_no ?? "—"} · 期状态 {summary.draw_status ?? "—"} · 结果批次 v
|
||||
{summary.result_batch_version ?? "—"}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="grid gap-2 text-sm sm:grid-cols-2">
|
||||
<p>
|
||||
<span className="text-muted-foreground">结算状态</span>{" "}
|
||||
<span className="font-mono">{summary.status}</span>
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-muted-foreground">注单数</span>{" "}
|
||||
<span className="tabular-nums">{summary.total_ticket_count}</span>
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-muted-foreground">中奖笔数</span>{" "}
|
||||
<span className="tabular-nums">{summary.total_win_count}</span>
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-muted-foreground">派彩合计</span>{" "}
|
||||
<span className="font-mono tabular-nums">{formatAdminMinorUnits(summary.total_payout_amount)}</span>
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-muted-foreground">Jackpot 划出</span>{" "}
|
||||
<span className="font-mono tabular-nums">
|
||||
{formatAdminMinorUnits(summary.total_jackpot_payout_amount)}
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-muted-foreground">开始</span> {formatDt(summary.started_at)}
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-muted-foreground">结束</span> {formatDt(summary.finished_at)}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : loading ? (
|
||||
<p className="text-muted-foreground text-sm">加载摘要…</p>
|
||||
) : null}
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">注单结算明细</CardTitle>
|
||||
<CardDescription>该批次内每条注项的匹配档与派彩拆分</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{details ? (
|
||||
<>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>注单号</TableHead>
|
||||
<TableHead>玩法</TableHead>
|
||||
<TableHead>玩家</TableHead>
|
||||
<TableHead>匹配档</TableHead>
|
||||
<TableHead className="text-right">常规派彩</TableHead>
|
||||
<TableHead className="text-right">Jackpot</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{details.items.map((r) => (
|
||||
<TableRow key={r.id}>
|
||||
<TableCell className="font-mono text-xs">{r.ticket_no ?? "—"}</TableCell>
|
||||
<TableCell className="font-mono text-xs">{r.play_code ?? "—"}</TableCell>
|
||||
<TableCell className="max-w-[10rem] truncate text-xs">
|
||||
{r.player_username ?? r.site_player_id ?? r.player_id ?? "—"}
|
||||
</TableCell>
|
||||
<TableCell className="text-xs">{r.matched_prize_tier ?? "—"}</TableCell>
|
||||
<TableCell className="text-right font-mono text-xs tabular-nums">
|
||||
{formatAdminMinorUnits(r.win_amount)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-mono text-xs tabular-nums">
|
||||
{formatAdminMinorUnits(r.jackpot_allocation_amount)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<AdminListPaginationFooter
|
||||
selectId="settlement-details-per-page"
|
||||
total={details.meta.total}
|
||||
page={details.meta.current_page}
|
||||
lastPage={details.meta.last_page}
|
||||
perPage={details.meta.per_page}
|
||||
loading={loading}
|
||||
onPerPageChange={(n) => {
|
||||
setPerPage(n);
|
||||
setPage(1);
|
||||
}}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<p className="text-muted-foreground text-sm">{loading ? "加载明细…" : "无数据"}</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</ModuleScaffold>
|
||||
);
|
||||
}
|
||||
218
src/modules/settlement/settlement-batches-console.tsx
Normal file
218
src/modules/settlement/settlement-batches-console.tsx
Normal file
@@ -0,0 +1,218 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getAdminSettlementBatches } from "@/api/admin-settlement";
|
||||
import { AdminListPaginationFooter } from "@/components/admin/admin-list-pagination-footer";
|
||||
import { ModuleScaffold } from "@/components/admin/module-scaffold";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
|
||||
import { formatAdminMinorUnits } from "@/lib/money";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { LotteryApiBizError } from "@/types/api/errors";
|
||||
import type { AdminSettlementBatchListData, AdminSettlementBatchRow } from "@/types/api/admin-settlement";
|
||||
|
||||
import { settlementModuleMeta } from "@/modules/settlement/meta";
|
||||
|
||||
const STATUS_ALL = "__all__";
|
||||
const STATUS_OPTIONS: { value: string; label: string }[] = [
|
||||
{ value: STATUS_ALL, label: "不限" },
|
||||
{ value: "running", label: "进行中" },
|
||||
{ value: "completed", label: "已完成" },
|
||||
{ value: "failed", label: "失败" },
|
||||
];
|
||||
|
||||
export function SettlementBatchesConsole() {
|
||||
const formatDt = useAdminDateTimeFormatter();
|
||||
const [data, setData] = useState<AdminSettlementBatchListData | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [draftDrawNo, setDraftDrawNo] = useState("");
|
||||
const [appliedDrawNo, setAppliedDrawNo] = useState("");
|
||||
const [draftStatus, setDraftStatus] = useState(STATUS_ALL);
|
||||
const [appliedStatus, setAppliedStatus] = useState(STATUS_ALL);
|
||||
const [page, setPage] = useState(1);
|
||||
const [perPage, setPerPage] = useState(20);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const d = await getAdminSettlementBatches({
|
||||
page,
|
||||
per_page: perPage,
|
||||
draw_no: appliedDrawNo.trim() || undefined,
|
||||
status:
|
||||
appliedStatus === STATUS_ALL || appliedStatus.trim() === ""
|
||||
? undefined
|
||||
: appliedStatus.trim(),
|
||||
});
|
||||
setData(d);
|
||||
} catch (e) {
|
||||
setError(e instanceof LotteryApiBizError ? e.message : "加载失败");
|
||||
setData(null);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [page, perPage, appliedDrawNo, appliedStatus]);
|
||||
|
||||
useEffect(() => {
|
||||
const t = window.setTimeout(() => void load(), 0);
|
||||
return () => window.clearTimeout(t);
|
||||
}, [load]);
|
||||
|
||||
const applyFilters = () => {
|
||||
setAppliedDrawNo(draftDrawNo);
|
||||
setAppliedStatus(draftStatus);
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
return (
|
||||
<ModuleScaffold>
|
||||
<div className="mb-6">
|
||||
<h1 className="text-lg font-semibold tracking-tight">{settlementModuleMeta.title}</h1>
|
||||
<p className="text-muted-foreground mt-1 text-sm">{settlementModuleMeta.description}</p>
|
||||
</div>
|
||||
<Card className="mb-6">
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-base">筛选</CardTitle>
|
||||
<CardDescription>按业务期号、批次状态过滤</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-4 sm:flex-row sm:flex-wrap sm:items-end">
|
||||
<div className="flex min-w-[12rem] flex-1 flex-col gap-1.5">
|
||||
<Label htmlFor="sb-draw-no">期号</Label>
|
||||
<Input
|
||||
id="sb-draw-no"
|
||||
value={draftDrawNo}
|
||||
onChange={(e) => setDraftDrawNo(e.target.value)}
|
||||
placeholder="如 20260511-001"
|
||||
className="font-mono"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex min-w-[10rem] flex-col gap-1.5">
|
||||
<Label>状态</Label>
|
||||
<Select value={draftStatus} onValueChange={(v) => setDraftStatus(v ?? STATUS_ALL)}>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{STATUS_OPTIONS.map((o) => (
|
||||
<SelectItem key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<Button type="button" onClick={applyFilters}>
|
||||
应用
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">结算批次</CardTitle>
|
||||
<CardDescription>每期与采纳开奖版本对应的一次结算运行</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{error ? <p className="text-destructive text-sm">{error}</p> : null}
|
||||
{loading && !data ? (
|
||||
<p className="text-muted-foreground text-sm">加载中…</p>
|
||||
) : (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>ID</TableHead>
|
||||
<TableHead>期号</TableHead>
|
||||
<TableHead>版本</TableHead>
|
||||
<TableHead>状态</TableHead>
|
||||
<TableHead className="text-right">注单数</TableHead>
|
||||
<TableHead className="text-right">中奖笔数</TableHead>
|
||||
<TableHead className="text-right">派彩合计</TableHead>
|
||||
<TableHead className="text-right">Jackpot</TableHead>
|
||||
<TableHead>完成时间</TableHead>
|
||||
<TableHead />
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{(data?.items ?? []).map((row: AdminSettlementBatchRow) => (
|
||||
<TableRow key={row.id}>
|
||||
<TableCell className="font-mono text-xs">{row.id}</TableCell>
|
||||
<TableCell className="font-mono text-sm">{row.draw_no ?? "—"}</TableCell>
|
||||
<TableCell className="font-mono text-xs">v{row.settle_version}</TableCell>
|
||||
<TableCell>
|
||||
<span
|
||||
className={cn(
|
||||
"rounded px-1.5 py-0.5 text-xs font-medium",
|
||||
row.status === "completed" && "bg-emerald-500/15 text-emerald-800",
|
||||
row.status === "running" && "bg-amber-500/15 text-amber-900",
|
||||
row.status === "failed" && "bg-destructive/15 text-destructive",
|
||||
)}
|
||||
>
|
||||
{row.status}
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell className="text-right tabular-nums">{row.total_ticket_count}</TableCell>
|
||||
<TableCell className="text-right tabular-nums">{row.total_win_count}</TableCell>
|
||||
<TableCell className="text-right font-mono text-xs tabular-nums">
|
||||
{formatAdminMinorUnits(row.total_payout_amount)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-mono text-xs tabular-nums">
|
||||
{formatAdminMinorUnits(row.total_jackpot_payout_amount)}
|
||||
</TableCell>
|
||||
<TableCell className="text-xs text-muted-foreground whitespace-nowrap">
|
||||
{formatDt(row.finished_at ?? row.started_at)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Link
|
||||
href={`/admin/settlement-batches/${row.id}/details`}
|
||||
className={cn(buttonVariants({ variant: "link", size: "sm" }), "px-0")}
|
||||
>
|
||||
明细
|
||||
</Link>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
{data ? (
|
||||
<AdminListPaginationFooter
|
||||
selectId="settlement-batches-per-page"
|
||||
total={data.meta.total}
|
||||
page={data.meta.current_page}
|
||||
lastPage={data.meta.last_page}
|
||||
perPage={data.meta.per_page}
|
||||
loading={loading}
|
||||
onPerPageChange={(n) => {
|
||||
setPerPage(n);
|
||||
setPage(1);
|
||||
}}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
) : null}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</ModuleScaffold>
|
||||
);
|
||||
}
|
||||
64
src/types/api/admin-jackpot.ts
Normal file
64
src/types/api/admin-jackpot.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
export type AdminJackpotPoolRow = {
|
||||
id: number;
|
||||
currency_code: string;
|
||||
current_amount: number;
|
||||
contribution_rate: string;
|
||||
trigger_threshold: number;
|
||||
payout_rate: string;
|
||||
force_trigger_draw_gap: number;
|
||||
min_bet_amount: number;
|
||||
status: number;
|
||||
last_trigger_draw_id: number | null;
|
||||
updated_at: string | null;
|
||||
};
|
||||
|
||||
export type AdminJackpotPoolsData = {
|
||||
items: AdminJackpotPoolRow[];
|
||||
};
|
||||
|
||||
export type AdminJackpotPayoutLogRow = {
|
||||
id: number;
|
||||
draw_id: number;
|
||||
draw_no: string | null;
|
||||
jackpot_pool_id: number;
|
||||
currency_code: string | null;
|
||||
trigger_type: string;
|
||||
total_payout_amount: number;
|
||||
winner_count: number;
|
||||
trigger_snapshot_json: unknown;
|
||||
created_at: string | null;
|
||||
};
|
||||
|
||||
export type AdminJackpotPayoutLogsData = {
|
||||
items: AdminJackpotPayoutLogRow[];
|
||||
meta: {
|
||||
current_page: number;
|
||||
per_page: number;
|
||||
total: number;
|
||||
last_page: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type AdminJackpotContributionRow = {
|
||||
id: number;
|
||||
draw_id: number;
|
||||
draw_no: string | null;
|
||||
jackpot_pool_id: number;
|
||||
currency_code: string | null;
|
||||
player_id: number;
|
||||
player_username: string | null;
|
||||
ticket_item_id: number | null;
|
||||
ticket_no: string | null;
|
||||
contribution_amount: number;
|
||||
created_at: string | null;
|
||||
};
|
||||
|
||||
export type AdminJackpotContributionsData = {
|
||||
items: AdminJackpotContributionRow[];
|
||||
meta: {
|
||||
current_page: number;
|
||||
per_page: number;
|
||||
total: number;
|
||||
last_page: number;
|
||||
};
|
||||
};
|
||||
70
src/types/api/admin-settlement.ts
Normal file
70
src/types/api/admin-settlement.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
export type AdminSettlementBatchRow = {
|
||||
id: number;
|
||||
draw_id: number;
|
||||
draw_no: string | null;
|
||||
result_batch_id: number;
|
||||
settle_version: number;
|
||||
status: string;
|
||||
total_ticket_count: number;
|
||||
total_win_count: number;
|
||||
total_payout_amount: number;
|
||||
total_jackpot_payout_amount: number;
|
||||
started_at: string | null;
|
||||
finished_at: string | null;
|
||||
created_at: string | null;
|
||||
};
|
||||
|
||||
export type AdminSettlementBatchListData = {
|
||||
items: AdminSettlementBatchRow[];
|
||||
meta: {
|
||||
current_page: number;
|
||||
per_page: number;
|
||||
total: number;
|
||||
last_page: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type AdminSettlementBatchShowData = {
|
||||
id: number;
|
||||
draw_id: number;
|
||||
draw_no: string | null;
|
||||
draw_status: string | null;
|
||||
result_batch_id: number;
|
||||
result_batch_version: number | null;
|
||||
result_batch_status: string | null;
|
||||
settle_version: number;
|
||||
status: string;
|
||||
total_ticket_count: number;
|
||||
total_win_count: number;
|
||||
total_payout_amount: number;
|
||||
total_jackpot_payout_amount: number;
|
||||
started_at: string | null;
|
||||
finished_at: string | null;
|
||||
created_at: string | null;
|
||||
};
|
||||
|
||||
export type AdminSettlementDetailRow = {
|
||||
id: number;
|
||||
ticket_item_id: number;
|
||||
ticket_no: string | null;
|
||||
play_code: string | null;
|
||||
player_id: number | null;
|
||||
player_username: string | null;
|
||||
site_player_id: string | null;
|
||||
matched_prize_tier: string | null;
|
||||
win_amount: number;
|
||||
jackpot_allocation_amount: number;
|
||||
match_detail_json: unknown;
|
||||
created_at: string | null;
|
||||
};
|
||||
|
||||
export type AdminSettlementBatchDetailsData = {
|
||||
batch_id: number;
|
||||
items: AdminSettlementDetailRow[];
|
||||
meta: {
|
||||
current_page: number;
|
||||
per_page: number;
|
||||
total: number;
|
||||
last_page: number;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user