Commit 72cae5aa by 周晓航

修改 token的刷新机制

Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent cefeab39
...@@ -32,10 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -32,10 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
...@@ -59,6 +56,8 @@ public class WeChatLiveMsgHandle { ...@@ -59,6 +56,8 @@ public class WeChatLiveMsgHandle {
@Autowired @Autowired
private RedisCache redisCache; private RedisCache redisCache;
private List<String> refresList = Arrays.asList("42001", "40001");
/** /**
* @param orderBean * @param orderBean
* @param flag 0 支付成功 * @param flag 0 支付成功
...@@ -95,7 +94,7 @@ public class WeChatLiveMsgHandle { ...@@ -95,7 +94,7 @@ public class WeChatLiveMsgHandle {
WeChatClient weChatClient = new WeChatClient(); WeChatClient weChatClient = new WeChatClient();
WeChatBaseResponse<NullFieldVo> weChatBaseResponse = weChatClient.orderApply(accessToken, request, WeChatConstant.OrderMethod.ORDER_PAY); WeChatBaseResponse<NullFieldVo> weChatBaseResponse = weChatClient.orderApply(accessToken, request, WeChatConstant.OrderMethod.ORDER_PAY);
if ("42001".equals(weChatBaseResponse.getErrcode())) { if (refresList.contains(weChatBaseResponse.getErrcode())) {
accessToken = this.refreshAccessToken(orderBean.getAppId(), orderBean.getParentCode()); accessToken = this.refreshAccessToken(orderBean.getAppId(), orderBean.getParentCode());
weChatBaseResponse = weChatClient.orderApply(accessToken, request, WeChatConstant.OrderMethod.ORDER_PAY); weChatBaseResponse = weChatClient.orderApply(accessToken, request, WeChatConstant.OrderMethod.ORDER_PAY);
} }
...@@ -148,7 +147,7 @@ public class WeChatLiveMsgHandle { ...@@ -148,7 +147,7 @@ public class WeChatLiveMsgHandle {
} }
// 处理 token失败的情况 42001 表示 accesstoken 有问题 重新调用一遍 // 处理 token失败的情况 42001 表示 accesstoken 有问题 重新调用一遍
if ("42001".equals(weChatBaseResponse.getErrcode())) { if (refresList.contains(weChatBaseResponse.getErrcode())) {
String accessTokenNew = this.refreshAccessToken(createPrepayRequestDto.getWxAppId(), createPrepayRequestDto.getPartnerId()); String accessTokenNew = this.refreshAccessToken(createPrepayRequestDto.getWxAppId(), createPrepayRequestDto.getPartnerId());
WeChatBaseResponse<OrderCreateResponseVO> agResponse = weChatClient.orderApply(accessTokenNew, requestVO, WeChatConstant.OrderMethod.ORDER_ADD); WeChatBaseResponse<OrderCreateResponseVO> agResponse = weChatClient.orderApply(accessTokenNew, requestVO, WeChatConstant.OrderMethod.ORDER_ADD);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment