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 4ef50e8..c215e18 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 @@ -115,8 +115,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { } } data.setOrderResults(orderResults); - PurchaseOrder purchaseOrder = purchaseOrderMapper.getByPurOrderId(purOrderIds.iterator().next()); - if (purchaseOrder == null) { + List currentPurchaseOrders = purchaseOrderMapper.getListByPurOrderId(purOrderIds.iterator().next()); + if (currentPurchaseOrders.isEmpty()) { purchaseOrderMapper.insertBatch(purchaseOrders); purchaseOrderItemMapper.insertBatch(purchaseOrderItems); } @@ -488,11 +488,17 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { throw new RuntimeException("采购单不存在"); } - PurchaseOrder purchaseOrder = purchaseOrderMapper.getByPurOrderId(purOrderId); + List purchaseOrders = purchaseOrderMapper.getListByPurOrderId(purOrderId); + List sourceOrderIds = new ArrayList<>(); + for (PurchaseOrder purchaseOrder: purchaseOrders) { + sourceOrderIds.add(purchaseOrder.getPurchaseOrderSn()); + } + if (sourceOrderIds.isEmpty()) { + throw new RuntimeException("采购单号不存在"); + } List paymentResults = new ArrayList<>(); for (BatchPayParam.Param p: param.getParams()) { - List sourceOrderIds = Collections.singletonList(purchaseOrder.getPurchaseOrderSn()); GetPurchaseOrderPayUrlResponseDTO response1 = dsApiService.getPurchaseOrderPayUrl(p.getShopId(), sourceOrderIds, "PC"); GetPurchaseOrderPayUrlResponseDTO response2 = dsApiService.getPurchaseOrderPayUrl(p.getShopId(), sourceOrderIds, "WIRELESS"); if (!response1.isSuccess()) { diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderMapper.java index 8df0b42..b4e708c 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderMapper.java @@ -32,4 +32,6 @@ public interface PurchaseOrderMapper { PurchaseOrder getByPurchaseOrderSn(@Param("purchaseOrderSn") String purchaseOrderSn); PurchaseOrder getByPurOrderId(@Param("purOrderId") String purOrderId); + + List getListByPurOrderId(@Param("purOrderId") String purOrderId); } diff --git a/ms-dal/src/main/resources/mapper/PurchaseOrderMapper.xml b/ms-dal/src/main/resources/mapper/PurchaseOrderMapper.xml index 9ffe860..a7d8876 100644 --- a/ms-dal/src/main/resources/mapper/PurchaseOrderMapper.xml +++ b/ms-dal/src/main/resources/mapper/PurchaseOrderMapper.xml @@ -56,6 +56,12 @@ from purchase_order where pur_order_id = #{purOrderId,jdbcType=VARCHAR} + delete from purchase_order