wwl 3 년 전
부모
커밋
5446381b07
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      twzd-service/src/main/java/com/miaxis/wx/service/impl/WxGzhServiceImpl.java

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