|  |  | @ -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 cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.fastjson.JSONObject; | 
			
		
	
	
		
			
				
					|  |  | @ -215,7 +217,8 @@ public class AppUserServiceImpl implements AppUserService { | 
			
		
	
		
			
				
					|  |  |  |         EpdcAppQueryUserInfoFormDTO formDTO = new EpdcAppQueryUserInfoFormDTO(); | 
			
		
	
		
			
				
					|  |  |  |         formDTO.setOpenId(wxMaJscode2SessionResult.getOpenid()); | 
			
		
	
		
			
				
					|  |  |  |         formDTO.setUnionId(wxMaJscode2SessionResult.getUnionid()); | 
			
		
	
		
			
				
					|  |  |  |         Result<UserDTO> userInfoResult = userFeignClient.queryUserDto(formDTO); | 
			
		
	
		
			
				
					|  |  |  |         // Result<UserDTO> userInfoResult = userFeignClient.queryUserDto(formDTO);
 | 
			
		
	
		
			
				
					|  |  |  |         Result<CachingUserInfoDTO> userInfoResult = userFeignClient.needCachingUserInfo(formDTO); | 
			
		
	
		
			
				
					|  |  |  |         if (!userInfoResult.success()) { | 
			
		
	
		
			
				
					|  |  |  |             return new Result().error(userInfoResult.getMsg()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  | @ -230,7 +233,7 @@ public class AppUserServiceImpl implements AppUserService { | 
			
		
	
		
			
				
					|  |  |  |      * @author work@yujt.net.cn | 
			
		
	
		
			
				
					|  |  |  |      * @date 2019/9/19 19:17 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private Result<EpdcAppAuthorizationDTO> getTokenByUserDto(UserDTO userDto) { | 
			
		
	
		
			
				
					|  |  |  |     private Result<EpdcAppAuthorizationDTO> getTokenByUserDto(CachingUserInfoDTO userDto) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         EpdcAppAuthorizationDTO authorization = new EpdcAppAuthorizationDTO(); | 
			
		
	
		
			
				
					|  |  |  |         // 用户未注册
 | 
			
		
	
	
		
			
				
					|  |  | @ -239,10 +242,11 @@ public class AppUserServiceImpl implements AppUserService { | 
			
		
	
		
			
				
					|  |  |  |             return new Result().ok(authorization); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         TokenDto tokenDto = ConvertUtils.sourceToTarget(userDto, TokenDto.class); | 
			
		
	
		
			
				
					|  |  |  |         tokenDto.setUserId(userDto.getId()); | 
			
		
	
		
			
				
					|  |  |  |         // tokenDto.setUserId(userDto.getId());
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         String state = userDto.getState(); | 
			
		
	
		
			
				
					|  |  |  |         authorization = this.packageEpdcAppAuthorization(tokenDto, userDto.getGrid(), userDto.getState()); | 
			
		
	
		
			
				
					|  |  |  |         // authorization = this.packageEpdcAppAuthorization(tokenDto, userDto.getGrid(), userDto.getState());
 | 
			
		
	
		
			
				
					|  |  |  |         authorization = this.packageEpdcAppAuthorization(tokenDto, userDto.getGrid(), state); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Result result = new Result().ok(authorization); | 
			
		
	
		
			
				
					|  |  |  |         // 已注册,未完善信息
 | 
			
		
	
	
		
			
				
					|  |  | @ -1350,4 +1354,20 @@ public class AppUserServiceImpl implements AppUserService { | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return completeResult; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @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.getPurePhoneNumber()); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } catch (WxErrorException e) { | 
			
		
	
		
			
				
					|  |  |  |             e.printStackTrace(); | 
			
		
	
		
			
				
					|  |  |  |             log.error(e.getError().getErrorMsg()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return new Result().error("解析用户手机号失败"); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |