Browse Source

Merge branch 'V2.0.1' into test

zhaoxian 3 years ago
parent
commit
658e3e9ba4

+ 88 - 63
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java

@@ -120,6 +120,9 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
         //==========账户{}执行自定义上新自动创建==========start==========
         String date = DateUtils.formatDate(new Date());
         //当前需要创建广告组数量
+        if (strategy.getCustomPlanCnt() == null || strategy.getCustomUnitCnt() == null) {
+            return;
+        }
         int unitNum = strategy.getCustomPlanCnt() * strategy.getCustomUnitCnt();
         //获取自定义已创建广告组数量
         String customkey = date + "_auto_custom_cnt_" + accountId;
@@ -169,6 +172,9 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
         //==========账户{}执行自定义(高质量、打捞、遗漏)自动创建==========start==========
         String date = DateUtils.formatDate(new Date());
         //当前需要创建广告组数量
+        if (strategy.getCustomPlanCnt() == null || strategy.getCustomUnitCnt() == null) {
+            return;
+        }
         int unitNum = strategy.getCustomPlanCnt() * strategy.getCustomUnitCnt();
         //获取自定义已创建广告组数量
         String customkey = date + "_auto_custom_cnt_" + accountId;
@@ -334,7 +340,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
                     }
                     Integer unitCode = null;
                     String unitMessage = null;
-                    String unitName = getName(strategy.getGroupName(), strategy, videoType, videoItem.getPhotoName(), "unit", newCampaignId, appId, usedchannel);
+                    String unitName = getName(strategy.getGroupName(), strategy, videoType, videoItem.getPhotoName(), "unit", newCampaignId, appId, videoItem.getAutoTargetId(), usedchannel);
                     Result<Object> result = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel, videoItem.getAutoTargetId());
                     if (result.getCode() != CommonConstant.SC_OK_200) {
                         //广告组数据获取失败
@@ -497,7 +503,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
                 }
 
                 /*开始执行创建组、创意*/
-                String unitName = getName(strategy.getGroupName(), strategy, videoType, videoItem.getPhotoName(), "unit", campaignId, appId, null);
+                String unitName = getName(strategy.getGroupName(), strategy, videoType, videoItem.getPhotoName(), "unit", campaignId, appId, videoItem.getAutoTargetId(), null);
                 Result<Object> result = createUnitParams(token, campaignId, strategy, unitName, appId, null, videoItem.getAutoTargetId());
                 if (result.getCode() != CommonConstant.SC_OK_200) {
                     //广告组数据获取失败
@@ -554,6 +560,9 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
         //==========账户{}执行自定义(高质量、打捞、遗漏)自动创建==========start==========
         String date = DateUtils.formatDate(new Date());
         //当前需要创建广告组数量
+        if (strategy.getProgramPlanCnt() == null || strategy.getProgramUnitCnt() == null) {
+            return;
+        }
         int unitNum = strategy.getProgramPlanCnt() * strategy.getProgramUnitCnt();
         //获取自定义已创建广告组数量
         String programkey = date + "_auto_program_cnt_" + accountId;
@@ -746,7 +755,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
                     }
                     Integer unitCode = null;
                     String unitMessage = null;
-                    String unitName = getName(strategy.getGroupName(), strategy, videoType, null, "unit", newCampaignId, appId, usedchannel);
+                    String unitName = getName(strategy.getGroupName(), strategy, videoType, null, "unit", newCampaignId, appId, videos.get(0).getAutoTargetId(), usedchannel);
                     Result<Object> result = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel, videos.get(0).getAutoTargetId());
                     if (result.getCode() != CommonConstant.SC_OK_200) {
                         //广告组数据获取失败
@@ -916,7 +925,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
                 }
 
                 /*开始执行创建组、创意*/
-                String unitName = getName(strategy.getGroupName(), strategy, videoType, null, "unit", campaignId, appId, null);
+                String unitName = getName(strategy.getGroupName(), strategy, videoType, null, "unit", campaignId, appId, autoTargetId, null);
                 Result<Object> result = createUnitParams(token, campaignId, strategy, unitName, appId, null, autoTargetId);
                 if (result.getCode() != CommonConstant.SC_OK_200) {
                     //广告组数据获取失败
@@ -1011,7 +1020,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
 
             Integer unitCode = null;
             String unitMessage = null;
-            String unitName = getName(strategy.getGroupName(), strategy, videoType, videoItem.getPhotoName(), "unit", newCampaignId, appId, channel);
+            String unitName = getName(strategy.getGroupName(), strategy, videoType, videoItem.getPhotoName(), "unit", newCampaignId, videoItem.getAutoTargetId(), appId, channel);
             Result<Object> result = createUnitParams(token, newCampaignId, strategy, unitName, appId, channel, videoItem.getAutoTargetId());
             if (result.getCode() != CommonConstant.SC_OK_200) {
                 //广告组数据获取失败
@@ -1141,7 +1150,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
 
             Integer unitCode = null;
             String unitMessage = null;
-            String unitName = getName(strategy.getGroupName(), strategy, videoType, null, "unit", newCampaignId, appId, channel);
+            String unitName = getName(strategy.getGroupName(), strategy, videoType, null, "unit", newCampaignId, appId, videos.get(0).getAutoTargetId(), channel);
             Result<Object> result = createUnitParams(token, newCampaignId, strategy, unitName, appId, channel, videos.get(0).getAutoTargetId());
             if (result.getCode() != CommonConstant.SC_OK_200) {
                 //广告组数据获取失败
@@ -1776,7 +1785,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
             //创建一个计划
             JSONObject campaignParams = new JSONObject();
             campaignParams.put("advertiser_id", token.getAccountId());
-            String campaignName = getName(strategy.getCampaignName(), strategy, videoType, null, "plan", null, null, channel);
+            String campaignName = getName(strategy.getCampaignName(), strategy, videoType, null, "plan", null, null, null, channel);
             campaignParams.put("campaign_name", campaignName);
             campaignParams.put("type", strategy.getCampaignType());
             if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget().compareTo(BigDecimal.ZERO) != 0) {
@@ -2358,7 +2367,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
      * 替换通配符({{***}})获取有效的计划名称/组名称
      */
     private String getName(String wildcard, AiKuaishouAccountAutoStrategy strategy, Integer videoType,
-                           String materialName, String type, Long campaignId, Long appId, KuaishouChannel channel) {
+                           String materialName, String type, Long campaignId, Long appId, Long targetId, KuaishouChannel channel) {
         if (wildcard.contains("{{渠道号}}") || wildcard.contains("{{渠道号名称}}")) {
             if (Check.isNull(channel)) {
                 wildcard = wildcard.replace("{{渠道号}}", "");
@@ -2369,6 +2378,15 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
             }
         }
 
+        if (wildcard.contains("{{定向包名}}")) {
+            AiKuaishouAccountAutoTarget templateTarget = autoTargetService.getById(targetId);
+            if (!Check.isNull(templateTarget)) {
+                wildcard = wildcard.replace("{{定向包名}}", templateTarget.getTargetName());
+            } else {
+                wildcard = wildcard.replace("{{定向包名}}", "");
+            }
+        }
+
         if (wildcard.contains("{{应用名称}}") || wildcard.contains("{{应用标记}}") || wildcard.contains("{{应用包名}}")) {
             KuaiShouAppList getAppInfo = appListService.getAppInfo(strategy.getAccountId(), appId);
             if (!Check.isNull(getAppInfo)) {
@@ -2511,65 +2529,72 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
         Long accountId = strategy.getAccountId();
         //==========账户{}执行自定义上新自动创建==========start==========
         String date = DateUtils.formatDate(new Date());
-        //当前需要创建广告组数量
-        int unitNum = strategy.getCustomPlanCnt() * strategy.getCustomUnitCnt();
-        //获取自定义已创建广告组数量
-        String customkey = date + "_auto_custom_cnt_" + accountId;
-        Integer customUnitCnt = (Integer) redisUtil.get(customkey);
-        if (Check.isNull(customUnitCnt)) {
-            if (unitNum > 600) {
-                unitNum = 600;
-            }
-        } else {
-            unitNum = unitNum - customUnitCnt;
-        }
-        if (unitNum == 0) {
-            return;
-        }
-        if (unitNum > 0) {
-            // 1上新
-            log.info("-----每日补充创建 (自定义上新)账户:{},本次可建组数:{}", strategy.getAccountId(), unitNum);
-            this.autoCreateCreative(strategy, 1, unitNum);
-        }
         String material = strategy.getSourceMaterial();
-        if (unitNum > 0 && material.contains("2")) {
-            //2高质量素材
-            log.info("-----每日补充创建 (自定义高质量)账户:{},本次可建组数:{}", strategy.getAccountId(), unitNum);
-            unitNum = this.autoCreateCreative(strategy, 2, unitNum);
-        }
-        if (unitNum > 0 && material.contains("3")) {
-            //3历史遗漏
-            log.info("-----每日补充创建 (自定义历史遗漏)账户:{},本次可建组数:{}", strategy.getAccountId(), unitNum);
-            unitNum = this.autoCreateCreative(strategy, 3, unitNum);
-        }
-        if (unitNum > 0 && material.contains("4")) {
-            //4历史打捞素材
-            log.info("-----每日补充创建 (自定义历史打捞)账户:{},本次可建组数:{}", strategy.getAccountId(), unitNum);
-            this.autoCreateCreative(strategy, 4, unitNum);
-        }
 
-        int punitNum = strategy.getProgramPlanCnt() * strategy.getProgramUnitCnt();
-        String programkey = date + "_auto_program_cnt_" + accountId;
-        Integer programUnitCnt = (Integer) redisUtil.get(programkey);
-        if (Check.isNull(programUnitCnt)) {
-            if (punitNum > 300) {
-                punitNum = 300;
+        if (strategy.getCustomPlanCnt() != null && strategy.getCustomUnitCnt() != null) {
+            //当前需要创建广告组数量
+            int unitNum = strategy.getCustomPlanCnt() * strategy.getCustomUnitCnt();
+            //获取自定义已创建广告组数量
+            String customkey = date + "_auto_custom_cnt_" + accountId;
+            Integer customUnitCnt = (Integer) redisUtil.get(customkey);
+            if (Check.isNull(customUnitCnt)) {
+                if (unitNum > 600) {
+                    unitNum = 600;
+                }
+            } else {
+                unitNum = unitNum - customUnitCnt;
+            }
+            if (unitNum == 0) {
+                return;
+            }
+            if (unitNum > 0) {
+                // 1上新
+                log.info("-----每日补充创建 (自定义上新)账户:{},本次可建组数:{}", strategy.getAccountId(), unitNum);
+                this.autoCreateCreative(strategy, 1, unitNum);
+            }
+
+            if (unitNum > 0 && material.contains("2")) {
+                //2高质量素材
+                log.info("-----每日补充创建 (自定义高质量)账户:{},本次可建组数:{}", strategy.getAccountId(), unitNum);
+                unitNum = this.autoCreateCreative(strategy, 2, unitNum);
+            }
+            if (unitNum > 0 && material.contains("3")) {
+                //3历史遗漏
+                log.info("-----每日补充创建 (自定义历史遗漏)账户:{},本次可建组数:{}", strategy.getAccountId(), unitNum);
+                unitNum = this.autoCreateCreative(strategy, 3, unitNum);
+            }
+            if (unitNum > 0 && material.contains("4")) {
+                //4历史打捞素材
+                log.info("-----每日补充创建 (自定义历史打捞)账户:{},本次可建组数:{}", strategy.getAccountId(), unitNum);
+                this.autoCreateCreative(strategy, 4, unitNum);
             }
-        } else {
-            punitNum = punitNum - programUnitCnt;
-        }
-        if (punitNum == 0) {
-            return;
-        }
-        if (punitNum > 0) {
-            //1上新
-            log.info("-----每日补充创建 (程序化上新)账户:{},本次可建组数:{}", strategy.getAccountId(), punitNum);
-            unitNum = this.autoCreateProgramCreative(strategy, 1, punitNum);
         }
-        if (punitNum > 0 && material.contains("2")) {
-            log.info("-----每日补充创建 (程序化高质量)账户:{},本次可建组数:{}", strategy.getAccountId(), punitNum);
-            //2高质量素材
-            unitNum = this.autoCreateProgramCreative(strategy, 2, punitNum);
+
+        if (strategy.getProgramPlanCnt() != null && strategy.getProgramUnitCnt() != null) {
+
+            int punitNum = strategy.getProgramPlanCnt() * strategy.getProgramUnitCnt();
+            String programkey = date + "_auto_program_cnt_" + accountId;
+            Integer programUnitCnt = (Integer) redisUtil.get(programkey);
+            if (Check.isNull(programUnitCnt)) {
+                if (punitNum > 300) {
+                    punitNum = 300;
+                }
+            } else {
+                punitNum = punitNum - programUnitCnt;
+            }
+            if (punitNum == 0) {
+                return;
+            }
+            if (punitNum > 0) {
+                //1上新
+                log.info("-----每日补充创建 (程序化上新)账户:{},本次可建组数:{}", strategy.getAccountId(), punitNum);
+                punitNum = this.autoCreateProgramCreative(strategy, 1, punitNum);
+            }
+            if (punitNum > 0 && material.contains("2")) {
+                log.info("-----每日补充创建 (程序化高质量)账户:{},本次可建组数:{}", strategy.getAccountId(), punitNum);
+                //2高质量素材
+                this.autoCreateProgramCreative(strategy, 2, punitNum);
+            }
         }
     }