浏览代码

自动投放修改

yumeng 4 年之前
父节点
当前提交
2fbe0e14dd

+ 135 - 68
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouCreativeLevelOperationRecord.java

@@ -9,79 +9,146 @@ import java.util.Date;
 
 /**
  * 自定义创意创建记录
+ *
  * @author jeecg-boot
- * @date   2021-04-12
  * @version V1.0
+ * @date 2021-04-12
  */
 @Data
 @TableName("ctop_ai_kuaishou_creative_level_operation_record")
 public class AiKuaishouCreativeLevelOperationRecord {
 
-	/**创意操作表uuid*/
-	@TableId(type = IdType.ASSIGN_UUID)
-	private String creativeUuid;
-	/**AI策略ID*/
-	private String aiStrategyUuid;
-	/**账户ID*/
-	private Long accountId;
-	/**广告计划ID*/
-	private Long campaignId;
-	/**广告组ID*/
-	private Long unitId;
-	/**广告创意ID*/
-	private Long creativeId;
-	/**是否为便利贴,默认为0*/
-	private Integer isSticky;
-	/**创意名称*/
-	private String creativeName;
-	/**视频ID*/
-	private String photoId;
-	/**封面md5*/
-	private String imageMd5;
-	/**封面图片token*/
-	private String imageToken;
-	/**素材类型*/
-	private Integer creativeMaterialType;
-	/**便利贴单图图片创意token*/
-	private String imageTokens;
-	/**行动号召按钮文案*/
-	private String actionBarText;
-	/**广告语*/
-	private String description;
-	/**便利贴创意短广告语*/
-	private String shortSlogan;
-	/**封面广告语标题*/
-	private String stickerTitle;
-	/**贴纸样式类型*/
-	private String overlayType;
-	/**广告标签*/
-	private String exposeTag;
-	/**广告标签2期*/
-	private String newExposeTag;
-	/**安卓下载中间页ID*/
-	private Integer siteId;
-	/**第三方点击检测链接*/
-	private String clickTrackUrl;
-	/**第三方开始播放监测链接*/
-	private String impressionUrl;
-	/**第三方有效播放监测链接*/
-	private String adPhotoPlayedT3sUrl;
-	/**第三方点击按钮监测链接*/
-	private String actionbarClickUrl;
-	/**创意分类*/
-	private Integer creativeCategory;
-	/**创意标签*/
-	private String creativeTag;
-	/**操作类型 1-新增 2-修改*/
-	private Integer operationType;
-	/**创意创建时间*/
-	private Date creativeCreateTime;
-	/**创意更新时间*/
-	private Date creativeUpdateTime;
-	/**创建时间*/
-	private Date createTime;
-	/**状态*/
-	private Integer status;
-	/**状态详情*/
-	private String message;
+    /**
+     * 创意操作表uuid
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String creativeUuid;
+    /**
+     * AI策略ID
+     */
+    private String aiStrategyUuid;
+    /**
+     * 账户ID
+     */
+    private Long accountId;
+    /**
+     * 广告计划ID
+     */
+    private Long campaignId;
+    /**
+     * 广告组ID
+     */
+    private Long unitId;
+    /**
+     * 广告创意ID
+     */
+    private Long creativeId;
+    /**
+     * 是否为便利贴,默认为0
+     */
+    private Integer isSticky;
+    /**
+     * 创意名称
+     */
+    private String creativeName;
+    /**
+     * 视频ID
+     */
+    private String photoId;
+    /**
+     * 封面md5
+     */
+    private String imageMd5;
+    /**
+     * 封面图片token
+     */
+    private String imageToken;
+    /**
+     * 素材类型
+     */
+    private Integer creativeMaterialType;
+    /**
+     * 便利贴单图图片创意token
+     */
+    private String imageTokens;
+    /**
+     * 行动号召按钮文案
+     */
+    private String actionBarText;
+    /**
+     * 广告语
+     */
+    private String description;
+    /**
+     * 便利贴创意短广告语
+     */
+    private String shortSlogan;
+    /**
+     * 封面广告语标题
+     */
+    private String stickerTitle;
+    /**
+     * 贴纸样式类型
+     */
+    private String overlayType;
+    /**
+     * 广告标签
+     */
+    private String exposeTag;
+    /**
+     * 广告标签2期
+     */
+    private String newExposeTag;
+    /**
+     * 安卓下载中间页ID
+     */
+    private Integer siteId;
+    /**
+     * 第三方点击检测链接
+     */
+    private String clickTrackUrl;
+    /**
+     * 第三方开始播放监测链接
+     */
+    private String impressionUrl;
+    /**
+     * 第三方有效播放监测链接
+     */
+    private String adPhotoPlayedT3sUrl;
+    /**
+     * 第三方点击按钮监测链接
+     */
+    private String actionbarClickUrl;
+    /**
+     * 创意分类
+     */
+    private Integer creativeCategory;
+    /**
+     * 创意标签
+     */
+    private String creativeTag;
+    /**
+     * 操作类型 1-新增 2-修改
+     */
+    private Integer operationType;
+    /**
+     * 创意创建时间
+     */
+    private Date creativeCreateTime;
+    /**
+     * 创意更新时间
+     */
+    private Date creativeUpdateTime;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 状态
+     */
+    private Integer status;
+    /**
+     * 状态详情
+     */
+    private String message;
 }

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

@@ -416,59 +416,65 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 if (Check.isNull(allVideos)) {
                     return;
                 }
-                List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
+                List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 1);
                 for (int j = 1; j < splitVideos.size() + 1; j++) {
-                    for (int i = 0; i < appIdArray.size(); i++) {
-                        Object redisObj = redisUtil.get(key);
-                        if (!Check.isNull(redisObj)) {
-                            Integer value = (Integer) redisObj;
-                            if (value == 1) {
-                                log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
-                                return;
+                    List<KuaiShouVideoGet> kuaiShouVideoGets = splitVideos.get(j);
+                    if (Check.isNull(kuaiShouVideoGets)) {
+                        continue;
+                    }
+                    for (KuaiShouVideoGet videoGet : kuaiShouVideoGets) {
+                        for (int i = 0; i < appIdArray.size(); i++) {
+                            Object redisObj = redisUtil.get(key);
+                            if (!Check.isNull(redisObj)) {
+                                Integer value = (Integer) redisObj;
+                                if (value == 1) {
+                                    log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
+                                    return;
+                                }
                             }
-                        }
-                        Long appId = appIdArray.getLong(i);
-                        if (Check.isNull(appId)) {
-                            continue;
-                        }
-                        KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
-                        if (Check.isNull(multipleBids)) {
-                            continue;
-                        }
-                        if (!Check.isNull(multipleBids.getTrackUrl())) {
-                            strategy.setClickTrackUrl(multipleBids.getTrackUrl());
-                        }
-                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
-                        //创建组
-                        String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId);
-                        JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
-                        unitParams.remove("cpa_bid");
-                        unitParams.put("cpa_bid", multipleBids.getCpaBid());
-                        if (!Check.isNull(multipleBids.getDeepConversionBid())) {
-                            unitParams.remove("deep_conversion_bid");
-                            unitParams.put("deep_conversion_bid", multipleBids.getDeepConversionBid());
-                        }
-                        Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
-                        Integer unitCode = (Integer) unitCreateResult.get("code");
-                        String unitMessage = (String) unitCreateResult.get("message");
-                        AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
-                        BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
-                        unitLevelOperationRecord.setGroupName(unitName);
-                        unitLevelOperationRecord.setCreateTime(new Date());
-                        unitLevelOperationRecord.setStatus(unitCode);
-                        unitLevelOperationRecord.setMessage(unitMessage);
-                        unitLevelOperationRecord.setCampaignId(newCampaignId);
-                        unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
-                        if (unitCode != 0) {
-                            log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                            Long appId = appIdArray.getLong(i);
+                            if (Check.isNull(appId)) {
+                                continue;
+                            }
+                            KuaiShouAppMultipleBids multipleBids = kuaiShouAppMultipleBidsService.getInfoByAccountAndAppId(accountId, appId);
+                            if (Check.isNull(multipleBids)) {
+                                continue;
+                            }
+                            if (!Check.isNull(multipleBids.getTrackUrl())) {
+                                strategy.setClickTrackUrl(multipleBids.getTrackUrl());
+                            }
+                            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
+                            //创建组
+                            String unitName = getName(strategy.getGroupName(), strategy, createType, videoGet.getPhotoName(), "unit", newCampaignId, appId);
+                            JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
+                            unitParams.remove("cpa_bid");
+                            unitParams.put("cpa_bid", multipleBids.getCpaBid());
+                            if (!Check.isNull(multipleBids.getDeepConversionBid())) {
+                                unitParams.remove("deep_conversion_bid");
+                                unitParams.put("deep_conversion_bid", multipleBids.getDeepConversionBid());
+                            }
+                            Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
+                            Integer unitCode = (Integer) unitCreateResult.get("code");
+                            String unitMessage = (String) unitCreateResult.get("message");
+                            AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
+                            BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
+                            unitLevelOperationRecord.setGroupName(unitName);
+                            unitLevelOperationRecord.setCreateTime(new Date());
+                            unitLevelOperationRecord.setStatus(unitCode);
+                            unitLevelOperationRecord.setMessage(unitMessage);
+                            unitLevelOperationRecord.setCampaignId(newCampaignId);
+                            unitLevelOperationRecord.setAiStrategyUuid(strategyUuid);
+                            if (unitCode != 0) {
+                                log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
+                                unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
+                                continue;
+                            }
+                            Long unitId = (Long) unitCreateResult.get("unitId");
+                            unitLevelOperationRecord.setUnitId(unitId);
                             unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                            continue;
+                            JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null);
+                            createProgramCreative(token, creativeParams, strategy);
                         }
-                        Long unitId = (Long) unitCreateResult.get("unitId");
-                        unitLevelOperationRecord.setUnitId(unitId);
-                        unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null);
-                        createProgramCreative(token, creativeParams, strategy);
                     }
                 }
             }
@@ -530,6 +536,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 createProgramCreative(token, creativeParams, strategy);
             }
         }
+
     }
 
     @Override
@@ -1402,6 +1409,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         BeanUtils.copyProperties(strategy, record);
         record.setCreativeName(creativeName);
         record.setStatus(creativeCode);
+        record.setDescription(creativeParams.getString("description"));
         record.setMessage(creativeMessage);
         record.setUnitId(unitId);
         record.setAiStrategyUuid(uuid);