You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.2 KiB
124 lines
3.2 KiB
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { Payment, PaymentParam } from './model';
|
|
import { SERVER_API_URL } from '@/config/setting';
|
|
|
|
/**
|
|
* 选择支付方式
|
|
*/
|
|
export async function select(params: PaymentParam) {
|
|
const res = await request.get<ApiResult<PageResult<Payment>>>(SERVER_API_URL + '/system/payment/select', {
|
|
params
|
|
});
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 分页查询商户
|
|
*/
|
|
export async function pagePayment(params: PaymentParam) {
|
|
const res = await request.get<ApiResult<PageResult<Payment>>>(SERVER_API_URL + '/system/payment/page', {
|
|
params
|
|
});
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询商户列表
|
|
*/
|
|
export async function listPayment(params?: PaymentParam) {
|
|
const res = await request.get<ApiResult<Payment[]>>(SERVER_API_URL + '/system/payment', {
|
|
params
|
|
});
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加商户
|
|
*/
|
|
export async function addPayment(data: Payment) {
|
|
const res = await request.post<ApiResult<unknown>>(SERVER_API_URL + '/system/payment', data);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改商户
|
|
*/
|
|
export async function updatePayment(data: Payment) {
|
|
const res = await request.put<ApiResult<unknown>>(SERVER_API_URL + '/system/payment', data);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除商户
|
|
*/
|
|
export async function removePayment(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(SERVER_API_URL + '/system/payment/' + id);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除商户
|
|
*/
|
|
export async function removeBatchPayment(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(SERVER_API_URL + '/system/payment/batch', {
|
|
data
|
|
});
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 检查IP是否存在
|
|
*/
|
|
export async function checkExistence(field: string, value: string, id?: number) {
|
|
const res = await request.get<ApiResult<unknown>>(SERVER_API_URL + '/system/payment/existence', {
|
|
params: { field, value, id }
|
|
});
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 拉起支付
|
|
*/
|
|
export async function alipay(data: PaymentParam) {
|
|
const res = await request.post<ApiResult<unknown>>(SERVER_API_URL + '/system/payment/alipay', data);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询商户列表
|
|
*/
|
|
export async function alipayQuery(orderId) {
|
|
const res = await request.get<ApiResult<unknown>>(SERVER_API_URL + '/system/payment/mp-alipay/query/' + orderId);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|