|
|
|
@ -61,9 +61,6 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpOrderAmountDetailService opOrderAmountDetailService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpOrderRedpackInfoService opOrderRedpackInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PurchaseSettingService purchaseSettingService;
|
|
|
|
|
|
|
|
|
@ -88,6 +85,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpLogisticsPlatformService opLogisticsPlatformService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PurchaseOrderTagService purchaseOrderTagService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BatchCreateDistributionOrdersResponseDTO batchCreateDistributionOrders(Long shopId, BatchCreateDistributionOrdersRequestDTO request) {
|
|
|
|
@ -124,11 +123,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
platformOrderDto.setEncryptOutOrderInfo(encryptOutOrderInfoDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> allDecryptFields = Arrays.asList("post_receiver", "post_tel", "detail");
|
|
|
|
|
Set<String> useManualConsigneeOrderIds = new HashSet<>();
|
|
|
|
|
HashMap<String, List<String>> tradeKeyAndDecryptFieldsMap = new HashMap<>();
|
|
|
|
|
HashMap<String, String> sourceItemIdAndSourceSellerIdMap = getSourceItemIdAndSourceSellerIdMap(request.getAllItems());
|
|
|
|
|
HashMap<String, String> rebuildPlatformOrdersByChoicesItem = new HashMap<>();
|
|
|
|
|
HashMap<Long, PlatformShopPurchaseSettingDTO> shopPurchaseSettings = new HashMap<>();
|
|
|
|
|
for (PlatformOrderDTO platformOrderDto : platformOrders) {
|
|
|
|
|
Set<String> sourceSellerIds = getSourceSellerIdsFromPlatformOrder(platformOrderDto, sourceItemIdAndSourceSellerIdMap);
|
|
|
|
@ -148,7 +144,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
if (platformOrderDto.getConsigneeInfo().getIsManualInput()) {
|
|
|
|
|
useManualConsigneeOrderIds.add(platformOrderDto.getPlatformOrderId());
|
|
|
|
|
} else if (checkNeedDecryptConsigneeInfo(platformOrderDto, shopPurchaseSettings.get(platformOrderDto.getShopId()), sourceSellerIds.iterator().next())) {
|
|
|
|
|
tradeKeyAndDecryptFieldsMap.put(platformOrderDto.getPlatformOrderId(), allDecryptFields);
|
|
|
|
|
throw new RuntimeException("不支持解密");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (PlatformOrderItemDTO item: platformOrderDto.getItems()) {
|
|
|
|
@ -325,19 +321,11 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkItems(List<PlatformOrderItemDTO> items) {
|
|
|
|
|
for (PlatformOrderItemDTO item: items) {
|
|
|
|
|
if (item.getSourceSkuId() == 0 || item.getItemTotal() == 0) {
|
|
|
|
|
throw new RuntimeException("items参数错误");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<PlatformOrderDTO> rebuildPlatformOrderItems(List<PlatformOrderDTO> platformOrders) {
|
|
|
|
|
private void rebuildPlatformOrderItems(List<PlatformOrderDTO> platformOrders) {
|
|
|
|
|
Stream<String> orderIdsStream = platformOrders.stream().map(PlatformOrderDTO::getPlatformOrderId);
|
|
|
|
|
List<String> orderIds = orderIdsStream.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<Integer> skuIds = new ArrayList<>();
|
|
|
|
|
List<Long> skuIds = new ArrayList<>();
|
|
|
|
|
for (PlatformOrderDTO platformOrder: platformOrders) {
|
|
|
|
|
for (PlatformOrderItemDTO item: platformOrder.getItems()) {
|
|
|
|
|
skuIds.add(item.getSourceSkuId());
|
|
|
|
@ -347,10 +335,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
HashMap<String, HashMap<Long, String>> orderIdAndSkuIdAndSkuSubNameMap = opOrderChildService.getOrderIdAndSkuIdAndSkuSubNameMap(orderIds, skuIds);
|
|
|
|
|
for (PlatformOrderDTO platformOrder: platformOrders) {
|
|
|
|
|
for (PlatformOrderItemDTO item: platformOrder.getItems()) {
|
|
|
|
|
item.setPlatformSkuSubName(orderIdAndSkuIdAndSkuSubNameMap.get(platformOrder.getPlatformOrderId()).get(Long.valueOf(item.getSourceSkuId())));
|
|
|
|
|
item.setPlatformSkuSubName(orderIdAndSkuIdAndSkuSubNameMap.get(platformOrder.getPlatformOrderId()).get(item.getSourceSkuId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return platformOrders;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dsRelatePurchaseOrder(PurchaseOrderRequestDTO purchaseOrderInfo, OpOrder opOrder) {
|
|
|
|
@ -472,8 +459,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
deliveryInfo.setWaybillCode(waybillCode);
|
|
|
|
|
}
|
|
|
|
|
for (PurchaseOrderItem item: purchaseOrder.getItems()) {
|
|
|
|
|
if (skuIds.contains(item.getSkuId().intValue())) {
|
|
|
|
|
List<OpOrderChild> childOrderInfoList = skuIdAndChildOrderInfoMap.get(item.getSkuId().intValue());
|
|
|
|
|
if (skuIds.contains(item.getSkuId())) {
|
|
|
|
|
List<OpOrderChild> childOrderInfoList = skuIdAndChildOrderInfoMap.get(item.getSkuId());
|
|
|
|
|
for (OpOrderChild child: childOrderInfoList) {
|
|
|
|
|
JSONObject opOrderChildAfterSale = child.getAfterSaleInfo();
|
|
|
|
|
if (opOrderChildAfterSale != null && opOrderChildAfterSale.get("after_sale_type").equals(AfterSaleConst.AFTERSALE_TYPE_REFUND_ONLY_BEFORE_SALE) && !AfterSaleConst.getAfterSaleCloseOrCancelStatusList().equals(opOrderChildAfterSale.get("after_sale_status"))) {
|
|
|
|
@ -487,7 +474,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
boolean hasMultiPackageOutstorage = opOrder.getOrderStatus().equals(OrderConst.ORDER_STATUS_PART_DELIVERY);
|
|
|
|
|
|
|
|
|
|
OrderPackageInfoDTO orderPackageInfoDTO = new OrderPackageInfoDTO();
|
|
|
|
|
orderPackageInfoDTO.setDeliveryInfo(deliveryInfo);;
|
|
|
|
|
orderPackageInfoDTO.setDeliveryInfo(deliveryInfo);
|
|
|
|
|
orderPackageInfoDTO.setPackageList(packageList);
|
|
|
|
|
orderPackageInfoDTO.setHasAfterSaleChildOrder(hasAfterSaleChildOrder);
|
|
|
|
|
orderPackageInfoDTO.setHasMultiPackageOutstorage(hasMultiPackageOutstorage);
|
|
|
|
@ -606,7 +593,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
return newSellerWords;
|
|
|
|
|
}
|
|
|
|
|
newSellerWords = newSellerWords.replaceAll(appChineseName, "0.0");
|
|
|
|
|
if (newSellerWords.equals(oldSellerWords) && shopRemarkFlag.equals(opOrder.getSellerRemarkStars())) {
|
|
|
|
|
if (newSellerWords.equals(oldSellerWords) && String.valueOf(shopRemarkFlag).equals(opOrder.getSellerRemarkStars())) {
|
|
|
|
|
return newSellerWords;
|
|
|
|
|
}
|
|
|
|
|
opOrderExtService.updateOpOrderShopNote(shopId, orderId, newSellerWords);
|
|
|
|
@ -667,9 +654,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
String profitText = "";
|
|
|
|
|
String profitRatioText = "";
|
|
|
|
|
if (needProfit || needProfitRatio) {
|
|
|
|
|
HashMap<String, Double> resuslt = getOrderProfitAndRatioByOrderId(firstPurchaseOrder.getOrderId());
|
|
|
|
|
profitText = "(总利润 ¥" + resuslt.get("orderProfitSum") + ")";
|
|
|
|
|
profitRatioText = "(利润率" + resuslt.get("orderTotalProfitRate") + "%)";
|
|
|
|
|
HashMap<String, Double> result = getOrderProfitAndRatioByOrderId(firstPurchaseOrder.getOrderId());
|
|
|
|
|
profitText = "(总利润 ¥" + result.get("orderProfitSum") + ")";
|
|
|
|
|
profitRatioText = "(利润率" + result.get("orderTotalProfitRate") + "%)";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (PurchaseOrder purchaseOrder: purchaseOrders) {
|
|
|
|
@ -813,9 +800,10 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
BigDecimal purchaseOrderPayment = new BigDecimal(purchaseOrderRequestDto.getPurchaseOrderPayment());
|
|
|
|
|
dbPurchaseOrder.setPurchaseOrderPayment(purchaseOrderPayment);
|
|
|
|
|
}
|
|
|
|
|
comparePurchaseOrderAndAddUpdateLog(purchaseOrderRequestDto, opOrder.getShopId(), PurchaseOrderConst.ACTION_RSYNC);
|
|
|
|
|
checkPurchaseOrderLogisticsChangeAndAddTag(purchaseOrderRequestDto, dbPurchaseOrder);
|
|
|
|
|
|
|
|
|
|
OpOrderExt orderExt = opOrderExtService.getByOrderId(dbPurchaseOrder.getOrderId());
|
|
|
|
|
|
|
|
|
|
if ("normal".equals(dbPurchaseOrder.getStatus()) && orderExt != null && orderExt.getFilterPurchaseStatus() != null) {
|
|
|
|
|
updateOpOrderFilterPurchaseStatus(opOrder.getOrderId(), orderExt);
|
|
|
|
|
}
|
|
|
|
@ -919,7 +907,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
|
|
|
|
|
List<PurchaseOrderItem> purchaseOrderItems = purchaseOrderItemService.getRelatedPurchaseOrderItems(opOrderDs.getShopId(), orderId);
|
|
|
|
|
List<String> purchaseWareIds;
|
|
|
|
|
List<Long> dsPurchaseSkuIds = new ArrayList<>();
|
|
|
|
|
List<String> dsPurchaseSkuIds = new ArrayList<>();
|
|
|
|
|
List<String> purchaseDsProductIds = new ArrayList<>();
|
|
|
|
|
if (!purchaseOrderItems.isEmpty()) {
|
|
|
|
|
Stream<String> wareIdsStream = purchaseOrderItems.stream().map(PurchaseOrderItem::getWareId);
|
|
|
|
@ -928,7 +916,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
if (purchaseOrderItem.getPurchasePlatform().equals(purchasePlatform)) {
|
|
|
|
|
purchaseDsProductIds.add(purchaseOrderItem.getWareId());
|
|
|
|
|
dsProductIds.add(purchaseOrderItem.getWareId());
|
|
|
|
|
dsPurchaseSkuIds.add(purchaseOrderItem.getSkuId());
|
|
|
|
|
dsPurchaseSkuIds.add(String.valueOf(purchaseOrderItem.getSkuId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -938,7 +926,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
List<String> noPurchaseDsProductIds = dsProductIds.stream().filter(i -> !purchaseWareIds.contains(i)).collect(Collectors.toList());
|
|
|
|
|
List<String> notPurchaseDsSkuIds = dsProductIds.stream().filter(i -> !dsPurchaseSkuIds.contains(i)).collect(Collectors.toList());
|
|
|
|
|
List<Long> notDsAndDsPurchaseSkuIds = skuIdList.stream().filter(i -> !dsOrderSkuIds.contains(i)).collect(Collectors.toList());
|
|
|
|
|
notDsAndDsPurchaseSkuIds = notDsAndDsPurchaseSkuIds.stream().filter(i -> !dsPurchaseSkuIds.contains(i)).collect(Collectors.toList());
|
|
|
|
|
notDsAndDsPurchaseSkuIds = notDsAndDsPurchaseSkuIds.stream().filter(i -> !dsPurchaseSkuIds.contains(String.valueOf(i))).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
if (orderPrintService.checkAndDeleteOpOrderDs(purchasePlatform, orderId, productToDsItemList, purchaseOrderItems)) {
|
|
|
|
|
return;
|
|
|
|
@ -1020,11 +1008,6 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
opOrderDsService.updateByPrimaryKeySelective(opOrderDs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void addPurchaseOrderRefundOrderTipMsg(Long shopId, String orderId, String purchaseOrderStatus, Long purchaseOrderId) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void savePurchaseOrderInfo(PurchaseOrderRequestDTO purchaseOrderRequestDto, OpOrder opOrder, HashMap<Long, OpOrderChild> skuIdAndOpOrderChildMap) {
|
|
|
|
|
purchaseAccountService.savePurchaseAccount(opOrder.getShopId(), purchaseOrderRequestDto.getPurchasePlatform(), purchaseOrderRequestDto.getPurchaseOrderBuyer());
|
|
|
|
|
PurchaseOrder dbPurchaseOrder = purchaseOrderService.getByPlatformAndPurchaseOrderSn(purchaseOrderRequestDto.getPurchasePlatform(), purchaseOrderRequestDto.getPurchaseOrderSn());
|
|
|
|
@ -1150,10 +1133,6 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
return log;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void savePurchaseOrderSetting(Long shopId) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PurchaseOrder buildPurchaseOrderByDto(PurchaseOrderRequestDTO purchaseOrderRequestDto, PurchaseOrder oldPurchaseOrder, OpOrder opOrder) {
|
|
|
|
|
PurchaseOrder purchaseOrder = oldPurchaseOrder;
|
|
|
|
|
if (purchaseOrder == null) {
|
|
|
|
@ -1245,6 +1224,15 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
return isReapt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void getOrderPurchaseItemsOldPackageInfo(PurchaseOrder purchaseOrder) {
|
|
|
|
|
List<PurchaseOrderItem> purchaseOrderItems = purchaseOrderItemService.getRelatePurchaseOrderItemsByPurchaseOrderId(purchaseOrder.getPurchaseOrderId());
|
|
|
|
|
List<Long> skuIds = purchaseOrderItems.stream().map(PurchaseOrderItem::getSkuId).collect(Collectors.toList());
|
|
|
|
|
List<String> orderIds = new ArrayList<>();
|
|
|
|
|
orderIds.add(purchaseOrder.getOrderId());
|
|
|
|
|
opOrderChildService.getListByOrderIdsAndSkuIds(orderIds, skuIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public GetPurchaseOrderItemsAndSourceItemsResponseDTO getSourceSkuInfos(Long shopId, List<OrderItemDTO> orderItems) {
|
|
|
|
|
Stream<String> orderIdsStream = orderItems.stream().map(OrderItemDTO::getOrderId);
|
|
|
|
@ -1256,7 +1244,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
Map<String, OpOrder> orderIdAndOpOrderMap = orders.stream().collect(Collectors.toMap(OpOrder::getOrderId, x->x));
|
|
|
|
|
Stream<Long> shopIdsStream = orders.stream().map(OpOrder::getShopId);
|
|
|
|
|
Set<Long> shopIdSet = shopIdsStream.collect(Collectors.toSet());
|
|
|
|
|
if (shopIdSet.size() != 1 || shopIdSet.contains(shopId)) {
|
|
|
|
|
if (shopIdSet.size() != 1 || !shopIdSet.contains(shopId)) {
|
|
|
|
|
throw new RuntimeException("订单归属异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1283,8 +1271,12 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public CommonResponseDTO batchAddDsPurchaseConfirmLog(BatchAddPurchaseConfirmLogRequestDTO request) {
|
|
|
|
|
return dsApiService.batchAddPurchaseConfirmLog(request);
|
|
|
|
|
public HashMap<String, Long> batchAddDsPurchaseConfirmLog(Long shopId, BatchAddPurchaseConfirmLogRequestDTO request) {
|
|
|
|
|
BatchAddDsPurchaseConfirmLogResponseDTO response = dsApiService.batchAddPurchaseConfirmLog(shopId, request);
|
|
|
|
|
if (!response.isSuccess()) {
|
|
|
|
|
throw new RuntimeException(response.getReason());
|
|
|
|
|
}
|
|
|
|
|
return response.getPlatformOrderIdAndPurchaseConfirmLogIdMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|