‘linchangsheng’ 1 月之前
父節點
當前提交
70e1d4dee0

+ 18 - 4
src/main/java/com/gree/mall/manager/controller/admin/AdminWebsitController.java

@@ -13,6 +13,7 @@ import com.gree.mall.manager.logic.admin.AdminWebsitLogic;
 import com.gree.mall.manager.plus.entity.AdminWebsit;
 import com.gree.mall.manager.plus.entity.AdminZone;
 import com.gree.mall.manager.plus.service.AdminWebsitService;
+import com.gree.mall.manager.utils.excel.ExcelUtils;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import io.swagger.annotations.Api;
@@ -21,9 +22,11 @@ import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.rmi.RemoteException;
 import java.util.List;
 
@@ -77,31 +80,42 @@ public class AdminWebsitController {
     }
 
     @PostMapping("/add")
-    @ApiOperation("新增商")
+    @ApiOperation("新增商")
     public ResponseHelper add(@RequestBody AdminWebsit adminWebsit, HttpServletRequest request) throws RemoteServiceException, WxErrorException {
         adminWebsitLogic.add(adminWebsit,request);
         return ResponseHelper.success();
     }
 
     @PostMapping("/update")
-    @ApiOperation("修改商")
+    @ApiOperation("修改商")
     public ResponseHelper update(@RequestBody AdminWebsit adminWebsit,HttpServletRequest request) throws RemoteServiceException, WxErrorException {
         adminWebsitLogic.update(adminWebsit,request);
         return ResponseHelper.success();
     }
 
     @PostMapping("/delete")
-    @ApiOperation("删除商")
+    @ApiOperation("删除商")
     public ResponseHelper delete(@RequestParam String id, HttpServletRequest request) throws WxErrorException {
         adminWebsitLogic.delete(id,request);
         return ResponseHelper.success();
     }
 
     @GetMapping("/detail")
-    @ApiOperation("部门商户")
+    @ApiOperation("商家详情")
     public ResponseHelper<AdminWebsit> detail(@RequestParam String id){
         AdminWebsit detail = adminWebsitLogic.detail(id);
         return ResponseHelper.success(detail);
     }
 
+    @PostMapping("/import")
+    @ApiOperation("导入商家附件(商家导入.xlsx)")
+    public ResponseHelper importData(
+            @RequestPart("file") MultipartFile file
+    ) throws IOException {
+        List<Object> objects = ExcelUtils.importExcel(file);
+        adminWebsitLogic.importData(objects);
+        return ResponseHelper.success();
+    }
+
+
 }

+ 53 - 0
src/main/java/com/gree/mall/manager/logic/admin/AdminWebsitLogic.java

@@ -13,10 +13,15 @@ import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.admin.ew.EnterpriseWechatWorkerLogic;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.common.WorkWechatLogic;
+import com.gree.mall.manager.plus.entity.AdminCompanyWechat;
+import com.gree.mall.manager.plus.entity.AdminCompanyWechatPayConfig;
 import com.gree.mall.manager.plus.entity.AdminWebsit;
 import com.gree.mall.manager.plus.entity.AdminZone;
+import com.gree.mall.manager.plus.service.AdminCompanyWechatPayConfigService;
+import com.gree.mall.manager.plus.service.AdminCompanyWechatService;
 import com.gree.mall.manager.plus.service.AdminWebsitService;
 import com.gree.mall.manager.plus.service.AdminZoneService;
+import com.gree.mall.manager.utils.CommonUtils;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -49,6 +54,9 @@ public class AdminWebsitLogic {
     @Autowired
     AdminMapper adminMapper;
 
+    @Autowired
+    AdminCompanyWechatPayConfigService adminCompanyWechatPayConfigService;
+
     /**
      * 区域列表
      */
@@ -227,4 +235,49 @@ public class AdminWebsitLogic {
         IPage<AdminWebsitVO> adminDeptWebsitVOIPage = adminMapper.listWebsit(page, zfireParam);
         return adminDeptWebsitVOIPage;
     }
+
+    public void importData(List<Object> objects) {
+
+        List<AdminWebsit> adminWebsits = new ArrayList<>();
+
+        for (int i = 0; i < objects.size(); i++) {
+            int rowIndex = i + 2;
+            List<Object> row = (List<Object>) objects.get(i);
+
+            AdminWebsit adminWebsit = new AdminWebsit();
+
+            adminWebsit.setWebsitId((String) row.get(0));
+            adminWebsit.setWebsitNumber((String) row.get(0));
+            adminWebsit.setName((String) row.get(1));
+            adminWebsit.setMobile((String) row.get(2));
+            adminWebsit.setPerson((String) row.get(3));
+            adminWebsit.setPersonMobile((String) row.get(4));
+            adminWebsit.setType((String) row.get(5));
+            adminWebsit.setAddress((String) row.get(6));
+            AdminCompanyWechatPayConfig one = adminCompanyWechatPayConfigService.lambdaQuery()
+                    .eq(AdminCompanyWechatPayConfig::getCompanyName, (String) row.get(7))
+
+                    .last("limit 1").one();
+
+            if (one == null)
+                throw new RemoteServiceException("第"+rowIndex+"行,找不到支付商户");
+            adminWebsit.setPayWorkerCodeName((String) row.get(7));
+            adminWebsit.setPayWorkerCodeId(one.getId());
+            if (row.size() > 7) {
+                adminWebsit.setYunAppid((String) row.get(8));
+                adminWebsit.setYunAppkey((String) row.get(9));
+                adminWebsit.setYunCompany((String) row.get(10));
+                adminWebsit.setYunNumber((String) row.get(11));
+                adminWebsit.setYunSystem((String) row.get(12));
+                adminWebsit.setYunTax((String) row.get(13));
+                adminWebsit.setYunName((String) row.get(14));
+                adminWebsit.setYunTwo((((String) row.get(15)).equals("是"))?"YES":"NO");
+            }
+
+            adminWebsits.add(adminWebsit);
+
+        }
+
+        adminWebsitService.saveBatch(adminWebsits);
+    }
 }

二進制
src/main/resources/static/商家导入.xlsx