mirror of
https://gitee.com/gz-yami/mall4j.git
synced 2025-12-25 23:56:20 +08:00
更新到最新的wxjava工具,并修复由于未插入微信access_token导致栈溢出和httpclient连接关闭的严重问题
This commit is contained in:
parent
d435bc9c42
commit
c8896cb30c
2
pom.xml
2
pom.xml
@ -32,7 +32,7 @@
|
||||
<jsoup.version>1.11.3</jsoup.version>
|
||||
<poi.version>3.17</poi.version>
|
||||
<qiniu.version>7.2.18</qiniu.version>
|
||||
<weixin.version>3.4.0</weixin.version>
|
||||
<weixin.version>3.5.0</weixin.version>
|
||||
<orika.version>1.5.4</orika.version>
|
||||
<swagger2.version>2.9.2</swagger2.version>
|
||||
<swagger-bootstrap.version>1.9.3</swagger-bootstrap.version>
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
package com.yami.shop.mp.component;
|
||||
|
||||
import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import com.yami.shop.common.annotation.RedisLock;
|
||||
import com.yami.shop.common.util.RedisUtil;
|
||||
import com.yami.shop.mp.config.bean.WxMiniApp;
|
||||
@ -29,7 +29,7 @@ import java.util.concurrent.locks.Lock;
|
||||
* @author LGH
|
||||
*/
|
||||
@Component
|
||||
public class WxMaInRedisConfig extends WxMaInMemoryConfig {
|
||||
public class WxMaInRedisConfig extends WxMaDefaultConfigImpl {
|
||||
|
||||
private static final String ACCESS_TOKEN_KEY = "wxMa:access_token:";
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.yami.shop.common.exception.YamiShopBindException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -16,9 +17,9 @@ import java.util.concurrent.TimeUnit;
|
||||
* WxMaServiceImpl 在集群模式获取accessToken的方式
|
||||
* @author LGH
|
||||
*/
|
||||
@Slf4j
|
||||
public class WxMaServiceClusterImpl extends WxMaServiceImpl {
|
||||
|
||||
|
||||
private static final String REDISSON_LOCK_PREFIX = "redisson_lock:";
|
||||
|
||||
private RedissonClient redissonClient;
|
||||
@ -47,7 +48,7 @@ public class WxMaServiceClusterImpl extends WxMaServiceImpl {
|
||||
throw new YamiShopBindException("服务器繁忙,请稍后再试");
|
||||
}
|
||||
|
||||
if (this.getWxMaConfig().isAccessTokenExpired() && !forceRefresh) {
|
||||
if (!this.getWxMaConfig().isAccessTokenExpired()) {
|
||||
return this.getWxMaConfig().getAccessToken();
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ import com.yami.shop.common.annotation.RedisLock;
|
||||
import com.yami.shop.common.util.RedisUtil;
|
||||
import com.yami.shop.mp.config.bean.WxMp;
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import me.chanjar.weixin.mp.enums.TicketType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -26,7 +26,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author LGH
|
||||
*/
|
||||
@Component
|
||||
public class WxMpInRedisConfigStorage extends WxMpInMemoryConfigStorage {
|
||||
public class WxMpInRedisConfigStorage extends WxMpDefaultConfigImpl {
|
||||
|
||||
private static final String ACCESS_TOKEN_KEY = "wxMp:access_token:";
|
||||
|
||||
|
||||
@ -6,18 +6,19 @@ import me.chanjar.weixin.common.WxType;
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.GET_ACCESS_TOKEN_URL;
|
||||
|
||||
/**
|
||||
* WxMpServiceImpl 在集群模式获取accessToken的方式
|
||||
* @author LGH
|
||||
*/
|
||||
public class WxMpServiceClusterImpl extends WxMpServiceImpl {
|
||||
public class WxMpServiceClusterImpl extends WxMpServiceHttpClientImpl {
|
||||
|
||||
|
||||
private static final String REDISSON_LOCK_PREFIX = "redisson_lock:";
|
||||
@ -48,12 +49,10 @@ public class WxMpServiceClusterImpl extends WxMpServiceImpl {
|
||||
throw new YamiShopBindException("服务器繁忙,请稍后再试");
|
||||
}
|
||||
|
||||
if (this.getWxMpConfigStorage().isAccessTokenExpired()) {
|
||||
if (!this.getWxMpConfigStorage().isAccessTokenExpired()) {
|
||||
return this.getWxMpConfigStorage().getAccessToken();
|
||||
}
|
||||
|
||||
String url = String.format(WxMpService.GET_ACCESS_TOKEN_URL,
|
||||
this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret());
|
||||
String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(this.getWxMpConfigStorage()), this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret());
|
||||
String resultContent = HttpUtil.get(url);
|
||||
|
||||
WxError error = WxError.fromJson(resultContent, WxType.MP);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user