新增:余额支付、微信支付、下单确认功能

This commit is contained in:
2025-07-26 12:33:45 +08:00
parent 7d255a2d3c
commit 469e020df5
13 changed files with 664 additions and 72 deletions

View File

@@ -153,5 +153,6 @@ export interface ShopOrderParam extends PageParam {
orderStatus?: number;
payType?: number;
isInvoice?: boolean;
userId?: number;
keywords?: string;
}

View File

@@ -1,17 +1,16 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api/index';
import type { Payment, PaymentParam } from './model';
import type { Order } from '@/api/shop/order/model';
import type {ApiResult, PageResult} from '@/api/index';
import type {Payment, PaymentParam} from './model';
import type {ShopOrder} from '@/api/shop/shopOrder/model';
import {SERVER_API_URL} from "@/utils/server";
/**
* 分页查询支付方式
*/
export async function pagePayment(params: PaymentParam) {
const res = await request.get<ApiResult<PageResult<Payment>>>(
'/system/payment/page',
{
params
}
SERVER_API_URL + '/system/payment/page',
params
);
if (res.code === 0) {
return res.data;
@@ -24,10 +23,8 @@ export async function pagePayment(params: PaymentParam) {
*/
export async function listPayment(params?: PaymentParam) {
const res = await request.get<ApiResult<Payment[]>>(
'/system/payment',
{
params
}
SERVER_API_URL + '/system/payment',
params
);
if (res.code === 0 && res.data) {
return res.data;
@@ -40,7 +37,7 @@ export async function listPayment(params?: PaymentParam) {
*/
export async function addPayment(data: Payment) {
const res = await request.post<ApiResult<unknown>>(
'/system/payment',
SERVER_API_URL + '/system/payment',
data
);
if (res.code === 0) {
@@ -54,7 +51,7 @@ export async function addPayment(data: Payment) {
*/
export async function updatePayment(data: Payment) {
const res = await request.put<ApiResult<unknown>>(
'/system/payment',
SERVER_API_URL + '/system/payment',
data
);
if (res.code === 0) {
@@ -68,7 +65,7 @@ export async function updatePayment(data: Payment) {
*/
export async function removePayment(id?: number) {
const res = await request.del<ApiResult<unknown>>(
'/system/payment/' + id
SERVER_API_URL + '/system/payment/' + id
);
if (res.code === 0) {
return res.message;
@@ -81,7 +78,7 @@ export async function removePayment(id?: number) {
*/
export async function removeBatchPayment(data: (number | undefined)[]) {
const res = await request.del<ApiResult<unknown>>(
'/system/payment/batch',
SERVER_API_URL + '/system/payment/batch',
{
data
}
@@ -97,7 +94,7 @@ export async function removeBatchPayment(data: (number | undefined)[]) {
*/
export async function getPayment(id: number) {
const res = await request.get<ApiResult<Payment>>(
'/system/payment/' + id
SERVER_API_URL + '/system/payment/' + id
);
if (res.code === 0 && res.data) {
return res.data;
@@ -108,9 +105,9 @@ export async function getPayment(id: number) {
/**
* 生成支付二维码(微信native)
*/
export async function getNativeCode(data: Order) {
export async function getNativeCode(data: ShopOrder) {
const res = await request.post<ApiResult<unknown>>(
'/system/wx-native-pay/codeUrl',
SERVER_API_URL + '/system/wx-native-pay/codeUrl',
data
);
if (res.code === 0) {
@@ -118,3 +115,31 @@ export async function getNativeCode(data: Order) {
}
return Promise.reject(new Error(res.message));
}
/**
* 使用余额支付
*/
export async function payByBalance(data: ShopOrder) {
const res = await request.post<ApiResult<unknown>>(
SERVER_API_URL + '/system/payment/balancePay',
data
);
if (res.code === 0) {
return res.message;
}
return Promise.reject(new Error(res.message));
}
/**
* 选择支付方式
*/
export async function selectPayment(params?: PaymentParam) {
const res = await request.get<ApiResult<Payment[]>>(
SERVER_API_URL + '/system/payment/select',
params
);
if (res.code === 0) {
return res.data;
}
return Promise.reject(new Error(res.message));
}

View File

@@ -1,4 +1,4 @@
import type { PageParam } from '@/api';
import type { PageParam } from '@/api/index';
/**
* 支付方式