|
|
|
@ -1,6 +1,14 @@
|
|
|
|
|
package com.ms.api.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
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.UUID;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -44,16 +52,25 @@ 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.*;
|
|
|
|
|
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.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.*;
|
|
|
|
|
import com.ms.api.service.OpOrderDsService;
|
|
|
|
|
import com.ms.api.service.OpOrderExtService;
|
|
|
|
|
import com.ms.api.service.OpOrderSellerWordsUpdateLogService;
|
|
|
|
|
import com.ms.api.service.OpOrderService;
|
|
|
|
|
import com.ms.api.service.OrderPrintService;
|
|
|
|
|
import com.ms.api.service.PurchaseOrderService;
|
|
|
|
|
import com.ms.api.service.ShopService;
|
|
|
|
|
import com.ms.api.tool.CommonTool;
|
|
|
|
|
import com.ms.api.tool.DsOrderTool;
|
|
|
|
|
import com.ms.api.util.DdRequestUtil;
|
|
|
|
|
import com.ms.dal.entity.*;
|
|
|
|
|
import com.ms.dal.entity.DsAutoPurchaseOrderBuffer;
|
|
|
|
|
import com.ms.dal.entity.OpCouponInfo;
|
|
|
|
|
import com.ms.dal.entity.OpOrder;
|
|
|
|
@ -73,11 +90,13 @@ import com.ms.dal.entity.OpOrderExt;
|
|
|
|
|
import com.ms.dal.entity.OpOrderGivenProduct;
|
|
|
|
|
import com.ms.dal.entity.OpOrderPhase;
|
|
|
|
|
import com.ms.dal.entity.OpOrderPriceProtection;
|
|
|
|
|
import com.ms.dal.entity.OpOrderRsyncQueue;
|
|
|
|
|
import com.ms.dal.entity.OpOrderSellerWordsUpdateLog;
|
|
|
|
|
import com.ms.dal.entity.OpOrderSensitive;
|
|
|
|
|
import com.ms.dal.entity.ProductToDsItem;
|
|
|
|
|
import com.ms.dal.entity.PurchaseOrder;
|
|
|
|
|
import com.ms.dal.entity.PurchaseOrderItem;
|
|
|
|
|
import com.ms.dal.entity.Shop;
|
|
|
|
|
import com.ms.dal.mapper.DsAutoPurchaseOrderBufferMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpCouponInfoMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderAddressHistoryEncryptIndexMapper;
|
|
|
|
@ -98,6 +117,7 @@ import com.ms.dal.mapper.OpOrderNoIndexEncryptMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderPhaseMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderPriceProtectionMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderPurchaseOutstorageQueueMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderRsyncQueueMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderSensitiveMapper;
|
|
|
|
|
import com.ms.dal.mapper.ProductToDsItemMapper;
|
|
|
|
|
import com.ms.dal.mapper.PurchaseOrderItemMapper;
|
|
|
|
@ -105,6 +125,7 @@ import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
import org.springframework.data.redis.core.ListOperations;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -138,7 +159,7 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
|
|
|
|
|
@Lazy
|
|
|
|
|
@Autowired
|
|
|
|
|
private OrderPrintService orderPrintService;
|
|
|
|
|
private OrderPrintService orderPrintService;
|
|
|
|
|
|
|
|
|
|
private final OpOrderEncryptIndexMapper opOrderEncryptIndexMapper;
|
|
|
|
|
|
|
|
|
@ -175,6 +196,8 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
private final OpOrderAddressHistoryEncryptMapper opOrderAddressHistoryEncryptMapper;
|
|
|
|
|
|
|
|
|
|
private final OpOrderAddressHistorySensitiveMapper opOrderAddressHistorySensitiveMapper;
|
|
|
|
|
|
|
|
|
|
private final OpOrderRsyncQueueMapper opOrderRsyncQueueMapper;
|
|
|
|
|
@Lazy
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpOrderSellerWordsUpdateLogService opOrderSellerWordsUpdateLogService;
|
|
|
|
@ -183,7 +206,6 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopService shopService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteByPrimaryKey(Long id) {
|
|
|
|
|
return opOrderMapper.deleteByPrimaryKey(id);
|
|
|
|
@ -1546,14 +1568,14 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<PackListItem> itemList = new ArrayList<>();
|
|
|
|
|
packageList.stream().forEach(e->{
|
|
|
|
|
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->{
|
|
|
|
|
e.getShippedOrderInfo().stream().forEach(it -> {
|
|
|
|
|
ShippedOrderInfoItem infoItem = new ShippedOrderInfoItem();
|
|
|
|
|
BeanUtil.copyProperties(it, infoItem);
|
|
|
|
|
infoItems.add(infoItem);
|
|
|
|
@ -1587,8 +1609,8 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
.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()));
|
|
|
|
|
}
|
|
|
|
@ -1617,14 +1639,14 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
List<String> childOrderIds = new ArrayList<>();
|
|
|
|
|
for (OrderMultiPackageOutstorageDTO.PackageInfoDTO packageInfoDTO : packageList) {
|
|
|
|
|
if (CollectionUtil.isNotEmpty(packageInfoDTO.getShippedOrderInfo())) {
|
|
|
|
|
packageInfoDTO.getShippedOrderInfo().stream().forEach(e->{
|
|
|
|
|
packageInfoDTO.getShippedOrderInfo().stream().forEach(e -> {
|
|
|
|
|
childOrderIds.add(e.getShippedOrderId());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(goingChildOrderIdList)) {
|
|
|
|
|
goingChildOrderIdList.stream().forEach(e->{
|
|
|
|
|
goingChildOrderIdList.stream().forEach(e -> {
|
|
|
|
|
if (!childOrderIds.contains(e)) {
|
|
|
|
|
childOrderIds.add(e);
|
|
|
|
|
}
|
|
|
|
@ -1662,6 +1684,47 @@ public class OpOrderServiceImpl implements OpOrderService {
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long tryRsyncOpOrder(Long shopid, String app, Integer priority, Date forceStart) {
|
|
|
|
|
OpOrderRsyncQueue queueInfo = opOrderRsyncQueueMapper.getByShopId(shopid);
|
|
|
|
|
Long queueId = 0L;
|
|
|
|
|
if (ObjectUtil.isNull(queueInfo)) {
|
|
|
|
|
queueInfo = new OpOrderRsyncQueue();
|
|
|
|
|
queueInfo.setShopId(shopid);
|
|
|
|
|
queueInfo.setApp(app);
|
|
|
|
|
queueInfo.setGmtForceStart(forceStart);
|
|
|
|
|
queueInfo.setGmtModified(new Date());
|
|
|
|
|
queueInfo.setPriority(priority);
|
|
|
|
|
queueInfo.setLocked(0L);
|
|
|
|
|
queueInfo.setOrderTotal(0L);
|
|
|
|
|
queueInfo.setCompleted(0L);
|
|
|
|
|
queueInfo.setStatus(StatusConst.wait);
|
|
|
|
|
queueInfo.setGmtCreate(new Date());
|
|
|
|
|
|
|
|
|
|
opOrderRsyncQueueMapper.insert(queueInfo);
|
|
|
|
|
queueId = queueInfo.getOpOrderRsyncQueueId();
|
|
|
|
|
if (ObjectUtil.isNotNull(queueId) && queueId > 0) {
|
|
|
|
|
String queueRedisKey = RedisKeyConst.getQueueRedisKey("op_order_rsync_queue", true);
|
|
|
|
|
ListOperations<String, String> listOps = redisTemplate.opsForList();
|
|
|
|
|
if (priority > 99) {
|
|
|
|
|
listOps.leftPush(queueRedisKey, queueId.toString());
|
|
|
|
|
} else {
|
|
|
|
|
listOps.rightPush(queueRedisKey, queueId.toString());
|
|
|
|
|
}
|
|
|
|
|
return queueId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
queueInfo.setGmtModified(new Date());
|
|
|
|
|
queueInfo.setPriority(priority < queueInfo.getPriority() ? priority : queueInfo.getPriority());
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(forceStart)){
|
|
|
|
|
queueInfo.setGmtForceStart(forceStart);
|
|
|
|
|
}
|
|
|
|
|
opOrderRsyncQueueMapper.updateByPrimaryKey(queueInfo);
|
|
|
|
|
return queueInfo.getOpOrderRsyncQueueId();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|