| 
					
				 | 
			
			
				@@ -27,6 +27,7 @@ import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.concurrent.TimeUnit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Controller 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @RequestMapping("/demo") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -42,10 +43,6 @@ public class AppUserInfoController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private CustomerPointsService customerPointsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private RedisCacheUtil redisCacheUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private WeiXinUserUtil weiXinUserUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private AesDecryptUtil aesDecryptUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //    String appId = "wxe1135cd390b38a54";        //微信小程序appID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //    String appSecret = "0532c7d9ae876c4ad636df0b1e3b9ddb";      //微信小程序密钥 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -68,7 +65,7 @@ public class AppUserInfoController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             appSecret = map.get("appSecret");      //微信小程序密钥 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取session_key 和 openid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return weiXinUserUtil.getUserSessionKeyAndOpenID(appId, appSecret, code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return WeiXinUserUtil.getUserSessionKeyAndOpenID(appId, appSecret, code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /* 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -82,17 +79,17 @@ public class AppUserInfoController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @RequestMapping(value = "/decryptEncryptedData", method = RequestMethod.POST, consumes = "application/json") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String decryptEncryptedData(@RequestBody JSONObject jsonObject){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         logger.info("解密获取手机号前台传入参数:" +jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return aesDecryptUtil.decryptEncryptedData(jsonObject.get("encryptedData").toString(), jsonObject.get("sessionKey").toString(), jsonObject.get("iv").toString(), "UTF-8").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return AesDecryptUtil.decryptEncryptedData(jsonObject.get("encryptedData").toString(), jsonObject.get("sessionKey").toString(), jsonObject.get("iv").toString(), "UTF-8").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //获取UnionId信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @RequestMapping(value = "/getUnionIdAndAccessToken", method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //获取公众号信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping(value = "/getGzhUserInfo", method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public String redisCacheUtil(@RequestParam String openId, Integer stationId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public String getGzhUserInfo(@RequestParam String openId, Integer stationId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Gson gson =new Gson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //返回结果集 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ResultData resultData = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, String> map= new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //Map<String, String> map= new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(openId !=null && stationId !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String gzhAppId =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String gzhAppSecret =""; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -101,22 +98,9 @@ public class AppUserInfoController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(m !=null && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 gzhAppId = m.get("gzhAppId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 gzhAppSecret = m.get("gzhAppSecret"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                accessToken  = weiXinUserUtil.getTokenByRedisCache(gzhAppId, gzhAppSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                net.sf.json.JSONObject unionIdInfo = weiXinUserUtil.getUnionIdInfo(accessToken, openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(unionIdInfo !=null && unionIdInfo.containsKey("nickname")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    map.put("nickName", unionIdInfo.get("nickname").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(unionIdInfo !=null && unionIdInfo.containsKey("openid")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    map.put("openId", unionIdInfo.get("openid").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(unionIdInfo !=null && unionIdInfo.containsKey("unionid")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    map.put("unoinId", unionIdInfo.get("unionid").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                if(unionIdInfo !=null && unionIdInfo.containsKey("headimgurl")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    map.put("headImgUrl", unionIdInfo.get("headimgurl").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                map.put("accessToken", accessToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                resultData=ResultData.success(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                accessToken  = this.getTokenByRedisCache(gzhAppId, gzhAppSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                net.sf.json.JSONObject unionIdInfo = WeiXinUserUtil.getUnionIdInfo(accessToken, openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultData=ResultData.success(unionIdInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultData=ResultData.success(CodeMsg.REQUEST_FAIL); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -124,6 +108,26 @@ public class AppUserInfoController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return gson.toJson(resultData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 从Redis缓存中获取 tokenCache 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param appId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param appSecret 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public String getTokenByRedisCache(String appId, String appSecret){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        logger.info("appId参数: "+ appId+" ;appSecret参数: " +appSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String tokenCache =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!redisCacheUtil.hasKey(appId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String token = WeiXinUserUtil.getToken(appId, appSecret).getAccessToken(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisCacheUtil.setCacheObject(appId, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisCacheUtil.expire(appId, 7200, TimeUnit.SECONDS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            tokenCache = token; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            logger.info("Redis缓存中token信息: " + tokenCache); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            tokenCache = redisCacheUtil.getCacheObject(appId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return tokenCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 添加用户信息 
			 |