diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/DistributionOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/DistributionOrderServiceImpl.java index 0cfce95..1df4a57 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/impl/DistributionOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/DistributionOrderServiceImpl.java @@ -83,15 +83,13 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { } boolean isRepurchase = false; + Map repurchasePlatformPurchaseOrderMap = new HashMap<>(); if (!platformPurchaseOrders.isEmpty()) { for (PlatformPurchaseOrder platformPurchaseOrder: platformPurchaseOrders) { log.info("platformPurchaseOrder[" + platformPurchaseOrder.getPurOrderId() + "]exist, purchaseStatus:" + platformPurchaseOrder.getPurchaseStatus()); if (platformPurchaseOrder.getPurchaseStatus().equals(StatusConst.cancel)) { isRepurchase = true; - platformPurchaseOrder.setPurchaseStatus(PurchaseOrderConst.PURCHASE_ORDER_STATUS_WAIT_PAY); - platformPurchaseOrder.setStatus(StatusConst.normal); - platformPurchaseOrder.setGmtModified(new Date()); - platformPurchaseOrderMapper.updateByPrimaryKeySelective(platformPurchaseOrder); + repurchasePlatformPurchaseOrderMap.put(platformPurchaseOrder.getPurOrderId(), platformPurchaseOrder); } } } @@ -124,11 +122,19 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { purchaseOrderItems.addAll(items); OrderResult orderResult = buildOrderResult(purchaseOrderDTO, orderIdAndPurOrderIdMap, skuIdAndPurSkuOrderIdMap); orderResults.add(orderResult); + if (isRepurchase && repurchasePlatformPurchaseOrderMap.containsKey(purOrderId)) { + PlatformPurchaseOrder platformPurchaseOrder = repurchasePlatformPurchaseOrderMap.get(purOrderId); + platformPurchaseOrder.setPurchaseStatus(PurchaseOrderConst.PURCHASE_ORDER_STATUS_WAIT_PAY); + platformPurchaseOrder.setStatus(StatusConst.normal); + platformPurchaseOrder.setGmtModified(new Date()); + platformPurchaseOrderMapper.updateByPrimaryKeySelective(platformPurchaseOrder); + } } } + data.setOrderResults(orderResults); List currentPurchaseOrders = purchaseOrderMapper.getListByPurOrderId(purOrderIds.iterator().next()); - if (currentPurchaseOrders.isEmpty()) { + if (currentPurchaseOrders.isEmpty() || isRepurchase) { purchaseOrderMapper.insertBatch(purchaseOrders); purchaseOrderItemMapper.insertBatch(purchaseOrderItems); }