2023-12-15 16:09:01 +00:00
|
|
|
|
import request from '@/sheep/request';
|
2024-08-06 08:09:53 +00:00
|
|
|
|
import { isEmpty } from '@/sheep/helper/utils';
|
2023-12-15 16:09:01 +00:00
|
|
|
|
|
|
|
|
|
const OrderApi = {
|
|
|
|
|
// 计算订单信息
|
|
|
|
|
settlementOrder: (data) => {
|
|
|
|
|
const data2 = {
|
|
|
|
|
...data,
|
|
|
|
|
};
|
|
|
|
|
// 移除多余字段
|
|
|
|
|
if (!(data.couponId > 0)) {
|
|
|
|
|
delete data2.couponId;
|
|
|
|
|
}
|
|
|
|
|
if (!(data.addressId > 0)) {
|
|
|
|
|
delete data2.addressId;
|
|
|
|
|
}
|
2024-08-06 08:09:53 +00:00
|
|
|
|
if (!(data.pickUpStoreId > 0)) {
|
|
|
|
|
delete data2.pickUpStoreId;
|
|
|
|
|
}
|
|
|
|
|
if (isEmpty(data.receiverName)) {
|
|
|
|
|
delete data2.receiverName;
|
|
|
|
|
}
|
|
|
|
|
if (isEmpty(data.receiverMobile)) {
|
|
|
|
|
delete data2.receiverMobile;
|
|
|
|
|
}
|
2024-03-04 07:14:45 +00:00
|
|
|
|
if (!(data.combinationActivityId > 0)) {
|
2024-01-13 10:24:00 +00:00
|
|
|
|
delete data2.combinationActivityId;
|
|
|
|
|
}
|
|
|
|
|
if (!(data.combinationHeadId > 0)) {
|
|
|
|
|
delete data2.combinationHeadId;
|
|
|
|
|
}
|
2024-01-13 12:23:41 +00:00
|
|
|
|
if (!(data.seckillActivityId > 0)) {
|
|
|
|
|
delete data2.seckillActivityId;
|
|
|
|
|
}
|
2023-12-15 16:09:01 +00:00
|
|
|
|
// 解决 SpringMVC 接受 List<Item> 参数的问题
|
|
|
|
|
delete data2.items;
|
|
|
|
|
for (let i = 0; i < data.items.length; i++) {
|
|
|
|
|
data2[encodeURIComponent('items[' + i + '' + '].skuId')] = data.items[i].skuId + '';
|
|
|
|
|
data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + '';
|
|
|
|
|
if (data.items[i].cartId) {
|
|
|
|
|
data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const queryString = Object.keys(data2)
|
|
|
|
|
.map((key) => key + '=' + data2[key])
|
|
|
|
|
.join('&');
|
2023-12-28 14:59:14 +00:00
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: `/trade/order/settlement?${queryString}`,
|
2023-12-15 16:09:01 +00:00
|
|
|
|
method: 'GET',
|
2024-01-13 10:24:00 +00:00
|
|
|
|
custom: {
|
|
|
|
|
showError: true,
|
|
|
|
|
showLoading: true,
|
|
|
|
|
},
|
2023-12-15 16:09:01 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
2024-09-16 11:30:56 +00:00
|
|
|
|
// 获得商品结算信息
|
|
|
|
|
getSettlementProduct: (spuIds) => {
|
|
|
|
|
return request({
|
|
|
|
|
url: '/trade/order/settlement-product',
|
|
|
|
|
method: 'GET',
|
|
|
|
|
params: { spuIds },
|
|
|
|
|
custom: {
|
|
|
|
|
showLoading: false,
|
|
|
|
|
showError: false,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-12-15 16:09:01 +00:00
|
|
|
|
// 创建订单
|
|
|
|
|
createOrder: (data) => {
|
2023-12-28 14:59:14 +00:00
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: `/trade/order/create`,
|
2023-12-15 16:09:01 +00:00
|
|
|
|
method: 'POST',
|
|
|
|
|
data,
|
|
|
|
|
});
|
|
|
|
|
},
|
2024-09-24 05:00:46 +00:00
|
|
|
|
// 获得订单详细:sync 是可选参数
|
|
|
|
|
getOrderDetail: (id, sync) => {
|
2023-12-28 14:59:14 +00:00
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: `/trade/order/get-detail`,
|
2023-12-15 16:09:01 +00:00
|
|
|
|
method: 'GET',
|
|
|
|
|
params: {
|
|
|
|
|
id,
|
2024-09-24 05:00:46 +00:00
|
|
|
|
sync,
|
2023-12-15 16:09:01 +00:00
|
|
|
|
},
|
2024-01-20 09:28:04 +00:00
|
|
|
|
custom: {
|
|
|
|
|
showLoading: false,
|
|
|
|
|
},
|
2023-12-15 16:09:01 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 订单列表
|
|
|
|
|
getOrderPage: (params) => {
|
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: '/trade/order/page',
|
2023-12-15 16:09:01 +00:00
|
|
|
|
method: 'GET',
|
|
|
|
|
params,
|
|
|
|
|
custom: {
|
|
|
|
|
showLoading: false,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 确认收货
|
|
|
|
|
receiveOrder: (id) => {
|
2023-12-28 14:59:14 +00:00
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: `/trade/order/receive`,
|
2023-12-15 16:09:01 +00:00
|
|
|
|
method: 'PUT',
|
|
|
|
|
params: {
|
|
|
|
|
id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 取消订单
|
|
|
|
|
cancelOrder: (id) => {
|
2023-12-28 14:59:14 +00:00
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: `/trade/order/cancel`,
|
2023-12-15 16:09:01 +00:00
|
|
|
|
method: 'DELETE',
|
|
|
|
|
params: {
|
|
|
|
|
id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 删除订单
|
|
|
|
|
deleteOrder: (id) => {
|
2023-12-28 14:59:14 +00:00
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: `/trade/order/delete`,
|
2023-12-15 16:09:01 +00:00
|
|
|
|
method: 'DELETE',
|
|
|
|
|
params: {
|
|
|
|
|
id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
2024-01-16 01:32:52 +00:00
|
|
|
|
// 获得交易订单的物流轨迹
|
|
|
|
|
getOrderExpressTrackList: (id) => {
|
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: `/trade/order/get-express-track-list`,
|
2024-01-16 01:32:52 +00:00
|
|
|
|
method: 'GET',
|
|
|
|
|
params: {
|
|
|
|
|
id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-12-28 14:00:07 +00:00
|
|
|
|
// 获得交易订单数量
|
|
|
|
|
getOrderCount: () => {
|
2023-12-28 14:59:14 +00:00
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: '/trade/order/get-count',
|
2023-12-28 14:00:07 +00:00
|
|
|
|
method: 'GET',
|
|
|
|
|
custom: {
|
|
|
|
|
showLoading: false,
|
|
|
|
|
auth: true,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-12-15 16:09:01 +00:00
|
|
|
|
// 创建单个评论
|
|
|
|
|
createOrderItemComment: (data) => {
|
2023-12-28 14:59:14 +00:00
|
|
|
|
return request({
|
2024-01-20 05:13:28 +00:00
|
|
|
|
url: `/trade/order/item/create-comment`,
|
2023-12-15 16:09:01 +00:00
|
|
|
|
method: 'POST',
|
|
|
|
|
data,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default OrderApi;
|