refactor: 移除冗余注释和描述,优化管理员模块的代码结构
This commit is contained in:
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getAdminDraw } from "@/api/admin-draws";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
|
||||
@@ -70,10 +70,6 @@ export function DrawDetailConsole({ drawId }: { drawId: string }) {
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">当期状态</CardTitle>
|
||||
<CardDescription>
|
||||
数据库 <code className="rounded bg-muted px-1 py-0.5 text-xs">status</code>{" "}
|
||||
为权威;以下为玩家大厅「展示态」预览(未跑 tick 时可能与 DB 不一致)。
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
@@ -103,7 +99,6 @@ export function DrawDetailConsole({ drawId }: { drawId: string }) {
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">批次统计</CardTitle>
|
||||
<CardDescription>用于跳转「开奖结果 / 审核」页前的概览。</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-4">
|
||||
<div className="flex flex-wrap gap-6 text-sm">
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getAdminDrawFinanceSummary } from "@/api/admin-draws";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -18,7 +18,6 @@ import { cn } from "@/lib/utils";
|
||||
import { LotteryApiBizError } from "@/types/api/errors";
|
||||
import type { AdminDrawFinanceSummaryData } from "@/types/api/admin-draw-finance";
|
||||
|
||||
/** PRD §15.4:单期投注/派彩与结算批次(`GET …/draws/{id}/finance-summary`) */
|
||||
export function DrawFinanceConsole({ drawId }: { drawId: string }): React.ReactElement {
|
||||
const idNum = Number(drawId);
|
||||
const [data, setData] = useState<AdminDrawFinanceSummaryData | null>(null);
|
||||
@@ -57,16 +56,11 @@ export function DrawFinanceConsole({ drawId }: { drawId: string }): React.ReactE
|
||||
return <p className="text-destructive text-sm">{err ?? "无数据"}</p>;
|
||||
}
|
||||
|
||||
const cur = data.currency_code ?? "—";
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">期号收支概览</CardTitle>
|
||||
<CardDescription>
|
||||
币种 {cur};金额为最小货币单位。毛损益 = 实扣投注 −(中奖派彩 + Jackpot),不含回水细项。
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-3">
|
||||
<div>
|
||||
@@ -120,7 +114,6 @@ export function DrawFinanceConsole({ drawId }: { drawId: string }): React.ReactE
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">本关联期结算批次</CardTitle>
|
||||
<CardDescription>与 `settlement_batches` 对照;明细见结算模块。</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{data.settlement_batches.length === 0 ? (
|
||||
|
||||
@@ -1,17 +1,2 @@
|
||||
/**
|
||||
* 后台开奖域与 PRD 阶段 3 · §11.4 / §11.7 验收对照(路径以 `API_V1_PREFIX=/api/v1` 为前缀)。
|
||||
*
|
||||
* - 期号列表:`GET …/admin/draws`
|
||||
* - 期号详情 / 状态:`GET …/admin/draws/{draw}`
|
||||
* - 开奖结果批次(含待审核、已发布):`GET …/admin/draws/{draw}/result-batches`
|
||||
* - 发布:`POST …/admin/draws/{draw}/result-batches/{batch}/publish`
|
||||
*/
|
||||
export const DRAW_ADMIN_API_PRD_LINES = [
|
||||
"GET /api/v1/admin/draws",
|
||||
"GET /api/v1/admin/draws/{draw}",
|
||||
"GET /api/v1/admin/draws/{draw}/result-batches",
|
||||
"POST /api/v1/admin/draws/{draw}/result-batches/{batch}/publish",
|
||||
] as const;
|
||||
|
||||
/** 具备其一即可执行发布、进入发布页(与 Laravel `prd.draw_result.manage` 一致) */
|
||||
/** 开奖结果发布权限 slug */
|
||||
export const PRD_DRAW_RESULT_MANAGE = "prd.draw_result.manage" as const;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { toast } from "sonner";
|
||||
import { getAdminDrawResultBatches, postAdminPublishResultBatch } from "@/api/admin-draws";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -112,38 +112,24 @@ export function DrawPublishConsole({ drawId, batchId }: { drawId: string; batchI
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">发布</CardTitle>
|
||||
<CardDescription>
|
||||
期号 <span className="font-mono font-medium">{data.draw_no}</span> · 批次 v
|
||||
{batch.result_version}{" "}
|
||||
<span className="rounded bg-muted px-1 py-0.5 font-mono text-xs">{batch.status}</span>
|
||||
· 接口{" "}
|
||||
<code className="rounded bg-muted px-1 text-xs">
|
||||
POST …/result-batches/{batch.id}/publish
|
||||
</code>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{!canManageDraw ? (
|
||||
<Alert variant="destructive">
|
||||
<AlertTitle>无发布权限</AlertTitle>
|
||||
<AlertDescription>
|
||||
需要 <code className="rounded bg-background/80 px-1">{PRD_DRAW_RESULT_MANAGE}</code>{" "}
|
||||
方可调用发布接口;当前账号仅可查看号码表。
|
||||
</AlertDescription>
|
||||
<AlertDescription>当前账号不可执行发布。</AlertDescription>
|
||||
</Alert>
|
||||
) : null}
|
||||
{!canPublish && canManageDraw ? (
|
||||
<Alert>
|
||||
<AlertTitle>不可发布</AlertTitle>
|
||||
<AlertDescription>
|
||||
仅 pending_review 可执行发布接口;当前为「{batch.status}」。已发布时请从「开奖结果」页核对。
|
||||
</AlertDescription>
|
||||
<AlertDescription>当前批次状态为「{batch.status}」。</AlertDescription>
|
||||
</Alert>
|
||||
) : null}
|
||||
{canPublish ? (
|
||||
<Alert>
|
||||
<AlertTitle>请核对以下号码后再发布</AlertTitle>
|
||||
<AlertDescription>发布后无期将进入冷静期并按配置写入结果版本。</AlertDescription>
|
||||
<AlertDescription>确认无误后点击发布。</AlertDescription>
|
||||
</Alert>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getAdminDrawResultBatches } from "@/api/admin-draws";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -74,8 +74,7 @@ export function DrawResultsConsole({ drawId }: { drawId: string }) {
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold">开奖结果</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
期号 {data.draw_no} · 当期库内状态 <DrawStatusBadge status={data.draw_status} /> ·
|
||||
以下为已发布批次号码表;未发布请在「审核与发布」中处理。
|
||||
期号 {data.draw_no} · <DrawStatusBadge status={data.draw_status} />
|
||||
</p>
|
||||
</div>
|
||||
<Link
|
||||
@@ -89,7 +88,7 @@ export function DrawResultsConsole({ drawId }: { drawId: string }) {
|
||||
{published.length === 0 ? (
|
||||
<Card>
|
||||
<CardContent className="py-8 text-center text-sm text-muted-foreground">
|
||||
暂无「已发布」批次。若存在待审核 RNG 结果,请先完成审核发布。
|
||||
暂无已发布批次。
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
@@ -104,9 +103,9 @@ function BatchTable({ batch }: { batch: AdminDrawBatchRow }) {
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-base">版本 v{batch.result_version}</CardTitle>
|
||||
<CardDescription className="font-mono text-xs">
|
||||
<p className="font-mono text-xs text-muted-foreground">
|
||||
RNG 摘要 {batch.rng_seed_hash ?? "—"} · 确认时间 {batch.confirmed_at ?? "—"}
|
||||
</CardDescription>
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent className="overflow-x-auto pt-0">
|
||||
<Table>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
|
||||
import { getAdminDrawResultBatches } from "@/api/admin-draws";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -74,13 +74,9 @@ export function DrawReviewConsole({ drawId }: { drawId: string }) {
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">审核</CardTitle>
|
||||
<CardDescription>
|
||||
待审核 RNG 批次会出现在下表;具备{" "}
|
||||
<code className="rounded bg-muted px-1 text-xs">{PRD_DRAW_RESULT_MANAGE}</code>{" "}
|
||||
时可进入发布页,调用{" "}
|
||||
<code className="rounded bg-muted px-1 text-xs">POST …/result-batches/…/publish</code>
|
||||
。当前 DB 状态:<DrawStatusBadge status={data.draw_status} />。
|
||||
</CardDescription>
|
||||
<p className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
||||
当前状态 <DrawStatusBadge status={data.draw_status} />
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{pending.length === 0 ? (
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getAdminDraws } from "@/api/admin-draws";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { AdminListPaginationFooter } from "@/components/admin/admin-list-pagination-footer";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
@@ -29,7 +29,6 @@ import { cn } from "@/lib/utils";
|
||||
import { LotteryApiBizError } from "@/types/api/errors";
|
||||
import type { AdminDrawListData, AdminDrawListItem } from "@/types/api/admin-draws";
|
||||
|
||||
import { DRAW_ADMIN_API_PRD_LINES } from "./draw-prd";
|
||||
import { DrawStatusBadge } from "./draw-status-badge";
|
||||
|
||||
/** 下拉「不限」;请求时不传 status */
|
||||
@@ -104,14 +103,6 @@ export function DrawsIndexConsole() {
|
||||
<Card>
|
||||
<CardHeader className="space-y-1">
|
||||
<CardTitle className="text-lg">期号列表</CardTitle>
|
||||
<CardDescription className="space-y-2">
|
||||
<span>
|
||||
按开奖时间倒序;点「详情」进入期号子页:状态、开奖结果、审核与发布(阶段 3 · §11.4)。
|
||||
</span>
|
||||
<span className="block font-mono text-[11px] leading-relaxed text-muted-foreground">
|
||||
{DRAW_ADMIN_API_PRD_LINES.join(" · ")}
|
||||
</span>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{/* Grid:桌面端标签一行 / 控件一行,避免 flex+items-end 与各列实际高度不一致;移动端单列自上而下 */}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export const drawsModuleMeta = {
|
||||
segment: "draws",
|
||||
title: "开奖",
|
||||
description:
|
||||
"PRD 阶段3 §11.4:期号列表 / 状态 / 开奖结果 / 审核队列 / 发布(POST …/result-batches/…/publish);路由 `/admin/draws/[id]/publish/[batchId]` 与接口动词对齐。",
|
||||
description: "",
|
||||
} as const;
|
||||
|
||||
Reference in New Issue
Block a user