|
@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.PubFun;
|
|
import com.fs.common.utils.PubFun;
|
|
@@ -106,6 +107,11 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
|
|
@Autowired
|
|
@Autowired
|
|
CloudHostProper cloudHostProper;
|
|
CloudHostProper cloudHostProper;
|
|
|
|
|
|
|
|
+ private static String TOKEN_VALID_CODE = "40001";
|
|
|
|
+
|
|
|
|
+ private static Integer version = 0;
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询短链
|
|
* 查询短链
|
|
*
|
|
*
|
|
@@ -746,6 +752,10 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
|
|
@Override
|
|
@Override
|
|
public String getGotoWxAppLink(String linkStr,String appId) {
|
|
public String getGotoWxAppLink(String linkStr,String appId) {
|
|
CloseableHttpClient client = null;
|
|
CloseableHttpClient client = null;
|
|
|
|
+ if(ObjectUtils.isNull(appId)){
|
|
|
|
+ appId="wx76cb55db092a41ae";
|
|
|
|
+ }
|
|
|
|
+
|
|
try {
|
|
try {
|
|
client = HttpClients.createDefault();
|
|
client = HttpClients.createDefault();
|
|
String[] split = linkStr.split("\\?");
|
|
String[] split = linkStr.split("\\?");
|
|
@@ -782,6 +792,18 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
|
|
String responseString = EntityUtils.toString(response);
|
|
String responseString = EntityUtils.toString(response);
|
|
log.info("微信小程序接口响应数据:{}", responseString);
|
|
log.info("微信小程序接口响应数据:{}", responseString);
|
|
JSONObject jsonObject = JSONObject.parseObject(responseString);
|
|
JSONObject jsonObject = JSONObject.parseObject(responseString);
|
|
|
|
+
|
|
|
|
+ if(TOKEN_VALID_CODE.equals(jsonObject.getString("code"))){
|
|
|
|
+ Integer curVersion = Integer.valueOf(version);
|
|
|
|
+ synchronized (TOKEN_VALID_CODE){
|
|
|
|
+ if(curVersion.equals(version)){
|
|
|
|
+ wxService.getAccessToken(true);
|
|
|
|
+ version = version.equals(Integer.MAX_VALUE) ? 0 : curVersion + 1;
|
|
|
|
+ }
|
|
|
|
+ return getGotoWxAppLink(linkStr,appId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if(null != jsonObject && !jsonObject.isEmpty() && jsonObject.containsKey("url_link")){
|
|
if(null != jsonObject && !jsonObject.isEmpty() && jsonObject.containsKey("url_link")){
|
|
return jsonObject.getString("url_link");
|
|
return jsonObject.getString("url_link");
|
|
}
|
|
}
|