feat(wallet): 钱包系统替代配额系统,新增支付与退款机制

- 新增钱包余额管理、充值、扣费、退款完整流程
- 新增支付网关抽象层(支持手动/支付宝/微信)
- 用量计费从配额系统迁移到钱包余额扣费
- 新增管理员钱包管理与支付订单管理页面
- 新增用户钱包中心页面
- 移除独立 Key 锁定机制,统一由钱包余额控制
- 新增相关 API 路由、序列化器与数据库迁移
- 新增钱包、支付、退款相关测试
This commit is contained in:
LewisPen
2026-03-08 00:05:48 +08:00
committed by fawney19
parent 9cdcce1b5f
commit 783f654953
108 changed files with 13152 additions and 3372 deletions
+17 -7
View File
@@ -588,8 +588,22 @@ const mockHandlers: Record<string, (config: AxiosRequestConfig) => Promise<Axios
total_cost: Number((totalCost * 20).toFixed(2)),
total_actual_cost: Number((totalActualCost * 20).toFixed(2)),
avg_response_time: Number(avgResponseTime.toFixed(2)) || 1.23,
quota_usd: 100,
used_usd: Number((totalCost * 20).toFixed(2)),
billing: {
id: 'wallet-demo-user',
balance: Number((100 - totalCost * 20).toFixed(2)),
recharge_balance: Number((100 - totalCost * 20).toFixed(2)),
gift_balance: 0,
refundable_balance: Number((100 - totalCost * 20).toFixed(2)),
currency: 'USD',
status: 'active',
limit_mode: 'finite',
unlimited: false,
total_recharged: 100,
total_consumed: Number((totalCost * 20).toFixed(2)),
total_refunded: 0,
total_adjusted: 0,
updated_at: new Date().toISOString(),
},
activity_heatmap: heatmap,
summary_by_model: Array.from(modelStats.entries()).map(([model, stats]) => ({
model,
@@ -726,10 +740,8 @@ const mockHandlers: Record<string, (config: AxiosRequestConfig) => Promise<Axios
username: body.username,
email: body.email,
role: body.role || 'user',
unlimited: Boolean(body.unlimited),
is_active: true,
quota_usd: body.quota_usd || null,
used_usd: 0,
total_usd: 0,
allowed_providers: null,
allowed_api_formats: null,
allowed_models: null,
@@ -757,8 +769,6 @@ const mockHandlers: Record<string, (config: AxiosRequestConfig) => Promise<Axios
key_display: 'sk-sa...demo',
is_active: true,
is_standalone: true,
balance_used_usd: 0,
current_balance_usd: body.initial_balance_usd || 100,
total_requests: 0,
created_at: new Date().toISOString()
}