|
@@ -8,35 +8,14 @@ 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.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.entity.*;
|
|
|
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.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.ai.service.*;
|
|
|
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.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.batch.service.*;
|
|
|
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;
|
|
@@ -54,14 +33,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
-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;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -302,12 +274,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
appName = appInfo.getAppName();
|
|
|
}
|
|
|
}
|
|
|
+ KuaishouChannel channel = null;
|
|
|
+ KuaishouChannel usedchannel = null;
|
|
|
+ Long newCampaignId = null;
|
|
|
//渠道号应用层级,account-账户,plan-计划,group-组
|
|
|
String level = strategy.getUsageLevel();
|
|
|
Integer useChannel = strategy.getUseChannel();//0不使用,1使用
|
|
|
- KuaishouChannel channel = null;
|
|
|
- if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
|
|
|
- try {
|
|
|
+ try {
|
|
|
+ if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
|
|
|
Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
|
|
|
Integer code = result.getCode();
|
|
|
if (code == 200) {
|
|
@@ -322,113 +296,123 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
log.error("通过账户(" + accountId + ")未获取到渠道号!!!");
|
|
|
return videoCnt;
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
- }
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
|
|
|
- if (null == newCampaignId) {
|
|
|
- return videoCnt;
|
|
|
- }
|
|
|
- KuaishouChannel usedchannel = null;
|
|
|
- if (useChannel == 1) {
|
|
|
- strategy.setMaterialKeyword(null);
|
|
|
- if (!"group".equals(level)) {
|
|
|
- usedchannel = channelService.queryUsedChannel(accountId, newCampaignId, level);
|
|
|
- if (Check.isNull(usedchannel)) {
|
|
|
- if ("account".equals(level)) {
|
|
|
- usedchannel = channel;
|
|
|
- } else {
|
|
|
- return videoCnt;
|
|
|
- }
|
|
|
+ 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);
|
|
|
}
|
|
|
- List<KuaishouChannelItems> items = usedchannel.getItems();
|
|
|
- if (!Check.isNull(items) && !items.isEmpty()) {
|
|
|
- strategy.setMaterialKeyword(items.get(0).getKeyword());
|
|
|
+ return videoCnt;
|
|
|
+ }
|
|
|
+ if (useChannel == 1) {
|
|
|
+ strategy.setMaterialKeyword(null);
|
|
|
+ if (!"group".equals(level)) {
|
|
|
+ usedchannel = channelService.queryUsedChannel(accountId, newCampaignId, level);
|
|
|
+ if (Check.isNull(usedchannel)) {
|
|
|
+ if ("account".equals(level)) {
|
|
|
+ usedchannel = channel;
|
|
|
+ } else {
|
|
|
+ if (!Check.isNull(channel)) {
|
|
|
+ channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
|
|
|
+ }
|
|
|
+ return videoCnt;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<KuaishouChannelItems> items = usedchannel.getItems();
|
|
|
+ if (!Check.isNull(items) && !items.isEmpty()) {
|
|
|
+ strategy.setMaterialKeyword(items.get(0).getKeyword());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
|
|
|
- if (null == newVideos || newVideos.isEmpty()) {
|
|
|
- log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
|
|
|
- return videoCnt;
|
|
|
- }
|
|
|
- //3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
|
- for (KuaiShouVideoGet videoItem : newVideos) {
|
|
|
- Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
- if (unitOverrun) {
|
|
|
- log.error("组创建超限,accountId:{}", accountId);
|
|
|
- return 0L;
|
|
|
+ List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
|
|
|
+ if (null == newVideos || newVideos.isEmpty()) {
|
|
|
+ log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
|
|
|
+ return videoCnt;
|
|
|
}
|
|
|
+ //3、在“上新”计划中新增广告组,一个素材搭配n张封面,组成一个广告组
|
|
|
+ for (KuaiShouVideoGet videoItem : newVideos) {
|
|
|
+ Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
+ if (unitOverrun) {
|
|
|
+ log.error("组创建超限,accountId:{}", accountId);
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
|
|
|
- KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
|
- if (null != overrunInfo) {
|
|
|
- return 0L;
|
|
|
- }
|
|
|
- // 每个组,搭配5个创意
|
|
|
- List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
|
|
|
- if ((null == cutFrameList || cutFrameList.isEmpty())) {
|
|
|
- log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
|
|
|
- continue;
|
|
|
- }
|
|
|
- //获取组级渠道号
|
|
|
- if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
|
|
|
- try {
|
|
|
- Result<Object> result = channelService.queryChannel(accountId, level, appName, videoItem.getPhotoName());
|
|
|
- Integer code = result.getCode();
|
|
|
- if (code == 200) {
|
|
|
- usedchannel = (KuaishouChannel) result.getResult();
|
|
|
- if (Check.isNull(usedchannel)) {
|
|
|
- log.info("(组级)账户:{}素材名称({}),{}",accountId,videoItem.getPhotoName(), result.getMessage());
|
|
|
- continue;
|
|
|
+ KuaishouAccountCreativeOverrunInfo overrunInfo = overrunInfoService.getByParams(accountId, DateUtils.formatDate(new Date()));
|
|
|
+ if (null != overrunInfo) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+ // 每个组,搭配5个创意
|
|
|
+ List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
|
|
|
+ if ((null == cutFrameList || cutFrameList.isEmpty())) {
|
|
|
+ log.info("未获取到视频封面=>videoSignature:{}", videoItem.getSignature());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //获取组级渠道号
|
|
|
+ if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
|
|
|
+ try {
|
|
|
+ Result<Object> result = channelService.queryChannel(accountId, level, appName, videoItem.getPhotoName());
|
|
|
+ Integer code = result.getCode();
|
|
|
+ if (code == 200) {
|
|
|
+ usedchannel = (KuaishouChannel) result.getResult();
|
|
|
+ if (Check.isNull(usedchannel)) {
|
|
|
+ log.info("(组级)账户:{}素材名称({}),{}", accountId, videoItem.getPhotoName(), result.getMessage());
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
|
|
|
+ }
|
|
|
} else {
|
|
|
- log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
|
|
|
+ log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!", accountId, videoItem.getPhotoName());
|
|
|
+ continue;
|
|
|
}
|
|
|
- } else {
|
|
|
- log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!",accountId,videoItem.getPhotoName());
|
|
|
- continue;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
- }
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, usedchannel);
|
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
|
|
|
- log.info("创建广告组入参:{}", unitParams);
|
|
|
- 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.setCampaignId(newCampaignId);
|
|
|
- unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
- unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
- unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
- 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);
|
|
|
+ String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, usedchannel);
|
|
|
+ JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
|
|
|
+ log.info("创建广告组入参:{}", unitParams);
|
|
|
+ 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.setCampaignId(newCampaignId);
|
|
|
+ unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
+ unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+ videoCnt--;
|
|
|
if (!Check.isNull(usedchannel)) {
|
|
|
- channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
|
|
|
+ channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
|
|
|
}
|
|
|
- continue;
|
|
|
+ JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, usedchannel);//TODO 添加素材
|
|
|
+ createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
|
|
|
+ if (videoCnt <= 0) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- Long unitId = (Long) unitCreateResult.get("unitId");
|
|
|
- unitLevelOperationRecord.setUnitId(unitId);
|
|
|
- unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
- videoCnt--;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("创建自定义广告组异常", e);
|
|
|
if (!Check.isNull(usedchannel)) {
|
|
|
- channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
|
|
|
- }
|
|
|
- JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, usedchannel);//TODO 添加素材
|
|
|
- createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
|
|
|
- if (videoCnt <= 0) {
|
|
|
- return 0L;
|
|
|
+ channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -662,8 +646,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
String level = strategy.getUsageLevel();
|
|
|
Integer useChannel = strategy.getUseChannel();//0不使用,1使用
|
|
|
KuaishouChannel channel = null;
|
|
|
- if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
|
|
|
- try {
|
|
|
+ KuaishouChannel usedchannel = null;
|
|
|
+ Long newCampaignId = null;
|
|
|
+ try {
|
|
|
+ if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
|
|
|
Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
|
|
|
Integer code = result.getCode();
|
|
|
if (code == 200) {
|
|
@@ -678,114 +664,123 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
log.error("通过账户(" + accountId + ")未获取到渠道号!!!");
|
|
|
return;
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
- }
|
|
|
- Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
|
|
|
- if (null == newCampaignId) {
|
|
|
- return;
|
|
|
- }
|
|
|
- KuaishouChannel usedchannel = null;
|
|
|
- if (useChannel == 1) {
|
|
|
- strategy.setMaterialKeyword(null);
|
|
|
- if (!"group".equals(level)) {
|
|
|
- usedchannel = channelService.queryUsedChannel(accountId, newCampaignId, level);
|
|
|
- if (Check.isNull(usedchannel)) {
|
|
|
- if ("account".equals(level)) {
|
|
|
- usedchannel = channel;
|
|
|
- } else {
|
|
|
- return;
|
|
|
- }
|
|
|
+ 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);
|
|
|
}
|
|
|
- List<KuaishouChannelItems> items = usedchannel.getItems();
|
|
|
- if (!Check.isNull(items) && !items.isEmpty()) {
|
|
|
- strategy.setMaterialKeyword(items.get(0).getKeyword());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (useChannel == 1) {
|
|
|
+ strategy.setMaterialKeyword(null);
|
|
|
+ if (!"group".equals(level)) {
|
|
|
+ usedchannel = channelService.queryUsedChannel(accountId, newCampaignId, level);
|
|
|
+ if (Check.isNull(usedchannel)) {
|
|
|
+ if ("account".equals(level)) {
|
|
|
+ usedchannel = channel;
|
|
|
+ } else {
|
|
|
+ if (!Check.isNull(channel)) {
|
|
|
+ channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<KuaishouChannelItems> items = usedchannel.getItems();
|
|
|
+ if (!Check.isNull(items) && !items.isEmpty()) {
|
|
|
+ strategy.setMaterialKeyword(items.get(0).getKeyword());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
|
|
|
- if (null == allVideos) {
|
|
|
- return;
|
|
|
- }
|
|
|
- //创意
|
|
|
- List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
|
- for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
|
- Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
- if (unitOverrun) {
|
|
|
- log.error("组创建超限,accountId:{}", accountId);
|
|
|
+ List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
|
|
|
+ if (null == allVideos) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- Object redisObj = redisUtil.get(key);
|
|
|
- if (!Check.isNull(redisObj)) {
|
|
|
- Integer value = (Integer) redisObj;
|
|
|
- if (value == 1) {
|
|
|
- log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
|
|
|
+ //创意
|
|
|
+ List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
|
|
|
+ for (int j = 1; j < splitVideos.size() + 1; j++) {
|
|
|
+ Boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
+ if (unitOverrun) {
|
|
|
+ log.error("组创建超限,accountId:{}", accountId);
|
|
|
return;
|
|
|
}
|
|
|
- }
|
|
|
- //获取组级渠道号
|
|
|
- if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
|
|
|
- try {
|
|
|
- KuaiShouVideoGet videoGet = splitVideos.get(1).get(0);
|
|
|
- if (Check.isNull(videoGet)) {
|
|
|
+
|
|
|
+ Object redisObj = redisUtil.get(key);
|
|
|
+ if (!Check.isNull(redisObj)) {
|
|
|
+ Integer value = (Integer) redisObj;
|
|
|
+ if (value == 1) {
|
|
|
+ log.error("程序化创意创建超限,accountId:{}", strategy.getAccountId());
|
|
|
return;
|
|
|
}
|
|
|
- Result<Object> result = channelService.queryChannel(accountId, level, appName, videoGet.getPhotoName());
|
|
|
- Integer code = result.getCode();
|
|
|
- if (code == 200) {
|
|
|
- usedchannel = (KuaishouChannel) result.getResult();
|
|
|
- if (Check.isNull(usedchannel)) {
|
|
|
- log.info("(组级)账户:{}素材名称({}),{}",accountId,videoGet.getPhotoName(), result.getMessage());
|
|
|
- continue;
|
|
|
+ }
|
|
|
+ //获取组级渠道号
|
|
|
+ if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
|
|
|
+ try {
|
|
|
+ KuaiShouVideoGet videoGet = splitVideos.get(1).get(0);
|
|
|
+ if (Check.isNull(videoGet)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Result<Object> result = channelService.queryChannel(accountId, level, appName, videoGet.getPhotoName());
|
|
|
+ Integer code = result.getCode();
|
|
|
+ if (code == 200) {
|
|
|
+ usedchannel = (KuaishouChannel) result.getResult();
|
|
|
+ if (Check.isNull(usedchannel)) {
|
|
|
+ log.info("(组级)账户:{}素材名称({}),{}", accountId, videoGet.getPhotoName(), result.getMessage());
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
|
|
|
+ }
|
|
|
} else {
|
|
|
- log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
|
|
|
+ log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!", accountId, videoGet.getPhotoName());
|
|
|
+ continue;
|
|
|
}
|
|
|
- } else {
|
|
|
- log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!",accountId,videoGet.getPhotoName());
|
|
|
- continue;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //创建组
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId, usedchannel);
|
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
|
|
|
- log.info("创建广告组入参:{}", unitParams);
|
|
|
- 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.setCampaignId(newCampaignId);
|
|
|
- unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
- unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
- unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
- 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);
|
|
|
+ //创建组
|
|
|
+ String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId, usedchannel);
|
|
|
+ JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, usedchannel);
|
|
|
+ log.info("创建广告组入参:{}", unitParams);
|
|
|
+ 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.setCampaignId(newCampaignId);
|
|
|
+ unitLevelOperationRecord.setCpaBid(unitParams.getInteger("cpa_bid"));
|
|
|
+ unitLevelOperationRecord.setBid(unitParams.getInteger("bid"));
|
|
|
+ unitLevelOperationRecord.setDeepConversionBid(unitParams.getInteger("deep_conversion_bid"));
|
|
|
+ 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);
|
|
|
+ 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, null, 0);
|
|
|
+ channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
|
|
|
}
|
|
|
- return;
|
|
|
+ JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
|
|
|
+ createProgramCreative(token, creativeParams, strategy);
|
|
|
}
|
|
|
- Long unitId = (Long) unitCreateResult.get("unitId");
|
|
|
- unitLevelOperationRecord.setUnitId(unitId);
|
|
|
- unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
- if (!Check.isNull(channel)) {
|
|
|
- channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("创建程序化广告组异常", e);
|
|
|
+ if (!Check.isNull(usedchannel)) {
|
|
|
+ channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
|
|
|
}
|
|
|
- JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
|
|
|
- createProgramCreative(token, creativeParams, strategy);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1058,14 +1053,17 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
String appVersion = null;
|
|
|
if (Check.isNull(strategy.getMaterialKeyword())) {
|
|
|
- if (!Check.isNull(appInfo.getAppVersion())) {
|
|
|
- String[] split = appInfo.getAppVersion().split("-");
|
|
|
- if (split.length > 1) {
|
|
|
- appVersion = split[1];
|
|
|
- } else {
|
|
|
- return null;
|
|
|
+ if (!Check.isNull(appInfo)) {
|
|
|
+ if (!Check.isNull(appInfo.getAppVersion())) {
|
|
|
+ String[] split = appInfo.getAppVersion().split("-");
|
|
|
+ if (split.length > 1) {
|
|
|
+ appVersion = split[1];
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
} else { // tt语音 特殊素材查询
|
|
|
appVersion = strategy.getMaterialKeyword();
|
|
|
}
|