|
|
|
@ -1,13 +1,6 @@
|
|
|
|
|
package com.ms.api.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -28,6 +21,12 @@ import com.doudian.open.api.order_addOrderRemark.param.OrderAddOrderRemarkParam;
|
|
|
|
|
import com.doudian.open.api.order_batchSensitive.data.DecryptInfosItem;
|
|
|
|
|
import com.doudian.open.api.order_batchSensitive.param.CipherInfosItem;
|
|
|
|
|
import com.doudian.open.api.order_batchSensitive.param.OrderBatchSensitiveParam;
|
|
|
|
|
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackRequest;
|
|
|
|
|
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackResponse;
|
|
|
|
|
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
|
|
|
|
|
import com.doudian.open.api.order_logisticsAddMultiPack.param.OrderLogisticsAddMultiPackParam;
|
|
|
|
|
import com.doudian.open.api.order_logisticsAddMultiPack.param.PackListItem;
|
|
|
|
|
import com.doudian.open.api.order_logisticsAddMultiPack.param.ShippedOrderInfoItem;
|
|
|
|
|
import com.doudian.open.api.order_orderDetail.data.AfterSaleInfo;
|
|
|
|
|
import com.doudian.open.api.order_orderDetail.data.CouponInfoItem;
|
|
|
|
|
import com.doudian.open.api.order_orderDetail.data.CouponInfoItem_6_6;
|
|
|
|
@ -45,13 +44,9 @@ import com.doudian.open.api.order_searchList.OrderSearchListResponse;
|
|
|
|
|
import com.doudian.open.api.order_searchList.param.OrderSearchListParam;
|
|
|
|
|
import com.ms.api.common.ApiResult;
|
|
|
|
|
import com.ms.api.consts.AfterSaleConst;
|
|
|
|
|
import com.ms.api.consts.DsOrderConst;
|
|
|
|
|
import com.ms.api.consts.OrderChildTagConst;
|
|
|
|
|
import com.ms.api.consts.OrderConst;
|
|
|
|
|
import com.ms.api.consts.PurchaseOrderConst;
|
|
|
|
|
import com.ms.api.consts.RedisKeyConst;
|
|
|
|
|
import com.ms.api.consts.StatusConst;
|
|
|
|
|
import com.ms.api.consts.*;
|
|
|
|
|
import com.ms.api.dto.order.DsPurchaseSettingDTO;
|
|
|
|
|
import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO;
|
|
|
|
|
import com.ms.api.dto.order.OriginalAndCustomConsigneeInfoRequestDTO;
|
|
|
|
|
import com.ms.api.dto.order.OriginalAndCustomConsigneeInfoResponseDTO;
|
|
|
|
|
import com.ms.api.service.*;
|
|
|
|
@ -186,6 +181,7 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopService shopService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteByPrimaryKey(Long id) {
|
|
|
|
|
return opOrderMapper.deleteByPrimaryKey(id);
|
|
|
|
@ -1535,6 +1531,109 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
private Boolean updateOpOrderSellerRemark(Long shopId, String orderId, String remark, Boolean isAddStar, Integer star) {
|
|
|
|
|
return opOrderMapper.updateOrderRemark(shopId, orderId, remark, isAddStar ? star : null, new Date()) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public OrderLogisticsAddMultiPackData orderLogisticsAddMultiPackToDd(String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList, String accessToken) {
|
|
|
|
|
if (StrUtil.isEmpty(orderId) || CollectionUtil.isEmpty(packageList)) {
|
|
|
|
|
throw new RuntimeException("参数错误");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Boolean check = checkCanOutStorage(Arrays.asList(orderId), packageList);
|
|
|
|
|
if (!check) {
|
|
|
|
|
throw new RuntimeException("检测失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<PackListItem> itemList = new ArrayList<>();
|
|
|
|
|
packageList.stream().forEach(e->{
|
|
|
|
|
PackListItem item = new PackListItem();
|
|
|
|
|
BeanUtil.copyProperties(e, item);
|
|
|
|
|
|
|
|
|
|
List<ShippedOrderInfoItem> infoItems = new ArrayList<>();
|
|
|
|
|
item.setShippedOrderInfo(infoItems);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(e.getShippedOrderInfo())) {
|
|
|
|
|
e.getShippedOrderInfo().stream().forEach(it->{
|
|
|
|
|
ShippedOrderInfoItem infoItem = new ShippedOrderInfoItem();
|
|
|
|
|
BeanUtil.copyProperties(it, infoItem);
|
|
|
|
|
infoItems.add(infoItem);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
itemList.add(item);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
OrderLogisticsAddMultiPackRequest request = new OrderLogisticsAddMultiPackRequest();
|
|
|
|
|
OrderLogisticsAddMultiPackParam param = new OrderLogisticsAddMultiPackParam();
|
|
|
|
|
param.setOrderId(orderId);
|
|
|
|
|
param.setRequestId(UUID.randomUUID().toString());
|
|
|
|
|
param.setPackList(itemList);
|
|
|
|
|
|
|
|
|
|
OrderLogisticsAddMultiPackResponse response = request.execute();
|
|
|
|
|
if (!response.isSuccess()) {
|
|
|
|
|
throw new RuntimeException(response.getSubMsg());
|
|
|
|
|
}
|
|
|
|
|
return response.getData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Boolean checkCanOutStorage(List<String> orderIds, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList) {
|
|
|
|
|
if (CollectionUtil.isEmpty(orderIds)) {
|
|
|
|
|
throw new RuntimeException("发货接口调用参数错误");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<OpOrder> orderList = getListByOrderIds(orderIds);
|
|
|
|
|
if (CollectionUtil.isEmpty(orderList)) {
|
|
|
|
|
throw new RuntimeException("订单不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> invalidStatusOrderIds = orderList.stream()
|
|
|
|
|
.filter(e-> (OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS.equals(e.getOrderStatus())||OrderConst.ORDER_STATUS_PART_DELIVERY.equals(e.getOrderStatus())))
|
|
|
|
|
.map(e-> e.getOrderId()).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtil.isNotEmpty(invalidStatusOrderIds)) {
|
|
|
|
|
throw new RuntimeException(String.format("订单:%s 当前状态不能进行发货操作", invalidStatusOrderIds.toString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<OpOrderChildAfterSale> afterSaleList = opOrderChildAfterSaleMapper.selectByOrderIds(orderIds);
|
|
|
|
|
List<Integer> statusList = AfterSaleConst.getAfterSaleCloseOrCancelStatusList();
|
|
|
|
|
statusList.add(Integer.valueOf(0));
|
|
|
|
|
List<String> goingOrderIdList = new ArrayList<>();
|
|
|
|
|
List<String> goingChildOrderIdList = new ArrayList<>();
|
|
|
|
|
for (OpOrderChildAfterSale afterSale : afterSaleList) {
|
|
|
|
|
if (!statusList.contains(afterSale.getAfterSaleStatus())) {
|
|
|
|
|
if (!StrUtil.isEmpty(afterSale.getOrderId())) {
|
|
|
|
|
goingOrderIdList.add(afterSale.getOrderId());
|
|
|
|
|
}
|
|
|
|
|
if (!StrUtil.isEmpty(afterSale.getChildOrderId())) {
|
|
|
|
|
goingChildOrderIdList.add(afterSale.getChildOrderId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(goingOrderIdList)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(packageList)) {
|
|
|
|
|
List<String> childOrderIds = new ArrayList<>();
|
|
|
|
|
for (OrderMultiPackageOutstorageDTO.PackageInfoDTO packageInfoDTO : packageList) {
|
|
|
|
|
if (CollectionUtil.isNotEmpty(packageInfoDTO.getShippedOrderInfo())) {
|
|
|
|
|
packageInfoDTO.getShippedOrderInfo().stream().forEach(e->{
|
|
|
|
|
childOrderIds.add(e.getShippedOrderId());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(goingChildOrderIdList)) {
|
|
|
|
|
goingChildOrderIdList.stream().forEach(e->{
|
|
|
|
|
if (!childOrderIds.contains(e)) {
|
|
|
|
|
childOrderIds.add(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException(String.format("子订单:%s 处于售后中不能进行发货操作", childOrderIds.toString()));
|
|
|
|
|
} else {
|
|
|
|
|
throw new RuntimeException(String.format("订单:%s 处于售后中不能进行发货操作", goingOrderIdList.toString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|