From 485b09d75ac79350392e234a62521050bf6374de Mon Sep 17 00:00:00 2001
From: luofl <1442745593@qq.com>
Date: 星期二, 04 三月 2025 11:00:43 +0800
Subject: [PATCH] 修改物流信息导入模板

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java |   99 +++++++++++++++++++++++++++----------------------
 1 files changed, 54 insertions(+), 45 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
index 4161606..e0d7b19 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -464,49 +464,7 @@
         return r;
     }
 
-    /**
-     * 确认发货操作
-     *
-     * @return
-     */
-    @Override
-    public R confirmDelivery(ConfirmDelivery confirmDelivery) {
-        Order order = this.getById(confirmDelivery.getOrderId());
-        if (1 == order.getPayStatus()) {
-            return R.fail("订单还未完成支付");
-        }
-        if (1 == order.getOrderType() || null == order.getAddressJson()) {
-            return R.fail("该订单不支付快递配送");
-        }
-        if (1 != order.getOrderStatus()) {
-            return R.fail("无效的操作");
-        }
-        //添加快递号和修改订单状态
-        order.setExpressJson(confirmDelivery.getCode());
-        order.setDeliverProvince(confirmDelivery.getDeliverProvince());
-        order.setDeliverProvinceCode(confirmDelivery.getDeliverProvinceCode());
-        order.setDeliverCity(confirmDelivery.getDeliverCity());
-        order.setDeliverCityCode(confirmDelivery.getDeliverCityCode());
-        order.setDeliverDistrict(confirmDelivery.getDeliverDistrict());
-        order.setDeliverDistrictCode(confirmDelivery.getDeliverDistrictCode());
-        order.setOrderStatus(2);
-        //添加查询快递信息队列
-        //一小时后定时查询快递信息
-        SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData();
-        JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
-        Integer waitTime = jsonObject.getInteger("waitTime");
-        redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC));
 
-        JSONObject jsonObject1 = JSON.parseObject(confirmDelivery.getCode());
-        String com = jsonObject1.getString("com");
-        String num = jsonObject1.getString("num");
-        UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class);
-        MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, order.getDeliverProvince() + order.getDeliverCity(),
-                userAddress.getProvince() + userAddress.getCity());
-        order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo));
-        this.updateById(order);
-        return R.ok();
-    }
 
 
     /**
@@ -1002,11 +960,15 @@
         }
     }
 
-    @SneakyThrows
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void importExpress(String url) {
-        URL url1 = new URL(url);
+        URL url1 = null;
+        try {
+            url1 = new URL(url);
+        } catch (MalformedURLException e) {
+            throw new RuntimeException(e);
+        }
         try (InputStream fileInputStream = url1.openStream()) {
             Workbook workbook = new XSSFWorkbook(fileInputStream);
             Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet
@@ -1070,7 +1032,10 @@
                 confirmDelivery.setDeliverProvinceCode(regionBiCode.getData().getCode());
                 confirmDelivery.setDeliverCity(regionBiCode1.getData().getName());
                 confirmDelivery.setDeliverCityCode(regionBiCode1.getData().getCode());
-                confirmDelivery(confirmDelivery);
+                R r = confirmDelivery(confirmDelivery);
+                if (R.isError(r)) {
+                    throw new ServiceException(r.getMsg(), 500);
+                }
             }
 
         } catch (IOException e) {
@@ -1081,6 +1046,50 @@
 
     }
 
+    /**
+     * 确认发货操作
+     *
+     * @return
+     */
+    @Override
+    public R confirmDelivery(ConfirmDelivery confirmDelivery) {
+        Order order = this.getById(confirmDelivery.getOrderId());
+        if (1 == order.getPayStatus()) {
+            return R.fail("订单还未完成支付");
+        }
+        if (1 == order.getOrderType() || null == order.getAddressJson()) {
+            return R.fail("该订单不支付快递配送");
+        }
+        if (1 != order.getOrderStatus()) {
+            return R.fail("无效的操作");
+        }
+        //添加快递号和修改订单状态
+        order.setExpressJson(confirmDelivery.getCode());
+        order.setDeliverProvince(confirmDelivery.getDeliverProvince());
+        order.setDeliverProvinceCode(confirmDelivery.getDeliverProvinceCode());
+        order.setDeliverCity(confirmDelivery.getDeliverCity());
+        order.setDeliverCityCode(confirmDelivery.getDeliverCityCode());
+        order.setDeliverDistrict(confirmDelivery.getDeliverDistrict());
+        order.setDeliverDistrictCode(confirmDelivery.getDeliverDistrictCode());
+        order.setOrderStatus(2);
+        //添加查询快递信息队列
+        //一小时后定时查询快递信息
+        SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData();
+        JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
+        Integer waitTime = jsonObject.getInteger("waitTime");
+        redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC));
+
+        JSONObject jsonObject1 = JSON.parseObject(confirmDelivery.getCode());
+        String com = jsonObject1.getString("com");
+        String num = jsonObject1.getString("num");
+        UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class);
+        MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, order.getDeliverProvince() + order.getDeliverCity(),
+                userAddress.getProvince() + userAddress.getCity());
+        order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo));
+        this.updateById(order);
+        return R.ok();
+    }
+
 
     public static void importExpress2(String filePath) throws MalformedURLException {
         // 从网络地址读取

--
Gitblit v1.7.1