FengChaoYu 10 månader sedan
förälder
incheckning
c4df49b5f1

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

@@ -14,12 +14,14 @@ import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.enums.ExamineStatusEnum;
 import com.gree.mall.manager.enums.WebsitAttrEnum;
 import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
+import com.gree.mall.manager.enums.base.BaseEnum;
 import com.gree.mall.manager.enums.material.WebsitGoodsTypeEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.common.LbsAmapLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
+import com.gree.mall.manager.utils.CommonUtils;
 import com.gree.mall.manager.utils.StringUtil;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -698,43 +700,87 @@ public class AdminWebsitLogic {
         List<AdminWebsitPayConfig> allPayConfigList = new ArrayList<>();
         for (int i = 0; i < objects.size(); i++) {
             int rowIndex = i + 2;
+            CommonUtils.initList2(objects, 40);
             List<Object> row = (List<Object>) objects.get(i);
             if (Objects.isNull(row.get(0)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(0).toString())) {
-                throw new RemoteServiceException("第" + rowIndex + "行, 网点编号不能为空");
+                throw new RemoteServiceException("第" + rowIndex + "行, 所属公司不能为空");
             }
             if (Objects.isNull(row.get(1)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(1).toString())) {
-                throw new RemoteServiceException("第" + rowIndex + "行, 网点名称不能为空");
+                throw new RemoteServiceException("第" + rowIndex + "行, 网点编号不能为空");
             }
             if (Objects.isNull(row.get(2)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(2).toString())) {
-                throw new RemoteServiceException("第" + rowIndex + "行, 联系人不能为空");
+                throw new RemoteServiceException("第" + rowIndex + "行, 网点名称不能为空");
             }
             if (Objects.isNull(row.get(3)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(3).toString())) {
-                throw new RemoteServiceException("第" + rowIndex + "行, 联系电话不能为空");
+                throw new RemoteServiceException("第" + rowIndex + "行, 网点属性不能为空");
             }
             if (Objects.isNull(row.get(4)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(4).toString())) {
-                throw new RemoteServiceException("第" + rowIndex + "行, 详细地址不能为空");
+                throw new RemoteServiceException("第" + rowIndex + "行, 网点级别不能为空");
             }
             if (Objects.isNull(row.get(5)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(5).toString())) {
-                throw new RemoteServiceException("第" + rowIndex + "行, 电子支付商户不能为空");
+                throw new RemoteServiceException("第" + rowIndex + "行, 企业法人不能为空");
             }
             if (Objects.isNull(row.get(6)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(6).toString())) {
-                throw new RemoteServiceException("第" + rowIndex + "行, 状态不能为空");
+                throw new RemoteServiceException("第" + rowIndex + "行, 法人手机不能为空");
             }
             if (Objects.isNull(row.get(7)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(7).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 法人身份证不能为空");
+            }
+            if (Objects.isNull(row.get(8)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(8).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 联系人不能为空");
+            }
+            if (Objects.isNull(row.get(9)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(9).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 联系电话不能为空");
+            }
+            if (Objects.isNull(row.get(10)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(10).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 详细地址不能为空");
+            }
+            if (Objects.isNull(row.get(11)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(11).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 电子支付商户不能为空");
+            }
+            if (Objects.isNull(row.get(12)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(12).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 保险类型不能为空");
+            }
+            if (Objects.isNull(row.get(15)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(15).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 状态不能为空");
+            }
+            if (Objects.isNull(row.get(16)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(16).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 办公电话不能为空");
+            }
+            if (Objects.isNull(row.get(17)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(17).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 开户银行不能为空");
+            }
+            if (Objects.isNull(row.get(18)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(18).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 银行账号不能为空");
+            }
+            if (Objects.isNull(row.get(19)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(19).toString())) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 邮箱不能为空");
+            }
+            if (Objects.isNull(row.get(20)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(20).toString())) {
                 throw new RemoteServiceException("第" + rowIndex + "行, 通联支付开关不能为空");
             }
 
-            String websitName = row.get(1).toString().trim();
+            String belongCompanyName = row.get(0).toString().trim();
+            final SysDictCompany belongCompany = sysDictCompanyService.lambdaQuery()
+                    .eq(SysDictCompany::getCompanyWechatId, adminUser.getCompanyWechatId())
+                    .eq(SysDictCompany::getDictType, "BELONG_COMPANY")
+                    .eq(SysDictCompany::getDictValue, belongCompanyName)
+                    .one();
+            if (Objects.isNull(belongCompany)) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 所属公司不存在");
+            }
+
+            String websitName = row.get(2).toString().trim();
             final Integer existNameCount = adminWebsitService.lambdaQuery()
                     .eq(AdminWebsit::getName, websitName)
                     .count();
             if (existNameCount > 0) {
                 throw new RemoteServiceException("第" + rowIndex + "行, 网点名称已重复存在");
             }
-            String address = row.get(4).toString().trim();
+            String address = row.get(10).toString().trim();
             String lnglat = lbsAmapLogic.getLocationByAddress(address);
 
-            String payName = row.get(5).toString().trim();
+            String payName = row.get(11).toString().trim();
             final AdminCompanyWechatPayConfig wechatPayConfig = adminCompanyWechatPayConfigService.lambdaQuery()
                     .eq(AdminCompanyWechatPayConfig::getPayMerchantName, payName)
                     .like(AdminCompanyWechatPayConfig::getAttr, Constant.COMPANY_PAY_CONFIG_1)
@@ -742,14 +788,67 @@ public class AdminWebsitLogic {
             if (Objects.isNull(wechatPayConfig)) {
                 throw new RemoteServiceException("第" + rowIndex + "行, 电子支付商户不存在");
             }
-            final String statusName = row.get(6).toString().trim();
+
+            final String attrName =row.get(3).toString().trim();
+            final WebsitAttrEnum websitAttrEnum = BaseEnum.valueToEnumDefault(WebsitAttrEnum.class, attrName, WebsitAttrEnum.SELF);
+            String insurePayConfigId = null;
+            if (websitAttrEnum.getKey().equals(WebsitAttrEnum.SELF.getKey())) {
+                String insurePayName = row.get(13).toString().trim();
+                final AdminCompanyWechatPayConfig insurePayConfig = adminCompanyWechatPayConfigService.lambdaQuery()
+                        .eq(AdminCompanyWechatPayConfig::getPayMerchantName, insurePayName)
+                        .like(AdminCompanyWechatPayConfig::getAttr, Constant.COMPANY_PAY_CONFIG_2)
+                        .one();
+                if (Objects.isNull(insurePayConfig)) {
+                    throw new RemoteServiceException("第" + rowIndex + "行, 保险支付商户号不存在");
+                }
+                insurePayConfigId = insurePayConfig.getId();
+            }
+
+            final String insureType = row.get(12).toString().trim();
+            if (org.apache.commons.lang3.StringUtils.isBlank(insureType)) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 保险类型不能为空");
+            }
+            if (!insureType.contains("意外险")) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 意外险不能为空");
+            }
+
+            if (!insureType.contains("雇主险")) {
+                if (!insureType.contains("工伤险")) {
+                    throw new RemoteServiceException("第" + rowIndex + "行, 雇主险,工伤险必选一个");
+                }
+            }
+
+            final String insureSteadUnitName = row.get(14).toString().trim();
+            if (insureType.contains("工伤险")
+                    && org.apache.commons.lang3.StringUtils.isBlank(insureSteadUnitName)) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 工伤险代买单位不能为空");
+            }
+
+
+            final SysDictCompany steadUnit = sysDictCompanyService.lambdaQuery()
+                    .eq(SysDictCompany::getCompanyWechatId, adminUser.getCompanyWechatId())
+                    .eq(SysDictCompany::getDictType, "INSURE_STEAD_UNIT")
+                    .eq(SysDictCompany::getDictValue, insureSteadUnitName)
+                    .one();
+            if (org.apache.commons.lang3.StringUtils.isNotBlank(insureSteadUnitName) && Objects.isNull(steadUnit)) {
+                throw new RemoteServiceException("第" + rowIndex + "行, 工伤险代买单位不存在");
+            }
+
+            final String statusName = row.get(15).toString().trim();
             final boolean status = statusName.equals("启用");
-            final String allinpayName = row.get(7).toString().trim();
+            final String allinpayName = row.get(20).toString().trim();
             final boolean isUseAllinpay = allinpayName.equals("开启");
 
             AdminWebsit addWebsit = new AdminWebsit();
-            addWebsit.setWebsitId(row.get(0).toString());
+            addWebsit.setBelongCompany(belongCompany.getDictValue())
+                    .setBelongCompanyCode(belongCompany.getDictCode());
+            addWebsit.setWebsitId(row.get(1).toString());
             addWebsit.setName(websitName);
+            addWebsit.setAttr(websitAttrEnum.getKey());
+            addWebsit.setLevel("一级网点".equals(row.get(4).toString().trim()) ? 1 : 2);
+            addWebsit.setLegalName(row.get(5).toString().trim())
+                    .setLegalMobile(row.get(6).toString().trim())
+                    .setLegalIdCard(row.get(7).toString().trim());
             addWebsit.setType(AdminWebsitTypeEnum.C.getKey());
             addWebsit.setParentId(parentWebsit.getWebsitId());
             addWebsit.setWebsitNumber(addWebsit.getWebsitId());
@@ -759,17 +858,24 @@ public class AdminWebsitLogic {
             addWebsit.setCompanyWechatName(companyName);
             addWebsit.setLng(lnglat.split(",")[0]);
             addWebsit.setLat(lnglat.split(",")[1]);
-            addWebsit.setLinkName(row.get(2).toString().trim());
-            addWebsit.setWebsitPhone(row.get(3).toString().trim());
+            addWebsit.setLinkName(row.get(8).toString().trim());
+            addWebsit.setLinkMobile(row.get(9).toString().trim());
+            addWebsit.setWebsitPhone(row.get(16).toString().trim());
             addWebsit.setPayWorkerCodeId(wechatPayConfig.getId());
             addWebsit.setIsUseAllinpay(isUseAllinpay);
+            addWebsit.setInsureType(insureType);
+            addWebsit.setPayInsureCodeId(insurePayConfigId);
+            addWebsit.setInsureSteadUnit(Objects.nonNull(steadUnit) ? steadUnit.getDictCode() : null);
+            addWebsit.setOpenBank(row.get(17).toString().trim());
+            addWebsit.setBankAccount(row.get(18).toString().trim());
+            addWebsit.setEmail(row.get(19).toString().trim());
 
             adminWebsitList.add(addWebsit);
             List<AdminWebsitPayConfig> payConfigList = new ArrayList<>();
             if (isUseAllinpay) {
                 boolean isOn = true;
                 int detailIndex = 1;
-                int detailStartIndex = 7;
+                int detailStartIndex = 20;
                 while (isOn) {
                     try {
                         row.get(detailStartIndex + 1);