Browse Source

微信批量发货(因客户接入汇付,暂停不做了)

yjwang 2 weeks ago
parent
commit
42dee2415f

+ 58 - 3
fs-admin/src/main/java/com/fs/hisStore/FsStoreHealthOrderScrmController.java

@@ -6,11 +6,13 @@ import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.service.ICompanyMoneyLogsService;
+import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.his.service.IFsUserService;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
@@ -21,9 +23,8 @@ import com.fs.hisStore.vo.FsStoreOrderItemExportVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -51,6 +52,12 @@ public class FsStoreHealthOrderScrmController extends BaseController {
     @Autowired
     private ICompanyMoneyLogsService moneyLogsService;
 
+    // 允许的文件扩展名
+    private static final String[] ALLOWED_EXCEL_EXTENSIONS = {".xlsx", ".xls"};
+
+    // 最大文件大小(5MB)
+    private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
+
     /**
      * 查询健康商城订单列表
      */
@@ -173,4 +180,52 @@ public class FsStoreHealthOrderScrmController extends BaseController {
         ExcelUtil<FsStoreOrderItemExportVO> util = new ExcelUtil<FsStoreOrderItemExportVO>(FsStoreOrderItemExportVO.class);
         return util.exportExcel(list, "订单明细数据");
     }
+
+    //订单发货批量导入
+    @Log(title = "发货同步导入", businessType = BusinessType.IMPORT)
+    @PostMapping("/importDeliveryNoteExpress")
+    public R importDeliveryNoteExpress(@RequestParam("file") MultipartFile file, @RequestParam("miniAppId") String miniAppId) {
+        // 1. 检查文件是否为空
+        if (file.isEmpty()) {
+            return R.error("上传的文件不能为空");
+        }
+        // 2. 检查文件大小
+        if (file.getSize() > MAX_FILE_SIZE) {
+            return R.error("文件大小不能超过5MB");
+        }
+        // 3. 检查文件扩展名
+        String fileName = file.getOriginalFilename();
+        if (fileName == null || !isValidExcelFile(fileName)) {
+            return R.error("请上传Excel文件(.xlsx或.xls格式)");
+        }
+
+        ExcelUtil<FsOrderDeliveryNoteDTO> util=new ExcelUtil<>(FsOrderDeliveryNoteDTO.class);
+        try {
+            List<FsOrderDeliveryNoteDTO> dtoList = util.importExcel(file.getInputStream());
+            if(!dtoList.isEmpty()){
+                fsStoreOrderService.importDeliveryNoteExpress(dtoList,miniAppId);
+            }else {
+                R.error("操作失败,导入数据不能小于1条!");
+            }
+        }catch (Exception e){
+            e.getStackTrace();
+        }
+        return R.ok();
+    }
+
+    @GetMapping("/importDeliveryNoteExpressTemplate")
+    public AjaxResult importTemplate() {
+        ExcelUtil<FsOrderDeliveryNoteDTO> util = new ExcelUtil<>(FsOrderDeliveryNoteDTO.class);
+        return util.importTemplateExcel("订单发货导入模板");
+    }
+
+    // 检查文件是否为有效的Excel文件
+    private boolean isValidExcelFile(String fileName) {
+        for (String ext : ALLOWED_EXCEL_EXTENSIONS) {
+            if (fileName.toLowerCase().endsWith(ext)) {
+                return true;
+            }
+        }
+        return false;
+    }
 }

+ 22 - 0
fs-service/src/main/java/com/fs/course/dto/FsOrderDeliveryNoteDTO.java

@@ -0,0 +1,22 @@
+package com.fs.course.dto;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+/**
+ * 订单发货下载模板
+ * **/
+@Data
+public class FsOrderDeliveryNoteDTO {
+    /**
+     * 系统订单号
+     * **/
+    @Excel(name = "系统订单号(必填)",width = 40,sort = 1)
+    private String orderNumber;
+
+    /**
+     * 发货状态
+     * **/
+    @Excel(name = "系统订单号(2 待收货 3 交易完成)填写对应数字",width = 50,sort = 2)
+    private Integer deliveryNoteStatus;
+}

+ 8 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java

@@ -10,6 +10,7 @@ import com.fs.api.param.OrderListParam;
 import com.fs.api.vo.OrderListVO;
 import com.fs.common.core.domain.R;
 import com.fs.company.domain.CompanyUser;
+import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.erp.domain.ErpOrder;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.dto.ExpressNotifyDTO;
@@ -239,4 +240,11 @@ public interface IFsStoreOrderScrmService
     R updateSalesOrderMoneyByProduct(FsStoreOrderMoneyByProductParam param);
 
     List<FsStoreProductCountsVO> selectFsStoreProductCountsByDept(Map<String, Object> map, Long deptId);
+
+    /**
+     * 批量导入更新微信订单发货状态
+     * @param dtoList 订单数据
+     * @param miniAppId 小程序Id
+     * **/
+    void importDeliveryNoteExpress(List<FsOrderDeliveryNoteDTO> dtoList,String miniAppId);
 }

+ 15 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.service.impl;
 
+import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.hutool.core.net.URLDecoder;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.NumberUtil;
@@ -31,7 +32,9 @@ import com.fs.company.mapper.CompanyMoneyLogsMapper;
 import com.fs.company.service.ICompanyDeptService;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
+import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
+import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.erp.domain.*;
 import com.fs.erp.dto.*;
 import com.fs.erp.mapper.FsErpFinishPushMapper;
@@ -2934,4 +2937,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService
 
         return vos;
     }
+
+    @Override
+    public void importDeliveryNoteExpress(List<FsOrderDeliveryNoteDTO> dtoList, String miniAppId) {
+       try {
+           //获取微信token逻辑
+           final WxMaService wxService = WxMaConfiguration.getMaService(miniAppId);
+           String token = wxService.getAccessToken();
+           System.out.println("获取到的token------------->:"+token);
+       }catch (Exception e){
+           e.getStackTrace();
+       }
+    }
 }