feat(finance): add customer recharge account
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
import { apiRequest } from '@/api/http'
|
||||
|
||||
export interface PageResult<T> {
|
||||
records: T[]
|
||||
total: number
|
||||
page: number
|
||||
size: number
|
||||
pages: number
|
||||
}
|
||||
|
||||
export interface FinanceAccount {
|
||||
currencyCode: 'CNY'
|
||||
actualBalance: string
|
||||
frozenBalance: string
|
||||
availableBalance: string
|
||||
version: number
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export type AccountChangeType = 'RECHARGE' | 'DEDUCTION' | 'FREEZE' | 'UNFREEZE' | 'CONSUMPTION'
|
||||
|
||||
export interface AccountLedgerEntry {
|
||||
ledgerId: string
|
||||
businessNo: string
|
||||
changeType: AccountChangeType
|
||||
amount: string
|
||||
actualBalanceAfter: string
|
||||
frozenBalanceAfter: string
|
||||
availableBalanceAfter: string
|
||||
sourceType: 'CLIENT_RECHARGE' | 'MANUAL_RECHARGE' | 'MANUAL_DEDUCTION'
|
||||
sourceNo: string
|
||||
operatorName: string | null
|
||||
remark: string | null
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export type RechargePaymentMethod = 'WECHAT' | 'ALIPAY'
|
||||
export type RechargeStatus = 'PENDING' | 'APPROVED' | 'REJECTED'
|
||||
|
||||
export interface RechargeRequest {
|
||||
requestId: string
|
||||
requestNo: string
|
||||
amount: string
|
||||
paymentMethod: RechargePaymentMethod
|
||||
voucherFileId: string
|
||||
voucherFileName: string
|
||||
status: RechargeStatus
|
||||
version: number
|
||||
submittedByName: string | null
|
||||
reviewedByName: string | null
|
||||
reviewRemark: string | null
|
||||
createdAt: string
|
||||
reviewedAt: string | null
|
||||
}
|
||||
|
||||
export interface RechargeChannel {
|
||||
paymentMethod: RechargePaymentMethod
|
||||
displayName: string
|
||||
enabled: boolean
|
||||
qrCodeUrl: string | null
|
||||
}
|
||||
|
||||
export function getFinanceAccount() {
|
||||
return apiRequest<FinanceAccount>({ method: 'GET', url: '/client/finance/v1/account' })
|
||||
}
|
||||
|
||||
export function getAccountLedger(page: number, size: number) {
|
||||
return apiRequest<PageResult<AccountLedgerEntry>>({
|
||||
method: 'GET',
|
||||
url: '/client/finance/v1/account/ledger',
|
||||
params: { page, size },
|
||||
})
|
||||
}
|
||||
|
||||
export function getRechargeRequests(page: number, size: number) {
|
||||
return apiRequest<PageResult<RechargeRequest>>({
|
||||
method: 'GET',
|
||||
url: '/client/finance/v1/recharge-requests',
|
||||
params: { page, size },
|
||||
})
|
||||
}
|
||||
|
||||
export function getRechargeChannels() {
|
||||
return apiRequest<RechargeChannel[]>({ method: 'GET', url: '/client/finance/v1/recharge-channels' })
|
||||
}
|
||||
|
||||
export function createRechargeRequest(amount: string, paymentMethod: RechargePaymentMethod, file: File,
|
||||
idempotencyKey: string) {
|
||||
const formData = new FormData()
|
||||
formData.append('amount', amount)
|
||||
formData.append('paymentMethod', paymentMethod)
|
||||
formData.append('file', file, file.name)
|
||||
return apiRequest<RechargeRequest>({
|
||||
method: 'POST',
|
||||
url: '/client/finance/v1/recharge-requests',
|
||||
headers: { 'Idempotency-Key': idempotencyKey },
|
||||
data: formData,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user