Ver código fonte

广告组落地页绑定逻辑

zhaoxian 4 anos atrás
pai
commit
bde23ab139

+ 42 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -8,13 +8,30 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
-import cn.com.ctop.kuaishou.modules.ai.entity.*;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCampaignLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCreativeLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
-import cn.com.ctop.kuaishou.modules.ai.service.*;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCampaignLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreativeLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouUnitLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -26,7 +43,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.text.ParseException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 @Slf4j
 @Service
@@ -57,7 +79,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     private IAiKuaishouUnitLevelOperationRecordService unitLevelOperationRecordService;
     @Autowired
     private IAiKuaishouCreativeLevelOperationRecordService creativeLevelOperationRecordService;
-
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
 
     /**
      * 创建自定义创意
@@ -444,6 +467,20 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             return;
         }
         log.info("创建程序化创意成功");
+        createLandPageAndUnit(creativeParams, resultJson.getJSONObject("data"));
+    }
+
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONObject data) {
+        if (!Check.isNull(data) && !Check.isNull(programJson.getLong("site_id"))) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    landpagePackageService.createLandPageAndUnit(programJson.getLong("site_id"), data.getLong("creative_id"), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
+                }
+            };
+            thread.start();
+        }
     }
 
     private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt, String appVersion) {

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

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
@@ -46,6 +47,8 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
     private IKuaiShouVideoGetService videoGetService;
     @Autowired
     private IKuaiShouGroupTemplateService groupTemplateService;
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
 
     @Value("${ai.callback.callback-unit-url}")
     private String unitUrl;
@@ -455,6 +458,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 if (resultJson.getInteger("code") == 0) {
                     returnJson.put("code", 0);
                     returnJson.put("message", "程序化创意创建成功");
+                    createLandPageAndUnit(programJson, resultJson.getJSONObject("data"));
                 } else {
                     log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", oauthToken.getAccountId(), resultJson.getString("message"), programCreativeJson);
                     returnJson.put("code", -1);
@@ -475,6 +479,18 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
         callback(creativeUrl, returnArray, "program_create");
     }
 
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONObject data) {
+        if (!Check.isNull(data) && !Check.isNull(programJson.getLong("site_id"))) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    landpagePackageService.createLandPageAndUnit(programJson.getLong("site_id"), data.getLong("creative_id"), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
+                }
+            };
+            thread.start();
+        }
+    }
 
     /**
      * 回调

+ 20 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java

@@ -7,7 +7,9 @@ import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.utils.RandomUtil;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.service.ICrossAccountBatchService;
@@ -50,6 +52,10 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
     private IKuaishouDirectionalPackageService directionalPackageService;
     @Autowired
     private IKuaishouPopulationGroupService populationGroupService;
+    @Autowired
+    private IKuaishouAppPackageService appPackageService;
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
 
     /**
      * 组装数据  jason
@@ -573,7 +579,7 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                                 try {
                                     Thread.sleep(100);
                                     kuaishouInterfaceService.getCreativeByCreativeIds(accessToken, advertiserId, add_creative_ids);
-
+                                    createLandPageAndUnit(requestJson, add_creative_ids);
                                 } catch (InterruptedException e) {
                                     e.printStackTrace();
                                 }
@@ -624,6 +630,19 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
 
     }
 
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONArray add_creative_ids) {
+        JSONArray creatives = programJson.getJSONArray("creatives");
+        if (creatives != null && !creatives.isEmpty()) {
+            JSONObject jsonObject = creatives.getJSONObject(0);
+            if (!Check.isNull(jsonObject)) {
+                for (Object creativeId : add_creative_ids) {
+                    landpagePackageService.createLandPageAndUnit(jsonObject.getLong("site_id"), Long.valueOf(String.valueOf(creativeId)), jsonObject.getLong("unit_id"), jsonObject.getLong("advertiser_id"));
+                }
+            }
+        }
+    }
+
     /**
      * 通用组创建数据组装
      *

+ 20 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -4,7 +4,9 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignDayBudget;
@@ -63,7 +65,10 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
     private IKuaishouDirectionalPackageService directionalPackageService;
     @Autowired
     private IKuaishouPopulationGroupService populationGroupService;
-
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+    @Autowired
+    private IKuaishouAppPackageService appPackageService;
     @Override
     public Map<String, Object> updateCampaign(String token, Long advertiserId, Long campaignId, Long dayBudget, String loginId) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -699,6 +704,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         try {
                             Thread.sleep(200);
                             interfaceService.getCreativeByCreativeId(accessToken, creativeJson.getLong("advertiser_id"), data.getLong("creative_id"));
+                            createLandPageAndUnit(creativeJson, resultJson.getJSONObject("data"));
                         } catch (InterruptedException e) {
                             e.printStackTrace();
                         }
@@ -725,6 +731,19 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
         return returnJson;
     }
 
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONObject data) {
+        if (!Check.isNull(data) && !Check.isNull(programJson.getLong("site_id"))) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    landpagePackageService.createLandPageAndUnit(programJson.getLong("site_id"), data.getLong("creative_id"), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
+                }
+            };
+            thread.start();
+        }
+    }
+
     @Override
     public Map<String, Object> updateUnitDeepConversionBid(String accessToken, Long accountId, Long unitId, Long deepConversionBid, String userId) {
 

+ 21 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -15,7 +15,9 @@ import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiCreativeLimitService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
@@ -117,6 +119,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     KuaishouReportDailyCampaignMapper dailyCampaignMapper;
     @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
+    @Autowired
     private KuaiShouGroupMapper groupMapper;
     @Autowired
     private IKuaiShouCreativeService creativeService;
@@ -2055,6 +2059,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                 try {
                                     Thread.sleep(100);
                                     getCreativeByCreativeId(accessToken, advertiserId, creativeId);
+                                    //绑定落地页与广告组、创意的关系
+                                    if (!Check.isNull(requestJson.getLong("site_id"))) {
+                                        landpagePackageService.createLandPageAndUnit(requestJson.getLong("site_id"), creativeId, requestJson.getLong("unit_id"), advertiserId);
+                                    }
                                 } catch (InterruptedException e) {
                                     e.printStackTrace();
                                 }
@@ -2139,6 +2147,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     try {
                                         Thread.sleep(100);
                                         getCreativeByCreativeIds(accessToken, advertiserId, add_creative_ids);
+                                        createLandPageAndUnit(requestJson, add_creative_ids);
                                     } catch (InterruptedException e) {
                                         e.printStackTrace();
                                     }
@@ -2191,6 +2200,18 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONArray add_creative_ids) {
+        JSONArray creatives = programJson.getJSONArray("creatives");
+        if (creatives != null && !creatives.isEmpty()) {
+            JSONObject jsonObject = creatives.getJSONObject(0);
+            if (!Check.isNull(jsonObject)) {
+                for (Object creativeId : add_creative_ids) {
+                    landpagePackageService.createLandPageAndUnit(jsonObject.getLong("site_id"), Long.valueOf(String.valueOf(creativeId)), jsonObject.getLong("unit_id"), jsonObject.getLong("advertiser_id"));
+                }
+            }
+        }
+    }
 
     /**
      * 获取视频信息

+ 17 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouProgramCreativeServiceImpl.java

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouProgramCreativeMapper;
@@ -45,6 +46,8 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
     @Autowired
     private IMaterialCutFrameService materialCutFrameService;
 
+    @Autowired
+    private IKuaishouLandpagePackageService landpagePackageService;
 
     @Override
     public void getProgramCreative(Long accountId, Long unitId, String accessToken, String startDate, String endDate, Integer page) {
@@ -194,6 +197,7 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
                 if (code == 0) {
                     returnJson.put("isTrueOrFalse", true);
                     returnJson.put("message", "创建成功");
+                    createLandPageAndUnit(pramsJson,jsonObject.getJSONObject("data"));
                 } else {
                     log.error("创建失败:入参:{}", pramsJson);
                     returnJson.put("isTrueOrFalse", false);
@@ -212,6 +216,19 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
         return returnJson;
     }
 
+    //绑定落地页与广告组、创意的关系
+    private void createLandPageAndUnit(JSONObject programJson, JSONObject data) {
+        if (!Check.isNull(data) && !Check.isNull(programJson.getLong("site_id"))) {
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    landpagePackageService.createLandPageAndUnit(programJson.getLong("site_id"), data.getLong("creative_id"), programJson.getLong("unit_id"), programJson.getLong("advertiser_id"));
+                }
+            };
+            thread.start();
+        }
+    }
+
     @Override
     public JSONArray getProgramCreativeCover(JSONArray md5Arr) {