|
|
@ -945,10 +945,65 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
// 验证身份证号格式,身份证号码字符串校正
|
|
|
|
String identityNo = fixAndCheckIdentityNo(infoDto.getIdentityNo(), infoDto.getPartyFlag()); |
|
|
|
infoDto.setIdentityNo(identityNo); |
|
|
|
return completeUserInfoNormally(tokenDto, infoDto); |
|
|
|
|
|
|
|
Result<UserDTO> completeResult = completeUserInfoCore(tokenDto, infoDto); |
|
|
|
UserDTO user = completeResult.getData(); |
|
|
|
|
|
|
|
// 更新用户缓存信息
|
|
|
|
Result<CachingUserInfoDTO> cachingUserResult = userFeignClient.needCachingUserInfoByUserId(tokenDto.getUserId()); |
|
|
|
CachingUserInfoDTO cachingUserInfoDTO = cachingUserResult.getData(); |
|
|
|
EpdcAppAuthorizationDTO authorizationDto = cachingUserInfoForAuthorization(cachingUserInfoDTO, user.getGrid(), user.getState()); |
|
|
|
|
|
|
|
// 党员认证失败
|
|
|
|
if (100006001 == completeResult.getCode()) { |
|
|
|
authorizationDto.setResultCode(YesOrNoEnum.YES.value()); |
|
|
|
authorizationDto.setResultMsg(completeResult.getMsg()); |
|
|
|
return new Result().ok(authorizationDto); |
|
|
|
} |
|
|
|
// 更新社群用户党员标识并加入关联的所有网格党员群
|
|
|
|
boolean partyFlag = UserTagUtils.containIdentity(cachingUserInfoDTO.getUserTagInfos(), UserTagEnum.PARTY_MEMBER); |
|
|
|
if (partyFlag) { |
|
|
|
initPartyGroupInfo(cachingUserInfoDTO); |
|
|
|
} |
|
|
|
return new Result().ok(authorizationDto); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private EpdcAppAuthorizationDTO cachingUserInfoForAuthorization(CachingUserInfoDTO cachingUserInfo, String userGrid, String userState) { |
|
|
|
TokenDto newTokenDto = ConvertUtils.sourceToTarget(cachingUserInfo, TokenDto.class); |
|
|
|
return this.packageEpdcAppAuthorization(newTokenDto, userGrid, userState); |
|
|
|
} |
|
|
|
|
|
|
|
private Result<EpdcAppAuthorizationDTO> completeUserInfoNormally(TokenDto tokenDto, EpdcCompleteUserInfoFormV2DTO infoDto) { |
|
|
|
/** |
|
|
|
* 认证为党员后,更新社群用户党员标识并加入关联的所有网格党员群 |
|
|
|
* |
|
|
|
* @param cachingUserInfo |
|
|
|
* @return void |
|
|
|
* @author work@yujt.net.cn |
|
|
|
* @date 2020/4/23 18:29 |
|
|
|
*/ |
|
|
|
private void initPartyGroupInfo(CachingUserInfoDTO cachingUserInfo) { |
|
|
|
GroupUserPartyMemberFormDTO formDto = new GroupUserPartyMemberFormDTO(); |
|
|
|
formDto.setUserId(cachingUserInfo.getUserId()); |
|
|
|
formDto.setPartyMember(YesOrNoEnum.YES.value()); |
|
|
|
formDto.setNickname(cachingUserInfo.getNickname()); |
|
|
|
formDto.setUserAvatar(cachingUserInfo.getFaceImg()); |
|
|
|
formDto.setMobile(cachingUserInfo.getMobile()); |
|
|
|
formDto.setDeptId(cachingUserInfo.getGridId()); |
|
|
|
formDto.setState(GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
groupFeignClient.updateUserPartyMember(formDto); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 完善个人信息 |
|
|
|
* |
|
|
|
* @param tokenDto 当前token信息 |
|
|
|
* @param infoDto 表单提交信息 |
|
|
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UserDTO> |
|
|
|
* @author work@yujt.net.cn |
|
|
|
* @date 2020/4/23 18:30 |
|
|
|
*/ |
|
|
|
private Result<UserDTO> completeUserInfoCore(TokenDto tokenDto, EpdcCompleteUserInfoFormV2DTO infoDto) { |
|
|
|
String userId = tokenDto.getUserId(); |
|
|
|
// 验证手机号身份证号是否已被注册,若未被注册,返回当前用户的状态
|
|
|
|
String userState = checkMobileAndIdentityNo(userId, infoDto.getMobile(), infoDto.getPartyFlag(), infoDto.getIdentityNo()); |
|
|
@ -965,36 +1020,9 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
|
|
|
|
// 用户认证失败,且不是因为党员匹配失败(未知异常导致流程出错)
|
|
|
|
if (!completeResult.success() && 100006001 != completeResult.getCode()) { |
|
|
|
return new Result().error(completeResult.getMsg()); |
|
|
|
} |
|
|
|
// 完善信息后的用户状态
|
|
|
|
userState = completeResult.getData().getState(); |
|
|
|
// 更新用户缓存信息
|
|
|
|
Result<CachingUserInfoDTO> cachingUserResult = userFeignClient.needCachingUserInfoByUserId(tokenDto.getUserId()); |
|
|
|
CachingUserInfoDTO cachingUserInfoDTO = cachingUserResult.getData(); |
|
|
|
TokenDto newTokenDto = ConvertUtils.sourceToTarget(cachingUserInfoDTO, TokenDto.class); |
|
|
|
EpdcAppAuthorizationDTO authorizationDto = this.packageEpdcAppAuthorization(newTokenDto, String.valueOf(gridId), userState); |
|
|
|
|
|
|
|
// 党员认证失败
|
|
|
|
if (100006001 == completeResult.getCode()) { |
|
|
|
authorizationDto.setResultCode(YesOrNoEnum.YES.value()); |
|
|
|
authorizationDto.setResultMsg(completeResult.getMsg()); |
|
|
|
return new Result().ok(authorizationDto); |
|
|
|
} |
|
|
|
// 更新社群用户党员标识并加入关联的所有网格党员群
|
|
|
|
boolean partyFlag = UserTagUtils.containIdentity(cachingUserInfoDTO.getUserTagInfos(), UserTagEnum.PARTY_MEMBER); |
|
|
|
if (partyFlag) { |
|
|
|
GroupUserPartyMemberFormDTO formDto = new GroupUserPartyMemberFormDTO(); |
|
|
|
formDto.setUserId(cachingUserInfoDTO.getUserId()); |
|
|
|
formDto.setPartyMember(YesOrNoEnum.YES.value()); |
|
|
|
formDto.setNickname(cachingUserInfoDTO.getNickname()); |
|
|
|
formDto.setUserAvatar(cachingUserInfoDTO.getFaceImg()); |
|
|
|
formDto.setMobile(cachingUserInfoDTO.getMobile()); |
|
|
|
formDto.setDeptId(cachingUserInfoDTO.getGridId()); |
|
|
|
formDto.setState(GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
groupFeignClient.updateUserPartyMember(formDto); |
|
|
|
throw new RenException(completeResult.getMsg()); |
|
|
|
} |
|
|
|
return new Result().ok(authorizationDto); |
|
|
|
return completeResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1274,6 +1302,14 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private UserDTO getUserInfoById(String userId) { |
|
|
|
Result<UserDTO> userResult = userFeignClient.getUserInfoById(userId); |
|
|
|
if (!userResult.success() || null == userResult.getData()) { |
|
|
|
throw new RenException("查询用户信息失败"); |
|
|
|
} |
|
|
|
return userResult.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 志愿者认证 |
|
|
|
* |
|
|
@ -1284,35 +1320,65 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
* @date 2019/12/13 14:41 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Result volunteerAuthenticate(TokenDto tokenDto, EpdcCompleteVolunteerInfoFormDTO formDto) { |
|
|
|
public Result |
|
|
|
volunteerAuthenticate(TokenDto tokenDto, EpdcCompleteVolunteerInfoFormDTO formDto) { |
|
|
|
logger.info("志愿者认证wxCode=" + formDto.getWxCode() + ";userId=" + tokenDto.getUserId()); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(formDto.getSmsCode())) { |
|
|
|
this.checkSmsCode(formDto.getMobile(), formDto.getSmsCode()); |
|
|
|
} |
|
|
|
|
|
|
|
// 验证是否为志愿者
|
|
|
|
Result<Integer> volunteerCountResult = userFeignClient.getVolunteerCountById(tokenDto.getUserId()); |
|
|
|
if (!volunteerCountResult.success() || null == volunteerCountResult.getData()) { |
|
|
|
return new Result().error("志愿者认证失败"); |
|
|
|
} else if (volunteerCountResult.getData() == 0) { |
|
|
|
// 是否为志愿者
|
|
|
|
boolean volunteerFlag = UserTagUtils.containIdentity(tokenDto.getUserTagInfos(), UserTagEnum.VOLUNTEER); |
|
|
|
// 当前是否为党员
|
|
|
|
boolean partyFlag = UserTagUtils.containIdentity(tokenDto.getUserTagInfos(), UserTagEnum.PARTY_MEMBER); |
|
|
|
// 此次完善信息后是否变为党员
|
|
|
|
boolean newPartyFlag = Boolean.FALSE; |
|
|
|
|
|
|
|
UserDTO user = getUserInfoById(tokenDto.getUserId()); |
|
|
|
if (!volunteerFlag) { |
|
|
|
// 处理和验证身份证号码
|
|
|
|
String identityNo = fixAndCheckIdentityNo(formDto.getIdentityNo()); |
|
|
|
formDto.setSex(IdentityNoUtils.getSex(identityNo)); // 性别
|
|
|
|
formDto.setBirthday(DateUtils.parse(IdentityNoUtils.getBirthday(identityNo), DateUtils.DATE_PATTERN)); // 生日
|
|
|
|
formDto.setUserId(tokenDto.getUserId()); // 用户ID
|
|
|
|
// 添加志愿者
|
|
|
|
String realName = ModuleUtils.replaceIllegalCharacter(formDto.getRealName()); |
|
|
|
if (partyFlag) { |
|
|
|
// 如果是党员,不再进行完善个人信息处理
|
|
|
|
if (!user.getIdentityNo().equals(identityNo) || !user.getRealName().equals(realName)) { |
|
|
|
return new Result().error("姓名或身份证号码有误,请核实信息"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 非党员,调用用户完善个人信息接口
|
|
|
|
EpdcCompleteUserInfoFormV2DTO epdcCompleteUserInfoFormDTO = ConvertUtils.sourceToTarget(formDto, EpdcCompleteUserInfoFormV2DTO.class); |
|
|
|
// set 党员标识,将志愿者完善信息视为党员完善信息,方便身份证号码唯一校验等操作
|
|
|
|
epdcCompleteUserInfoFormDTO.setPartyFlag(YesOrNoEnum.YES.value()); |
|
|
|
epdcCompleteUserInfoFormDTO.setUserAuthType(UserAuthTypeEnum.VOLUNTEER_AUTH.value()); |
|
|
|
Result<UserDTO> result = completeUserInfoCore(tokenDto, epdcCompleteUserInfoFormDTO); |
|
|
|
|
|
|
|
UserDTO completeUser = result.getData(); |
|
|
|
user.setGrid(completeUser.getGrid()); |
|
|
|
user.setState(completeUser.getState()); |
|
|
|
if (YesOrNoEnum.YES.value().equals(completeUser.getPartyFlag())) { |
|
|
|
newPartyFlag = Boolean.TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
formDto.setSex(IdentityNoUtils.getSex(identityNo)); |
|
|
|
formDto.setBirthday(DateUtils.parse(IdentityNoUtils.getBirthday(identityNo), DateUtils.DATE_PATTERN)); |
|
|
|
formDto.setUserId(tokenDto.getUserId()); |
|
|
|
// 新增志愿者
|
|
|
|
Result<Integer> insertCountResult = userFeignClient.insertVolunteerInfo(formDto); |
|
|
|
if (!insertCountResult.success()) { |
|
|
|
return insertCountResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 调用用户完善个人信息-保存
|
|
|
|
EpdcCompleteUserInfoFormV2DTO epdcCompleteUserInfoFormDTO = ConvertUtils.sourceToTarget(formDto, EpdcCompleteUserInfoFormV2DTO.class); |
|
|
|
// set 党员标识,将志愿者完善信息视为党员完善信息,方便身份证号码唯一校验等操作
|
|
|
|
epdcCompleteUserInfoFormDTO.setPartyFlag(YesOrNoEnum.YES.value()); |
|
|
|
epdcCompleteUserInfoFormDTO.setUserAuthType(UserAuthTypeEnum.VOLUNTEER_AUTH.value()); |
|
|
|
Result<EpdcAppAuthorizationDTO> result = completeUserInfoNormally(tokenDto, epdcCompleteUserInfoFormDTO); |
|
|
|
// 更新用户缓存信息
|
|
|
|
Result<CachingUserInfoDTO> cachingUserResult = userFeignClient.needCachingUserInfoByUserId(tokenDto.getUserId()); |
|
|
|
CachingUserInfoDTO cachingUserInfoDTO = cachingUserResult.getData(); |
|
|
|
|
|
|
|
EpdcAppAuthorizationDTO authorizationDto = cachingUserInfoForAuthorization(cachingUserInfoDTO, user.getGrid(), user.getState()); |
|
|
|
if (!partyFlag && newPartyFlag) { |
|
|
|
initPartyGroupInfo(cachingUserInfoDTO); |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
return new Result().ok(authorizationDto); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1337,79 +1403,6 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/*private Result<EpdcAppAuthorizationDTO> completeUserInfoNoVerifyCode(TokenDto tokenDto, EpdcCompleteUserInfoFormDTO infoDto) { |
|
|
|
|
|
|
|
UserDTO userDto = ConvertUtils.sourceToTarget(infoDto, UserDTO.class); |
|
|
|
userDto.setDeptId(Long.valueOf(infoDto.getGridId())); |
|
|
|
userDto.setId(tokenDto.getUserId()); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(infoDto.getWxCode())) { |
|
|
|
String sessionKey = this.getUserSessionKey(infoDto.getWxCode()); |
|
|
|
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.normalWxMaService().getUserService().getUserInfo(sessionKey, infoDto.getEncryptedData(), infoDto.getIv()); |
|
|
|
if (StringUtils.isBlank(wxMaUserInfo.getUnionId())) { |
|
|
|
return new Result().error("解析微信开放平台ID失败"); |
|
|
|
} |
|
|
|
userDto.setWxUnionId(wxMaUserInfo.getUnionId()); |
|
|
|
userDto.setWxOpenId(wxMaUserInfo.getOpenId()); |
|
|
|
} |
|
|
|
|
|
|
|
// 党员提交,验证身份证号
|
|
|
|
if (YesOrNoEnum.YES.value().equals(userDto.getPartyFlag())) { |
|
|
|
String identityNo = userDto.getIdentityNo(); |
|
|
|
if (StringUtils.isBlank(identityNo)) { |
|
|
|
return new Result().error("身份证号不能为空"); |
|
|
|
} else { |
|
|
|
String verification = IdentityNoUtils.IdentityNoVerification(identityNo); |
|
|
|
if (StringUtils.isNotBlank(verification)) { |
|
|
|
return new Result().error(verification); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 验证手机号验证码
|
|
|
|
//this.checkSmsCode(userDto.getMobile(), infoDto.getSmsCode());
|
|
|
|
// 验证用户提交的信息
|
|
|
|
Result<String> verifyResult = userFeignClient.verifyUserCompleteData(userDto); |
|
|
|
if (!verifyResult.success()) { |
|
|
|
return new Result().error(verifyResult.getMsg()); |
|
|
|
} |
|
|
|
String userState = verifyResult.getData(); |
|
|
|
|
|
|
|
UserGridRelationDTO userGrid = this.packageUserGridRelationInfo(infoDto.getGridId()); |
|
|
|
EpdcCompleteAppUserDTO completeAppUserDto = ConvertUtils.sourceToTarget(userDto, EpdcCompleteAppUserDTO.class); |
|
|
|
completeAppUserDto = this.packageUserCompleteInfo(completeAppUserDto, userState); |
|
|
|
// 组装对象,准备保存用户信息
|
|
|
|
EpdcAppUserCompleteInfoFormDTO dto = new EpdcAppUserCompleteInfoFormDTO(); |
|
|
|
dto.setCompleteAppUser(completeAppUserDto); |
|
|
|
dto.setUserGridRelation(userGrid); |
|
|
|
|
|
|
|
Result<UserDTO> completeResult = userFeignClient.completeUserInfo(dto); |
|
|
|
if (!completeResult.success()) { |
|
|
|
return new Result().error(completeResult.getMsg()); |
|
|
|
} |
|
|
|
UserDTO user = completeResult.getData(); |
|
|
|
tokenDto.setRealName(user.getRealName()); |
|
|
|
tokenDto.setNickname(user.getNickname()); |
|
|
|
tokenDto.setMobile(user.getMobile()); |
|
|
|
EpdcAppAuthorizationDTO authorizationDto = this.packageEpdcAppAuthorization(tokenDto, userGrid.getGrid(), userDto.getState()); |
|
|
|
|
|
|
|
// 更新社群用户党员标识并加入关联的所有网格党员群
|
|
|
|
if (NumConstant.ONE_STR.equals(user.getPartyFlag())) { |
|
|
|
GroupUserPartyMemberFormDTO formDto = new GroupUserPartyMemberFormDTO(); |
|
|
|
formDto.setUserId(user.getId()); |
|
|
|
formDto.setPartyMember(user.getPartyFlag()); |
|
|
|
formDto.setNickname(user.getNickname()); |
|
|
|
formDto.setUserAvatar(user.getFaceImg()); |
|
|
|
formDto.setMobile(user.getMobile()); |
|
|
|
formDto.setDeptId(user.getGridId()); |
|
|
|
formDto.setState(GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
|
|
|
|
groupTask.updateUserPartyMember(formDto); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result().ok(authorizationDto); |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<String> getUserWxPhone(EpdcAppUserMaInfoFormDTO formDto) { |
|
|
|
try { |
|
|
|