|
@@ -40,13 +40,18 @@ public class WxGzhServiceImpl implements IWxGzhService {
|
|
|
@Override
|
|
|
public String getGzhToken() {
|
|
|
String token = "";
|
|
|
+ Integer expiresIn;
|
|
|
if (redisTemplate.hasKey(Constants.GZH_MESSAGE_TOKEN)){
|
|
|
token = (String)redisTemplate.opsForValue().get(Constants.GZH_MESSAGE_TOKEN);
|
|
|
}else if (StringUtils.isEmpty(token)){
|
|
|
String result = wxSendService.getAccessToken("client_credential",appid,secret);
|
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
|
token = json.getString("access_token");
|
|
|
- int expiresIn = json.getIntValue("expires_in");
|
|
|
+ expiresIn = json.getIntValue("expires_in");
|
|
|
+ if (expiresIn <= 0){
|
|
|
+ expiresIn = 1000;
|
|
|
+ }
|
|
|
+
|
|
|
redisTemplate.opsForValue().set(Constants.GZH_MESSAGE_TOKEN,token,expiresIn, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|