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

@@ -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);