feat: 增强钱包 API 与玩家会话管理

- 新增钱包 API 函数:getWalletLogs(获取钱包日志)、postWalletTransferIn(充值)及 postWalletTransferOut(提现)
- 更新钱包相关类型定义,提升类型安全性
- 改进玩家会话管理:若当前无玩家资料,则自动拉取玩家信息
- 增强入口网关对过期会话的错误处理能力
- 更新 UI 组件,以适配新的结构与功能
This commit is contained in:
2026-05-09 15:22:08 +08:00
parent 14c297fe1a
commit 7743c14e83
28 changed files with 1719 additions and 33 deletions

View File

@@ -9,3 +9,10 @@ export type { HealthData } from "./health";
export type { ScopePingData } from "./ping";
export type { PlayerMeData } from "./player-me";
export type { WalletBalanceData } from "./wallet-balance";
export type { WalletTransferBody, WalletTransferResultData } from "./wallet-transfer";
export type {
GetWalletLogsParams,
WalletLogItem,
WalletLogsData,
WalletPendingTransfer,
} from "./wallet-logs";

View File

@@ -3,8 +3,12 @@ export type PlayerMeData = {
id: number;
site_code: string;
site_player_id: string;
username: string;
username: string | null;
nickname: string | null;
default_currency: string;
status: number;
/** 当次请求解析后的界面语言zh / en / ne */
locale: string;
last_login_at: string | null;
created_at: string | null;
};

View File

@@ -2,6 +2,8 @@
export type WalletBalanceData = {
/** 最小货币单位 bigint序列化可能为 string */
balance: string | number;
/** 可用余额 = balance - frozen_balance服务端保证 ≥0 */
available_balance: string | number;
main_balance: null;
currency_code: string;
wallet_type: string;

View File

@@ -0,0 +1,47 @@
/** `GET /api/v1/wallet/logs` 单条流水 */
export type WalletLogItem = {
log_id: string;
type: string;
biz_type: string;
/** 正数为加款,负数为扣款(最小货币单位) */
amount: number;
amount_abs: number;
direction: "in" | "out";
currency_code: string;
balance_after: number;
ref_id: string | null;
idempotent_key: string | null;
external_ref_no: string | null;
status: string;
remark: string | null;
created_at: string | null;
};
/** 待对账划转主站超时等PRD §6.2 / §6.7 */
export type WalletPendingTransfer = {
transfer_no: string;
direction: string;
type: string;
currency_code: string;
amount: number;
status: string;
fail_reason: string | null;
idempotent_key: string;
created_at: string | null;
};
export type WalletLogsData = {
items: WalletLogItem[];
total: number;
page: number;
per_page: number;
pending_reconcile: WalletPendingTransfer[];
};
export type GetWalletLogsParams = {
page?: number;
/** 每页条数PRD 示例 `size` */
size?: number;
/** 逗号分隔transfer_in,transfer_out,bet,prize,refund */
type?: string;
};

View File

@@ -0,0 +1,26 @@
/** `POST /api/v1/wallet/transfer-in` | `transfer-out` 请求体 */
export type WalletTransferBody = {
/** 最小货币单位正整数 */
amount: number;
/** 客户端生成的幂等键,重复请求须携带相同键与参数 */
idempotent_key: string;
/** 不传则使用玩家 `default_currency` / 系统默认 */
currency?: string;
};
/** 转入/转出成功时 `data`(含 PRD §10.1.1 示例字段 `balance` / `log_id` */
export type WalletTransferResultData = {
transfer_no: string;
direction: "in" | "out";
currency_code: string;
amount: number;
status: string;
external_ref_no: string | null;
/** 成功后彩票钱包余额,与 `lottery_balance_after` 相同 */
balance: number;
/** 本笔对应主流水号(`wallet_txns.txn_no` */
log_id: string | null;
lottery_balance_after: number;
lottery_available_after: number;
finished_at: string | null;
};