新增微信支付、Native支付
This commit is contained in:
@@ -28,12 +28,20 @@ export interface Merchant {
|
||||
region?: string;
|
||||
// 地址
|
||||
address?: string;
|
||||
// 每小时价格
|
||||
price?: number;
|
||||
// 手续费
|
||||
commission?: number;
|
||||
// 关键字
|
||||
keywords?: string;
|
||||
// 资质图片
|
||||
files?: string;
|
||||
// 营业时间
|
||||
businessTime?: string;
|
||||
timePeriod1?: string;
|
||||
timePeriod2?: string;
|
||||
// 商户介绍
|
||||
content?: string;
|
||||
// 是否自营
|
||||
ownStore?: number;
|
||||
// 是否推荐
|
||||
|
||||
121
src/api/system/payment/index.ts
Normal file
121
src/api/system/payment/index.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { Payment, PaymentParam } from './model';
|
||||
import { SERVER_API_URL } from '@/config/setting';
|
||||
import type { Order } from '@/api/shop/order/model';
|
||||
|
||||
/**
|
||||
* 分页查询支付方式
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询支付方式
|
||||
*/
|
||||
export async function getPayment(id: number) {
|
||||
const res = await request.get<ApiResult<Payment>>(
|
||||
SERVER_API_URL + '/system/payment/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成支付二维码(微信native)
|
||||
*/
|
||||
export async function getNativeCode(data: Order) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/system/wx-native-pay/codeUrl',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
51
src/api/system/payment/model/index.ts
Normal file
51
src/api/system/payment/model/index.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
export interface Payment {
|
||||
// ID
|
||||
id?: number;
|
||||
// 支付方式
|
||||
name?: string;
|
||||
// 标识
|
||||
code?: string;
|
||||
// 支付图标
|
||||
image?: string;
|
||||
// 微信商户号类型 1普通商户2子商户
|
||||
wechatType?: number;
|
||||
// 应用ID
|
||||
appId?: string;
|
||||
// 商户号
|
||||
mchId?: string;
|
||||
// 设置APIv3密钥
|
||||
apiKey?: string;
|
||||
// 证书文件 (CERT)
|
||||
apiclientCert?: string;
|
||||
// 证书文件 (KEY)
|
||||
apiclientKey?: string;
|
||||
// 商户证书序列号
|
||||
merchantSerialNumber?: string;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 文章排序(数字越小越靠前)
|
||||
sortNumber?: number;
|
||||
// 状态, 0启用, 1禁用
|
||||
status?: boolean;
|
||||
// 是否删除, 0否, 1是
|
||||
deleted?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 注册时间
|
||||
createTime?: string;
|
||||
// 修改时间
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付方式搜索条件
|
||||
*/
|
||||
export interface PaymentParam extends PageParam {
|
||||
id?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user