| | |
| | | import com.ruoyi.company.api.domain.dto.MgtCompanyDTO; |
| | | import com.ruoyi.company.api.domain.excel.MgtCompanyExcel; |
| | | import com.ruoyi.company.api.domain.query.MgtCompanyQuery; |
| | | import com.ruoyi.company.api.domain.vo.MgtCompanyVO; |
| | | import com.ruoyi.company.domain.vo.MgtCompanyDetailVO; |
| | | import com.ruoyi.company.domain.vo.MgtCompanyVO; |
| | | import com.ruoyi.company.mapper.CompanyMapper; |
| | | import com.ruoyi.company.service.CompanyService; |
| | | import com.ruoyi.company.service.UserService; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MgtCompanyVO queryCompanyDetail(Long id) { |
| | | public MgtCompanyDetailVO queryCompanyDetail(Long id) { |
| | | Company company = this.getById(id); |
| | | MgtCompanyVO mgtCompanyVO = BeanUtils.copyBean(company, MgtCompanyVO.class); |
| | | MgtCompanyDetailVO mgtCompanyVO = BeanUtils.copyBean(company, MgtCompanyDetailVO.class); |
| | | if (Objects.isNull(mgtCompanyVO)) { |
| | | mgtCompanyVO = new MgtCompanyVO(); |
| | | mgtCompanyVO = new MgtCompanyDetailVO(); |
| | | return mgtCompanyVO; |
| | | } |
| | | User user = userService.getById(company.getUserId()); |
| | |
| | | Company company = BeanUtils.copyBean(dto, Company.class); |
| | | company.setUserId(user.getUserId()); |
| | | //根据公司名称查询数据库 |
| | | Long count = this.lambdaQuery().eq(Company::getCompanyName, company.getCompanyName()).count(); |
| | | Long count = this.lambdaQuery().eq(Company::getCompanyName, company.getCompanyName()).eq(Company::getSocialCode, dto.getSocialCode()).count(); |
| | | if (count > 0) { |
| | | throw new ServiceException("该公司账号已存在"); |
| | | throw new ServiceException("该企业已存在"); |
| | | } |
| | | //身份证二要素校验 |
| | | Boolean res = aliyunCloudAuthUtil.verifyIdCard(dto.getLegalPersonName(), dto.getIdCardNumber()); |
| | | if (!res) { |
| | | throw new ServiceException("身份证信息不匹配"); |
| | | } |
| | | identityVerification(dto, user); |
| | | this.save(company); |
| | | } |
| | | |
| | |
| | | if (Objects.isNull(user)) { |
| | | throw new ServiceException("该企业账号不存在"); |
| | | } |
| | | Long accountCount = userService.lambdaQuery().ne(User::getUserId, user.getUserId()).eq(User::getAccountName, dto.getAccountName()).count(); |
| | | Long accountCount = userService.lambdaQuery() |
| | | .ne(User::getUserId, user.getUserId()) |
| | | .eq(User::getAccountName, dto.getAccountName()) |
| | | .count(); |
| | | if (accountCount > 0) { |
| | | throw new ServiceException("账户名重复"); |
| | | } |
| | |
| | | if (StringUtils.isNotBlank(company.getCompanyName())){ |
| | | Long count = this.lambdaQuery() |
| | | .ne(Company::getId, dto.getId()) |
| | | .eq(Company::getCompanyName, company.getCompanyName()) |
| | | .and(i -> { |
| | | i.eq(Company::getSocialCode, dto.getSocialCode()); |
| | | i.or(); |
| | | i.eq(Company::getCompanyName, dto.getCompanyName()); |
| | | }) |
| | | .count(); |
| | | if (count > 0) { |
| | | throw new ServiceException("该公司账号已存在"); |
| | | throw new ServiceException("该企业已存在"); |
| | | } |
| | | } |
| | | identityVerification(dto, user); |
| | | Company companyUpd = BeanUtils.copyBean(dto, Company.class); |
| | | companyUpd.setId(company.getId()); |
| | | this.updateById(companyUpd); |
| | | } |
| | | |
| | | private void identityVerification(MgtCompanyDTO dto, User user) { |
| | | //身份证二要素校验 |
| | | Boolean res = aliyunCloudAuthUtil.verifyIdCard(dto.getLegalPersonName(), dto.getIdCardNumber()); |
| | | if (!res) { |
| | | throw new ServiceException("身份证信息不匹配"); |
| | | } |
| | | Company companyUpd = BeanUtils.copyBean(dto, Company.class); |
| | | companyUpd.setId(company.getId()); |
| | | this.updateById(companyUpd); |
| | | //营业执照二要素校验 |
| | | res = aliyunCloudAuthUtil.verifyBusinessLicense(dto.getSocialCode(), dto.getCompanyName(), user.getUserId()); |
| | | if (!res) { |
| | | throw new ServiceException("营业执照信息不匹配"); |
| | | } |
| | | } |
| | | |
| | | /** |