| | |
| | | import cn.idev.excel.FastExcel; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.page.BeanUtils; |
| | | import com.ruoyi.common.core.page.PageDTO; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.company.api.domain.Company; |
| | | import com.ruoyi.company.api.domain.User; |
| | |
| | | import com.ruoyi.company.service.CompanyService; |
| | | import com.ruoyi.company.service.UserService; |
| | | import com.ruoyi.company.utils.AliyunCloudAuthUtil; |
| | | import com.ruoyi.system.api.model.AppUser; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | private final HttpServletResponse response; |
| | | |
| | | private final AliyunCloudAuthUtil aliyunCloudAuthUtil; |
| | | |
| | | private final RedisService redisService; |
| | | /** |
| | | * 获取企业列表 |
| | | * |
| | |
| | | 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::getSocialCode, company.getSocialCode()) |
| | | .eq(Company::getCompanyName, dto.getCompanyName()) |
| | | .and(i -> { |
| | | i.eq(Company::getSocialCode, dto.getSocialCode()); |
| | | i.or(); |
| | | i.eq(Company::getCompanyName, dto.getCompanyName()); |
| | | }) |
| | | .count(); |
| | | if (count > 0) { |
| | | 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("营业执照信息不匹配"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | //删除企业信息 |
| | | this.removeById(id); |
| | | |
| | | //强退用户 |
| | | forceLogout(company.getUserId()); |
| | | |
| | | } |
| | | |
| | | public void forceLogout(Long userId) { |
| | | Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); |
| | | for (String key : keys) { |
| | | Object user = redisService.getCacheObject(key); |
| | | if (user instanceof AppUser) { |
| | | AppUser appUser = (AppUser) user; |
| | | if (appUser.getUserId().equals(userId)) { |
| | | redisService.deleteObject(key); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |