|  | @@ -8,14 +8,35 @@ 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.KuaiShouAppMultipleBids;
 | 
	
		
			
				|  |  | +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.IKuaiShouAppMultipleBidsService;
 | 
	
		
			
				|  |  | +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.KuaiShouAppList;
 | 
	
		
			
				|  |  |  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.IKuaiShouAppListService;
 | 
	
		
			
				|  |  | +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.IKuaiShouUpdateService;
 | 
	
		
			
				|  |  | +import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 | 
	
		
			
				|  |  | +import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 | 
	
		
			
				|  |  |  import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
 | 
	
		
			
				|  |  |  import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 | 
	
		
			
				|  |  |  import cn.com.ctop.kuaishou.modules.channel.service.IKuaishouChannelService;
 | 
	
	
		
			
				|  | @@ -33,7 +54,14 @@ import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.text.ParseException;
 | 
	
		
			
				|  |  | -import java.util.*;
 | 
	
		
			
				|  |  | +import java.util.ArrayList;
 | 
	
		
			
				|  |  | +import java.util.Collections;
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  | +import java.util.HashMap;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.Map;
 | 
	
		
			
				|  |  | +import java.util.Random;
 | 
	
		
			
				|  |  | +import java.util.UUID;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Slf4j
 | 
	
		
			
				|  |  |  @Service
 | 
	
	
		
			
				|  | @@ -299,9 +327,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
 | 
	
		
			
				|  |  |                  if (null == newCampaignId) {
 | 
	
		
			
				|  |  | -                    if (!Check.isNull(channel)) {
 | 
	
		
			
				|  |  | -                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  |                      return videoCnt;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  if (useChannel == 1) {
 | 
	
	
		
			
				|  | @@ -312,9 +337,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |                              if ("account".equals(level)) {
 | 
	
		
			
				|  |  |                                  usedchannel = channel;
 | 
	
		
			
				|  |  |                              } else {
 | 
	
		
			
				|  |  | -                                if (!Check.isNull(channel)) {
 | 
	
		
			
				|  |  | -                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  |                                  return videoCnt;
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
	
		
			
				|  | @@ -389,9 +411,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |                      if (unitCode != 0) {
 | 
	
		
			
				|  |  |                          log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
 | 
	
		
			
				|  |  |                          unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
 | 
	
		
			
				|  |  | -                        if (!Check.isNull(usedchannel)) {
 | 
	
		
			
				|  |  | -                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  |                          continue;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      Long unitId = (Long) unitCreateResult.get("unitId");
 | 
	
	
		
			
				|  | @@ -399,7 +418,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |                      unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
 | 
	
		
			
				|  |  |                      videoCnt--;
 | 
	
		
			
				|  |  |                      if (!Check.isNull(usedchannel)) {
 | 
	
		
			
				|  |  | -                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
 | 
	
		
			
				|  |  | +                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, usedchannel);//TODO 添加素材
 | 
	
		
			
				|  |  |                      createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
 | 
	
	
		
			
				|  | @@ -411,9 +430,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |              } catch (Exception e) {
 | 
	
		
			
				|  |  |                  e.printStackTrace();
 | 
	
		
			
				|  |  |                  log.error("创建自定义广告组异常", e);
 | 
	
		
			
				|  |  | -                if (!Check.isNull(usedchannel)) {
 | 
	
		
			
				|  |  | -                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return videoCnt;
 | 
	
	
		
			
				|  | @@ -667,9 +683,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
 | 
	
		
			
				|  |  |                  if (null == newCampaignId) {
 | 
	
		
			
				|  |  | -                    if (!Check.isNull(channel)) {
 | 
	
		
			
				|  |  | -                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  |                      return;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  if (useChannel == 1) {
 | 
	
	
		
			
				|  | @@ -680,9 +693,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |                              if ("account".equals(level)) {
 | 
	
		
			
				|  |  |                                  usedchannel = channel;
 | 
	
		
			
				|  |  |                              } else {
 | 
	
		
			
				|  |  | -                                if (!Check.isNull(channel)) {
 | 
	
		
			
				|  |  | -                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  |                                  return;
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
	
		
			
				|  | @@ -761,16 +771,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |                      if (unitCode != 0) {
 | 
	
		
			
				|  |  |                          log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
 | 
	
		
			
				|  |  |                          unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
 | 
	
		
			
				|  |  | -                        if (!Check.isNull(usedchannel)) {
 | 
	
		
			
				|  |  | -                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  |                          continue;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      Long unitId = (Long) unitCreateResult.get("unitId");
 | 
	
		
			
				|  |  |                      unitLevelOperationRecord.setUnitId(unitId);
 | 
	
		
			
				|  |  |                      unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
 | 
	
		
			
				|  |  |                      if (!Check.isNull(usedchannel)) {
 | 
	
		
			
				|  |  | -                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
 | 
	
		
			
				|  |  | +                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
 | 
	
		
			
				|  |  |                      createProgramCreative(token, creativeParams, strategy);
 | 
	
	
		
			
				|  | @@ -778,9 +785,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |              } catch (Exception e) {
 | 
	
		
			
				|  |  |                  e.printStackTrace();
 | 
	
		
			
				|  |  |                  log.error("创建程序化广告组异常", e);
 | 
	
		
			
				|  |  | -                if (!Check.isNull(usedchannel)) {
 | 
	
		
			
				|  |  | -                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -801,7 +805,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |          Long unitNum = customUnitCnt * hour / 20;
 | 
	
		
			
				|  |  |          log.info("{}当前时间内需要创建组总数:{}", strategy.getAccountId(), unitNum);
 | 
	
		
			
				|  |  |          //查询当前账户创建自定义类型组数量
 | 
	
		
			
				|  |  | -        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
 | 
	
		
			
				|  |  | +        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
 | 
	
		
			
				|  |  |          log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
 | 
	
		
			
				|  |  |          long remindCnt = unitNum - unitCreateCnt;
 | 
	
		
			
				|  |  |          if (remindCnt >= 1) {
 | 
	
	
		
			
				|  | @@ -834,7 +838,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          log.info("{}当天可创建组总数:{}", strategy.getAccountId(), unitNum);
 | 
	
		
			
				|  |  |          //查询当前账户创建自定义类型组数量
 | 
	
		
			
				|  |  | -        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
 | 
	
		
			
				|  |  | +        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
 | 
	
		
			
				|  |  |          log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
 | 
	
		
			
				|  |  |          long remindCnt = unitNum - unitCreateCnt;
 | 
	
		
			
				|  |  |          if (remindCnt >= 1) {
 | 
	
	
		
			
				|  | @@ -1132,7 +1136,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          campaignId = (Long) campaignCreateResult.get("campaignId");
 | 
	
		
			
				|  |  |          if (!Check.isNull(channel)) {
 | 
	
		
			
				|  |  | -            channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null, 1);
 | 
	
		
			
				|  |  | +            channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          record.setCampaignId(campaignId);
 | 
	
		
			
				|  |  |          aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);
 |