| 
						
						
							
								
							
						
						
					 | 
					@ -11,7 +11,6 @@ import com.epmet.common.token.constant.LoginConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.rocketmq.messages.LoginMQMsg; | 
					 | 
					 | 
					import com.epmet.commons.rocketmq.messages.LoginMQMsg; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.constant.AppClientConstant; | 
					 | 
					 | 
					import com.epmet.commons.tools.constant.AppClientConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.constant.ServiceConstant; | 
					 | 
					 | 
					import com.epmet.commons.tools.constant.ServiceConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.enums.DingMiniAppEnum; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.enums.EnvEnum; | 
					 | 
					 | 
					import com.epmet.commons.tools.enums.EnvEnum; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.EpmetErrorCode; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.EpmetErrorCode; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.EpmetException; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.EpmetException; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -800,13 +799,11 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return token; | 
					 | 
					 | 
					        return token; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    public ResiDingAppLoginResDTO resiLoginDingTemp(ResiDingAppLoginFormDTO formDTO) { | 
					 | 
					 | 
					    public ResiDingAppLoginResDTO resiLoginDingMd(ResiDingAppLoginMdFormDTO formDTO) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        // 获取用户手机号
 | 
					 | 
					 | 
					        // 获取用户手机号
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        log.info("钉钉居民端应用登录入参:"+ JSON.toJSONString(formDTO)); | 
					 | 
					 | 
					        log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO)); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        ResiDingAppLoginResDTO resDTO = null; | 
					 | 
					 | 
					        ResiDingAppLoginResDTO resDTO = null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        try { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        resDTO = new ResiDingAppLoginResDTO(); | 
					 | 
					 | 
					        resDTO = new ResiDingAppLoginResDTO(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        EnvEnum currentEnv = EnvEnum.getCurrentEnv(); | 
					 | 
					 | 
					        EnvEnum currentEnv = EnvEnum.getCurrentEnv(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) { | 
					 | 
					 | 
					        if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -815,41 +812,50 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } else if (EnvEnum.TEST.getCode().equals(currentEnv.getCode())) { | 
					 | 
					 | 
					        } else if (EnvEnum.TEST.getCode().equals(currentEnv.getCode())) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            // 最美琴岛
 | 
					 | 
					 | 
					            // 最美琴岛
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            resDTO.setCustomerId("0c41b272ee9ee95ac6f184ad548a30eb"); | 
					 | 
					 | 
					            resDTO.setCustomerId("0c41b272ee9ee95ac6f184ad548a30eb"); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                resDTO.setGridId("f896b59f3cddf1f54280546d79803652"); | 
					 | 
					 | 
					        } else { | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setGridName("抚顺社区-抚顺第一网格"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setAgencyId("f6e183d8e6687020074e6d8061926bfa"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setEpmetUserId("f838614e67cf8ae0edaefe562b6660e5"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setRegFlag(true); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            }else if(EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())||EnvEnum.DEV.getCode().equals(currentEnv.getCode())){ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            // 其余统一走开发环境
 | 
					 | 
					 | 
					            // 其余统一走开发环境
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            resDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); | 
					 | 
					 | 
					            resDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setGridId("763d6e09b9081d63195d53da84b3ae3a"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setGridName("抚顺社区-抚顺第二网格"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setAgencyId("f6e183d8e6687020074e6d8061926bfa"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setEpmetUserId("f838614e67cf8ae0edaefe562b6660e5"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                resDTO.setRegFlag(true); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            //1、获取用户手机号 todo 这里暂时没改为miniappId
 | 
					 | 
					 | 
					        // 1、获取用户手机号
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            String clientId = formDTO.getMiniAppId(); | 
					 | 
					 | 
					        DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOMd(formDTO.getMiniAppId(), formDTO.getAuthCode()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            DingTalkResult<AccessTokenResult> userAccessToken = dingTalkClientToken.getUserAccessToken(formDTO.getAuthCode(), clientId, DingMiniAppEnum.getEnum(clientId).getSuiteSecret()); | 
					 | 
					 | 
					        dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            log.info("resiLoginDing userAccessToken:{}",JSON.toJSONString(userAccessToken)); | 
					 | 
					 | 
					        // 2、调用userfeign接口获取userId、注册网格相关信息
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if (!userAccessToken.success() || null == userAccessToken.getData()) { | 
					 | 
					 | 
					        Result<DingLoginResiResDTO> loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "调用微信api异常:" + JSON.toJSONString(userAccessToken), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); | 
					 | 
					 | 
					        if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            // 临时打个日志
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.error(String.format("resiLoginDingMd获取epmetUserId异常,入参:%s,user服务返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(loginResiResDTOResult))); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:" + JSON.toJSONString(loginResiResDTOResult), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            DingTalkResult<UserBaseInfo> me = dingTalkClientUser.getUserInfo("me", userAccessToken.getData().getAccessToken()); | 
					 | 
					 | 
					        DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            log.info("resiLoginDing me:{}",JSON.toJSONString(me)); | 
					 | 
					 | 
					        resDTO.setGridId(resiResDTO.getGridId()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            resDTO.setExtInfo(JSON.toJSONString(me.getData())); | 
					 | 
					 | 
					        resDTO.setGridName(resiResDTO.getGridName()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					
 | 
					 | 
					 | 
					        resDTO.setAgencyId(resiResDTO.getAgencyId()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            // 2、调用userfeign接口获取userId、注册网格相关信息 todo
 | 
					 | 
					 | 
					        resDTO.setEpmetUserId(resiResDTO.getEpmetUserId()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        resDTO.setRegFlag(resiResDTO.getRegFlag()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        // 3.生成token,并且存放Redis
 | 
					 | 
					 | 
					        // 3.生成token,并且存放Redis
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            String token=this.saveTokenDtoDing(clientId,AppClientConstant.APP_RESI,AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); | 
					 | 
					 | 
					        String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        resDTO.setAuthorization(token); | 
					 | 
					 | 
					        resDTO.setAuthorization(token); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } catch (ApiException e) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getErrMsg(), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return resDTO; | 
					 | 
					 | 
					        return resDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private DingLoginResiFormDTO getDingLoginResiFormDTOMd(String miniAppId, String authCode) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 1、服务商获取第三方应用授权企业的access_token,文档地址:https://open.dingtalk.com/document/orgapp-server/obtains-the-enterprise-authorized-credential
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 烟台的CorpId:  dingaae55cbc47a96845f5bf40eda33b7ba0
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        DingTalkResult<String> res = dingTalkClientToken.getThirdAuthCorpAccessToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), "abc", "dingaae55cbc47a96845f5bf40eda33b7ba0"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (!res.success() || StringUtils.isBlank(res.getData())) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "服务商获取第三方应用授权企业的access_token", "服务商获取第三方应用授权企业的access_token"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // dingTalkClientToken.getTodo();
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        // dingTalkClientToken.getTodo();
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        return dingLoginResiFormDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					
  |