81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
/**
|
|
* 支付配置管理 API
|
|
*/
|
|
|
|
import { BaseService } from '../BaseService'
|
|
import type { BaseResponse } from '@/types/api'
|
|
import type {
|
|
PaymentSettings,
|
|
PaymentSettingsQueryParams,
|
|
PaymentSettingsListResponse,
|
|
CreatePaymentSettingsRequest,
|
|
UpdatePaymentSettingsRequest
|
|
} from '@/types/api/paymentSettings'
|
|
|
|
const PAYMENT_SETTINGS_BASE_URL = '/api/admin/wechat-configs'
|
|
|
|
export class PaymentSettingsService extends BaseService {
|
|
/**
|
|
* 获取支付配置列表
|
|
*/
|
|
static getPaymentSettings(
|
|
params?: PaymentSettingsQueryParams
|
|
): Promise<BaseResponse<PaymentSettingsListResponse>> {
|
|
return this.get<BaseResponse<PaymentSettingsListResponse>>(PAYMENT_SETTINGS_BASE_URL, params)
|
|
}
|
|
|
|
/**
|
|
* 获取支付配置详情
|
|
*/
|
|
static getPaymentSettingsById(id: number): Promise<BaseResponse<PaymentSettings>> {
|
|
return this.get<BaseResponse<PaymentSettings>>(`${PAYMENT_SETTINGS_BASE_URL}/${id}`)
|
|
}
|
|
|
|
/**
|
|
* 创建支付配置
|
|
*/
|
|
static createPaymentSettings(
|
|
data: CreatePaymentSettingsRequest
|
|
): Promise<BaseResponse<PaymentSettings>> {
|
|
return this.post<BaseResponse<PaymentSettings>>(PAYMENT_SETTINGS_BASE_URL, data)
|
|
}
|
|
|
|
/**
|
|
* 更新支付配置
|
|
*/
|
|
static updatePaymentSettings(
|
|
id: number,
|
|
data: UpdatePaymentSettingsRequest
|
|
): Promise<BaseResponse<PaymentSettings>> {
|
|
return this.put<BaseResponse<PaymentSettings>>(`${PAYMENT_SETTINGS_BASE_URL}/${id}`, data)
|
|
}
|
|
|
|
/**
|
|
* 删除支付配置
|
|
*/
|
|
static deletePaymentSettings(id: number): Promise<BaseResponse<void>> {
|
|
return this.delete<BaseResponse<void>>(`${PAYMENT_SETTINGS_BASE_URL}/${id}`)
|
|
}
|
|
|
|
/**
|
|
* 激活支付配置
|
|
*/
|
|
static activatePaymentSettings(id: number): Promise<BaseResponse<PaymentSettings>> {
|
|
return this.post<BaseResponse<PaymentSettings>>(`${PAYMENT_SETTINGS_BASE_URL}/${id}/activate`)
|
|
}
|
|
|
|
/**
|
|
* 停用支付配置
|
|
*/
|
|
static deactivatePaymentSettings(id: number): Promise<BaseResponse<PaymentSettings>> {
|
|
return this.post<BaseResponse<PaymentSettings>>(`${PAYMENT_SETTINGS_BASE_URL}/${id}/deactivate`)
|
|
}
|
|
|
|
/**
|
|
* 获取当前生效的支付配置
|
|
*/
|
|
static getActivePaymentSettings(): Promise<BaseResponse<PaymentSettings>> {
|
|
return this.get<BaseResponse<PaymentSettings>>(`${PAYMENT_SETTINGS_BASE_URL}/active`)
|
|
}
|
|
}
|