wangyunpeng 19 hours ago
parent
commit
6688695dd1

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/component/ManagerApiService.java

@@ -184,7 +184,7 @@ public class ManagerApiService {
         try {
             JSONObject param = new JSONObject();
             param.put("queryText", queryText);
-            param.put("configCode", "ALL");
+            param.put("configCode", "VIDEO_TITLE");
             param.put("topN", topN);
             param.put("simMin", 0.8);
             String post = httpPoolClient.post(url, param.toJSONString());

+ 17 - 6
api-module/src/main/java/com/tzld/piaoquan/api/component/TouLiuHttpClient.java

@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,10 +36,6 @@ public class TouLiuHttpClient {
         String url = baseUrl + "/ad/put/flow/add/tencent";
         UUID uuid = UUID.randomUUID();
         String experimentIdParam = (experimentId != null && !experimentId.isEmpty()) ? "&experimentId=" + experimentId : "";
-        String growthExtDataParam = "";
-        if (experimentId != null && !experimentId.isEmpty()) {
-            growthExtDataParam = "&growthExtData={\"experimentId\":\"" + experimentId + "\"}";
-        }
         String experimentIdField = (experimentId != null && !experimentId.isEmpty()) ? "\"experimentId\":\"" + experimentId + "\"," : "";
         String jsonBody = "{" +
                 "\"videoId\":\"" + videoId + "\"," +
@@ -52,11 +49,25 @@ public class TouLiuHttpClient {
                 experimentIdField +
                 "\"path\":\"" + "pages/category" + "\"," +
                 "\"requestParam\":{" +
-                "\"jumpPage\":\"" + "pages/user-videos?fromGzh=1&rootShareId=" + uuid + "&id=" + videoId + "&shareId=" + uuid + "&rootSourceId=[rootSourceId]" + experimentIdParam + growthExtDataParam + "\"" +
+                "\"jumpPage\":\"" + "pages/user-videos?fromGzh=1&rootShareId=" + uuid + "&id=" + videoId + "&shareId=" + uuid + "&rootSourceId=[rootSourceId]" + experimentIdParam + "\"" +
                 "}" +
                 "}";
         try {
-            return httpPoolClient.post(url, jsonBody);
+            String response = httpPoolClient.post(url, jsonBody);
+            // 在返回的url字段后拼接growthExtData参数(URL编码)
+            if (experimentId != null && !experimentId.isEmpty() && response != null && !response.isEmpty()) {
+                JSONObject responseJson = JSONObject.parseObject(response);
+                JSONObject data = responseJson.getJSONObject("data");
+                if (data != null && data.getString("url") != null) {
+                    String pageUrl = data.getString("url");
+                    String growthExtDataJson = "{\"experimentId\":\"" + experimentId + "\"}";
+                    pageUrl = pageUrl + "%26growthExtData%3D" + URLEncoder.encode(growthExtDataJson, "UTF-8");
+                    data.put("url", pageUrl);
+                    responseJson.put("data", data);
+                    return responseJson.toJSONString();
+                }
+            }
+            return response;
         } catch (Exception e) {
             log.error("sendAdFlowAddRequest error", e);
         }

+ 20 - 17
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java

@@ -37,6 +37,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.*;
@@ -433,22 +434,23 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         param.setTestId(experimentId);
         Map<String, String> requestParam = new HashMap<>();
         String experimentIdParam = (experimentId != null && !experimentId.isEmpty()) ? "&experimentId=" + experimentId : "";
-        String growthExtDataParam = "";
-        if (experimentId != null && !experimentId.isEmpty()) {
-            JSONObject growthExtData = new JSONObject();
-            growthExtData.put("experimentId", experimentId);
-            growthExtDataParam = "&growthExtData=" + growthExtData.toJSONString();
-        }
         String jumpPage = "pages/user-videos?fromGzh=1&rootShareId=${uuid}&id=${videoId}&shareId=${uuid}&rootSourceId=[rootSourceId]"
                 .replace("${videoId}", "" + videoId)
                 .replace("${uuid}", "" + UUID.randomUUID())
-                + experimentIdParam + growthExtDataParam;
+                + experimentIdParam;
         requestParam.put("jumpPage", jumpPage);
         param.setRequestParam(requestParam);
         String res = httpPoolClient.post(POST_ADD_TENCENT, JSONObject.toJSONString(param));
         JSONObject jsonObject = JSONObject.parseObject(res);
         JSONObject data = jsonObject.getJSONObject("data");
-        return data.getString("url");
+        String pageUrl = data.getString("url");
+        // 在返回的url字段后拼接growthExtData参数(URL编码,作为jumpPage内部参数)
+        if (experimentId != null && !experimentId.isEmpty() && pageUrl != null) {
+            JSONObject growthExtData = new JSONObject();
+            growthExtData.put("experimentId", experimentId);
+            pageUrl = pageUrl + "%26growthExtData%3D" + URLEncoder.encode(growthExtData.toJSONString(), "UTF-8");
+        }
+        return pageUrl;
     }
 
     public String selectPage(String putScene, String channel, Long videoId, String carrierId, String typeOne, String typeTwo) {
@@ -518,24 +520,25 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         param.setTestId(experimentId);
         Map<String, String> requestParam = new HashMap<>();
         String experimentIdParam = (experimentId != null && !experimentId.isEmpty()) ? "&experimentId=" + experimentId : "";
-        String growthExtDataParam = "";
-        if (experimentId != null && !experimentId.isEmpty()) {
-            JSONObject growthExtData = new JSONObject();
-            growthExtData.put("experimentId", experimentId);
-            growthExtDataParam = "&growthExtData=" + growthExtData.toJSONString();
-        }
         String jumpPage = "pages/user-videos?fromGzh=1&rootShareId=${uuid}&id=${videoId}&shareId=${uuid}&rootSourceId=[rootSourceId]"
                 .replace("${videoId}", "" + videoId)
                 .replace("${uuid}", "" + UUID.randomUUID())
-                + experimentIdParam + growthExtDataParam;
+                + experimentIdParam;
         requestParam.put("jumpPage", jumpPage);
         param.setRequestParam(requestParam);
         try {
             String res = httpPoolClient.post(POST_ADD_TENCENT, JSONObject.toJSONString(param));
             JSONObject jsonObject = JSONObject.parseObject(res);
             JSONObject data = jsonObject.getJSONObject("data");
-            return data.getString("url");
-        } catch (IOException e) {
+            String pageUrl = data.getString("url");
+            // 在返回的url字段后拼接growthExtData参数(URL编码,作为jumpPage内部参数)
+            if (experimentId != null && !experimentId.isEmpty() && pageUrl != null) {
+                JSONObject growthExtData = new JSONObject();
+                growthExtData.put("experimentId", experimentId);
+                pageUrl = pageUrl + "%26growthExtData%3D" + URLEncoder.encode(growthExtData.toJSONString(), "UTF-8");
+            }
+            return pageUrl;
+        } catch (Exception e) {
             log.error("MessageAttachmentService getPage error", e);
         }
         return null;