Browse Source

coding:投流代码提交

zhangqin 4 days ago
parent
commit
c74da64811

+ 2 - 2
fs-ad-new-api/src/main/java/com/fs/app/controller/LandingPageController.java

@@ -39,9 +39,9 @@ public class LandingPageController {
     }
 
     /**
-     * 落地页访问
+     * 小程序访问
      */
-    @PostMapping("/wx/home")
+    @PostMapping("/mini/home")
     public Result<LandingIndexRes> track(@RequestBody WeChatLandingIndexReq req) {
         return Result.success(facadeService.getWxLandingIndexBySiteId(req));
     }

+ 32 - 17
fs-ad-new-api/src/main/java/com/fs/app/controller/WeChatController.java

@@ -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"));
     }
 }

+ 3 - 3
fs-ad-new-api/src/main/java/com/fs/app/task/DataSyncTask.java

@@ -47,7 +47,7 @@ public class DataSyncTask {
      * 数据同步任务->同步昨日数据
      * cron: 每天00:10
      */
-    // @Scheduled(cron = "0 10 0 * * ?")
+    @Scheduled(cron = "0 10 0 * * ?")
     public void syncYesterdayData() {
         String batchNo = DateUtil.format(LocalDateTime.now().minusDays(1), "yyyy-MM-dd");
         statisticsService.syncData(batchNo, 1);
@@ -55,9 +55,9 @@ public class DataSyncTask {
 
     /**
      * 数据同步任务->当日数据
-     * cron: 每2小时统计站点数据
+     * cron: 每1小时统计站点数据
      */
-    // @Scheduled(cron = "0 0 0/1 * * ?")
+    @Scheduled(cron = "0 0 0/1 * * ?")
     public void syncTodayData() {
         String batchNo = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
         statisticsService.syncData(batchNo, 1);

+ 1 - 1
fs-ad-new-api/src/main/resources/application.yml

@@ -1,6 +1,6 @@
 # 开发环境配置
 server:
-  port: 8011
+  port: 7775
 # Spring配置
 spring:
   profiles: