sync(theme-3): 从 main 同步优胜赛结算态与钱包流水展示优化
- checkout shared/api/admin 自 d3c2114
- player: outright 结算态逻辑、wallet txAmountClass、i18n 新增 key(保留主题 CSS 变量)
This commit is contained in:
13
apps/admin/src/utils/adminListStale.ts
Normal file
13
apps/admin/src/utils/adminListStale.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
const STALE_KEY = 'admin:list-stale';
|
||||
|
||||
/** 标记赛事相关列表需在下次激活时刷新(结算/预览等变更后端统计后调用) */
|
||||
export function markAdminListStale() {
|
||||
sessionStorage.setItem(STALE_KEY, '1');
|
||||
}
|
||||
|
||||
/** 若曾标记过 stale 则清除标记并返回 true */
|
||||
export function consumeAdminListStale(): boolean {
|
||||
if (sessionStorage.getItem(STALE_KEY) !== '1') return false;
|
||||
sessionStorage.removeItem(STALE_KEY);
|
||||
return true;
|
||||
}
|
||||
39
apps/admin/src/utils/format-datetime.ts
Normal file
39
apps/admin/src/utils/format-datetime.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { getAdminLocale } from '../i18n';
|
||||
import type { AdminLocale } from '../i18n/admin-messages';
|
||||
|
||||
function resolveLocale(locale?: AdminLocale): AdminLocale {
|
||||
return locale ?? getAdminLocale();
|
||||
}
|
||||
|
||||
/** 列表展示:年月日 */
|
||||
export function formatAdminDateTimeBrief(
|
||||
value: string | null | undefined,
|
||||
locale?: AdminLocale,
|
||||
): string {
|
||||
if (!value) return '—';
|
||||
const d = new Date(value);
|
||||
if (Number.isNaN(d.getTime())) return '—';
|
||||
return d.toLocaleString(resolveLocale(locale), {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
});
|
||||
}
|
||||
|
||||
/** 悬停详情:含秒 */
|
||||
export function formatAdminDateTimeFull(
|
||||
value: string | null | undefined,
|
||||
locale?: AdminLocale,
|
||||
): string {
|
||||
if (!value) return '—';
|
||||
const d = new Date(value);
|
||||
if (Number.isNaN(d.getTime())) return '—';
|
||||
return d.toLocaleString(resolveLocale(locale), {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
});
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
export { txDisplayAmount } from '@thebet365/shared';
|
||||
|
||||
export const TX_KEY_MAP: Record<string, string> = {
|
||||
MANUAL_DEPOSIT: 'finance.tx.deposit',
|
||||
ADMIN_DEPOSIT: 'finance.tx.admin_deposit',
|
||||
@@ -64,3 +66,45 @@ export function walletDepositMethodLabel(
|
||||
if (type === 'PLAYER_DEPOSIT') return t('finance.tx.player_deposit');
|
||||
return '—';
|
||||
}
|
||||
|
||||
const WALLET_REMARK_EXACT: Record<string, string> = {
|
||||
'Agent deposit': 'finance.remark.agent_deposit',
|
||||
'Agent withdraw': 'finance.remark.agent_withdraw',
|
||||
'代理上分': 'finance.remark.agent_deposit',
|
||||
'代理下分': 'finance.remark.agent_withdraw',
|
||||
'管理员上分': 'finance.remark.admin_deposit',
|
||||
'管理员下分': 'finance.remark.admin_withdraw',
|
||||
'开户初始余额': 'finance.remark.initial_balance',
|
||||
'Resettlement adjustment': 'finance.tx.resettle',
|
||||
};
|
||||
|
||||
/** 钱包流水备注:系统英文/中文模板按当前语言展示 */
|
||||
export function walletRemarkLabel(
|
||||
remark: string | null | undefined,
|
||||
transactionType: string,
|
||||
t: (key: string, params?: Record<string, unknown>) => string,
|
||||
): string {
|
||||
const raw = remark?.trim();
|
||||
if (!raw) {
|
||||
if (transactionType === 'MANUAL_DEPOSIT') return t('finance.remark.agent_deposit');
|
||||
if (transactionType === 'MANUAL_WITHDRAW') return t('finance.remark.agent_withdraw');
|
||||
return '—';
|
||||
}
|
||||
|
||||
const exactKey = WALLET_REMARK_EXACT[raw];
|
||||
if (exactKey) return t(exactKey);
|
||||
|
||||
const revokeEn = raw.match(/^Revoke approved deposit\s+([A-Z0-9]+)$/i);
|
||||
if (revokeEn) return t('finance.remark.revoke_deposit', { orderNo: revokeEn[1] });
|
||||
|
||||
const revokeZh = raw.match(/^撤销已通过充值\s+([A-Z0-9]+)$/);
|
||||
if (revokeZh) return t('finance.remark.revoke_deposit', { orderNo: revokeZh[1] });
|
||||
|
||||
const depositOrder = raw.match(/^Deposit order\s+([A-Z0-9]+)$/i);
|
||||
if (depositOrder) return t('finance.remark.deposit_order', { orderNo: depositOrder[1] });
|
||||
|
||||
const cashbackBatch = raw.match(/^Cashback batch\s+(.+)$/i);
|
||||
if (cashbackBatch) return t('finance.remark.cashback_batch', { batchNo: cashbackBatch[1].trim() });
|
||||
|
||||
return raw;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user