|  |  | @ -2,14 +2,13 @@ package com.epmet.service.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.fastjson.JSONObject; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.dto.TokenDto; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.ModuleConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.ThirdPlatformConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.ThirdPlatformEventFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.WeChatPlatformAuthCodeFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.exception.AesException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.redis.RedisThird; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.ComponentVerifyTicketService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.util.OkHttpHelper; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.util.WXBizMsgCrypt; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.util.WXXmlToMapUtil; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
	
		
			
				
					|  |  | @ -18,6 +17,7 @@ import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.io.IOException; | 
			
		
	
		
			
				
					|  |  |  | import java.util.HashMap; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -33,6 +33,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private RedisThird redisThird; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private OkHttpHelper okHttpHelper; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  获得授权事件的票据 | 
			
		
	
	
		
			
				
					|  |  | @ -77,9 +79,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
			
				
					|  |  |  |             jsonObject.put(ModuleConstant.COMPONENT_APPID, PLATFORM_APP_ID); | 
			
		
	
		
			
				
					|  |  |  |             jsonObject.put(ModuleConstant.COMPONENT_APPSECRET, PLATFORM_APP_SECRET); | 
			
		
	
		
			
				
					|  |  |  |             jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); | 
			
		
	
		
			
				
					|  |  |  | //            String post = OkHttpHelper.post(API_COMPONENT_TOKEN_URl, JSON.toJSONString(jsonObject));
 | 
			
		
	
		
			
				
					|  |  |  |             String post = null; | 
			
		
	
		
			
				
					|  |  |  |             log.info("====================返回post结果:" + post); | 
			
		
	
		
			
				
					|  |  |  |             // todo OkHttpHelper  无法引入
 | 
			
		
	
		
			
				
					|  |  |  |             String post = okHttpHelper.post(API_COMPONENT_TOKEN_URl, JSON.toJSONString(jsonObject)); | 
			
		
	
		
			
				
					|  |  |  |             HashMap<String, String> hashMap = JSON.parseObject(post, HashMap.class); | 
			
		
	
		
			
				
					|  |  |  |             String componentAccessToken = hashMap.get(ModuleConstant.COMPONENT_ACCESS_TOKEN); | 
			
		
	
		
			
				
					|  |  |  |             if (StringUtils.isNotEmpty(componentAccessToken)) { | 
			
		
	
	
		
			
				
					|  |  | @ -102,18 +103,15 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
			
				
					|  |  |  |     public void preAuthCode() { | 
			
		
	
		
			
				
					|  |  |  |         log.info("====================开始执行定时任务获取预授权码【pre_auth_code】===================="); | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  | //            String accessToken = redisTemplate.opsForValue().get(ModuleConstant.COMPONENT_ACCESS_TOKEN).toString();
 | 
			
		
	
		
			
				
					|  |  |  |             String accessToken = redisThird.getComponentAccessToken(ModuleConstant.COMPONENT_ACCESS_TOKEN); | 
			
		
	
		
			
				
					|  |  |  |             JSONObject jsonObject = new JSONObject(); | 
			
		
	
		
			
				
					|  |  |  |             jsonObject.put(ModuleConstant.COMPONENT_APPID, PLATFORM_APP_ID); | 
			
		
	
		
			
				
					|  |  |  | //            String post = OkHttpHelper.post(API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject));
 | 
			
		
	
		
			
				
					|  |  |  |             String post = null; | 
			
		
	
		
			
				
					|  |  |  |             String post = okHttpHelper.post(API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)); | 
			
		
	
		
			
				
					|  |  |  |             log.info("====================返回post结果:" + post); | 
			
		
	
		
			
				
					|  |  |  |             HashMap<String, String> hashMap = JSON.parseObject(post, HashMap.class); | 
			
		
	
		
			
				
					|  |  |  |             String authCode = hashMap.get("pre_auth_code"); | 
			
		
	
		
			
				
					|  |  |  |             if (StringUtils.isNotEmpty(authCode)) { | 
			
		
	
		
			
				
					|  |  |  |                 redisThird.setPreAuthCode(authCode); | 
			
		
	
		
			
				
					|  |  |  | //                redisTemplate.opsForValue().set("pre_auth_code", authCode, 60 * 10, TimeUnit.SECONDS);
 | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |                 throw new RuntimeException("微信开放平台,第三方平台获取【预授权码】失败"); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
	
		
			
				
					|  |  | @ -133,7 +131,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
			
				
					|  |  |  |         JSONObject jsonObject = new JSONObject(); | 
			
		
	
		
			
				
					|  |  |  |         jsonObject.put(ModuleConstant.COMPONENT_APPID, PLATFORM_APP_ID); | 
			
		
	
		
			
				
					|  |  |  |         jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, authCode); | 
			
		
	
		
			
				
					|  |  |  | //        String post = OkHttpHelper.post(API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject));
 | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             String post = okHttpHelper.post(API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)); | 
			
		
	
		
			
				
					|  |  |  |         } catch (IOException e) { | 
			
		
	
		
			
				
					|  |  |  |             e.printStackTrace(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         // 重定向地址
 | 
			
		
	
		
			
				
					|  |  |  | //        response.sendRedirect("/wechat/authcode");
 | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | 
 |