| 
						
						
							
								
							
						
						
					 | 
					@ -14,7 +14,6 @@ import com.epmet.dao.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.PaCustomerUserAgencyDTO; | 
					 | 
					 | 
					import com.epmet.dto.PaCustomerUserAgencyDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.form.*; | 
					 | 
					 | 
					import com.epmet.dto.form.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.result.*; | 
					 | 
					 | 
					import com.epmet.dto.result.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.feign.EpmetUserOpenFeignClient; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.mpaes.WXBizMsgCrypt; | 
					 | 
					 | 
					import com.epmet.mpaes.WXBizMsgCrypt; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.mpaes.WXXmlToMapUtil; | 
					 | 
					 | 
					import com.epmet.mpaes.WXXmlToMapUtil; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.redis.RedisThird; | 
					 | 
					 | 
					import com.epmet.redis.RedisThird; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -77,8 +76,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Autowired | 
					 | 
					 | 
					    @Autowired | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private BusinessInfoDao businessInfoDao; | 
					 | 
					 | 
					    private BusinessInfoDao businessInfoDao; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Autowired | 
					 | 
					 | 
					    @Autowired | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private EpmetUserOpenFeignClient epmetUserOpenFeignClient; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Autowired | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private AuthResultRecordDao authResultRecordDao; | 
					 | 
					 | 
					    private AuthResultRecordDao authResultRecordDao; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Autowired | 
					 | 
					 | 
					    @Autowired | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private PaCustomerUserAgencyDao paCustomerUserAgencyDao; | 
					 | 
					 | 
					    private PaCustomerUserAgencyDao paCustomerUserAgencyDao; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -112,6 +109,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String nonce = request.getParameter(ModuleConstant.NONCE); | 
					 | 
					 | 
					            String nonce = request.getParameter(ModuleConstant.NONCE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); | 
					 | 
					 | 
					            String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String signature = request.getParameter(ModuleConstant.SIGNATURE); | 
					 | 
					 | 
					            String signature = request.getParameter(ModuleConstant.SIGNATURE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            // 从请求中读取整个post数据
 | 
					 | 
					 | 
					            // 从请求中读取整个post数据
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            InputStream inputStream; | 
					 | 
					 | 
					            InputStream inputStream; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String postData = null; | 
					 | 
					 | 
					            String postData = null; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -123,9 +121,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            // 将xml转为map
 | 
					 | 
					 | 
					            // 将xml转为map
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Map<String, String> result = WXXmlToMapUtil.xmlToMap(msg); | 
					 | 
					 | 
					            Map<String, String> result = WXXmlToMapUtil.xmlToMap(msg); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String infotype = result.get(ModuleConstant.INFO_TYPE); | 
					 | 
					 | 
					            String infotype = result.get(ModuleConstant.INFO_TYPE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.info(String.format(ThirdRunTimeInfoConstant.INFO_TYPE,infotype)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            switch (infotype){ | 
					 | 
					 | 
					            switch (infotype){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                case ModuleConstant.TICKET_UNDERLINE_KEY:   //接收票据 【component_verify_ticket】
 | 
					 | 
					 | 
					                case ModuleConstant.TICKET_UNDERLINE_KEY:   //接收票据 【component_verify_ticket】
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY); | 
					 | 
					 | 
					                    String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    log.info(String.format(COMPONENT_VERIFY_TICKET)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    // 缓存 ticket
 | 
					 | 
					 | 
					                    // 缓存 ticket
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    redisThird.setComponentVerifyTicket(ComponentVerifyTicket); | 
					 | 
					 | 
					                    redisThird.setComponentVerifyTicket(ComponentVerifyTicket); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    // 存数据库
 | 
					 | 
					 | 
					                    // 存数据库
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -139,15 +139,18 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    break; | 
					 | 
					 | 
					                    break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                case ModuleConstant.AUTHORIZED: //授权成功
 | 
					 | 
					 | 
					                case ModuleConstant.AUTHORIZED: //授权成功
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    this.disposeAuthResult(result); | 
					 | 
					 | 
					                    this.disposeAuthResult(result); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    log.info(AUTH_STATUS); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    break; | 
					 | 
					 | 
					                    break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                case ModuleConstant.UNAUTHORIZED://用户取消授权
 | 
					 | 
					 | 
					                case ModuleConstant.UNAUTHORIZED://用户取消授权
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    //todo 取消授权
 | 
					 | 
					 | 
					                    //todo 取消授权
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    String authorizerAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP); | 
					 | 
					 | 
					                    String authorizerAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    customerMpDao.updateAuthorizationFlag(authorizerAppId); | 
					 | 
					 | 
					                    customerMpDao.updateAuthorizationFlag(authorizerAppId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    this.disposeAuthResult(result); | 
					 | 
					 | 
					                    this.disposeAuthResult(result); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    log.info(REMOVE_AUTH); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    break; | 
					 | 
					 | 
					                    break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                case ModuleConstant.UPDATE_AUTHORIZED://授权变更
 | 
					 | 
					 | 
					                case ModuleConstant.UPDATE_AUTHORIZED://授权变更
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    this.disposeAuthResult(result); | 
					 | 
					 | 
					                    this.disposeAuthResult(result); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    log.info(UPDATE_AUTH); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    break; | 
					 | 
					 | 
					                    break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } catch (Exception e) { | 
					 | 
					 | 
					        } catch (Exception e) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -195,11 +198,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        //距离超时时间小于15分钟的数量
 | 
					 | 
					 | 
					        //距离超时时间小于15分钟的数量
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        Integer tokenCount = componentAccessTokenDao.selectWillOverTokenCount(); | 
					 | 
					 | 
					        Integer tokenCount = componentAccessTokenDao.selectWillOverTokenCount(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if ((tokenCount > NumConstant.ZERO && accessTokenCountFlag.equals(ModuleConstant.ACCOUNT_TOKEN_FLAG_TWO)) || accessTokenCountFlag.equals(ModuleConstant.ACCOUNT_TOKEN_FLAG_ONE)) { | 
					 | 
					 | 
					        if ((tokenCount > NumConstant.ZERO && accessTokenCountFlag.equals(ModuleConstant.ACCOUNT_TOKEN_FLAG_TWO)) || accessTokenCountFlag.equals(ModuleConstant.ACCOUNT_TOKEN_FLAG_ONE)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.info(String.format(EXIST_UPCOMING_EXPIRED)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String componentVerifyTicket = redisThird.getComponentVerifyTicket(); | 
					 | 
					 | 
					            String componentVerifyTicket = redisThird.getComponentVerifyTicket(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            JSONObject jsonObject = new JSONObject(); | 
					 | 
					 | 
					            JSONObject jsonObject = new JSONObject(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); | 
					 | 
					 | 
					            jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            jsonObject.put(ModuleConstant.COMPONENT_APPSECRET, appSecret); | 
					 | 
					 | 
					            jsonObject.put(ModuleConstant.COMPONENT_APPSECRET, appSecret); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); | 
					 | 
					 | 
					            jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.info(String.format(ThirdRunTimeInfoConstant.COMPONENT_ACCESS_TOKEN,componentVerifyTicket)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); | 
					 | 
					 | 
					            String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Map hashMap = JSON.parseObject(post, Map.class); | 
					 | 
					 | 
					            Map hashMap = JSON.parseObject(post, Map.class); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) { | 
					 | 
					 | 
					            if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -389,7 +394,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        formDTO.setExpiresInTime(expiresInTime); | 
					 | 
					 | 
					        formDTO.setExpiresInTime(expiresInTime); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        formDTO.setClientType(clientType); | 
					 | 
					 | 
					        formDTO.setClientType(clientType); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        formDTO.setCustomerId(customerId); | 
					 | 
					 | 
					        formDTO.setCustomerId(customerId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        log.info(formDTO.toString()); | 
					 | 
					 | 
					        log.info(ThirdRunTimeInfoConstant.BEGIN_DELETE_INSERT_AUTH_CODE); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        authCodeDao.deleteCustomerAuthCode(customerId,clientType); | 
					 | 
					 | 
					        authCodeDao.deleteCustomerAuthCode(customerId,clientType); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        authCodeDao.insertRedirectAuthCode(formDTO); | 
					 | 
					 | 
					        authCodeDao.insertRedirectAuthCode(formDTO); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        //authCode存缓存
 | 
					 | 
					 | 
					        //authCode存缓存
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -523,6 +528,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){ | 
					 | 
					 | 
					    public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        log.info(ThirdRunTimeInfoConstant.BEGIN_CREATE_OPEN); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); | 
					 | 
					 | 
					        Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); | 
					 | 
					 | 
					        String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        JSONObject bindInfoForm = new JSONObject(); | 
					 | 
					 | 
					        JSONObject bindInfoForm = new JSONObject(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -531,7 +537,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        Map<String,Object> bindInfo = JSON.parseObject(bindResult, Map.class); | 
					 | 
					 | 
					        Map<String,Object> bindInfo = JSON.parseObject(bindResult, Map.class); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); | 
					 | 
					 | 
					        boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (bindStatus != true) { | 
					 | 
					 | 
					        if (bindStatus != true) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            log.info(CREATE_AND_BIND_SUCCESS); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Integer authCount = customerMpDao.selectAuthCount(customerId); | 
					 | 
					 | 
					            Integer authCount = customerMpDao.selectAuthCount(customerId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String openPlatformId = null; | 
					 | 
					 | 
					            String openPlatformId = null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            if (authCount > 0) { | 
					 | 
					 | 
					            if (authCount > 0) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -655,11 +660,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @author zxc | 
					 | 
					 | 
					     * @author zxc | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     */ | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public String getLoginUserCustomerId(TokenDto tokenDto){ | 
					 | 
					 | 
					    public String getLoginUserCustomerId(TokenDto tokenDto){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        /*LoginUserDetailsFormDTO dto = new LoginUserDetailsFormDTO(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        BeanUtils.copyProperties(tokenDto,dto); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        LoginUserDetailsResultDTO data = epmetUserOpenFeignClient.getLoginUserDetails(dto).getData();*/ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        PaCustomerUserAgencyDTO result = paCustomerUserAgencyDao.selectByUserId(tokenDto.getUserId()); | 
					 | 
					 | 
					        PaCustomerUserAgencyDTO result = paCustomerUserAgencyDao.selectByUserId(tokenDto.getUserId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					//        return data.getCustomerId();
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return result.getCustomerId(); | 
					 | 
					 | 
					        return result.getCustomerId(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |