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.
133 lines
2.9 KiB
133 lines
2.9 KiB
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { Order, OrderParam } from './model';
|
|
import { MODULES_API_URL } from '@/config/setting';
|
|
|
|
/**
|
|
* 分页查询订单
|
|
*/
|
|
export async function pageOrder(params : OrderParam) {
|
|
const res = await request.get<ApiResult<PageResult<Order>>>(
|
|
MODULES_API_URL + '/shop/order/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询订单列表
|
|
*/
|
|
export async function listOrder(params ?: OrderParam) {
|
|
const res = await request.get<ApiResult<Order[]>>(
|
|
MODULES_API_URL + '/shop/order',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加订单
|
|
*/
|
|
export async function addOrder(data : Order) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/shop/order',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改订单
|
|
*/
|
|
export async function updateOrder(data : Order) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/shop/order',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除订单
|
|
*/
|
|
export async function removeOrder(id ?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/shop/order/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除订单
|
|
*/
|
|
export async function removeBatchOrder(data : (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/shop/order/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 根据id查询订单
|
|
*/
|
|
export async function getOrder(id : number) {
|
|
const res = await request.get<ApiResult<Order>>(
|
|
MODULES_API_URL + '/shop/order/' + id
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 根据orderNo查询订单
|
|
*/
|
|
export async function getByOrderNo(orderNo : string) {
|
|
const res = await request.get<ApiResult<Order>>(
|
|
MODULES_API_URL + '/shop/order/getByOrderNo/' + orderNo
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 根据orderNo核销订单
|
|
*/
|
|
export async function verification(orderNo : string) {
|
|
const res = await request.get<ApiResult<Order>>(
|
|
MODULES_API_URL + '/shop/order/verification/' + orderNo
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|