feat: 优化下注异常清理与开奖结果详情展示

- 支持玩法关闭错误返回 cleanup_lines 时自动清空对应下注格并提示原因
- 调整下注预览与下注结果金额汇总文案,补充金额、回水、合计多语言翻译
- 下注结果弹窗新增注单状态展示
- 重构开奖结果详情页样式,强化前三名、派奖提示与查看中奖入口展示
- 精简底部导航激活态视觉效果
This commit is contained in:
2026-05-16 09:54:28 +08:00
parent 01baf9c18b
commit d5415888e6
8 changed files with 176 additions and 64 deletions

View File

@@ -107,27 +107,27 @@ export function HallBetPreviewDialog({
{summary ? (
<ul className="mt-2 space-y-1 tabular-nums text-slate-700">
<li>
{t("hall.preview.totalBet")}{" "}
{t("hall.preview.amount")}{" "}
<span className="font-semibold text-[#d81435]">
{formatMinorAsCurrency(summary.total_bet_amount, currencyCode)}
</span>
</li>
<li>
{t("hall.preview.rebateDeduct")}{" "}
{t("hall.preview.rebate")}{" "}
<span className="font-semibold text-emerald-600">
{formatMinorAsCurrency(summary.total_rebate_amount, currencyCode)}
</span>
</li>
<li>
{t("hall.preview.actualDeduct")}{" "}
{t("hall.preview.actual")}{" "}
<span className="font-bold text-[#0b3f96]">
{formatMinorAsCurrency(summary.total_actual_deduct, currencyCode)}
</span>
</li>
<li>
{t("hall.preview.estimatedPayout")}{" "}
{t("hall.preview.total")}{" "}
<span className="font-medium text-slate-800">
{formatMinorAsCurrency(summary.total_estimated_payout, currencyCode)}
{formatMinorAsCurrency(summary.total_actual_deduct, currencyCode)}
</span>
</li>
</ul>

View File

@@ -74,6 +74,12 @@ export function HallBetResultDialog({
{t("hall.result.draw", { defaultValue: "期号" })}{" "}
<span className="font-mono font-semibold text-[#32518d]">{data.draw.draw_id}</span>
</p>
<p className="mt-1 text-xs text-slate-500">
{t("hall.result.status", { defaultValue: "注单状态" })}{" "}
<span className="font-semibold text-[#32518d]">
{t("ticketStatus.success", { defaultValue: "待开奖" })}
</span>
</p>
<Separator className="my-3 bg-[#e8eef7]" />
<ul className="space-y-1 text-xs tabular-nums text-slate-700">
<li>
@@ -85,7 +91,25 @@ export function HallBetResultDialog({
<span className="font-semibold text-rose-600">{totalFailure}</span>
</li>
<li>
{t("hall.result.totalDeduct", { defaultValue: "成功扣款" })}{" "}
{t("hall.result.amount", { defaultValue: "金额" })}{" "}
<span className="font-semibold text-slate-800">
{formatMinorAsCurrency(data.summary.total_bet_amount, currencyCode)}
</span>
</li>
<li>
{t("hall.result.rebate", { defaultValue: "回水" })}{" "}
<span className="font-semibold text-emerald-700">
{formatMinorAsCurrency(data.summary.total_rebate_amount, currencyCode)}
</span>
</li>
<li>
{t("hall.result.actual", { defaultValue: "实扣" })}{" "}
<span className="font-bold text-[#0b3f96]">
{formatMinorAsCurrency(data.summary.total_actual_deduct, currencyCode)}
</span>
</li>
<li>
{t("hall.result.total", { defaultValue: "合计" })}{" "}
<span className="font-bold text-[#0b3f96]">
{formatMinorAsCurrency(data.summary.total_actual_deduct, currencyCode)}
</span>

View File

@@ -50,6 +50,11 @@ type DraftEntry = {
line: TicketLineInput;
};
type ClosedPlayCleanupData = {
cleanup_hint?: string;
cleanup_lines?: Array<{ client_line_no?: number; play_code?: string }>;
};
type CellRiskState = "open" | "warning" | "sold_out";
type QuickFillState = Record<HallCategory, { favorites: string[]; history: string[] }>;
@@ -569,6 +574,40 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
const buildLines = (): TicketLineInput[] => collectEntries().map((entry) => entry.line);
const applyClosedPlayCleanup = (data: unknown): boolean => {
const payload = data as ClosedPlayCleanupData | null;
const cleanupLines = Array.isArray(payload?.cleanup_lines) ? payload.cleanup_lines : [];
if (cleanupLines.length === 0) return false;
const entries = collectEntries();
const cleanupPairs = new Set<string>();
cleanupLines.forEach((item) => {
const clientLineNo = Number(item?.client_line_no ?? 0);
const playCode = String(item?.play_code ?? "");
if (!Number.isInteger(clientLineNo) || clientLineNo <= 0 || playCode.trim() === "") return;
const entry = entries[clientLineNo - 1];
if (!entry) return;
cleanupPairs.add(`${entry.rowId}::${playCode}`);
});
if (cleanupPairs.size === 0) return false;
setRows((current) =>
current.map((row) => {
const nextAmounts = { ...row.amounts };
let changed = false;
Object.keys(nextAmounts).forEach((playCode) => {
if (!cleanupPairs.has(`${row.id}::${playCode}`)) return;
nextAmounts[playCode] = "";
changed = true;
});
return changed ? { ...row, amounts: nextAmounts } : row;
}),
);
return true;
};
const handlePreview = async () => {
if (!display) {
toast.error(t("hall.noDraw"));
@@ -609,6 +648,11 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
} catch (e) {
const code = e instanceof LotteryApiBizError ? e.code : 0;
const msg = e instanceof LotteryApiBizError ? e.message : t("hall.previewFailed");
if (e instanceof LotteryApiBizError && code === 2002 && applyClosedPlayCleanup(e.data)) {
const payload = e.data as ClosedPlayCleanupData;
toast.error(payload.cleanup_hint ?? t("hall.ticketError.2002"));
return;
}
toast.error(mapTicketBetError(code, msg, t));
} finally {
setPreviewLoading(false);
@@ -658,6 +702,13 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
} catch (e) {
const code = e instanceof LotteryApiBizError ? e.code : 0;
const msg = e instanceof LotteryApiBizError ? e.message : t("hall.placeFailed");
if (e instanceof LotteryApiBizError && code === 2002 && applyClosedPlayCleanup(e.data)) {
const payload = e.data as ClosedPlayCleanupData;
toast.error(payload.cleanup_hint ?? t("hall.ticketError.2002"));
setPreviewOpen(false);
setPreviewData(null);
return;
}
toast.error(mapTicketBetError(code, msg, t));
} finally {
setPlaceLoading(false);