nidapeng
2024-03-14 7ad3d376d3ccb029bb8077725aa70747b0ebb2ad
server/service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
@@ -88,6 +88,7 @@
        company.setStatus(Constants.ZERO);
        company.setType(Constants.ZERO);
        company.setSignStatus(Constants.ZERO);
        company.setType(Constants.ZERO);
        company.setSignIdStatus(Constants.ZERO);
        companyMapper.insert(company);
        company.setEditDate(company.getCreateDate());
@@ -98,6 +99,36 @@
        dealFileData(company);
        //处理关联方案
        dealSolutionsData(company);
        return company;
    }
    @Override
    @Transactional
    public Company createShop(Company company) {
        isValidCreateParam(company);
        if(companyMapper.selectCount(new QueryWrapper<Company>().lambda()
                .eq(Company::getCode,company.getCode())
               .or().eq(Company::getPhone,company.getPhone())
               .or().eq(Company::getEmail,company.getEmail())
               .or().eq(Company::getUsername,company.getUsername())
                .or().eq(Company::getName,company.getName()))>0){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,该企业【名称】【统一信用代码】【邮箱】或者【手机号】已存在,请确认后重新提交!");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        company.setCreator(user.getId());
        company.setCreateDate(new Date());
        company.setType(Constants.ONE);
        company.setIsdeleted(Constants.ZERO);
        company.setStatus(Constants.ZERO);
        company.setType(Constants.ZERO);
        company.setSignStatus(Constants.ZERO);
        company.setSignIdStatus(Constants.ZERO);
        companyMapper.insert(company);
        company.setEditDate(company.getCreateDate());
        company.setEditor(user.getId());
        //处理登陆账号信息
        dealSystemUserData(company);
        //处理附件信息
        dealFileData(company);
        return company;
    }
    @Override
@@ -116,6 +147,8 @@
        //处理关联方案
        dealSolutionsData(company);
    }
    @Override
    @Transactional
    public void exportFiles(Integer id, HttpServletResponse response){
        try {
@@ -151,7 +184,7 @@
            response.setContentType("application/octet-stream");
            response.setHeader("eva-opera-type", "download");
            response.setHeader("eva-download-filename", encodeFileName);
            Constants. packFilesToZip(fileList,response.getOutputStream());
            Constants.packFilesToZip(fileList,response.getOutputStream());
        } catch (IOException e) {
            throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
        }
@@ -225,6 +258,54 @@
        List<CompanySolution> list = new ArrayList<>();
        int num =0;
        for(CompanySolution s :company.getSolutionList()){
            if(Objects.isNull(s.getSolution())){
                continue;
            }
            if(s.getSolution().getBaseId() == null){
                continue;
            }
            Solutions newVersion = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().eq(Solutions::getBaseId,s.getSolution().getBaseId())
                    .eq(Solutions::getDataType,Constants.TWO).last("limit 1"));
            if(Objects.isNull(newVersion)){
                throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请添加有效的保险方案信息!");
            }
            sIds.add(s.getSolution().getBaseId());
            s.setCompanyId(company.getId());
            s.setIsdeleted(Constants.ZERO);
            s.setCanAdd(Constants.formatIntegerNum(s.getCanAdd()));
            s.setCanReduce(Constants.formatIntegerNum(s.getCanReduce()));
            s.setCreateDate(company.getCreateDate());
            s.setCreator(company.getCreator());
            s.setSortnum(num++);
            s.setSolutionBaseId( s.getSolution().getBaseId() );
            s.setSolutionId( newVersion.getId() );
            s.setStatus(Constants.ZERO);
            list.add(s);
        }
        if(list.size() ==0){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请添加有效的保险方案信息!");
        }
        List<Solutions> solutionsList = solutionsMapper.selectList(new QueryWrapper<Solutions>().lambda()
                .in(Solutions::getId,sIds)
                .eq(Solutions::getIsdeleted,Constants.ZERO));
        if(solutionsList.size()!= list.size()){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请添加有效的保险方案信息哦");
        }
        for(Solutions s:solutionsList){
            if(Constants.equalsInteger(s.getStatus(),Constants.ONE)){
                throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"保险方案【"+s.getName()+"】已被禁用,不能进行该操作");
            }
        }
        companySolutionJoinMapper.insertBatchSomeColumn(list);
    }
   /* private void dealSolutionsData(Company company) {
        List<Integer> sIds = new ArrayList<>();
        List<CompanySolution> list = new ArrayList<>();
        int num =0;
        for(CompanySolution s :company.getSolutionList()){
            if(s.getSolution() == null || s.getSolution().getBaseId() == null ||s.getSolution().getId()==null){
                continue;
            }
@@ -256,8 +337,7 @@
            }
        }
        companySolutionJoinMapper.insertBatchSomeColumn(list);
    }
    }*/
    private void isValidCreateParam(Company company) {
        if(StringUtils.isBlank(company.getPhone())
            ||StringUtils.isBlank(company.getName())
@@ -290,7 +370,7 @@
        if(company.getSignImg()!=null && StringUtils.isNotBlank(company.getSignImg().getFileurl())){
            multifileList.add(initMultiFileByCompay(company,company.getSignImg(),Constants.MultiFile.COM_SING_IMG.getKey()));
        }else {
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请上传电子签章!");
         //   throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请上传电子签章!");
        }
        if(company.getIdcardImgList()!=null && company.getIdcardImgList()!=null&& company.getIdcardImgList().size()>0){
            for(Multifile f : company.getIdcardImgList()){