feat: add avatar payments and finance management

This commit is contained in:
stefanfeng
2026-09-08 18:47:29 +08:00
parent 62eb9578fd
commit 8585d101d5
36 changed files with 10228 additions and 43 deletions
+35 -3
View File
@@ -152,16 +152,35 @@ export interface TokenPaymentOrder {
planId: string
paymentMethod: 'wechat' | 'alipay'
payType: 'WECHAT' | 'ALIPAY'
payWay: 'APP' | 'LITE' | 'JSAPI'
payWay: 'APP' | 'H5' | 'LITE' | 'JSAPI'
pointsAmount: number
price: number
status: 'pending' | 'paid' | 'failed'
status: 'pending' | 'paid' | 'failed' | 'closed' | 'refunded'
provider: 'huihui' | 'wechat_virtual'
providerStatus: string
payMessage: string
failureReason: string
refundStatus: 'none' | 'pending' | 'processing' | 'succeeded' | 'failed'
createdAt: string | null
paidAt: string | null
refundedAt: string | null
balance: number
}
export interface TokenInvoice {
id: string
orderNo: string
title: string
invoiceType: 'personal' | 'company'
taxNumber: string
email: string
amount: number
status: 'pending' | 'issued' | 'rejected' | 'cancelled'
invoiceNo: string
invoiceUrl: string
remark: string
}
// 获取 Token 余额
export const getTokenBalance = () =>
request.get<TokenBalance>('/token/balance')
@@ -174,12 +193,25 @@ export const getRechargePlans = () =>
export const chargeToken = (
planId: string,
paymentMethod: 'wechat' | 'alipay',
payScene: 'APP' | 'LITE' | 'JSAPI'
payScene: 'APP' | 'H5' | 'LITE' | 'JSAPI'
) => request.post<TokenPaymentOrder>('/token/charge', { planId, paymentMethod, payScene })
export const getTokenPaymentStatus = (orderId: string) =>
request.get<TokenPaymentOrder>(`/token/payment/${orderId}`)
export const bindWechatVirtualSession = (code: string) =>
request.post<{ ready: boolean }>('/token/wechat/session', { code })
export const getTokenOrders = (page = 1, pageSize = 20) =>
request.get<{ total: number; page: number; pageSize: number; items: Array<TokenPaymentOrder & { invoice?: TokenInvoice }> }>(
'/token/orders', { params: { page, page_size: pageSize } }
)
export const applyTokenInvoice = (
orderNo: string,
payload: { title: string; invoiceType: 'personal' | 'company'; taxNumber?: string; email?: string }
) => request.post<TokenInvoice>(`/token/orders/${orderNo}/invoice`, payload)
// 按分身和使用场景汇总 Token 消耗
export const getTokenUsage = () =>
request.get<TokenUsageSummary[]>('/token/usage')