|
|
@@ -1,12 +1,13 @@
|
|
|
package com.fs.app.controller;
|
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.app.facade.CallbackProcessingFacadeService;
|
|
|
-import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.constant.SystemConstant;
|
|
|
import com.fs.common.result.Result;
|
|
|
-import com.fs.common.utils.http.HttpUtils;
|
|
|
import com.fs.wx.miniapp.config.WxMaProperties;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -14,6 +15,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* 广告商监测链接
|
|
|
*
|
|
|
@@ -32,21 +36,32 @@ public class WeChatController {
|
|
|
|
|
|
@GetMapping("/getSchemeUrl")
|
|
|
public Result<String> getSchemeUrl(@RequestParam(value = "traceId") String traceId) {
|
|
|
-/* String appId = properties.getConfigs().get(0).getAppid();
|
|
|
- String secret = properties.getConfigs().get(0).getSecret();
|
|
|
- String rspStr = HttpUtils.sendGet("https://api.weixin.qq.com/cgi-bin/token", "grant_type=client_credential&" + "appid=" + appId + "&secret=" + secret);
|
|
|
- JSONObject obj = JSONObject.parseObject(rspStr);
|
|
|
+ String appId = "wx0447a16ef6199f03";
|
|
|
+ String secret = "f063fcd818e31d4c89013a67f5123990";
|
|
|
+ HttpResponse execute2 = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token")
|
|
|
+ .form("grant_type", "client_credential")
|
|
|
+ .form("appid", appId)
|
|
|
+ .form("secret", secret)
|
|
|
+ .timeout(SystemConstant.API_TIMEOUT)
|
|
|
+ .execute();
|
|
|
+ JSONObject obj = JSONObject.parseObject(execute2.body());
|
|
|
String access_token = obj.getString("access_token");
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- JSONObject jump_wxaObj = new JSONObject();
|
|
|
- jump_wxaObj.put("path", "/pages_company/card");
|
|
|
- jump_wxaObj.put("query", "traceId=" + traceId);
|
|
|
- jsonObject.put("jump_wxa", jump_wxaObj);
|
|
|
- jsonObject.put("is_expire", false);
|
|
|
- String paramStr = jsonObject.toJSONString();
|
|
|
- String postStr = HttpUtils.sendPost("https://api.weixin.qq.com/wxa/generatescheme?access_token=" + access_token, paramStr);
|
|
|
- obj = JSONObject.parseObject(postStr);*/
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map2 = new HashMap<>();
|
|
|
+ map2.put("path", "/pages/shopping/productDetails");
|
|
|
+ map2.put("query", "traceId=" + traceId);
|
|
|
+ //map2.put("env_version", "trial");
|
|
|
+ map.put("jump_wxa", map2);
|
|
|
+ map.put("is_expire", false);
|
|
|
+ HttpResponse execute = HttpRequest.post("https://api.weixin.qq.com/wxa/generatescheme?access_token=" + access_token)
|
|
|
+ .header("Content-Type", "application/json")
|
|
|
+ .body(JSONUtil.toJsonStr(map))
|
|
|
+ .timeout(SystemConstant.API_TIMEOUT)
|
|
|
+ .execute();
|
|
|
+ log.info("getSchemeUrl:{}", execute.body());
|
|
|
+ obj = JSONObject.parseObject(execute.body());
|
|
|
//response.addHeader("Access-Control-Allow-Origin", "*");
|
|
|
- return Result.success("weixin://dl/business/?t=GqPFu1oh2fn");
|
|
|
+ return Result.success(obj.getString("openlink"));
|
|
|
}
|
|
|
}
|