luodangjia
2025-01-26 f673fd85f198a8d99f531ae6ca16246bcc3bdea9
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -937,11 +937,12 @@
    public void importExpress(String url) {
        URL url1 = new URL(url);
        try (InputStream  fileInputStream = url1.openStream()) {
            Workbook workbook = new SXSSFWorkbook(new XSSFWorkbook(fileInputStream));
            Workbook workbook = new XSSFWorkbook(fileInputStream);
            Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet
            int lastRowNum = sheet.getLastRowNum();
            for (int i = 2; i <= lastRowNum; i++) {
                Row row = sheet.getRow(i);
                row.getCell(1).setCellType(CellType.STRING);
                String orderNum = row.getCell(1).getStringCellValue();
                // 快递单号
                row.getCell(7).setCellType(CellType.STRING);
@@ -957,14 +958,23 @@
                String cityCode = row.getCell(12).getStringCellValue();
                Order order = this.getOne(new LambdaQueryWrapper<Order>()
                        .eq(Order::getOrderNumber, orderNum)
                        .eq(Order::getOrderType, 2)
                        .eq(Order::getDistributionMode,2)
                        .eq(Order::getOrderStatus, 1)
                );
                if (order == null){
                    throw new ServiceException("订单不存在:"+orderNum, 500);
                }
                Integer orderType = order.getOrderType();
                if (orderType != 2){
                    throw new ServiceException("该订单:"+orderNum+"类型不为单品订单", 500);
                }
                if (order.getDistributionMode() != 2){
                    throw new ServiceException("该订单:"+orderNum+"配送方式不为快递", 500);
                }
                Integer orderStatus = order.getOrderStatus();
                if (orderStatus != 1){
                    throw new ServiceException("该订单:"+orderNum+"状态不为待发货", 500);
                }
                String companyNameByCode = ExpressCompanyMap.getCompanyNameByCode(expressName);
                if(StringUtils.isEmpty(companyNameByCode)){
                    throw new ServiceException("快递公司编码错误:"+expressName, 500);