提交代码

dev-discount
胡锐 2 years ago
parent ff0c2b148f
commit 58f5ec6bc5
  1. 20
      hai-service/src/main/java/com/hai/config/WeChatQrcodeUtils.java

@ -113,28 +113,24 @@ public class WeChatQrcodeUtils {
object.put("action_name" , "QR_STR_SCENE");
object.put("expire_seconds" , 2592000);
object.put("action_info" , objectActionInfo);
if (redisUtil.get("WxToken") == null) {
getWxToken();
}
return HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + redisUtil.get("WxToken"), object);
return HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + getWxToken(), object);
}
// 获取微信Token存入redis
public void getWxToken() {
public String getWxToken() {
Object token = redisUtil.get("WxToken");
if (null != token) {
return token.toString();
};
// 获取access_token
Map<String, Object> params = new HashMap<>();
params.put("appid", CommonSysConst.getSysConfig().getWxH5AppId());
params.put("secret", CommonSysConst.getSysConfig().getWxH5AppSecret());
params.put("grant_type", "client_credential");
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params);
if (accessTokenObject != null && accessTokenObject.getString("access_token") != null) {
redisUtil.set("WxToken" , accessTokenObject.getString("access_token") , 7000);
}
redisUtil.set("WxToken" , accessTokenObject.getString("access_token") , 7000);
return accessTokenObject.getString("access_token");
}
/**

Loading…
Cancel
Save