|
@@ -66,13 +66,19 @@ public class WechatServiceImpl implements WechatService {
|
|
sessionObj.put("openId", openId);
|
|
sessionObj.put("openId", openId);
|
|
sessionObj.put("sessionKey", sessionKey);
|
|
sessionObj.put("sessionKey", sessionKey);
|
|
// sessionkey 保存到redis
|
|
// sessionkey 保存到redis
|
|
- redisService.setCacheObject(RedisKey.USER_OPPEN_ID_AND_SESSION_KEY_PREFIX, sessionObj.toJSONString(), 10L, TimeUnit.DAYS);
|
|
|
|
|
|
+ redisService.setCacheObject(RedisKey.USER_OPPEN_ID_AND_SESSION_KEY_PREFIX + code, sessionObj.toJSONString(), 10L, TimeUnit.DAYS);
|
|
infoJsonObject.put("unionid", authInfo.get("unionid"));
|
|
infoJsonObject.put("unionid", authInfo.get("unionid"));
|
|
infoJsonObject.put("openId", openId);
|
|
infoJsonObject.put("openId", openId);
|
|
infoJsonObject.put("sessionKey", sessionKey);
|
|
infoJsonObject.put("sessionKey", sessionKey);
|
|
return AjaxResult.successZero(infoJsonObject);
|
|
return AjaxResult.successZero(infoJsonObject);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 解析返回的状态码对应的问题
|
|
|
|
+ *
|
|
|
|
+ * @param authInfo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
private String validatWechatInfo(JSONObject authInfo) {
|
|
private String validatWechatInfo(JSONObject authInfo) {
|
|
String errMsg = "";
|
|
String errMsg = "";
|
|
int errcode = (Integer) authInfo.get("errcode");
|
|
int errcode = (Integer) authInfo.get("errcode");
|
|
@@ -90,7 +96,7 @@ public class WechatServiceImpl implements WechatService {
|
|
errMsg = "频率限制,每个用户每分钟100次";
|
|
errMsg = "频率限制,每个用户每分钟100次";
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- errMsg = "信息接口调用未知错误";
|
|
|
|
|
|
+ errMsg = (String) authInfo.get("errmsg");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
return errMsg;
|
|
return errMsg;
|
|
@@ -114,6 +120,9 @@ public class WechatServiceImpl implements WechatService {
|
|
requestUrlParam.put("grant_type", properties.getGrantType());
|
|
requestUrlParam.put("grant_type", properties.getGrantType());
|
|
// 发送post请求读取调用微信接口获取openid用户唯一标识
|
|
// 发送post请求读取调用微信接口获取openid用户唯一标识
|
|
String result = HttpClientUtils.doGet(properties.getHost(), requestUrlParam);
|
|
String result = HttpClientUtils.doGet(properties.getHost(), requestUrlParam);
|
|
|
|
+ if(StringUtils.isEmpty(result)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
return JSON.parseObject(result);
|
|
return JSON.parseObject(result);
|
|
}
|
|
}
|
|
}
|
|
}
|