|
@@ -187,6 +187,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
unitNum = unitNum - customUnitCnt;
|
|
|
}
|
|
|
if (unitNum <= 0) {
|
|
|
+ log.info("今日创建已达标");
|
|
|
return;
|
|
|
}
|
|
|
log.info("----- (自定义)账户:{},已建组数:{};剩余待建组数:{}", strategy.getAccountId(), customUnitCnt, unitNum);
|
|
@@ -270,8 +271,9 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
KuaishouChannel usedchannel = null;
|
|
|
try {
|
|
|
KuaishouChannel channel = null;
|
|
|
- Integer useChannel = Check.isNull(strategy.getUseChannel()) ? 0 : strategy.getUseChannel();//0不使用,1使用
|
|
|
- if (useChannel == 1) {
|
|
|
+ //0不使用,1使用
|
|
|
+ Integer useChannel = Check.isNull(strategy.getUseChannel()) ? 0 : strategy.getUseChannel();
|
|
|
+ if (useChannel == 1 && !"group".equals(level)) {
|
|
|
/*获取渠道号*/
|
|
|
channel = getChannel(level, accountId, appName);
|
|
|
if (Check.isNull(channel)) {
|
|
@@ -283,6 +285,8 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (null == newCampaignId) {
|
|
|
return videoCnt;
|
|
|
}
|
|
|
+ //赋值本次执行可创建数
|
|
|
+ videoCnt = strategy.getToBeBuiltCnt();
|
|
|
log.info("---------获取计划成功,计划id:{}", newCampaignId);
|
|
|
// 1 :使用渠道号
|
|
|
if (useChannel == 1) {
|
|
@@ -298,6 +302,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
log.error("****** 获取已创建的计划所使用的渠道号失败");
|
|
|
return videoCnt;
|
|
|
}
|
|
|
+ log.info("------因计划层级,更新为已创建的计划所使用的渠道号:{}", usedchannel.getChannelCode());
|
|
|
} else {
|
|
|
usedchannel = channel;
|
|
|
}
|
|
@@ -414,14 +419,14 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 更新广告组数
|
|
|
+ * 更新广告组编号数
|
|
|
*/
|
|
|
private void updateVideoStatus(String key) {
|
|
|
Integer unitCnt = (Integer) redisUtil.get(key);
|
|
|
if (Check.isNull(unitCnt)) {
|
|
|
redisUtil.set(key, 1, 100000L);
|
|
|
} else {
|
|
|
- redisUtil.set(key, unitCnt + 1, 100000L);
|
|
|
+ redisUtil.set(key, unitCnt - 1, 100000L);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -476,6 +481,8 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (campaignId == null) {
|
|
|
continue;
|
|
|
}
|
|
|
+ //赋值本次执行可创建数
|
|
|
+ videoCnt = strategy.getToBeBuiltCnt();
|
|
|
/*根据匹配逻辑,定向包和素材进行匹配,获取匹配后的素材*/
|
|
|
getTargetsAndVideos(strategy, allVideos, videoKey, appId, campaignId, appInfo.getAppVersion(), 0);
|
|
|
}
|
|
@@ -575,6 +582,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
unitNum = unitNum - programUnitCnt;
|
|
|
}
|
|
|
if (unitNum == 0) {
|
|
|
+ log.info("今日创建已达标");
|
|
|
return;
|
|
|
}
|
|
|
log.info("----- (程序化)账户:{},已建组数:{};剩余待建组数:{}", strategy.getAccountId(), programUnitCnt, unitNum);
|
|
@@ -671,6 +679,8 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (null == newCampaignId) {
|
|
|
return videoCnt;
|
|
|
}
|
|
|
+ //赋值本次执行可创建数
|
|
|
+ videoCnt = strategy.getToBeBuiltCnt();
|
|
|
log.info("---------获取计划成功,计划id:{}", newCampaignId);
|
|
|
|
|
|
if (!Check.isNull(channel)) {
|
|
@@ -893,6 +903,8 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (campaignId == null) {
|
|
|
continue;
|
|
|
}
|
|
|
+ //赋值本次执行可创建数
|
|
|
+ videoCnt = strategy.getToBeBuiltCnt();
|
|
|
/*根据匹配逻辑,定向包和素材进行匹配,获取匹配后的素材*/
|
|
|
getProTargetsAndVideos(strategy, proVideos, programKey, 0, appId, campaignId, appInfo.getAppVersion());
|
|
|
}
|
|
@@ -975,6 +987,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
Long accountId = strategy.getAccountId();
|
|
|
KuaishouChannel channel = null;
|
|
|
/*获取组级渠道号*/
|
|
|
+ /*
|
|
|
channel = getChannel("group", accountId, appName);
|
|
|
if (Check.isNull(channel)) {
|
|
|
log.error("****** 获取组级渠道号失败");
|
|
@@ -985,6 +998,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (!Check.isNull(items) && !items.isEmpty()) {
|
|
|
strategy.setMaterialKeyword(items.get(0).getKeyword());
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
//待建素材集 redis key值
|
|
|
String date = DateUtils.formatDate(new Date());
|
|
@@ -1004,7 +1018,14 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
|
|
|
//记录创建成功的素材,待最后执行删除redis
|
|
|
List<AiKuaishouAccountAutoVideo> successVideoList = new ArrayList<>();
|
|
|
+ Integer unitCode = null;
|
|
|
+ String unitMessage = null;
|
|
|
for (AiKuaishouAccountAutoVideo videoItem : targetsAndVideos) {
|
|
|
+ channel = getChannel("group", accountId, appName);
|
|
|
+ if (Check.isNull(channel)) {
|
|
|
+ log.error("****** 获取组级渠道号失败");
|
|
|
+ return videoCnt;
|
|
|
+ }
|
|
|
boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
if (unitOverrun) {
|
|
|
log.error("****** 账户({})创建广告组超限", accountId);
|
|
@@ -1018,8 +1039,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- Integer unitCode = null;
|
|
|
- String unitMessage = null;
|
|
|
+
|
|
|
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) {
|
|
@@ -1066,7 +1086,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
}
|
|
|
}
|
|
|
removeRedisVideos(successVideoList, videoKey);
|
|
|
- if (videoCnt > 0) {
|
|
|
+ if (videoCnt > 0 && unitCode == 0) {
|
|
|
return addCustomByGroupChannel(strategy, appName, videoType, token, newCampaignId, appId, videoCnt, strategyUuid);
|
|
|
}
|
|
|
return videoCnt;
|
|
@@ -1079,7 +1099,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
private Integer addProgramByGroupChannel(AiKuaishouAccountAutoStrategy strategy, String appName, Integer videoType, CtopOauthToken token, Long newCampaignId, Long appId, Integer videoCnt, String uuid) throws Exception {
|
|
|
Long accountId = strategy.getAccountId();
|
|
|
/*获取组级渠道号*/
|
|
|
- KuaishouChannel channel = getChannel("group", accountId, appName);
|
|
|
+ /*KuaishouChannel channel = getChannel("group", accountId, appName);
|
|
|
if (Check.isNull(channel)) {
|
|
|
log.error("****** 获取组级渠道号失败");
|
|
|
return videoCnt;
|
|
@@ -1089,6 +1109,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (!Check.isNull(items) && !items.isEmpty()) {
|
|
|
strategy.setMaterialKeyword(items.get(0).getKeyword());
|
|
|
}
|
|
|
+ */
|
|
|
String date = DateUtils.formatDate(new Date());
|
|
|
|
|
|
//程序化创建创意超限标识,redis key值
|
|
@@ -1103,21 +1124,25 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
log.error("****** {}账户({})通过组级渠道号关键词{},未获取到素材(程序化)", date, accountId, strategy.getMaterialKeyword());
|
|
|
} else {
|
|
|
if (allVideos.size() >= 3) {
|
|
|
- List<List<AiKuaishouAccountAutoVideo>> splitVideos = Lists.partition(allVideos, 10);
|
|
|
- int size = splitVideos.size() - 1;
|
|
|
+ List<List<AiKuaishouAccountAutoVideo>> splitVideos = Lists.newArrayList(Lists.partition(allVideos, 10));
|
|
|
+ List<List<AiKuaishouAccountAutoVideo>> newVideos = new ArrayList<>();
|
|
|
+ for (List<AiKuaishouAccountAutoVideo> splitVideo : splitVideos) {
|
|
|
+ newVideos.add(Lists.newArrayList(splitVideo));
|
|
|
+ }
|
|
|
+ int size = newVideos.size() - 1;
|
|
|
if (size > 0) {
|
|
|
//判断最后一个集合小于3
|
|
|
- List<AiKuaishouAccountAutoVideo> lastVideos = splitVideos.get(size);
|
|
|
+ List<AiKuaishouAccountAutoVideo> lastVideos = newVideos.get(size);
|
|
|
if (lastVideos.size() < 3) {
|
|
|
//小于3 则去除
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
- proVideos.add(splitVideos.get(i));
|
|
|
+ proVideos.add(newVideos.get(i));
|
|
|
}
|
|
|
} else {
|
|
|
- proVideos = splitVideos;
|
|
|
+ proVideos = newVideos;
|
|
|
}
|
|
|
} else {
|
|
|
- proVideos = splitVideos;
|
|
|
+ proVideos = newVideos;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1130,6 +1155,8 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
|
|
|
//记录创建成功的素材,待最后执行删除redis
|
|
|
List<List<AiKuaishouAccountAutoVideo>> successVideoList = new ArrayList<>();
|
|
|
+ Integer unitCode = null;
|
|
|
+ String unitMessage = null;
|
|
|
for (List<AiKuaishouAccountAutoVideo> videos : targetsAndVideos) {
|
|
|
boolean unitOverrun = getUnitOverrun(accountId);
|
|
|
if (unitOverrun) {
|
|
@@ -1137,6 +1164,12 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
removeProRedisVideos(successVideoList, videoKey);
|
|
|
return 0;
|
|
|
}
|
|
|
+ /*获取组级渠道号*/
|
|
|
+ KuaishouChannel channel = getChannel("group", accountId, appName);
|
|
|
+ if (Check.isNull(channel)) {
|
|
|
+ log.error("****** 获取组级渠道号失败");
|
|
|
+ return videoCnt;
|
|
|
+ }
|
|
|
|
|
|
Object redisObj = redisUtil.get(programKey);
|
|
|
if (!Check.isNull(redisObj)) {
|
|
@@ -1148,8 +1181,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Integer unitCode = null;
|
|
|
- String unitMessage = null;
|
|
|
+
|
|
|
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) {
|
|
@@ -1197,7 +1229,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
}
|
|
|
//删除已使用的素材
|
|
|
removeProRedisVideos(successVideoList, videoKey);
|
|
|
- if (videoCnt > 0) {
|
|
|
+ if (videoCnt > 0 && unitCode == 0) {
|
|
|
return addProgramByGroupChannel(strategy, appName, videoType, token, newCampaignId, appId, videoCnt, uuid);
|
|
|
}
|
|
|
return videoCnt;
|
|
@@ -1511,18 +1543,16 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
KuaishouChannel channel = null;
|
|
|
try {
|
|
|
channel = null;
|
|
|
- if (("account".equals(level) || "plan".equals(level))) {
|
|
|
- Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
|
|
|
- if (result.getCode() == 200) {
|
|
|
- channel = (KuaishouChannel) result.getResult();
|
|
|
- if (Check.isNull(channel)) {
|
|
|
- log.error("****** 账户({})未获取到渠道号,{}", accountId, result.getMessage());
|
|
|
- } else {
|
|
|
- log.info("------获取渠道号:{}", channel.getChannelCode());
|
|
|
- }
|
|
|
+ Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
|
|
|
+ if (result.getCode() == 200) {
|
|
|
+ channel = (KuaishouChannel) result.getResult();
|
|
|
+ if (Check.isNull(channel)) {
|
|
|
+ log.error("****** 账户({})未获取到渠道号,{}", accountId, result.getMessage());
|
|
|
} else {
|
|
|
- log.error("****** 账户({})根据应用名:{},未查询渠道号!{}", accountId, appName, result.getMessage());
|
|
|
+ log.info("------获取渠道号:{}", channel.getChannelCode());
|
|
|
}
|
|
|
+ } else {
|
|
|
+ log.error("****** 账户({})根据应用名:{},未查询渠道号!{}", accountId, appName, result.getMessage());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -1592,8 +1622,8 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (!Check.isNull(strategy.getClickTrackUrl())) {
|
|
|
programJson.put("click_url", strategy.getClickTrackUrl());
|
|
|
}
|
|
|
- if (!Check.isNull(channel) && !Check.isNull(channel.getActionbarClickUrl())) {
|
|
|
- programJson.put("click_url", channel.getActionbarClickUrl());
|
|
|
+ if (!Check.isNull(channel) && !Check.isNull(channel.getClickTrackUrl())) {
|
|
|
+ programJson.put("click_url", channel.getClickTrackUrl());
|
|
|
}
|
|
|
|
|
|
//第三方 ActionBar 点击监控链接
|
|
@@ -1776,6 +1806,8 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//判断是否扔可创建计划
|
|
|
if (planCnt > datas.size()) {
|
|
|
return createCampaign(strategy, token, videoType, uuid, channel);
|
|
|
+ }else{
|
|
|
+ log.info("当日创建量已达标");
|
|
|
}
|
|
|
} else {
|
|
|
return createCampaign(strategy, token, videoType, uuid, channel);
|