feat(api): 按开注商支持获取赔率数据并完善相关功能
Some checks failed
lotteryfront CI / build (push) Has been cancelled

- 在getPlayEffective接口中增加provider_code参数支持
- 优化接口调用时对currency和provider_code的传递逻辑
- hall-bet-preview-dialog新增previewLineKey方法,解决列表渲染key冲突问题
- 修改投注和结果弹窗中开注商标题的国际化调用方式
- hall-betting-grid中增加选中开注商的默认逻辑,接口调用时传递provider_code
- 优化provider名称显示逻辑,完善开注商选择及摘要文本显示
- 订单详情页中显示开注商名称,提升显示准确性
- 补充i18n中开注商相关文案,支持多语言环境
- 更新PlayEffectiveOddsSlice和PlayEffectivePayload类型,加入provider_code字段支持
This commit is contained in:
2026-07-09 10:51:45 +08:00
parent add3d1fc05
commit 5cbabb5d0f
10 changed files with 70 additions and 23 deletions

View File

@@ -23,7 +23,7 @@ import {
} from "@/components/ui/dialog";
import { formatMinorAsCurrency } from "@/lib/money";
import { playLabel } from "@/lib/play-labels";
import type { TicketPreviewData, TicketPreviewWarning } from "@/types/api/ticket";
import type { TicketPreviewData, TicketPreviewLine, TicketPreviewWarning } from "@/types/api/ticket";
type HallBetPreviewDialogProps = {
open: boolean;
@@ -65,6 +65,16 @@ function providerLabel(providerName?: string | null, providerCode?: string | nul
return providerName || providerCode || "-";
}
function previewLineKey(line: TicketPreviewLine, index: number): string {
return [
line.client_line_no,
line.provider_code ?? "provider",
line.play_code,
line.number,
index,
].join(":");
}
function SubmittingPanel() {
const { t } = useTranslation("player");
@@ -221,7 +231,7 @@ export function HallBetPreviewDialog({
{t("orders.play")}
</th>
<th className="border-r border-[#dfe8f6] px-2 py-3 text-center font-black">
{t("hall.providers.title", { defaultValue: "开注商" })}
{t("hall.providers.title")}
</th>
<th className="border-r border-[#dfe8f6] px-2 py-3 text-center font-black">
{t("hall.preview.amount")}
@@ -238,8 +248,8 @@ export function HallBetPreviewDialog({
</tr>
</thead>
<tbody>
{lines.map((ln) => (
<tr key={ln.client_line_no} className="border-t border-[#e8eef7] bg-white">
{lines.map((ln, index) => (
<tr key={previewLineKey(ln, index)} className="border-t border-[#e8eef7] bg-white">
<td className="border-r border-[#e8eef7] px-2 py-3 text-center">
<span className="inline-flex size-6 items-center justify-center rounded-full border border-[#dfe8f6] font-black text-[#304f86]">
{ln.client_line_no}

View File

@@ -219,7 +219,7 @@ export function HallBetResultDialog({
{t("orders.play")}
</th>
<th className="border-r border-[#dfe8f6] px-2 py-2.5 text-center font-black">
{t("hall.providers.title", { defaultValue: "开注商" })}
{t("hall.providers.title")}
</th>
<th className="px-2 py-2.5 text-center font-black">
{t("hall.result.actualDeduct")}

View File

@@ -482,12 +482,19 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
}, []);
const catalogSeqRef = useRef(0);
const walletSeqRef = useRef(0);
const selectedCatalogProviderCode =
selectedProviderCodes[0] ??
betProviders.find((provider) => provider.is_default)?.code ??
betProviders[0]?.code;
const loadCatalog = useCallback(async () => {
const seq = ++catalogSeqRef.current;
setCatalogState({ kind: "loading" });
try {
const data = await getPlayEffective({ currency: currencyParam });
const data = await getPlayEffective({
currency: currencyParam,
provider_code: selectedCatalogProviderCode,
});
if (seq !== catalogSeqRef.current) return;
setCatalogState({ kind: "ok", data });
} catch (e) {
@@ -495,7 +502,7 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
const msg = e instanceof LotteryApiBizError ? e.message : t("hall.loadingError");
setCatalogState({ kind: "error", message: msg });
}
}, [currencyParam, t]);
}, [currencyParam, selectedCatalogProviderCode, t]);
const refreshWallet = useCallback(async () => {
const seq = ++walletSeqRef.current;
@@ -1257,14 +1264,13 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
const providerSummaryText =
selectedProviderCodes.length > 0
? t("hall.providers.summary", {
defaultValue: "已选 {{count}} 家,金额按每家公司计算",
count: providerSummaryCount,
})
: t("hall.providers.platformDefaultSummary", {
defaultValue: implicitDefaultProvider
? `未选择时走平台默认(${implicitDefaultProvider.name}`
: "未选择时走平台默认",
});
: implicitDefaultProvider
? t("hall.providers.platformDefaultSummary", {
provider: implicitDefaultProvider.name,
})
: t("hall.providers.platformDefaultSummaryNoProvider");
return (
<>
@@ -1511,7 +1517,7 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
<div className="flex flex-wrap items-center justify-between gap-2">
<div className="flex flex-wrap items-center gap-1.5">
<span className="mr-1 text-[11px] font-black text-[#304f86]">
{t("hall.providers.title", { defaultValue: "开注商" })}
{t("hall.providers.title")}
</span>
{!isMobile ? betProviders.map((provider) => {
const checked = selectedProviderCodes.includes(provider.code);
@@ -1544,11 +1550,9 @@ export function HallBettingGrid({ drawLive }: { drawLive: HallDrawLiveSnapshot }
<span className="text-xs font-semibold text-[#58709d]">
{selectedProviderNames.length > 0
? selectedProviderNames.join(" / ")
: t("hall.providers.platformDefault", {
defaultValue: implicitDefaultProvider
? `平台默认(${implicitDefaultProvider.name}`
: "平台默认",
})}
: implicitDefaultProvider
? t("hall.providers.platformDefault", { provider: implicitDefaultProvider.name })
: t("hall.providers.platformDefaultNoProvider")}
</span>
)}
</div>

View File

@@ -366,7 +366,7 @@ export function TicketOrderDetailScreen({ ticketNo }: { ticketNo: string }) {
</div>
<div className="flex items-baseline justify-between gap-3">
<span className="shrink-0 text-slate-500">
{t("hall.providers.title", { defaultValue: "开注商" })}
{t("hall.providers.title")}
</span>
<span className="text-right font-black text-[#0b56b7]">
{providerLabel(data.provider_name, data.provider_code)}