Browse Source

no message

FengChaoYu 7 months ago
parent
commit
312f459601

+ 51 - 45
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminWebsitLogic.java

@@ -543,6 +543,7 @@ public class AdminWebsitLogic {
         List<Object> objects = ExcelUtils.importExcel(file);
 
         List<AdminWebsit> adminWebsitList = new ArrayList<>();
+        List<AdminWebsitPayConfig> allPayConfigList = new ArrayList<>();
         for (int i = 0; i < objects.size(); i++) {
             int rowIndex = i + 2;
             List<Object> row = (List<Object>) objects.get(i);
@@ -665,61 +666,66 @@ public class AdminWebsitLogic {
                 }
             }
 
-            if (CollectionUtil.isNotEmpty(adminWebsitList)) {
-                // 检查本次导入是否有重复编号和名称
-                Map<String, List<AdminWebsit>> websitGroup = adminWebsitList.stream().collect(Collectors.groupingBy(AdminWebsit::getName));
-                for (Map.Entry<String, List<AdminWebsit>> entry : websitGroup.entrySet()) {
-                    if (entry.getValue().size() > 1) {
-                        throw new RemoteServiceException("导入文档有重复的网点名称" + entry.getKey());
-                    }
+            if (CollectionUtil.isNotEmpty(payConfigList)) {
+                allPayConfigList.addAll(payConfigList);
+            }
+        }
+
+        if (CollectionUtil.isNotEmpty(adminWebsitList)) {
+            // 检查本次导入是否有重复编号和名称
+            Map<String, List<AdminWebsit>> websitGroup = adminWebsitList.stream().collect(Collectors.groupingBy(AdminWebsit::getName));
+            for (Map.Entry<String, List<AdminWebsit>> entry : websitGroup.entrySet()) {
+                if (entry.getValue().size() > 1) {
+                    throw new RemoteServiceException("导入文档有重复的网点名称" + entry.getKey());
                 }
+            }
 
-                websitGroup = adminWebsitList.stream().collect(Collectors.groupingBy(AdminWebsit::getWebsitId));
-                for (Map.Entry<String, List<AdminWebsit>> entry : websitGroup.entrySet()) {
-                    if (entry.getValue().size() > 1) {
-                        throw new RemoteServiceException("导入文档有重复的网点编号" + entry.getKey());
-                    }
-                    final Integer count = adminWebsitService.lambdaQuery()
-                            .eq(AdminWebsit::getCompanyWechatId, companyWechatId)
-                            .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
-                            .eq(AdminWebsit::getWebsitId, entry.getKey())
-                            .count();
-                    if (count > 0) {
-                        throw new RemoteServiceException("网点编号" + entry.getKey() + " 在系统里已存在");
-                    }
+            websitGroup = adminWebsitList.stream().collect(Collectors.groupingBy(AdminWebsit::getWebsitId));
+            for (Map.Entry<String, List<AdminWebsit>> entry : websitGroup.entrySet()) {
+                if (entry.getValue().size() > 1) {
+                    throw new RemoteServiceException("导入文档有重复的网点编号" + entry.getKey());
+                }
+                final Integer count = adminWebsitService.lambdaQuery()
+                        .eq(AdminWebsit::getCompanyWechatId, companyWechatId)
+                        .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
+                        .eq(AdminWebsit::getWebsitId, entry.getKey())
+                        .count();
+                if (count > 0) {
+                    throw new RemoteServiceException("网点编号" + entry.getKey() + " 在系统里已存在");
+                }
 
-                    final Integer nameCount = adminWebsitService.lambdaQuery()
-                            .eq(AdminWebsit::getCompanyWechatId, companyWechatId)
-                            .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
-                            .eq(AdminWebsit::getName, entry.getValue().get(0).getName())
-                            .count();
-                    if (nameCount > 0) {
-                        throw new RemoteServiceException("网点名称" + entry.getKey() + " 在系统里已存在");
-                    }
+                final Integer nameCount = adminWebsitService.lambdaQuery()
+                        .eq(AdminWebsit::getCompanyWechatId, companyWechatId)
+                        .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
+                        .eq(AdminWebsit::getName, entry.getValue().get(0).getName())
+                        .count();
+                if (nameCount > 0) {
+                    throw new RemoteServiceException("网点名称" + entry.getKey() + " 在系统里已存在");
                 }
+            }
 
-                adminWebsitService.saveBatch(adminWebsitList);
-                for (AdminWebsit websit : adminWebsitList) {
-                    reloadJoinCode(websit.getCompanyWechatId(), websit.getJoinCode());
 
-                    // 初始化辅材配件默认仓
-                    initMaterialStorage(adminUser, websit);
+            for (AdminWebsit websit : adminWebsitList) {
+                reloadJoinCode(websit.getCompanyWechatId(), websit.getJoinCode());
 
+                // 初始化辅材配件默认仓
+                initMaterialStorage(adminUser, websit);
 
-                    AdminDept adminDept = adminDeptService.lambdaQuery().eq(AdminDept::getCompanyWechatId, websit.getCompanyWechatId())
-                            .eq(AdminDept::getPId, "1").last("limit 1").one();
-                    AdminDeptWebsit adminDeptWebsit = new AdminDeptWebsit();
-                    adminDeptWebsit.setAdminDeptId(adminDept.getAdminDeptId());
-                    adminDeptWebsit.setWebsitId(websit.getWebsitId());
-                    adminDeptWebsit.setWebsitName(websit.getName());
-                    adminDeptWebsit.setDeptName(adminDept.getDeptName());
-                    adminDeptWebsit.insert();
-                }
 
-                if (CollectionUtil.isNotEmpty(payConfigList)) {
-                    adminWebsitPayConfigService.saveBatch(payConfigList);
-                }
+                AdminDept adminDept = adminDeptService.lambdaQuery().eq(AdminDept::getCompanyWechatId, websit.getCompanyWechatId())
+                        .eq(AdminDept::getPId, "1").last("limit 1").one();
+                AdminDeptWebsit adminDeptWebsit = new AdminDeptWebsit();
+                adminDeptWebsit.setAdminDeptId(adminDept.getAdminDeptId());
+                adminDeptWebsit.setWebsitId(websit.getWebsitId());
+                adminDeptWebsit.setWebsitName(websit.getName());
+                adminDeptWebsit.setDeptName(adminDept.getDeptName());
+                adminDeptWebsit.insert();
+            }
+
+            if (CollectionUtil.isNotEmpty(allPayConfigList)) {
+                adminWebsitPayConfigService.saveBatch(allPayConfigList);
             }
+            adminWebsitService.saveBatch(adminWebsitList);
         }
     }