diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/domain/vo/WxAccessTokenRet.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/domain/vo/WxAccessTokenRet.java index aab11bb..20bf0c3 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/domain/vo/WxAccessTokenRet.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/domain/vo/WxAccessTokenRet.java @@ -6,14 +6,14 @@ package com.flossom.miniProgram.domain.vo; public class WxAccessTokenRet { private String access_token; - private String expires_in; + private Integer expires_in; private Integer errcode; private String errmsg; public WxAccessTokenRet() { } - public WxAccessTokenRet(String access_token, String expires_in, Integer errcode, String errmsg) { + public WxAccessTokenRet(String access_token, Integer expires_in, Integer errcode, String errmsg) { this.access_token = access_token; this.expires_in = expires_in; this.errcode = errcode; @@ -28,11 +28,11 @@ public class WxAccessTokenRet { this.access_token = access_token; } - public String getExpires_in() { + public Integer getExpires_in() { return expires_in; } - public void setExpires_in(String expires_in) { + public void setExpires_in(Integer expires_in) { this.expires_in = expires_in; } diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxUserMemberServiceImpl.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxUserMemberServiceImpl.java index a8e7614..073024c 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxUserMemberServiceImpl.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxUserMemberServiceImpl.java @@ -186,7 +186,9 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService { throw new ServiceException("用户不存在"); } int floatScore = 0; + Boolean isCompleteInformation = false; if (wxUserMember.getIsCompleteInformation() == null || wxUserMember.getIsCompleteInformation() == 0) { + isCompleteInformation = true; // 修改完善状态 wxUserMember.setIsCompleteInformation(1); List integralGlobalList = integralGlobalMapper.selectIntegralGlobalList(new IntegralGlobal()); @@ -212,7 +214,7 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService { // 刷新用户信息 LoginUserVo loginUserVo = refreshWxUserInfo(); - if (wxUserMember.getIsCompleteInformation() == 1) { + if (isCompleteInformation) { loginUserVo.setIntegralText("您已完善个人信息,获得" + floatScore + "积分"); } return loginUserVo; diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/MiniProgramUtils.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/MiniProgramUtils.java index 205e873..5411824 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/MiniProgramUtils.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/MiniProgramUtils.java @@ -125,9 +125,12 @@ public class MiniProgramUtils { logger.error("获取 access_token 失败: {}", wxAccessTokenRet.getErrmsg()); return null; } - // 保存缓存 - redisService.setCacheObject(cacheKey, - wxAccessTokenRet.getAccess_token(), CacheConstants.WX_ACCESS_TOKEN_EXPIRATION, TimeUnit.MINUTES); + // 保存缓存,按照返回的有效期来缓存,如果没有有效期则临时使用一次 + if (wxAccessTokenRet.getExpires_in() != null && wxAccessTokenRet.getExpires_in() > 0) { + Integer minutes = wxAccessTokenRet.getExpires_in() / 60; + redisService.setCacheObject(cacheKey, + wxAccessTokenRet.getAccess_token(), minutes.longValue(), TimeUnit.MINUTES); + } return wxAccessTokenRet.getAccess_token(); } return accessToken;