فهرست منبع

项目自动投放策略,添加日志

zhaoxian 3 سال پیش
والد
کامیت
8557283de4

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/enums/KuaishouProjectCreativeMatTypeEnum.java

@@ -9,7 +9,7 @@ public enum KuaishouProjectCreativeMatTypeEnum {
      * type字段 第一位创意创建方式,第二位素材获取方式
      * 快手创意素材获取类型
      */
-    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_NEW("41","自定义上新",-20L,-10L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_NEW("41","自定义上新",-28*60*24L,-2L),
     KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HIGH_quality("42","自定义高质量",-28*60*24L,-1*60*24L),
     KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_MISSING("43","自定义上新",-60*60*24L,-1*60*24L),
     KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HISTORY("44","自定义历史",-60*60*24L,-1*60*24L),

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

@@ -334,9 +334,10 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
                         log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
                         continue;
                     }
-                    String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, videoItem.getMaterialType());
-                    JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, videoItem, operationType);
+                    JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, appId, videoItem, operationType);
                     if (!Check.isNull(unitParams) && operationType == 2) {
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, videoItem.getMaterialType());
+                        unitParams.put("unit_name", unitName);
                         AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                         BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                         unitLevelOperationRecord.setGroupName(unitName);
@@ -361,17 +362,19 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
                             unitLevelOperationRecord.setMessage(msg);
                             if (unitCode == 0) {
                                 Long unitId = (Long) unitCreateResult.get("unitId");
+                                log.info("(accountId:{})创建自定义组({}).....success....",accountId,unitId);
                                 unitLevelOperationRecord.setUnitId(unitId);
                                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                                 videoCnt--;
                                 JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
                                 createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
-                            }
-                            if (unitCode != 0) {
+                            } else {
+                                log.info("(accountId:{})创建自定义组.....fail....{}",accountId, msg);
                                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                                 redisUtil.set(redisKey, redisValue - 1, 100000L);
                             }
                         } else {
+                            log.info("(accountId:{})创建自定义组.....fail....{}",accountId, msg);
                             unitLevelOperationRecord.setStatus(unitCode);
                             unitLevelOperationRecord.setMessage(msg);
                             unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
@@ -481,9 +484,10 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
                         }
                     }
                     //创建组
-                    String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId, null);
-                    JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, null, operationType);
-                    if (!Check.isNull(unitParams)) {
+                    JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, appId, null, operationType);
+                    if (!Check.isNull(unitParams) && operationType == 2) {
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId, null);
+                        unitParams.put("unit_name", unitName);
                         AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                         BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                         unitLevelOperationRecord.setGroupName(unitName);
@@ -508,17 +512,18 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
                             unitLevelOperationRecord.setMessage(errorMsg);
                             if (unitCode == 0) {
                                 Long unitId = (Long) unitCreateResult.get("unitId");
+                                log.info(".........程序化组创建成功 =>accountId:{};unitId:{}", accountId, unitId);
                                 unitLevelOperationRecord.setUnitId(unitId);
                                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                                 JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null);
                                 createProgramCreative(token, creativeParams, strategy);
-                            }
-                            if (unitCode != 0) {
-                                log.error("组创建失败=>accountId:{};message:{}", accountId, errorMsg);
+                            } else {
+                                log.info(".........程序化组创建失败=>accountId:{};message:{}", accountId, errorMsg);
                                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                                 redisUtil.set(redisKey, redisValue - 1, 100000L);
                             }
                         } else {
+                            log.info(".........程序化组创建失败=>accountId:{};message:{}", accountId, errorMsg);
                             unitLevelOperationRecord.setStatus(unitCode);
                             unitLevelOperationRecord.setMessage(errorMsg);
                             unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
@@ -816,7 +821,7 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
         return campaignId;
     }
 
-    private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, KuaishouProjectStrategy strategy, String unitName, Long appId, KuaiShouVideoGet videoItem, Integer operationType) {
+    private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, KuaishouProjectStrategy strategy, Long appId, KuaiShouVideoGet videoItem, Integer operationType) {
         JSONObject unitParams = null;
         try {
             // 拼装创建组的入参 json
@@ -826,7 +831,6 @@ public class AiKuaishouProjectCreateCreativeServiceImpl implements IAiKuaishouPr
             unitParams.put("unit_type", unitType);
             unitParams.put("advertiser_id", token.getAccountId());
             unitParams.put("campaign_id", campaignId);
-            unitParams.put("unit_name", unitName);
             //出价类型
             unitParams.put("bid_type", strategy.getBidType());
             if (!Check.isNull(strategy.getGroupStatus()) && strategy.getGroupStatus() == 2) {