wwl il y a 3 ans
Parent
commit
5446381b07

+ 6 - 1
twzd-service/src/main/java/com/miaxis/wx/service/impl/WxGzhServiceImpl.java

@@ -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);
         }