|
|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.elink.esua.epdc.service.impl; |
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; |
|
|
|
import com.elink.esua.epdc.async.GroupTask; |
|
|
|
import com.elink.esua.epdc.common.token.dto.TokenDto; |
|
|
|
@ -23,6 +25,7 @@ import com.elink.esua.epdc.dto.epdc.result.EpdcUserRegisterInfoResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserInfoResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.UserInvitationRecordResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.*; |
|
|
|
import com.elink.esua.epdc.dto.form.v2.EpdcCompleteUserInfoFormV2DTO; |
|
|
|
import com.elink.esua.epdc.dto.group.form.GroupUserFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.group.form.GroupUserPartyMemberFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.result.EpdcAppRegisterCallbackDTO; |
|
|
|
@ -777,16 +780,11 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
return userDto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<EpdcAppAuthorizationDTO> completeUserInfo(TokenDto tokenDto, EpdcCompleteUserInfoFormDTO infoDto) { |
|
|
|
private Result<EpdcAppAuthorizationDTO> completeUserInfo(TokenDto tokenDto, UserDTO userDto, String wxCode, String encryptedData, String iv, String smsCode) { |
|
|
|
|
|
|
|
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.isNotBlank(wxCode)) { |
|
|
|
String sessionKey = this.getUserSessionKey(wxCode); |
|
|
|
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.normalWxMaService().getUserService().getUserInfo(sessionKey, encryptedData, iv); |
|
|
|
if (StringUtils.isBlank(wxMaUserInfo.getUnionId())) { |
|
|
|
return new Result().error("解析微信开放平台ID失败"); |
|
|
|
} |
|
|
|
@ -808,7 +806,9 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
userDto.setIdentityNo(null); |
|
|
|
} |
|
|
|
// 验证手机号
|
|
|
|
this.checkSmsCode(userDto.getMobile(), infoDto.getSmsCode()); |
|
|
|
if (StringUtils.isNotBlank(smsCode)) { |
|
|
|
this.checkSmsCode(userDto.getMobile(), smsCode); |
|
|
|
} |
|
|
|
// 验证用户提交的信息
|
|
|
|
Result<String> verifyResult = userFeignClient.verifyUserCompleteData(userDto); |
|
|
|
if (!verifyResult.success()) { |
|
|
|
@ -816,7 +816,7 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
} |
|
|
|
String userState = verifyResult.getData(); |
|
|
|
|
|
|
|
UserGridRelationDTO userGrid = this.packageUserGridRelationInfo(infoDto.getGridId()); |
|
|
|
UserGridRelationDTO userGrid = this.packageUserGridRelationInfo(userDto.getDeptId()); |
|
|
|
EpdcCompleteAppUserDTO completeAppUserDto = ConvertUtils.sourceToTarget(userDto, EpdcCompleteAppUserDTO.class); |
|
|
|
completeAppUserDto = this.packageUserCompleteInfo(completeAppUserDto, userState); |
|
|
|
// 组装对象,准备保存用户信息
|
|
|
|
@ -854,12 +854,28 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
formDto.setState(GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
|
|
|
|
groupFeignClient.updateUserPartyMember(formDto); |
|
|
|
// groupTask.updateUserPartyMember(formDto);
|
|
|
|
} |
|
|
|
|
|
|
|
return new Result().ok(authorizationDto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<EpdcAppAuthorizationDTO> completeUserInfo(TokenDto tokenDto, EpdcCompleteUserInfoFormDTO infoDto) { |
|
|
|
UserDTO userDto = ConvertUtils.sourceToTarget(infoDto, UserDTO.class); |
|
|
|
userDto.setDeptId(infoDto.getGridId()); |
|
|
|
userDto.setId(tokenDto.getUserId()); |
|
|
|
return this.completeUserInfo(tokenDto, userDto, infoDto.getWxCode(), infoDto.getEncryptedData(), infoDto.getIv(), infoDto.getSmsCode()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<EpdcAppAuthorizationDTO> completeUserInfo(TokenDto tokenDto, EpdcCompleteUserInfoFormV2DTO infoDto) { |
|
|
|
UserDTO userDto = ConvertUtils.sourceToTarget(infoDto, UserDTO.class); |
|
|
|
userDto.setDeptId(infoDto.getGridId()); |
|
|
|
userDto.setId(tokenDto.getUserId()); |
|
|
|
return this.completeUserInfo(tokenDto, userDto, infoDto.getWxCode(), infoDto.getEncryptedData(), infoDto.getIv(), null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<EpdcCompleteUserInfoDTO> prepareCompleteUserInfo(TokenDto tokenDto) { |
|
|
|
|
|
|
|
@ -1082,4 +1098,20 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<String> getUserWxPhone(EpdcAppUserMaInfoFormDTO formDto) { |
|
|
|
try { |
|
|
|
WxMaService wxMaService = wxMaServiceUtils.normalWxMaService(); |
|
|
|
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(formDto.getWxCode()); |
|
|
|
WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(wxMaJscode2SessionResult.getSessionKey(), formDto.getEncryptedData(), formDto.getIv()); |
|
|
|
if (null != phoneNoInfo) { |
|
|
|
return new Result().ok(phoneNoInfo.getPhoneNumber()); |
|
|
|
} |
|
|
|
} catch (WxErrorException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error(e.getError().getErrorMsg()); |
|
|
|
} |
|
|
|
return new Result().error("解析用户手机号失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|