From 2cbd12e0433dd28aa7a5a88f7c4cb8728de444f9 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期三, 23 七月 2025 10:49:39 +0800
Subject: [PATCH] Merge branch 'hlg' of http://120.76.84.145:10101/gitblit/r/java/gy_jifenshangcheng into dev

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ChargeOrderServiceImpl.java |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ChargeOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ChargeOrderServiceImpl.java
index bfbc7a6..5027c93 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ChargeOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ChargeOrderServiceImpl.java
@@ -1,7 +1,7 @@
 package com.ruoyi.order.service.impl;
 
 import cn.hutool.core.util.IdUtil;
-import com.alibaba.fastjson2.JSONObject;
+import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.account.api.feignClient.AppUserClient;
@@ -30,6 +30,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.io.IOException;
@@ -37,6 +38,8 @@
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
@@ -65,17 +68,22 @@
 
 
     @Override
-    public void importExpress(String url) {
+    public R<JSONObject> importExpress(MultipartFile file) {
+ /*       System.out.println("导入订单url:"+url);
         URL url1 = null;
         try {
-            url1 = new URL(url);
+            String encodedUrl = new URI(url).toASCIIString();
+            url1 = new URL(encodedUrl);
         } catch (MalformedURLException e) {
             throw new RuntimeException(e);
-        }
+        } catch (URISyntaxException e) {
+            throw new RuntimeException(e);
+        }*/
         List<String> orderNumberList=new ArrayList<>();
-
-        try (InputStream fileInputStream = url1.openStream()) {
-            Workbook workbook = new XSSFWorkbook(fileInputStream);
+        JSONObject result = new JSONObject();
+        try (InputStream inputStream = file.getInputStream();
+             Workbook workbook = new XSSFWorkbook(inputStream)) {
+//            Workbook workbook = new XSSFWorkbook(fileInputStream);
             Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet
             int lastRowNum = sheet.getLastRowNum();
             for (int i = 1; i <= lastRowNum; i++) {//第二行开始
@@ -230,14 +238,18 @@
 
                 //检查订单号是否重复
                 if (orderNumberList.contains(orderNum)) {
-                    throw new ServiceException("订单号重复:" + orderNum, 500);
+//                    throw new ServiceException("订单号重复:" + orderNum, 500);
+                    result.append("订单号:[", orderNum+"]重复");
+                    continue;
                 }
                 //数据库中是否存在
                 ChargeOrder order = chargeOrderService.getOne(new LambdaQueryWrapper<ChargeOrder>()
                         .eq(ChargeOrder::getOrderNumber, orderNum)
                 );
                 if (order != null) {
-                    throw new ServiceException("数据库中订单已存在:" + orderNum, 500);
+//                    throw new ServiceException("数据库中订单已存在:" + orderNum, 500);
+                    result.append("订单号:[", orderNum+"]数据库中订单已存在");
+                    continue;
                 }
                 orderNumberList.add(orderNum);//添加到订单集合中
 
@@ -271,6 +283,10 @@
             e.printStackTrace();
             throw new ServiceException(e.getMessage());
         }
+        if(!result.isEmpty()){
+            return R.ok(result);
+        }
+        return R.ok();
     }
 
     @Override

--
Gitblit v1.7.1