hbsmUniapp/src/api/order.ts

272 lines
4.8 KiB
TypeScript
Raw Normal View History

2025-08-19 23:31:48 +08:00
import type { PageResult, TabItem } from '@/types/global'
import type {
orderResult,
orderCreateParams,
orderCreateResult,
orderPreResult,
orderListResult,
orderListParams,
orderPreParams,
orderEvaluateParams,
orderEvaluateListParams,
orderEvaluateListResult,
orderRefundRequest,
orderRefundDetailResult,
orderRefundListResult,
orderDeliveryResult,
} from '@/types/order'
import { request } from '@/utils/request'
const orderUrl = '/order'
const refundUrl = '/orderRefund'
const evaluateUrl = '/orderEvaluate'
/**
*
* @param id
* @returns
*/
export const getCartOrderPreApi = (data: {
address_id: string | number
coupon_id: string | number
}) => {
return request<orderPreResult>({
method: 'GET',
url: `${orderUrl}/preCart`,
data,
})
}
/**
*
* @param data
* @returns
*/
export const getOrderPreApi = (data: orderPreParams) => {
return request<orderPreResult>(
{
method: 'GET',
url: `${orderUrl}/pre`,
data,
},
false,
)
}
/**
*
* @returns
*/
export const postOrderApi = (data: orderCreateParams) => {
return request<orderCreateResult>({
method: 'POST',
url: `${orderUrl}/create`,
data,
})
}
/**
* -
* @param id id
*/
export const getRepurchaseOrderPreByOrderIdApi = (data: {
id: number | string
address_id: string | number
coupon_id: string | number
}) => {
return request<orderPreResult>({
method: 'GET',
url: `${orderUrl}/preRepurchase`,
data,
})
}
/**
*
* @param id id
*/
export const receiveOrderById = (id: number) => {
return request<orderResult>({
method: 'POST',
url: `${orderUrl}/receive`,
data: {
id,
},
})
}
/**
*
* @param id id
*/
export const getOrderDeliveryByIdApi = (id: number) => {
return request<orderDeliveryResult[]>({
method: 'GET',
url: `${orderUrl}/delivery`,
data: {
id,
},
})
}
/**
*
* @param data id集合
* @returns
*/
export const deleteOrderApi = (data: { id: number[] }) => {
return request({
method: 'POST',
url: `${orderUrl}/delete`,
data,
})
}
/**
*
* @param id id
* @param data cancelReason
*/
export const putOrderCancelByIdApi = (data: {
id: number | number
cancel_reason?: string
time_out?: boolean //是否超时取消
}) => {
return request<orderResult>({
method: 'POST',
url: `${orderUrl}/cancel`,
data,
})
}
/**
*
* @param data orderState
*/
export const getOrderListApi = (data: orderListParams) => {
return request<
PageResult<orderListResult> & {
tabs: TabItem[]
}
>({
method: 'GET',
url: `${orderUrl}/list`,
data,
})
}
export const getOrderTabsApi = () => {
return request<TabItem[]>({
method: 'GET',
url: `${orderUrl}/tabs`,
})
}
/**
* ID获取订单详情
* @param id
* @returns
*/
export const getOrderDetailByIdApi = (id: number) => {
return request<orderResult>({
method: 'GET',
url: `${orderUrl}/detail`,
data: {
id,
},
})
}
/**
*
* @param data
* @returns
*/
export const postOrderEvaluateApi = (data: orderEvaluateParams) => {
return request({
method: 'POST',
url: `${evaluateUrl}/add`,
data,
})
}
/**
*
* @param data
* @returns
*/
export const getOrderEvaluateListApi = (data: orderEvaluateListParams) => {
return request<PageResult<orderEvaluateListResult[]>>({
method: 'GET',
url: `${evaluateUrl}/list`,
data,
})
}
/**
* tab项
* @returns
*/
export const getOrderEvaluateTabsApi = (data: { goods_id: string }) => {
return request<TabItem[]>({
method: 'GET',
url: `${evaluateUrl}/tabs`,
data,
})
}
/**
*
* @param data
* @returns
*/
export const postOrderRefundApi = (data: orderRefundRequest) => {
return request({
method: 'POST',
url: `${refundUrl}/refund`,
data,
})
}
/**
*
* @param status
* @returns
*/
export const getOrderRefundListApi = (data: { status: string | number }) => {
return request<PageResult<orderRefundListResult[]>>({
method: 'GET',
url: `${refundUrl}/list`,
data,
})
}
/**
*
* @param data
* @returns
*/
export const getOrderRefundDetailApi = (data: { id: number }) => {
return request<orderRefundDetailResult>({
method: 'GET',
url: `${refundUrl}/detail`,
data,
})
}
/**
* 退
*/
export const postOrderRefundReturnApi = (data: {
id: number
delivery_company_id: number
delivery_no: string
delivery_company: string
}) => {
return request({
method: 'POST',
url: `${refundUrl}/refundReturn`,
data,
})
}