Kaynağa Gözat

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-boot

zhaoxian 4 yıl önce
ebeveyn
işleme
2b79e4458d

+ 4 - 0
jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -286,3 +286,7 @@ bytedance:
     ad-report-get: /2/report/ad/get/
     ad-creative-get: /2/report/creative/get/
     advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+ai:
+  callback:
+    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
+    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative

+ 4 - 0
jeecg-boot-module-system/src/main/resources/application-jiaoyang.yml

@@ -244,3 +244,7 @@ bytedance:
     ad-report-get: /2/report/ad/get/
     ad-creative-get: /2/report/creative/get/
     advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+ai:
+  callback:
+    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
+    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative

+ 4 - 0
jeecg-boot-module-system/src/main/resources/application-prod.yml

@@ -257,3 +257,7 @@ bytedance:
     ad-report-get: /2/report/ad/get/
     ad-creative-get: /2/report/creative/get/
     advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+ai:
+  callback:
+    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
+    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative

+ 4 - 0
jeecg-boot-module-system/src/main/resources/application-prod2.yml

@@ -249,3 +249,7 @@ bytedance:
     ad-report-get: /2/report/ad/get/
     ad-creative-get: /2/report/creative/get/
     advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+ai:
+  callback:
+    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
+    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative

+ 4 - 0
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -240,3 +240,7 @@ bytedance:
     ad-report-get: /2/report/ad/get/
     ad-creative-get: /2/report/creative/get/
     advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+ai:
+  callback:
+    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
+    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative

+ 5 - 1
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -103,7 +103,7 @@ spring:
   #redis 配置
   redis:
     database: 0
-#    host: 172.30.0.17
+    #    host: 172.30.0.17
     host: 127.0.0.1
     lettuce:
       pool:
@@ -234,4 +234,8 @@ bytedance:
     ad-report-get: /2/report/ad/get/
     ad-creative-get: /2/report/creative/get/
     advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+ai:
+  callback:
+    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
+    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative
 

+ 0 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreateController.java

@@ -83,7 +83,6 @@ public class KuaiShouCreateController {
             JSONObject data = new JSONObject();
             data.put("account_id", requestJson.getLong("account_id"));
             result.put("data", data);
-
         }
         return result;
     }
@@ -125,11 +124,7 @@ public class KuaiShouCreateController {
             JSONObject data = new JSONObject();
             data.put("account_id", requestJson.getLong("account_id"));
             result.put("data", data);
-
         }
         return result;
-
     }
-
-
 }

+ 44 - 34
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java

@@ -15,6 +15,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.Map;
@@ -32,26 +33,32 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
     private IMaterialCutFrameService cutFrameService;
     @Autowired
     private IKuaiShouMaterialUploadService uploadService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+
+    @Value("${ai.callback.callback-unit-url}")
+    private String unitUrl;
+    @Value("${ai.callback.callback-creative-url}")
+    private String creativeUrl;
 
     @Override
     public void createUnitAndCreative(CtopOauthToken oauthToken, Long campaign_id, JSONArray group_list) {
-
         JSONArray returnArr = new JSONArray();
-        try {
-            for (int i = 0; i < group_list.size(); i++) {
-                JSONObject groupCreateJson = group_list.getJSONObject(i);
-                if (Check.isNull(groupCreateJson)) {
-                    continue;
-                }
+        for (int i = 0; i < group_list.size(); i++) {
+            JSONObject groupCreateJson = group_list.getJSONObject(i);
+            if (Check.isNull(groupCreateJson)) {
+                continue;
+            }
+            String group_uuid = groupCreateJson.getString("group_uuid");
+            try {
                 JSONObject createJson = new JSONObject();
                 createJson.put("advertiser_id", oauthToken.getAccountId());
                 createJson.put("campaign_id", campaign_id);
                 createJson.put("unit_name", groupCreateJson.getString("unit_name")); // 组名称
-                createJson.put("bid_type", groupCreateJson.getString("bid_type")); // 组名称
+                createJson.put("bid_type", groupCreateJson.getString("bid_type")); // 出价类型
                 if (!Check.isNull(groupCreateJson.getInteger("use_app_market"))) {
                     createJson.put("use_app_market", groupCreateJson.getInteger("use_app_market")); // 优先从系统应用商店下载
                 }
-
                 if (!Check.isNull(groupCreateJson.getJSONArray("app_store"))) {
                     createJson.put("app_store", groupCreateJson.getJSONArray("app_store")); //应用商店列表
                 }
@@ -140,7 +147,6 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 if (!Check.isNull(groupCreateJson.getBoolean("auto_create_photo"))) {
                     createJson.put("auto_create_photo", groupCreateJson.getBoolean("auto_create_photo")); //是否开启自动生成视频
                 }
-
                 if (!Check.isNull(groupCreateJson.getLong("item_id"))) {
                     createJson.put("item_id", groupCreateJson.getLong("item_id")); //电商关联Id (小店通)
                 }
@@ -160,7 +166,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 }
                 Map<String, Object> unitMap = iKuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), createJson, 1);
                 JSONObject returnJson = new JSONObject();
-                returnJson.put("table_id", groupCreateJson.getLong("table_id"));
+                returnJson.put("group_uuid", group_uuid);
                 if ((Integer) unitMap.get("code") == 0) {
                     Long unitId = (Long) unitMap.get("unitId");
                     returnJson.put("unit_id", unitId);
@@ -182,18 +188,18 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     returnJson.put("message", unitMap.get("message"));
                 }
                 returnArr.add(returnJson);
+            } catch (Exception e) {
+                JSONObject returnJson = new JSONObject();
+                returnJson.put("group_uuid", group_uuid);
+                returnJson.put("code", -1);
+                returnJson.put("message", e.getMessage());
+                returnArr.add(returnJson);
             }
-            callback("http://192.168.1.193:31012/ai_callback_add_group", returnArr);
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("创建组错误!!!!!");
         }
+        callback(unitUrl, returnArr, "unit");
     }
 
 
-    @Autowired
-    private IKuaiShouVideoGetService videoGetService;
-
     /**
      * 创建广告创意
      *
@@ -203,12 +209,13 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
      */
     private void createCreative(CtopOauthToken oauthToken, Long unit_id, JSONArray creative_list) {
         JSONArray returnArr = new JSONArray();
-        try {
-            for (int i = 0; i < creative_list.size(); i++) {
-                JSONObject creativeJson = creative_list.getJSONObject(i);
-                if (Check.isNull(creativeJson)) {
-                    continue;
-                }
+        for (int i = 0; i < creative_list.size(); i++) {
+            JSONObject creativeJson = creative_list.getJSONObject(i);
+            if (Check.isNull(creativeJson)) {
+                continue;
+            }
+            String creative_uuid = creativeJson.getString("creative_uuid");
+            try {
                 JSONObject createJson = new JSONObject();
                 createJson.put("advertiser_id", oauthToken.getAccountId());
                 createJson.put("unit_id", unit_id);
@@ -279,7 +286,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 }
                 Map<String, Object> creativeMap = iKuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), createJson, 1);
                 JSONObject returnJson = new JSONObject();
-                returnJson.put("table_id", creativeJson.getLong("table_id"));
+                returnJson.put("creative_uuid", creative_uuid);
                 if ((Integer) creativeMap.get("code") == 0) {
                     Long creativeId = (Long) creativeMap.get("creativeId");
                     returnJson.put("creative_id", creativeId);
@@ -291,19 +298,25 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     returnJson.put("message", creativeMap.get("message"));
                 }
                 returnArr.add(returnJson);
+            } catch (Exception e) {
+                e.printStackTrace();
+                JSONObject returnJson = new JSONObject();
+                returnJson.put("creative_uuid", creative_uuid);
+                returnJson.put("message", e.getMessage());
+                returnJson.put("code", -1);
+                returnArr.add(returnJson);
             }
-            callback("http://192.168.1.193:31012/ai_callback_add_creative", returnArr);
-        } catch (Exception e) {
-            e.printStackTrace();
         }
+        callback(creativeUrl, returnArr, "creative");
+
     }
 
-    private void callback(String url, JSONArray requestArr) {
+    private void callback(String url, JSONArray requestArr, String type) {
         JSONObject requestJson = new JSONObject();
         requestJson.put("callbackData", requestArr);
         String s = HttpUtils2.httpPostRequest(url, requestJson, null);
         JSONObject jsonObject = JSONObject.parseObject(s);
-        log.info("回调数据返回结果:{}", jsonObject);
+        log.info("{},回调数据返回结果:{}", type, jsonObject);
     }
 
     private String getImageToken(String md5, Long accountId, String accessToken) {
@@ -320,12 +333,10 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
             if (!Check.isNull(cutFrame)) {
                 imageToken = uploadService.kuauiShouImageUpload(cutFrame.getUrl(), md5, accountId, accessToken);
             }
-
         }
         return imageToken;
     }
 
-
     private JSONObject getTarget(JSONObject unitJson) {
         JSONObject target = new JSONObject();
         if (!Check.isNull(unitJson.getJSONArray("region"))) {
@@ -344,7 +355,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
             target.put("age", age); //自定义年龄段
         }
         if (!Check.isNull(unitJson.getJSONArray("ages_range"))) {
-            target.put("ages_range", unitJson.getInteger("ages_range")); // 固定年龄段
+            target.put("ages_range", unitJson.getJSONArray("ages_range")); // 固定年龄段
         }
         if (!Check.isNull(unitJson.getInteger("gender"))) {
             target.put("gender", unitJson.getInteger("gender")); // 性别
@@ -410,7 +421,6 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 intelli_extend.put("no_area_break", unitJson.getInteger("no_area_break")); //  不可突破地域
             }
             target.put("intelli_extend", intelli_extend); // 智能扩量
-
         }
         if (Check.isNull(unitJson.getJSONObject("behavior_interest"))) {
             // TODO 只是单独结构体 后续需要优化