feat: 增强开奖 API 的币种支持并优化钱包处理逻辑

更新 getDrawCurrent、getDrawResults 与 getDrawResultByNo 方法,新增币种参数支持,以适配玩家币种偏好。
优化 HallBettingGrid 及相关组件:支持币种切换时自动刷新钱包数据。
重构钱包处理逻辑,简化余额更新流程并提升用户体验。
新增会话过期相关多语言提示文案,并优化现有翻译内容,提升多语言环境下的提示清晰度。
This commit is contained in:
2026-05-27 16:52:12 +08:00
parent adae4a0be1
commit 58afa8e844
34 changed files with 373 additions and 379 deletions

View File

@@ -29,6 +29,10 @@ import { getLotteryEcho } from "@/lib/lottery-echo";
import { getLotteryRequestLocale } from "@/lib/lottery-locale";
import { formatMinorAsCurrency, parseDecimalInputToMinor } from "@/lib/money";
import { playLabel } from "@/lib/play-labels";
import {
PLAY_CATALOG_REFRESH_EVENT,
type PlayCatalogRefreshSource,
} from "@/lib/play-catalog-events";
import { PLAYER_CURRENCY_CHANGE_EVENT } from "@/lib/player-currency-preference";
import { cn } from "@/lib/utils";
import { LotteryApiBizError } from "@/types/api/errors";
@@ -36,7 +40,6 @@ import type { PlayEffectivePayload, PlayEffectivePlayRow } from "@/types/api/pla
import type { TicketLineInput, TicketPlaceData, TicketPreviewData } from "@/types/api/ticket";
import type { DrawCurrentRiskPoolAlert } from "@/types/api/draw-current";
const DEFAULT_POLL_MS = 120_000;
const MAX_ROWS = 20;
type HallCategory = "D2" | "D3" | "D4" | "JACKPOT";
@@ -421,7 +424,7 @@ function cellRiskState(
for (const alert of alerts) {
if (matchesRiskAlert(alert.normalized_number, play.play_code, normalizedRow, category, digitSlot)) {
return alert.is_sold_out ? "sold_out" : "warning";
return alert.status === "sold_out" ? "sold_out" : "warning";
}
}
@@ -512,12 +515,20 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
}, [loadCatalog, refreshWallet]);
useEffect(() => {
const id = window.setInterval(() => {
const onCatalogRefresh = (ev: Event) => {
void loadCatalog();
void refreshWallet();
}, DEFAULT_POLL_MS);
return () => window.clearInterval(id);
}, [loadCatalog, refreshWallet]);
const source = (ev as CustomEvent<{ source?: PlayCatalogRefreshSource }>).detail
?.source;
if (source === "play_config" || source === "risk_cap") {
setPreviewOpen(false);
setPreviewData(null);
clearPlaceTraceId();
toast.message(t("hall.playConfig.updated"));
}
};
window.addEventListener(PLAY_CATALOG_REFRESH_EVENT, onCatalogRefresh);
return () => window.removeEventListener(PLAY_CATALOG_REFRESH_EVENT, onCatalogRefresh);
}, [clearPlaceTraceId, loadCatalog, t]);
const openPlays = useMemo(() => {
if (catalogState.kind !== "ok") return [];
@@ -731,7 +742,6 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
const channel = echo.channel("lottery-hall");
const onPlayToggle = (evt: PlayToggleWsEvent) => {
void loadCatalog();
if (evt.enabled === false && typeof evt.play_code === "string") {
const removed = clearAmountsForPlay(evt.play_code);
setPreviewOpen(false);
@@ -746,13 +756,10 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
playCode: evt.play_code,
}),
);
} else {
toast.message(t("hall.playConfig.updated"));
}
};
const onOddsUpdate = (evt: OddsUpdateWsEvent) => {
void loadCatalog();
setPreviewOpen(false);
setPreviewData(null);
clearPlaceTraceId();