2023-12-15 16:09:01 +00:00
|
|
|
import request from '@/sheep/request';
|
|
|
|
|
|
|
|
const OrderApi = {
|
|
|
|
// 计算订单信息
|
|
|
|
settlementOrder: (data) => {
|
|
|
|
const data2 = {
|
|
|
|
...data,
|
|
|
|
};
|
|
|
|
// 移除多余字段
|
|
|
|
if (!(data.couponId > 0)) {
|
|
|
|
delete data2.couponId;
|
|
|
|
}
|
|
|
|
if (!(data.addressId > 0)) {
|
|
|
|
delete data2.addressId;
|
|
|
|
}
|
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
|
|
|
});
|
|
|
|
},
|
|
|
|
// 创建订单
|
|
|
|
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,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 获得订单
|
|
|
|
getOrder: (id) => {
|
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-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;
|