|
|
|
@ -105,6 +105,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
orderIdAndOpOrderMap.put(opOrder.getOrderId(), opOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("orderIdAndOpOrderMap" + orderIdAndOpOrderMap);
|
|
|
|
|
|
|
|
|
|
Stream<Long> shopIdsStream = orderIdAndOpOrderMap.values().stream().map(OpOrder::getShopId);
|
|
|
|
|
Set<Long> shopIds = shopIdsStream.collect(Collectors.toSet());
|
|
|
|
|
if (shopIds.size() != 1 || !shopIds.contains(shopId)) {
|
|
|
|
@ -135,15 +137,16 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
throw new RuntimeException("购买的商品不属于同一个卖家,请检查后重新提交!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!shopPurchaseSettings.containsKey(platformOrderDto.getShopId())) {
|
|
|
|
|
if (!shopPurchaseSettings.containsKey(Long.valueOf(platformOrderDto.getShopId()))) {
|
|
|
|
|
GetPlatformShopPurchaseSettingResponseDTO resp = dsApiService.getPlatformShopPurchaseSetting(String.valueOf(platformOrderDto.getShopId()), "dd");
|
|
|
|
|
shopPurchaseSettings.put(platformOrderDto.getShopId(), resp.getPurchaseSetting());
|
|
|
|
|
shopPurchaseSettings.put(Long.valueOf(platformOrderDto.getShopId()), resp.getPurchaseSetting());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkConsigneeInfo(platformOrderDto.getConsigneeInfo());
|
|
|
|
|
System.out.println("getConsigneeInfo" + platformOrderDto.getConsigneeInfo());
|
|
|
|
|
if (platformOrderDto.getConsigneeInfo().getIsManualInput()) {
|
|
|
|
|
useManualConsigneeOrderIds.add(platformOrderDto.getPlatformOrderId());
|
|
|
|
|
} else if (checkNeedDecryptConsigneeInfo(platformOrderDto, shopPurchaseSettings.get(platformOrderDto.getShopId()), sourceSellerIds.iterator().next())) {
|
|
|
|
|
} else if (checkNeedDecryptConsigneeInfo(platformOrderDto, shopPurchaseSettings.get(Long.valueOf(platformOrderDto.getShopId())), sourceSellerIds.iterator().next())) {
|
|
|
|
|
throw new RuntimeException("不支持解密");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -159,17 +162,23 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
rebuildPlatformOrderItems(platformOrders);
|
|
|
|
|
request.setPlatformOrders(platformOrders);
|
|
|
|
|
|
|
|
|
|
BatchCreateDistributionOrdersResponseDTO dsResponse = dsApiService.batchCreateDistributionOrders(request);
|
|
|
|
|
BatchCreateDistributionOrdersResponseDTO dsResponse = dsApiService.batchCreateDistributionOrders(shopId, request);
|
|
|
|
|
if (!dsResponse.isSuccess()) {
|
|
|
|
|
throw new RuntimeException(dsResponse.getReason());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (DsSuccessRetDTO successRet: dsResponse.getSuccessList()) {
|
|
|
|
|
HashMap<String, PurchaseOrderRequestDTO> relatePurchaseOrderInfos = successRet.getRelatePurchaseOrderInfos();
|
|
|
|
|
List<PurchaseOrderRequestDTO> relatePurchaseOrderInfos = successRet.getRelatePurchaseOrderInfos();
|
|
|
|
|
boolean isUseManualConsignee = useManualConsigneeOrderIds.contains(successRet.getPlatformOrderId());
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, PurchaseOrderRequestDTO> entry: relatePurchaseOrderInfos.entrySet()) {
|
|
|
|
|
for (PurchaseOrderRequestDTO purchaseOrder: relatePurchaseOrderInfos) {
|
|
|
|
|
if (isUseManualConsignee) {
|
|
|
|
|
entry.getValue().setIsUseManualConsignee(true);
|
|
|
|
|
purchaseOrder.setIsUseManualConsignee(true);
|
|
|
|
|
}
|
|
|
|
|
dsRelatePurchaseOrder(entry.getValue(), orderIdAndOpOrderMap.get(successRet.getPlatformOrderId()));
|
|
|
|
|
|
|
|
|
|
System.out.println("getPlatformOrderId" + successRet.getPlatformOrderId());
|
|
|
|
|
|
|
|
|
|
dsRelatePurchaseOrder(purchaseOrder, orderIdAndOpOrderMap.get(successRet.getPlatformOrderId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -280,8 +289,11 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
if (PurchaseOrderConst.DS_ENCRYPT_ORDER_TYPE_ALL_SELLER.equals(shopPurchaseSetting.getEncryptDsOrderType())) {
|
|
|
|
|
isSettingEncryptDsOrder = true;
|
|
|
|
|
}
|
|
|
|
|
Stream<String> sellerIdMd5sStream = shopPurchaseSetting.getAllowDsEncryptOrderSourceSellers().values().stream().map(SellerInfoDTO::getSellerIdMd5);
|
|
|
|
|
List<String> sellerIdMd5sList = sellerIdMd5sStream.collect(Collectors.toList());
|
|
|
|
|
Map<String, SellerInfoDTO> allowDsEncryptOrderSourceSellers = shopPurchaseSetting.getAllowDsEncryptOrderSourceSellers();
|
|
|
|
|
List<String> sellerIdMd5sList = new ArrayList<>();
|
|
|
|
|
if (allowDsEncryptOrderSourceSellers != null) {
|
|
|
|
|
sellerIdMd5sList = allowDsEncryptOrderSourceSellers.values().stream().map(SellerInfoDTO::getSellerIdMd5).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
if (sellerIdMd5sList.contains(sourceSellerId)) {
|
|
|
|
|
isSettingEncryptDsOrder = true;
|
|
|
|
|
}
|
|
|
|
@ -309,15 +321,15 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
|
|
|
|
|
private void checkConsigneeInfo(ConsigneeInfoDTO consigneeInfo) {
|
|
|
|
|
if (
|
|
|
|
|
StringUtils.isNotBlank(consigneeInfo.getFullname()) ||
|
|
|
|
|
StringUtils.isNotBlank(consigneeInfo.getMobile()) ||
|
|
|
|
|
StringUtils.isNotBlank(consigneeInfo.getProvince()) ||
|
|
|
|
|
StringUtils.isNotBlank(consigneeInfo.getCity()) ||
|
|
|
|
|
StringUtils.isNotBlank(consigneeInfo.getCounty()) ||
|
|
|
|
|
StringUtils.isNotBlank(consigneeInfo.getAddress()) ||
|
|
|
|
|
StringUtils.isNotBlank(consigneeInfo.getFullAddress())
|
|
|
|
|
StringUtils.isBlank(consigneeInfo.getFullname()) ||
|
|
|
|
|
StringUtils.isBlank(consigneeInfo.getMobile()) ||
|
|
|
|
|
StringUtils.isBlank(consigneeInfo.getProvince()) ||
|
|
|
|
|
StringUtils.isBlank(consigneeInfo.getCity()) ||
|
|
|
|
|
StringUtils.isBlank(consigneeInfo.getCounty()) ||
|
|
|
|
|
StringUtils.isBlank(consigneeInfo.getAddress()) ||
|
|
|
|
|
StringUtils.isBlank(consigneeInfo.getFullAddress())
|
|
|
|
|
) {
|
|
|
|
|
throw new RuntimeException("采购单参数异常");
|
|
|
|
|
throw new RuntimeException("采购单收件人异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -328,11 +340,13 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
List<Long> skuIds = new ArrayList<>();
|
|
|
|
|
for (PlatformOrderDTO platformOrder: platformOrders) {
|
|
|
|
|
for (PlatformOrderItemDTO item: platformOrder.getItems()) {
|
|
|
|
|
skuIds.add(item.getSourceSkuId());
|
|
|
|
|
skuIds.add(item.getPlatformSkuId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HashMap<String, HashMap<Long, String>> orderIdAndSkuIdAndSkuSubNameMap = opOrderChildService.getOrderIdAndSkuIdAndSkuSubNameMap(orderIds, skuIds);
|
|
|
|
|
System.out.println("orderIdAndSkuIdAndSkuSubNameMap" + orderIdAndSkuIdAndSkuSubNameMap);
|
|
|
|
|
System.out.println("platformOrders" + platformOrders);
|
|
|
|
|
for (PlatformOrderDTO platformOrder: platformOrders) {
|
|
|
|
|
for (PlatformOrderItemDTO item: platformOrder.getItems()) {
|
|
|
|
|
item.setPlatformSkuSubName(orderIdAndSkuIdAndSkuSubNameMap.get(platformOrder.getPlatformOrderId()).get(item.getSourceSkuId()));
|
|
|
|
@ -353,7 +367,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
savePurchaseOrderInfo(purchaseOrderInfo, opOrder, skuIdAndOpOrderChildMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dsPurchaseOrderOutStorageAndUpdateRemark(purchaseOrderInfo, opOrder, purchaseOrder);
|
|
|
|
|
// dsPurchaseOrderOutStorageAndUpdateRemark(purchaseOrderInfo, opOrder, purchaseOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dsPurchaseOrderOutStorageAndUpdateRemark(PurchaseOrderRequestDTO purchaseOrderInfo, OpOrder opOrder, PurchaseOrder purchaseOrder) {
|
|
|
|
@ -649,6 +663,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
if (fields.contains(PurchaseOrderConst.PROFIT_RATIO_FIELD)) {
|
|
|
|
|
needProfitRatio = true;
|
|
|
|
|
}
|
|
|
|
|
System.out.println("purchaseOrders" + purchaseOrders);
|
|
|
|
|
PurchaseOrder firstPurchaseOrder = purchaseOrders.iterator().next();
|
|
|
|
|
|
|
|
|
|
String profitText = "";
|
|
|
|
@ -856,9 +871,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
if (opOrderExt == null) {
|
|
|
|
|
opOrderExt = opOrderExtService.getByOrderId(orderId);
|
|
|
|
|
}
|
|
|
|
|
List<Integer> historySkuIds = opOrderChildService.getHistorySkuIdsByOrderId(orderId);
|
|
|
|
|
List<Integer> purchaseSkuIds = purchaseOrderItemService.getSkuIdsByOrderId(orderId);
|
|
|
|
|
List<Integer> noPurchaseSkuIds = historySkuIds.stream().filter(i -> !purchaseSkuIds.contains(i)).collect(Collectors.toList());
|
|
|
|
|
List<Long> historySkuIds = opOrderChildService.getSkuIdsByOrderId(orderId);
|
|
|
|
|
List<Long> purchaseSkuIds = purchaseOrderItemService.getSkuIdsByOrderId(orderId);
|
|
|
|
|
List<Long> noPurchaseSkuIds = historySkuIds.stream().filter(i -> !purchaseSkuIds.contains(i)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
Integer filterPurchaseStatus = null;
|
|
|
|
|
if (purchaseSkuIds.isEmpty()) {
|
|
|
|
@ -1070,11 +1085,16 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
HashMap<Long, Double> purchasePriceMap = buildPurchaseOrderItemsPurchasePrice(skuIdAndOpOrderChildMap, needRebuildSkuIds, (double) 0, purchaseNumMap);
|
|
|
|
|
|
|
|
|
|
PurchaseOrder purchaseOrder = buildPurchaseOrderByDto(purchaseOrderRequestDto, oldPurchaseOrder, opOrder);
|
|
|
|
|
if (purchaseOrder.getPurchaseOrderId() != null && purchaseOrder.getPurchaseOrderId() > 0) {
|
|
|
|
|
purchaseOrderService.updateByPrimaryKeySelective(purchaseOrder);
|
|
|
|
|
} else {
|
|
|
|
|
purchaseOrderService.insertSelective(purchaseOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO purchase_order_ds_encrypt
|
|
|
|
|
|
|
|
|
|
Map<Long, PurchaseOrderItemRequestDTO> skuIdAndItemMap = purchaseOrderRequestDto.getSkuIdAndItemMap();
|
|
|
|
|
System.out.println("needRebuildSkuIds" + needRebuildSkuIds);
|
|
|
|
|
for (Long skuId: needRebuildSkuIds) {
|
|
|
|
|
OpOrderChild opOrderChild = skuIdAndOpOrderChildMap.get(skuId);
|
|
|
|
|
PurchaseOrderItem oldPurchaseOrderitem = oldPurchaseOrderItemMap.get(skuId);
|
|
|
|
@ -1142,10 +1162,10 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
Date purchaseOrderSendTime = null;
|
|
|
|
|
Date purchaseOrderStartTime = null;
|
|
|
|
|
if (StringUtils.isNotBlank(purchaseOrderRequestDto.getPurchaseOrderStartTime())) {
|
|
|
|
|
purchaseOrderStartTime = DateUtils.parseDate(purchaseOrderRequestDto.getPurchaseOrderStartTime(), new String[]{"yyyy-MM-dd HH:ii:ss"});
|
|
|
|
|
purchaseOrderStartTime = DateUtils.parseDate(purchaseOrderRequestDto.getPurchaseOrderStartTime(), new String[]{"yyyy-MM-dd HH:mm:ss"});
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(purchaseOrderRequestDto.getPurchaseOrderSendTime())) {
|
|
|
|
|
purchaseOrderSendTime = DateUtils.parseDate(purchaseOrderRequestDto.getPurchaseOrderSendTime(), new String[]{"yyyy-MM-dd HH:ii:ss"});
|
|
|
|
|
purchaseOrderSendTime = DateUtils.parseDate(purchaseOrderRequestDto.getPurchaseOrderSendTime(), new String[]{"yyyy-MM-dd HH:mm:ss"});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String purchaseStatus = purchaseOrderRequestDto.getPurchaseOrderStatus();
|
|
|
|
|