dev: 相关方app注册,扫码入职逻辑修改

dev_xiangguanfang
SondonYong 2025-12-29 16:18:23 +08:00
parent b78a92f630
commit a1db7575b2
2 changed files with 77 additions and 62 deletions

View File

@ -130,21 +130,20 @@ public class UserAddExe {
zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone()); zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
} }
//验证手机号重复 //验证手机号重复
UserDO userDO = userRepository.getByPhone(cmd.getPhone()); // 12.29,不验证手机号(用户名)是否重复
if(userDO != null){ // UserDO userDO = userRepository.getByPhone(cmd.getPhone());
throw new BizException("手机号已注册"); // if(userDO != null){
} // throw new BizException("手机号已注册");
// }
// 注册的时候底座不创建用户所以在user表插入一条用户数据即可企业id部门id岗位为空
CorpInfoDO corpInfoDO = corpInfoRepository.getCorpInfoByCorpName("相关方通用租户"); // CorpInfoDO corpInfoDO = corpInfoRepository.getCorpInfoByCorpName("相关方通用租户");
if(corpInfoDO == null){ // if(corpInfoDO == null){
throw new BizException("未创建相关方通用租户"); // throw new BizException("未创建相关方通用租户");
} // }
BeanUtils.copyProperties(cmd, userE); BeanUtils.copyProperties(cmd, userE);
userE.setPassword(cmd.getNewPassword()); userE.setPassword(cmd.getNewPassword());
userE.encryptionPassword(); userE.encryptionPassword();
userE.setCorpinfoId(corpInfoDO.getId());
userE.setDepartmentId(corpInfoDO.getId());
userGateway.register(userE); userGateway.register(userE);
return true; return true;
@ -161,13 +160,14 @@ public class UserAddExe {
if(userDO == null){ if(userDO == null){
throw new BizException("用户不存在"); throw new BizException("用户不存在");
} }
userRepository.checkUserIdCard(cmd.getId(),cmd.getUserIdCard()); // 12.29 不校验身份证号
// userRepository.checkUserIdCard(cmd.getId(),cmd.getUserIdCard());
if(userDO.getFlowFlag()!=null && !userDO.getFlowFlag().equals(cmd.getFlowFlag())){ if(userDO.getFlowFlag()!=null && !userDO.getFlowFlag().equals(cmd.getFlowFlag())){
// 已完善,与旧数据对比 // 已完善,与旧数据对比
List<UserCorpRecordDO> userCorpRecordDOList = userCorpRecordRepository.getInfoListByUserId(cmd.getId()); List<UserCorpRecordDO> userCorpRecordDOList = userCorpRecordRepository.getInfoListByUserId(cmd.getId());
if(CollUtil.isNotEmpty(userCorpRecordDOList)){ if(CollUtil.isNotEmpty(userCorpRecordDOList)){
throw new BizException("该用户尚有未离职企业,不能修人员流动状态"); throw new BizException("该用户尚有未离职企业,不能修人员流动状态");
} }
} }
userGateway.update(userE); userGateway.update(userE);
@ -178,62 +178,75 @@ public class UserAddExe {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean executeOnboarding(AppUserOnboardingCmd cmd) { public boolean executeOnboarding(AppUserOnboardingCmd cmd) {
// todo 底座将人转移到另一个租户 UserDO userDO = userRepository.getById(cmd.getId());
//// 如果是流动人员, 判断user_corp表是否有未离职的数据, 如果有则不能入职(1-离职) if(userDO == null){
List<Integer> statusList = Arrays.asList(UserEmploymentFlagEnum.RESIGNATION.getCode(), UserEmploymentFlagEnum.NOT_ON.getCode()); throw new BizException("用户不存在");
List<UserCorpDO> userCorpDOS = userCorpRepository.listByUserIdAndCorpIdAndNoStatus(cmd.getId(), cmd.getCorpinfoId(), statusList);
if(CollUtil.isNotEmpty(userCorpDOS)){
throw new BizException("该用户在当前企业存在未离职信息,无法入职");
} }
// 把user表和user_corp表相关企业,部门,岗位数据补充完整 // 校验是否存在未离职信息(不包括未入职状态)
List<UserDO> userDOS = userRepository.listByPhone(userDO.getUsername());
if(CollUtil.isNotEmpty(userDOS)){
userDOS.forEach(u -> {
if(!UserEmploymentFlagEnum.NOT_ON.getCode().equals(u.getEmploymentFlag()) && !UserEmploymentFlagEnum.RESIGNATION.getCode().equals(u.getEmploymentFlag())){
throw new BizException("该用户存在未离职信息,无法入职");
}
});
}
// 判断user表是否有未离职的数据, 如果有则不能入职(1-离职)
// List<Integer> statusList = Arrays.asList(UserEmploymentFlagEnum.RESIGNATION.getCode(), UserEmploymentFlagEnum.NOT_ON.getCode());
// 12.29不校验userCorp表
// List<UserCorpDO> userCorpDOS = userCorpRepository.listByUserIdAndCorpIdAndNoStatus(cmd.getId(), cmd.getCorpinfoId(), statusList);
// if(CollUtil.isNotEmpty(userCorpDOS)){
// throw new BizException("该用户在当前企业存在未离职信息,无法入职");
// }
// 把user表相关企业,部门,岗位数据补充完整
UserE userE = new UserE(); UserE userE = new UserE();
BeanUtils.copyProperties(cmd, userE); BeanUtils.copyProperties(cmd, userE);
// 查询用户信息, 获取是否流动人员 // // 查询用户信息, 获取是否流动人员
UserDO userDO = userRepository.getById(cmd.getId()); // if(UserFlowFlagEnum.FLOW.getCode().equals(userDO.getFlowFlag())){
if(userDO == null){ //// List<UserCorpDO> userCorpList = userCorpRepository.listByUserIdAndCorpIdAndStatus(cmd.getId(), cmd.getCorpinfoId(), statusList);
throw new BizException("用户不存在"); // if(CollUtil.isNotEmpty(userCorpList)){
} // if(userCorpList.size() > 1){
if(UserFlowFlagEnum.FLOW.getCode().equals(userDO.getFlowFlag())){ // throw new BizException("用户在当前企业存在多条离职数据,请联系管理员。");
List<UserCorpDO> userCorpList = userCorpRepository.listByUserIdAndCorpIdAndStatus(cmd.getId(), cmd.getCorpinfoId(), statusList); // }
if(CollUtil.isNotEmpty(userCorpList)){ // UserCorpDO userCorpDO = userCorpList.get(0);
if(userCorpList.size() > 1){ // if(userCorpDO.getEmploymentFlag() != null && UserEmploymentFlagEnum.ON.getCode().equals(userCorpDO.getEmploymentFlag()) ){
throw new BizException("用户在当前企业存在多条离职数据,请联系管理员。"); // throw new BizException("该用户在当前企业已入职,无法入职");
} // }
UserCorpDO userCorpDO = userCorpList.get(0); // userCorpDO.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
if(userCorpDO.getEmploymentFlag() != null && UserEmploymentFlagEnum.ON.getCode().equals(userCorpDO.getEmploymentFlag()) ){ // UserCorpE userCorpE = new UserCorpE();
throw new BizException("该用户在当前企业已入职,无法入职"); // BeanUtils.copyProperties(userCorpDO, userCorpE);
} // userCorpGateway.update(userCorpE);
userCorpDO.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode()); // }else {
UserCorpE userCorpE = new UserCorpE(); // // 插入user_corp表
BeanUtils.copyProperties(userCorpDO, userCorpE); // UserCorpE userCorpE = new UserCorpE();
userCorpGateway.update(userCorpE); // userCorpE.setUserId(userE.getId());
}else { // userCorpE.setCorpinfoId(userE.getCorpinfoId());
// 插入user_corp表 // userCorpE.setDepartmentId(userE.getDepartmentId());
UserCorpE userCorpE = new UserCorpE(); // userCorpE.setPostName(userE.getPostName());
userCorpE.setUserId(userE.getId()); // userCorpE.setRoleId(userE.getRoleId());
userCorpE.setCorpinfoId(userE.getCorpinfoId()); // userCorpE.setDepartmentLeaderFlag(0);
userCorpE.setDepartmentId(userE.getDepartmentId()); // userCorpE.setSort(9999);
userCorpE.setPostName(userE.getPostName()); // userCorpE.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
userCorpE.setRoleId(userE.getRoleId()); // userCorpGateway.add(userCorpE);
userCorpE.setDepartmentLeaderFlag(0); // }
userCorpE.setSort(9999); // }else{
userCorpE.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode()); // if(userDO.getCorpinfoId() != null ){
userCorpGateway.add(userCorpE); // throw new BizException("固定用户在当前企业已入职,无法入职");
} // }
}else{ //
if(userDO.getCorpinfoId() != null ){ //
throw new BizException("固定用户在当前企业已入职,无法入职"); // userE.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
} // // 扫码入职时, 固定人员user表企业id变为入职的企业
// userE.setCorpinfoId(cmd.getCorpinfoId());
// }
userE.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
// 扫码入职时, 固定人员user表企业id变为入职的企业
userE.setCorpinfoId(cmd.getCorpinfoId());
}
userGateway.update(userE); userGateway.update(userE);
// 插入user_corp_record表 // 插入user_corp_record表

View File

@ -79,6 +79,8 @@ public interface UserRepository extends BaseRepository<UserDO> {
UserDO getByPhone(String phone); UserDO getByPhone(String phone);
UserDO getByPhoneAndCorpInfoId(String phone, Long corpInfoId);
UserDO getByPhoneAndIdCard(String phone, String idCardNumber); UserDO getByPhoneAndIdCard(String phone, String idCardNumber);
void checkUserIdCard(@NotNull(message = "主键id不能为空") Long id, String userIdCard); void checkUserIdCard(@NotNull(message = "主键id不能为空") Long id, String userIdCard);