From 647622edc14771970af888d612933bfee8c909b9 Mon Sep 17 00:00:00 2001 From: ljl Date: Mon, 15 Jan 2024 19:20:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=B9=E9=87=8F=E6=94=AF?= =?UTF-8?q?=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DistributionOrderServiceImpl.java | 42 ++++++++++--------- .../mapper/PlatformPurchaseOrderMapper.java | 2 + .../ms/dal/mapper/PurchaseOrderMapper.java | 2 + .../mapper/PlatformPurchaseOrderMapper.xml | 19 +++++++++ .../resources/mapper/PurchaseOrderMapper.xml | 17 ++++++++ 5 files changed, 62 insertions(+), 20 deletions(-) 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..d252934 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 @@ -478,29 +478,34 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { @Override public void batchPay(BatchPayParam param, BatchPayData data) { - if (param.getParams().size() != 1) { - throw new RuntimeException("每次只能请求1个采购单"); + List purOrderIds = new ArrayList<>(); + for (BatchPayParam.Param payParam: param.getParams()) { + purOrderIds.add(payParam.getPurOrderId()); } - - String purOrderId = param.getParams().get(0).getPurOrderId(); - PlatformPurchaseOrder platformPurchaseOrder = platformPurchaseOrderMapper.selectByPrimaryKey(param.getParams().get(0).getPurOrderId()); - if (platformPurchaseOrder == null) { + List platformPurchaseOrders = platformPurchaseOrderMapper.getListByPurOrderIds(purOrderIds); + if (platformPurchaseOrders.isEmpty()) { throw new RuntimeException("采购单不存在"); } - PurchaseOrder purchaseOrder = purchaseOrderMapper.getByPurOrderId(purOrderId); + List purchaseOrders = purchaseOrderMapper.getListByPurOrderIds(purOrderIds); + + List sourceOrderIds = new ArrayList<>(); + for (PurchaseOrder purchaseOrder: purchaseOrders) { + sourceOrderIds.add(purchaseOrder.getPurchaseOrderSn()); + } + + Long shopId = param.getParams().get(0).getShopId(); + GetPurchaseOrderPayUrlResponseDTO response1 = dsApiService.getPurchaseOrderPayUrl(shopId, sourceOrderIds, "PC"); + GetPurchaseOrderPayUrlResponseDTO response2 = dsApiService.getPurchaseOrderPayUrl(shopId, sourceOrderIds, "WIRELESS"); + if (!response1.isSuccess()) { + throw new RuntimeException(response1.getReason()); + } + if (!response2.isSuccess()) { + throw new RuntimeException(response2.getReason()); + } 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()) { - throw new RuntimeException(response1.getReason()); - } - if (!response2.isSuccess()) { - throw new RuntimeException(response2.getReason()); - } PaymentResult paymentResult = new PaymentResult(); PaymentResult.PayUrl payUrl = new PaymentResult.PayUrl(); @@ -510,11 +515,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { paymentResult.setPayUrl(payUrl); paymentResult.setPurOrderId(p.getPurOrderId()); paymentResults.add(paymentResult); - - platformPurchaseOrder.setPayPcUrl(response1.getPayUrl()); - platformPurchaseOrder.setPayH5Url(response2.getPayUrl()); - platformPurchaseOrderMapper.updateByPrimaryKeySelective(platformPurchaseOrder); } + platformPurchaseOrderMapper.updatePayUrlByPurOrderIds(response1.getPayUrl(), response2.getPayUrl(), purOrderIds); data.setPaymentResults(paymentResults); } diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/PlatformPurchaseOrderMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/PlatformPurchaseOrderMapper.java index b88a5e6..ff3871f 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/PlatformPurchaseOrderMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/PlatformPurchaseOrderMapper.java @@ -27,4 +27,6 @@ public interface PlatformPurchaseOrderMapper { int updateByPrimaryKey(PlatformPurchaseOrder record); List getListByPurOrderIds(@Param("purOrderIds") List purOrderIds); + + int updatePayUrlByPurOrderIds(@Param("payPcUrl") String payPcUrl, @Param("payH5Url") String payH5Url, @Param("purOrderIds") List purOrderIds); } 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..bcc26a2 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 getListByPurOrderIds(@Param("purOrderIds") List purOrderIds); } diff --git a/ms-dal/src/main/resources/mapper/PlatformPurchaseOrderMapper.xml b/ms-dal/src/main/resources/mapper/PlatformPurchaseOrderMapper.xml index 743f94d..ace7c06 100644 --- a/ms-dal/src/main/resources/mapper/PlatformPurchaseOrderMapper.xml +++ b/ms-dal/src/main/resources/mapper/PlatformPurchaseOrderMapper.xml @@ -234,4 +234,23 @@ gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} where pur_order_id = #{purOrderId,jdbcType=VARCHAR} + + update platform_purchase_order + set + pay_h5_url = #{payH5Url,jdbcType=VARCHAR}, + pay_pc_url = #{payPcUrl,jdbcType=VARCHAR}, + gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} + where 1=1 + + + and pur_order_id in + + #{item} + + + + AND 1=0 + + + diff --git a/ms-dal/src/main/resources/mapper/PurchaseOrderMapper.xml b/ms-dal/src/main/resources/mapper/PurchaseOrderMapper.xml index 9ffe860..f11e222 100644 --- a/ms-dal/src/main/resources/mapper/PurchaseOrderMapper.xml +++ b/ms-dal/src/main/resources/mapper/PurchaseOrderMapper.xml @@ -56,6 +56,23 @@ from purchase_order where pur_order_id = #{purOrderId,jdbcType=VARCHAR} + delete from purchase_order