|
@@ -2,7 +2,6 @@ package com.qs.mp.framework.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.qs.mp.common.exception.ServiceException;
|
|
|
import com.qs.mp.common.qcloud.QcloudFileUtils;
|
|
|
import com.qs.mp.common.utils.LogUtil;
|
|
|
import com.qs.mp.common.utils.UUIDUtils;
|
|
@@ -33,9 +32,6 @@ public class WxUrlLinkServiceImpl implements IWxUrlLinkService {
|
|
|
@Autowired
|
|
|
private IAppTokenService appTokenService;
|
|
|
|
|
|
- @Value("${wx-channel.appId}")
|
|
|
- private String channelAppId;
|
|
|
-
|
|
|
/**
|
|
|
* 公开
|
|
|
*/
|
|
@@ -43,7 +39,7 @@ public class WxUrlLinkServiceImpl implements IWxUrlLinkService {
|
|
|
private String publicBucketName;
|
|
|
|
|
|
@Override
|
|
|
- public String generate(String path, String query) {
|
|
|
+ public String generate(String path, String query, String appId) {
|
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
|
param.put("path", path);
|
|
|
param.put("query", query);
|
|
@@ -54,7 +50,7 @@ public class WxUrlLinkServiceImpl implements IWxUrlLinkService {
|
|
|
param.put("expire_interval", 30);
|
|
|
// 云管铺小程序永久短链接https://wxaurl.cn/YL8D48CQbMr
|
|
|
// 获取access_token
|
|
|
- String accessToken = appTokenService.getAccessToken(channelAppId);
|
|
|
+ String accessToken = appTokenService.getAccessToken(appId);
|
|
|
String res = HttpUtils.sendPost(
|
|
|
"https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + accessToken,
|
|
|
JSON.toJSONString(param));
|
|
@@ -70,12 +66,12 @@ public class WxUrlLinkServiceImpl implements IWxUrlLinkService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public String generateUrlSchema(String path, String query) {
|
|
|
+ public String generateUrlSchema(String path, String query, String appId) {
|
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
|
Map<String, Object> jumpParam = new HashMap<>();
|
|
|
jumpParam.put("path", path);
|
|
|
jumpParam.put("query", query);
|
|
|
- jumpParam.put("env_version", "trial");
|
|
|
+ jumpParam.put("env_version", "release");
|
|
|
param.put("jump_wxa", jumpParam);
|
|
|
// 有效时间超过31天的 Link 或永久有效的 Link 为长期有效Link,
|
|
|
// 单个小程序总共可生成长期有效 Link 上限为10万个,请谨慎调用
|
|
@@ -84,7 +80,7 @@ public class WxUrlLinkServiceImpl implements IWxUrlLinkService {
|
|
|
param.put("expire_interval", 1);
|
|
|
// 云管铺小程序永久短链接https://wxaurl.cn/YL8D48CQbMr
|
|
|
// 获取access_token
|
|
|
- String accessToken = appTokenService.getAccessToken(channelAppId);
|
|
|
+ String accessToken = appTokenService.getAccessToken(appId);
|
|
|
String res = HttpUtils.sendPost(
|
|
|
"https://api.weixin.qq.com/wxa/generatescheme?access_token=" + accessToken,
|
|
|
JSON.toJSONString(param));
|
|
@@ -99,16 +95,16 @@ public class WxUrlLinkServiceImpl implements IWxUrlLinkService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String generateCode(String path, String scene) {
|
|
|
+ public String generateCode(String path, String scene, String appId) {
|
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
|
- param.put("path", path); // 页面路径
|
|
|
- param.put("scene", scene); // 参数
|
|
|
- param.put("check_path", false);// 为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);为 false 时允许小程序未发布或者 page 不存在
|
|
|
+ param.put("path", path + "?" + scene); // 页面路径
|
|
|
+ //param.put("scene", scene); // 参数
|
|
|
+// param.put("check_path", true);// 为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);为 false 时允许小程序未发布或者 page 不存在
|
|
|
param.put("env_version", "trial");
|
|
|
// 获取access_token
|
|
|
- String accessToken = appTokenService.getAccessToken(channelAppId);
|
|
|
+ String accessToken = appTokenService.getAccessToken(appId);
|
|
|
InputStream in = HttpUtils.sendImagePost(
|
|
|
- "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken,
|
|
|
+ "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + accessToken,
|
|
|
JSON.toJSONString(param));
|
|
|
LogUtil.info(logger, "小程序链接获取,path:{0},scene:{1}",
|
|
|
new Object[]{path, scene});
|