diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java index f884ae3..4875a0e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.model.GenericResult; import com.ningdatech.cache.model.cache.CacheKey; import com.ningdatech.cache.repository.CachePlusOps; import com.ningdatech.file.entity.vo.result.AttachFileVo; @@ -41,6 +42,8 @@ import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import com.ningdatech.pmapi.user.service.IUserInfoService; import com.ningdatech.pmapi.user.util.LoginUserUtil; +import com.ningdatech.zwdd.client.ZwddClient; +import com.ningdatech.zwdd.model.dto.DingInfoByMobileDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -69,17 +72,18 @@ import java.util.stream.Collectors; public class ExpertManage { private final ExpertManageHelper expertManageHelper; - private final IExpertUserFullInfoService iExpertUserFullInfoService; + private final IExpertUserFullInfoService expertUserFullInfoService; private final ExpertInfoService expertInfoService; private final ExpertInfoCommonHelper expertInfoCommonHelper; private final FileService fileService; private final ExpertUserInfoAssembler expertUserInfoAssembler; - private final IUserInfoService iUserInfoService; + private final IUserInfoService userInfoService; private final ExpertMetaApplyManage expertMetaApplyManage; - private final IUserRoleService iUserRoleService; - private final IRoleService iRoleService; + private final IUserRoleService userRoleService; + private final IRoleService roleService; private final VerifyCodeCheckHelper verifyCodeCheckHelper; private final CachePlusOps cachePlusOps; + private final ZwddClient zwddClient; @Value("${expert-registration.verify-code.check:true}") private Boolean expertRegistrationVerifyCodeCheck; @@ -136,13 +140,13 @@ public class ExpertManage { expertMetaApplyManage.autoPassExpertApply(userId); // 增加用户专家角色 - Role role = iRoleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getCode, RoleEnum.EXPERT.name())); - UserRole expertRole = iUserRoleService.getOne(userId, role.getId()); + Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getCode, RoleEnum.EXPERT.name())); + UserRole expertRole = userRoleService.getOne(userId, role.getId()); if (Objects.isNull(expertRole)) { expertRole = new UserRole(); expertRole.setUserId(userId); expertRole.setRoleId(role.getId()); - iUserRoleService.save(expertRole); + userRoleService.save(expertRole); } } @@ -151,7 +155,7 @@ public class ExpertManage { public Long expertRecommendProofSubmit (List recommendedWay, List recommendProofFile, Long expertUserId) { // 用户id - ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(expertUserId); + ExpertUserFullInfo expertUserFullInfo = expertUserFullInfoService.getByUserId(expertUserId); // 判断专家状态,是否可以进行证明材料提交 if (Objects.isNull(expertUserFullInfo) || !ExpertAccountStatusEnum.APPLYING.getKey().equals(expertUserFullInfo.getExpertAccountStatus()) @@ -195,23 +199,35 @@ public class ExpertManage { @Transactional(rollbackFor = Exception.class) public Long generateOrGetUserId(ExpertBasicInfo basicInfo, Long operatorId) { String phoneNo = basicInfo.getPhoneNo(); - UserInfo userInfo = iUserInfoService.getUserInfoByPhoneNo(phoneNo); + UserInfo userInfo = userInfoService.getUserInfoByPhoneNo(phoneNo); if (Objects.isNull(userInfo)) { - userInfo = UserInfo.builder() - //.accountId(dingEmployeeInfo.getAccountId()) - .username(basicInfo.getName()) - .realName(basicInfo.getName()) - //.employeeCode(dingEmployeeInfo.getEmployeeCode()) - .available(UserAvailableEnum.DISABLE.name()) - .mobile(phoneNo) - .createBy(operatorId) - .updateBy(operatorId) - .createOn(LocalDateTime.now()) - .updateOn(LocalDateTime.now()) - .build(); - iUserInfoService.save(userInfo); + GenericResult dingInfoByMobile = zwddClient.getDingInfoByMobile(basicInfo.getPhoneNo()); + if (dingInfoByMobile.isSuccess()) { + DingInfoByMobileDTO data = dingInfoByMobile.getData(); + String accountId = data.getAccountId(); + userInfo = userInfoService.getUserInfoByAccountId(Long.parseLong(accountId)); + } + if (userInfo == null) { + userInfo = UserInfo.builder() + .username(basicInfo.getName()) + .realName(basicInfo.getName()) + .available(UserAvailableEnum.DISABLE.name()) + .mobile(phoneNo) + .createBy(operatorId) + .updateBy(operatorId) + .createOn(LocalDateTime.now()) + .updateOn(LocalDateTime.now()) + .build(); + userInfoService.save(userInfo); + } else if (!StrUtil.equals(userInfo.getRealName(), basicInfo.getName())) { + log.warn("相似账户为:{} ==> {}", basicInfo.getPhoneNo(), userInfo); + throw BizException.wrap("已存在同手机号,但不同名的账号"); + } else if (StrUtil.isBlank(userInfo.getMobile())) { + userInfo.setMobile(basicInfo.getPhoneNo()); + userInfoService.updateById(userInfo); + } } - ExpertUserFullInfo one = iExpertUserFullInfoService.getOne(Wrappers.lambdaQuery(ExpertUserFullInfo.class) + ExpertUserFullInfo one = expertUserFullInfoService.getOne(Wrappers.lambdaQuery(ExpertUserFullInfo.class) .eq(ExpertUserFullInfo::getPhoneNo, phoneNo)); if (Objects.nonNull(one) && !one.getUserId().equals(userInfo.getId())) { throw new BizException("该手机号已被专家注册,请确认后再填写"); @@ -259,7 +275,7 @@ public class ExpertManage { // 校验字典字段 expertManageHelper.dictionaryFieldCheck(basicInfo, eduInfo, jobInfo); // 判断专家提交状态,判断是否可以进行此操作 - ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(userId); + ExpertUserFullInfo expertUserFullInfo = expertUserFullInfoService.getByUserId(userId); boolean submitBasicInfoStatusEnable = Objects.isNull(expertUserFullInfo) || (ExpertAccountStatusEnum.APPLYING.getKey().equals(expertUserFullInfo.getExpertAccountStatus()) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java index 7f5ac38..7be2c12 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java @@ -20,5 +20,7 @@ public interface IUserInfoService extends IService { UserInfo getUserInfoByEmployeeCode(String employeeCode); + UserInfo getUserInfoByAccountId(Long accountId); + List getUserInfoByEmployeeCodes(Collection employeeCodes); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java index 3f5fa28..bd27052 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java @@ -36,6 +36,13 @@ public class UserInfoServiceImpl extends ServiceImpl } @Override + public UserInfo getUserInfoByAccountId(Long accountId) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) + .eq(UserInfo::getAccountId, accountId); + return getOne(query); + } + + @Override public UserInfo getUserInfoByEmployeeCode(String employeeCode) { LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getEmployeeCode, employeeCode);