Files
thebet365/apps/player/src/utils/walletTx.ts
Mars d3c211411b feat(admin+api+player): 优胜赛结算态、禁止新增单场与钱包流水展示优化
- API/管理端:优胜赛 SETTLED 后禁止新增单场,列表与子页展示结算状态
- 玩家端:已结算 outright 只读展示并高亮冠军
- 管理端:结算后 stale 标记驱动列表刷新;财务流水时间与备注 i18n 优化
- shared:txDisplayAmount 与 LEAGUE_OUTRIGHT_SETTLED 错误码
2026-06-23 12:20:40 +08:00

102 lines
3.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 { txDisplayAmount } from '@thebet365/shared';
export { txDisplayAmount };
/** 流水金额样式0 用中性色,正数金色,负数红色 */
export function txAmountClass(amount: string): 'zero' | 'pos' | 'neg' {
const n = parseFloat(amount);
if (n === 0) return 'zero';
return n > 0 ? 'pos' : 'neg';
}
export const TX_KEY_MAP: Record<string, string> = {
MANUAL_DEPOSIT: 'wallet.tx_deposit',
ADMIN_DEPOSIT: 'wallet.tx_admin_deposit',
AGENT_DEPOSIT: 'wallet.tx_agent_deposit',
INITIAL_DEPOSIT: 'wallet.tx_admin_deposit',
MANUAL_WITHDRAW: 'wallet.tx_withdraw',
ADMIN_WITHDRAW: 'wallet.tx_admin_withdraw',
AGENT_WITHDRAW: 'wallet.tx_agent_withdraw',
MANUAL_ADJUST: 'wallet.tx_adjust',
BET_FREEZE: 'wallet.tx_bet_freeze',
BET_DEDUCT: 'wallet.tx_bet_deduct',
BET_SETTLE_WIN: 'wallet.tx_bet_win',
BET_SETTLE_LOSE: 'wallet.tx_bet_lose',
BET_SETTLE_PUSH: 'wallet.tx_bet_push',
BET_WIN: 'wallet.tx_bet_win',
BET_REFUND: 'wallet.tx_bet_refund',
BET_VOID: 'wallet.tx_bet_void',
BET_VOID_REFUND: 'wallet.tx_bet_void',
CASHBACK: 'wallet.tx_cashback',
CASHBACK_DEPOSIT: 'wallet.tx_cashback',
RESETTLE_REVERSE: 'wallet.tx_resettle',
DEPOSIT: 'wallet.tx_deposit',
WITHDRAW: 'wallet.tx_withdraw',
PLAYER_DEPOSIT: 'wallet.tx_player_deposit',
PLAYER_DEPOSIT_REVERSAL: 'wallet.tx_player_deposit_reversal',
};
export function txTypeKey(type: string): string {
return TX_KEY_MAP[type.toUpperCase()] ?? '';
}
export function txDisplayType(tx: { displayType?: string; transactionType: string }): string {
return tx.displayType?.trim() || tx.transactionType;
}
export function txSummaryLabel(
tx: {
summary?: string | null;
summaryKind?: 'opening_bonus' | null;
referenceType?: string | null;
},
t: (key: string, params?: Record<string, unknown>) => string,
): string {
if (tx.summaryKind === 'opening_bonus') {
return t('wallet.summary_opening_bonus');
}
const summary = tx.summary?.trim();
if (!summary) return '';
if (tx.referenceType === 'BET') {
return t('wallet.summary_bet', { betNo: summary });
}
return summary;
}
export function isDepositType(type: string): boolean {
const t = type.toUpperCase();
return (t.includes('DEPOSIT') || t === 'CASHBACK_DEPOSIT') && !isCashbackType(type) && t !== 'PLAYER_DEPOSIT_REVERSAL';
}
export function isDepositReversalType(type: string): boolean {
return type.toUpperCase() === 'PLAYER_DEPOSIT_REVERSAL';
}
export function txRemarkLabel(
tx: { transactionType: string; remark?: string | null; referenceId?: string | null },
t: (key: string, params?: Record<string, unknown>) => string,
): string {
const type = tx.transactionType.toUpperCase();
const remark = tx.remark?.trim() ?? '';
if (type === 'PLAYER_DEPOSIT_REVERSAL') {
return t('wallet.remark_deposit_revoke_generic');
}
return remark;
}
export function isWithdrawType(type: string): boolean {
const t = type.toUpperCase();
if (t === 'PLAYER_DEPOSIT_REVERSAL') return false;
return t.includes('WITHDRAW');
}
export function isBetType(type: string): boolean {
return type.toUpperCase().startsWith('BET_') || type.toUpperCase() === 'RESETTLE_REVERSE';
}
export function isCashbackType(type: string): boolean {
const t = type.toUpperCase();
return t === 'CASHBACK' || t === 'CASHBACK_DEPOSIT';
}