Files
lotteryAdmin/src/lib/admin-settlement-settings-cache.ts
kang b15e377187 feat(api, i18n): add agent_node_id to various admin queries and enhance multi-language support
Introduced the agent_node_id field in AdminDrawListQuery, AdminPlayerListQuery, AdminSettlementBatchListQuery, TicketItemsListQuery, and TransferOrderListQuery to improve filtering capabilities. Updated the admin-breadcrumb and admin-sidebar components to include new translations for agent-related terms in English, Nepali, and Chinese, enhancing the overall user experience and multi-language support across the admin interface.
2026-06-02 14:37:08 +08:00

45 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { getAdminSettings } from "@/api/admin-settings";
const SETTLEMENT_GROUP = "settlement";
const APPLY_REBATE_TO_PAYOUT_KEY = "settlement.apply_rebate_to_payout";
let cachedApplyRebateToPayout: boolean | null = null;
let inflight: Promise<boolean> | null = null;
export function peekApplyRebateToPayoutSetting(): boolean | null {
return cachedApplyRebateToPayout;
}
export function setCachedApplyRebateToPayoutSetting(value: boolean): void {
cachedApplyRebateToPayout = value;
}
export function clearCachedSettlementSettings(): void {
cachedApplyRebateToPayout = null;
inflight = null;
}
/** 读取「派彩时再扣回水」开关(模块级缓存,避免配置页重复 GET settings */
export async function loadApplyRebateToPayoutSetting(): Promise<boolean> {
if (cachedApplyRebateToPayout !== null) {
return cachedApplyRebateToPayout;
}
if (inflight !== null) {
return inflight;
}
inflight = getAdminSettings(SETTLEMENT_GROUP)
.then((res) => {
const hit = res.items.find((item) => item.key === APPLY_REBATE_TO_PAYOUT_KEY);
const value = Boolean(hit?.value ?? false);
cachedApplyRebateToPayout = value;
return value;
})
.catch(() => false)
.finally(() => {
inflight = null;
});
return inflight;
}