@ -124,12 +124,12 @@ public class AppUserServiceImpl implements AppUserService {
@Override
public Result < EpdcAppAuthorizationDTO > getMpToken ( EpdcAppUserTokenFormDTO formDto ) {
return this . getTokenByOpenId ( this . getWxMaUser ( formDto . getWxCode ( ) ) ) ;
return this . getTokenByOpenId ( this . getWxMaUser ( formDto . getWxCode ( ) , formDto . getType ( ) ) ) ;
}
@Override
public Result < EpdcAppAuthorizationDTO > getMaToken ( EpdcAppUserMaTokenFormDTO formDto ) {
return this . getTokenByOpenId ( this . getWxMaUser ( formDto . getWxCode ( ) ) ) ;
return this . getTokenByOpenId ( this . getWxMaUser ( formDto . getWxCode ( ) , formDto . getType ( ) ) ) ;
}
@Override
@ -144,7 +144,7 @@ public class AppUserServiceImpl implements AppUserService {
EpdcUserSaveWxFormIdFormDTO saveFormId = new EpdcUserSaveWxFormIdFormDTO ( ) ;
saveFormId . setWxFormId ( formDto . getWxFormId ( ) ) ;
saveFormId . setWxOpenId ( this . getWxMaUser ( formDto . getWxCode ( ) ) . getOpenid ( ) ) ;
saveFormId . setWxOpenId ( this . getWxMaUser ( formDto . getWxCode ( ) , formDto . getType ( ) ) . getOpenid ( ) ) ;
return this . userFeignClient . saveWxFormId ( saveFormId ) ;
}
@ -224,6 +224,8 @@ public class AppUserServiceImpl implements AppUserService {
formDTO . setOpenId ( wxMaJscode2SessionResult . getOpenid ( ) ) ;
formDTO . setUnionId ( wxMaJscode2SessionResult . getUnionid ( ) ) ;
// Result<UserDTO> userInfoResult = userFeignClient.queryUserDto(formDTO);
logger . info ( "getToken接口调用,unionId:" + wxMaJscode2SessionResult . getUnionid ( ) ) ;
logger . info ( "getToken接口调用,openId:" + wxMaJscode2SessionResult . getOpenid ( ) ) ;
Result < CachingUserInfoDTO > userInfoResult = userFeignClient . needCachingUserInfo ( formDTO ) ;
if ( ! userInfoResult . success ( ) ) {
return new Result ( ) . error ( userInfoResult . getMsg ( ) ) ;
@ -267,7 +269,7 @@ public class AppUserServiceImpl implements AppUserService {
this . verifyUserRegisterData ( formDto ) ;
WxMaJscode2SessionResult wxMaUser = this . getWxMaUser ( formDto . getWxCode ( ) ) ;
WxMaJscode2SessionResult wxMaUser = this . getWxMaUser ( formDto . getWxCode ( ) , formDto . getType ( ) ) ;
UserDTO userDto = this . packageUserDto ( formDto , null , wxMaUser ) ;
// IP地址
HttpServletRequest request = HttpContextUtils . getHttpServletRequest ( ) ;
@ -300,7 +302,7 @@ public class AppUserServiceImpl implements AppUserService {
GridLeaderRegisterDTO leaderRegisterDto = adminResult . getData ( ) ;
// 组装用户注册信息
EpdcGridLeaderRegisterDTO gridLeaderRegister = this . packageGridLeaderWhileRegister ( leaderRegisterDto . getSysUser ( ) , formDto . getWxCode ( ) ) ;
EpdcGridLeaderRegisterDTO gridLeaderRegister = this . packageGridLeaderWhileRegister ( leaderRegisterDto . getSysUser ( ) , formDto . getWxCode ( ) , formDto . getType ( ) ) ;
List < UserGridRelationDTO > userGridList = ConvertUtils . sourceToTarget ( leaderRegisterDto . getLeaderGridList ( ) , UserGridRelationDTO . class ) ;
for ( UserGridRelationDTO item : userGridList ) {
item . setAllDeptNames ( item . getDistrict ( ) + "-" + item . getStreet ( ) + "-" + item . getCommunity ( ) + "-" + item . getGrid ( ) ) ;
@ -336,13 +338,14 @@ public class AppUserServiceImpl implements AppUserService {
*
* @param sysUser 后台管理端管理员账号
* @param wxCode
* @param formDto
* @return com . elink . esua . epdc . dto . UserDTO
* @author work @yujt.net.cn
* @date 2019 / 10 / 23 10 : 01
* /
private EpdcGridLeaderRegisterDTO packageGridLeaderWhileRegister ( SysUserDTO sysUser , String wxCode ) {
private EpdcGridLeaderRegisterDTO packageGridLeaderWhileRegister ( SysUserDTO sysUser , String wxCode , String formDto ) {
WxMaJscode2SessionResult wxMaUser = this . getWxMaUser ( wxCode ) ;
WxMaJscode2SessionResult wxMaUser = this . getWxMaUser ( wxCode , formDto ) ;
Date now = new Date ( ) ;
String mobile = sysUser . getMobile ( ) ;
@ -569,14 +572,19 @@ public class AppUserServiceImpl implements AppUserService {
* 解析微信code获取小程序用户信息
*
* @param wxCode
* @param type
* @return cn . binarywang . wx . miniapp . bean . WxMaJscode2SessionResult
* @author work @yujt.net.cn
* @date 2019 / 9 / 19 19 : 32
* /
private WxMaJscode2SessionResult getWxMaUser ( String wxCode ) {
private WxMaJscode2SessionResult getWxMaUser ( String wxCode , String type ) {
WxMaJscode2SessionResult wxMaJscode2SessionResult = null ;
try {
wxMaJscode2SessionResult = wxMaServiceUtils . normalWxMaService ( ) . jsCode2SessionInfo ( wxCode ) ;
if ( StringUtils . isNotBlank ( type ) & & "volunteer" . equals ( type ) ) {
wxMaJscode2SessionResult = wxMaServiceUtils . volunteerWxMaService ( ) . jsCode2SessionInfo ( wxCode ) ;
} else {
wxMaJscode2SessionResult = wxMaServiceUtils . normalWxMaService ( ) . jsCode2SessionInfo ( wxCode ) ;
}
} catch ( WxErrorException e ) {
log . error ( "->[getMaOpenId]::error[{}]" , "解析微信code失败" ) ;
}
@ -680,9 +688,11 @@ public class AppUserServiceImpl implements AppUserService {
@Override
public Result < EpdcAppAuthorizationDTO > getMaV2Token ( EpdcAppUserRegisterFormDTO formDto ) {
WxMaJscode2SessionResult wxMaResult = this . getWxMaUser ( formDto . getWxCode ( ) ) ;
WxMaJscode2SessionResult wxMaResult = this . getWxMaUser ( formDto . getWxCode ( ) , formDto . getType ( ) ) ;
String openId = wxMaResult . getOpenid ( ) ;
String unionId = wxMaResult . getUnionid ( ) ;
logger . info ( "getTokenV2接口调用,unionId:" + openId ) ;
logger . info ( "getTokenV2接口调用,openId:" + unionId ) ;
// if (null == formDto.getGridId()) {
// // 获取用户绑定网格信息
// Result<EpdcUserRegisterInfoResultDTO> dtoResult = userFeignClient.getUserLastSwitchGrid(openId);
@ -804,12 +814,19 @@ public class AppUserServiceImpl implements AppUserService {
userDto . setId ( tokenDto . getUserId ( ) ) ;
if ( StringUtils . isNotBlank ( infoDto . getWxCode ( ) ) ) {
String sessionKey = this . getUserSessionKey ( infoDto . getWxCode ( ) ) ;
String sessionKey = this . getUserSessionKey ( infoDto . getWxCode ( ) , infoDto . getType ( ) ) ;
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils . normalWxMaService ( ) . getUserService ( ) . getUserInfo ( sessionKey , infoDto . getEncryptedData ( ) , infoDto . getIv ( ) ) ;
if ( StringUtils . isBlank ( wxMaUserInfo . getUnionId ( ) ) ) {
return new Result ( ) . error ( "解析微信开放平台ID失败" ) ;
}
logger . info ( "完善用户信息(带验证码)接口调用,unionId:" + wxMaUserInfo . getUnionId ( ) ) ;
logger . info ( "完善用户信息(带验证码)接口调用,openId:" + wxMaUserInfo . getOpenId ( ) ) ;
userDto . setWxUnionId ( wxMaUserInfo . getUnionId ( ) ) ;
//检验志愿者去哪儿 和 居民端 用户重复问题
/ * String userId = this . checkRepeatUser ( wxMaUserInfo ) ;
if ( StringUtils . isNotBlank ( userId ) ) {
userDto . setId ( userId ) ;
} * /
}
// 党员提交,验证身份证号
@ -893,6 +910,28 @@ public class AppUserServiceImpl implements AppUserService {
//获取用户认证网格ID - 积分使用 - end
return new Result ( ) . ok ( authorizationDto ) ;
}
/ * *
* @Description 检验用户重复问题 , 并返回合并后的userId
* @Author songyunpeng
* @Date 2021 / 4 / 9
* @Param [ wxMaUserInfo ]
* @return void
* * /
private String checkRepeatUser ( WxMaUserInfo wxMaUserInfo ) {
String unionId = wxMaUserInfo . getUnionId ( ) ;
String openId = wxMaUserInfo . getOpenId ( ) ;
if ( StringUtils . isBlank ( unionId ) | | StringUtils . isBlank ( openId ) ) {
return "" ;
}
CheckRepeatUserFormDTO checkRepeatUserFormDTO = new CheckRepeatUserFormDTO ( ) ;
checkRepeatUserFormDTO . setOpenId ( openId ) ;
checkRepeatUserFormDTO . setUnionId ( unionId ) ;
Result < String > userIdResult = userFeignClient . checkRepeatUser ( checkRepeatUserFormDTO ) ;
if ( userIdResult . success ( ) ) {
userIdResult . getData ( ) ;
}
return "" ;
}
@Override
public Result < EpdcCompleteUserInfoDTO > prepareCompleteUserInfo ( TokenDto tokenDto ) {
@ -1008,7 +1047,7 @@ public class AppUserServiceImpl implements AppUserService {
if ( null = = userDetail | | StringUtils . isEmpty ( userDetail . getUserId ( ) ) ) {
return new Result ( ) . error ( "获取用户信息失败" ) ;
}
String sessionKey = this . getUserSessionKey ( formDto . getWxCode ( ) ) ;
String sessionKey = this . getUserSessionKey ( formDto . getWxCode ( ) , formDto . getType ( ) ) ;
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils . normalWxMaService ( ) . getUserService ( ) . getUserInfo ( sessionKey , formDto . getEncryptedData ( ) , formDto . getIv ( ) ) ;
// 是否需要unionId,0 否 1 是
Object requireUnionid = redisUtils . get ( "epdc:unionid:require" ) ;
@ -1062,9 +1101,14 @@ public class AppUserServiceImpl implements AppUserService {
* @author liuchuang
* @since 2019 / 10 / 25 16 : 31
* /
private String getUserSessionKey ( String code ) {
private String getUserSessionKey ( String code , String type ) {
try {
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaServiceUtils . normalWxMaService ( ) . jsCode2SessionInfo ( code ) ;
WxMaJscode2SessionResult wxMaJscode2SessionResult ;
if ( StringUtils . isNotBlank ( type ) & & "volunteer" . equals ( type ) ) {
wxMaJscode2SessionResult = wxMaServiceUtils . volunteerWxMaService ( ) . jsCode2SessionInfo ( code ) ;
} else {
wxMaJscode2SessionResult = wxMaServiceUtils . normalWxMaService ( ) . jsCode2SessionInfo ( code ) ;
}
if ( wxMaJscode2SessionResult ! = null ) {
return wxMaJscode2SessionResult . getSessionKey ( ) ;
}
@ -1348,7 +1392,9 @@ public class AppUserServiceImpl implements AppUserService {
String encryptedData = infoDto . getEncryptedData ( ) ;
if ( StringUtils . isNotBlank ( wxCode ) ) {
// 解析微信用户openid
WxMaJscode2SessionResult maJscode2SessionResult = getWxMaUser ( wxCode ) ;
WxMaJscode2SessionResult maJscode2SessionResult = getWxMaUser ( wxCode , infoDto . getType ( ) ) ;
logger . info ( "完善用户信息(不带验证码)接口调用,unionId:" + maJscode2SessionResult . getUnionid ( ) ) ;
logger . info ( "完善用户信息(不带验证码)接口调用,openId:" + maJscode2SessionResult . getOpenid ( ) ) ;
userDto . setWxOpenId ( maJscode2SessionResult . getOpenid ( ) ) ;
// 解析微信用户加密数据
if ( StringUtils . isNotBlank ( iv ) & & StringUtils . isNotBlank ( encryptedData ) ) {
@ -1368,6 +1414,11 @@ public class AppUserServiceImpl implements AppUserService {
}
userDto . setWxUnionId ( wxMaUserInfo . getUnionId ( ) ) ;
userDto . setFaceImg ( wxMaUserInfo . getAvatarUrl ( ) ) ;
//检验志愿者去哪儿 和 居民端 用户重复问题
/ * String unionUserId = this . checkRepeatUser ( wxMaUserInfo ) ;
if ( StringUtils . isNotBlank ( unionUserId ) ) {
userDto . setId ( unionUserId ) ;
} * /
}
}
EpdcCompleteAppUserDTO completeAppUserDto = ConvertUtils . sourceToTarget ( userDto , EpdcCompleteAppUserDTO . class ) ;
@ -1409,7 +1460,12 @@ public class AppUserServiceImpl implements AppUserService {
@Override
public Result < String > getUserWxPhone ( EpdcAppUserMaInfoFormDTO formDto ) {
try {
WxMaService wxMaService = wxMaServiceUtils . normalWxMaService ( ) ;
WxMaService wxMaService ;
if ( StringUtils . isNotBlank ( formDto . getType ( ) ) & & "volunteer" . equals ( formDto . getType ( ) ) ) {
wxMaService = wxMaServiceUtils . volunteerWxMaService ( ) ;
} else {
wxMaService = wxMaServiceUtils . normalWxMaService ( ) ;
}
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaService . jsCode2SessionInfo ( formDto . getWxCode ( ) ) ;
WxMaPhoneNumberInfo phoneNoInfo = wxMaService . getUserService ( ) . getPhoneNoInfo ( wxMaJscode2SessionResult . getSessionKey ( ) , formDto . getEncryptedData ( ) , formDto . getIv ( ) ) ;
if ( null ! = phoneNoInfo ) {
@ -1497,6 +1553,21 @@ public class AppUserServiceImpl implements AppUserService {
if ( StringUtils . isNotBlank ( formDto . getSmsCode ( ) ) ) {
this . checkSmsCode ( formDto . getMobile ( ) , formDto . getSmsCode ( ) ) ;
}
// 合并用户开始 ----- start
CombineVolunteerUserFormDTO combineVolunteerUserFormDTO = new CombineVolunteerUserFormDTO ( ) ;
combineVolunteerUserFormDTO . setMobile ( formDto . getMobile ( ) ) ;
combineVolunteerUserFormDTO . setUserId ( tokenDto . getUserId ( ) ) ;
Result < UserDTO > combineUserDto = userFeignClient . combineVolunteerUser ( combineVolunteerUserFormDTO ) ;
if ( combineUserDto . success ( ) & & combineUserDto . getData ( ) ! = null ) {
UserDTO userDTO = combineUserDto . getData ( ) ;
tokenDto = ConvertUtils . sourceToTarget ( userDTO , TokenDto . class ) ;
tokenDto . setUserId ( userDTO . getId ( ) ) ;
tokenDto . setGridId ( userDTO . getDeptId ( ) ) ;
}
logger . info ( "返回后的UserID userID:" + tokenDto . getUserId ( ) ) ;
// 合并用户开始 ----- end
// 此次完善信息后是否变为党员
boolean newPartyFlag = Boolean . FALSE ;