|
@@ -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;
|
|
|
}
|
|
@@ -359,7 +364,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
AiKuaishouUnitLevelOperationRecord unitRecord = new AiKuaishouUnitLevelOperationRecord(strategy, unitParams, unitCode, unitMessage, strategyUuid, videoItem.getAutoTargetId(), channelId);
|
|
|
if (unitCode != 0) {
|
|
|
log.error("****** 账户({})组创建失败,入参:{},message:{}", accountId, unitParams, unitMessage);
|
|
|
- String redisKey = strategy.getAccountId() + "_" + newCampaignId + DateUtils.formatDate(new Date(), "yy-MMdd");
|
|
|
+ String redisKey = strategy.getAccountId() + "_" + newCampaignId + DateUtils.formatDate(new Date(), "yyMMdd");
|
|
|
Integer redisCnt = (Integer) redisUtil.get(redisKey);
|
|
|
redisUtil.set(redisKey, redisCnt - 1, 100000L);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitRecord);
|
|
@@ -377,7 +382,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//获取创意参数
|
|
|
JSONObject creativeParams = getCreativeParams(token, unitId, videoItem, strategy, usedchannel, null);
|
|
|
//执行创建创意
|
|
|
- boolean flag = createCreative(token, creativeParams, strategy, unitId, strategyUuid);
|
|
|
+ boolean flag = createCreative(token, creativeParams, strategy, newCampaignId, unitId, strategyUuid);
|
|
|
if (flag) {
|
|
|
//创意成功,则素材置为不可用,添加素材使用记录
|
|
|
updateVideoUsed(videoType, null, "custom", videoItem);
|
|
@@ -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);
|
|
|
}
|
|
@@ -534,7 +541,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//获取创意参数
|
|
|
JSONObject creativeParams = getCreativeParams(token, unitId, videoItem, strategy, null, videoItem.getAppVersion());
|
|
|
//执行创建创意
|
|
|
- createCreative(token, creativeParams, strategy, unitId, strategyUuid);
|
|
|
+ createCreative(token, creativeParams, strategy, campaignId, unitId, strategyUuid);
|
|
|
if (videoCnt <= 0) {
|
|
|
removeRedisVideos(successVideoList, videoKey);
|
|
|
return 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) {
|
|
@@ -1054,7 +1074,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//获取创意参数
|
|
|
JSONObject creativeParams = getCreativeParams(token, unitId, videoItem, strategy, channel, null);
|
|
|
//执行创建创意
|
|
|
- boolean flag = createCreative(token, creativeParams, strategy, unitId, strategyUuid);
|
|
|
+ boolean flag = createCreative(token, creativeParams, strategy, newCampaignId, unitId, strategyUuid);
|
|
|
if (flag) {
|
|
|
//创意成功,则素材置为不可用,添加素材使用记录
|
|
|
updateVideoUsed(videoType, null, "custom", videoItem);
|
|
@@ -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();
|
|
@@ -1585,15 +1615,15 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
|
|
|
//行动号召按钮
|
|
|
if (!Check.isNull(strategy.getActionBarText())) {
|
|
|
- programJson.put("action_bar", strategy.getActionBarText());
|
|
|
+ programJson.put("action_bar", getActionBar(strategy.getActionBarText()));
|
|
|
}
|
|
|
|
|
|
//第三方点击检测链接
|
|
|
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 点击监控链接
|
|
@@ -1746,7 +1776,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
*/
|
|
|
private Long getCampaignId(AiKuaishouAccountAutoStrategy strategy, CtopOauthToken token, Integer videoType, String uuid, KuaishouChannel channel) {
|
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd") + " 00:00:01";
|
|
|
- String typeNa = "程序化";
|
|
|
+ String typeNa = "程序化新";
|
|
|
//计划数
|
|
|
Integer planCnt = strategy.getProgramPlanCnt();
|
|
|
//组数
|
|
@@ -1754,7 +1784,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (strategy.getUnitType() == 4) {
|
|
|
planCnt = strategy.getCustomPlanCnt();
|
|
|
unitCnt = strategy.getCustomUnitCnt();
|
|
|
- typeNa = "自定义";
|
|
|
+ typeNa = "自定义新";
|
|
|
}
|
|
|
List<JSONObject> datas = campaignService.getCampaignIdsByParameters(strategy.getAccountId(), typeNa, nowDate);
|
|
|
int toBeBuiltCnt = 0;
|
|
@@ -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);
|
|
@@ -1939,6 +1971,9 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (!Check.isNull(appId)) {
|
|
|
unitParams.put("app_id", appId);
|
|
|
}
|
|
|
+ if (!Check.isNull(channel) && !Check.isNull(channel.getAppId())) {
|
|
|
+ unitParams.put("app_id", channel.getAppId());
|
|
|
+ }
|
|
|
// url
|
|
|
if (!Check.isNull(strategy.getUrl())) {
|
|
|
unitParams.put("url", strategy.getUrl());
|
|
@@ -1947,6 +1982,9 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (!Check.isNull(strategy.getSchemaUri())) {
|
|
|
unitParams.put("schema_uri", strategy.getSchemaUri());
|
|
|
}
|
|
|
+ if (!Check.isNull(channel) && !Check.isNull(channel.getSchemaUri())) {
|
|
|
+ unitParams.put("schema_uri", channel.getSchemaUri());
|
|
|
+ }
|
|
|
}
|
|
|
//投放开始时间
|
|
|
if (!Check.isNull(strategy.getBeginTime())) {
|
|
@@ -1982,6 +2020,11 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (!Check.isNull(strategy.getAutoTarget())) {
|
|
|
unitParams.put("auto_target", strategy.getAutoTarget());
|
|
|
}
|
|
|
+ //行为意向-系统优选
|
|
|
+ if (!Check.isNull(strategy.getIntentionTarget()) && strategy.getIntentionTarget() != 0) {
|
|
|
+ unitParams.put("intention_target", true);
|
|
|
+ }
|
|
|
+
|
|
|
//是否开启自动生成视频
|
|
|
if (!Check.isNull(strategy.getAutoCreatePhoto())) {
|
|
|
unitParams.put("auto_create_photo", strategy.getAutoCreatePhoto());
|
|
@@ -2271,7 +2314,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
if (Check.isNull(count) || count == 0) {
|
|
|
count = 1;
|
|
|
}
|
|
|
- //广告语集
|
|
|
+ //广告语集
|
|
|
JSONArray descList = JSONArray.parseArray(strategy.getDescription());
|
|
|
JSONArray creatives = new JSONArray();
|
|
|
for (int i = 0; i < count; i++) {
|
|
@@ -2286,7 +2329,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//素材类型 1:竖版视频 2:横版视频
|
|
|
creative.put("creative_material_type", videoItem.getMaterialType());
|
|
|
//行动号召按钮文案
|
|
|
- creative.put("action_bar_text", strategy.getActionBarText());
|
|
|
+ creative.put("action_bar_text", getActionBar(strategy.getActionBarText()));
|
|
|
//广告语
|
|
|
int index = new Random().nextInt(descList.size());
|
|
|
creative.put("description", descList.getString(index));
|
|
@@ -2334,7 +2377,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
/**
|
|
|
* 执行创建自定义创意
|
|
|
*/
|
|
|
- private boolean createCreative(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAccountAutoStrategy strategy, Long unitId, String uuid) {
|
|
|
+ private boolean createCreative(CtopOauthToken token, JSONObject creativeParams, AiKuaishouAccountAutoStrategy strategy, Long newCampaignId, Long unitId, String uuid) {
|
|
|
try {
|
|
|
Map<String, Object> creativeCreateResult = kuaishouInterfaceService.batchCreativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1, null);
|
|
|
Integer creativeCode = (Integer) creativeCreateResult.get("code");
|
|
@@ -2347,7 +2390,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
} else if (creativeCode == -1 && creativeMessage.contains("视频不存在")) {
|
|
|
updateService.updateUnitStatus(token.getAccessToken(), token.getAccountId(), unitId, 3, "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
}
|
|
|
- AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord(strategy, creativeCode, creativeParams, creativeMessage, unitId, uuid);
|
|
|
+ AiKuaishouCreativeLevelOperationRecord record = new AiKuaishouCreativeLevelOperationRecord(strategy, creativeCode, creativeParams, creativeMessage, newCampaignId, unitId, uuid);
|
|
|
if (creativeCode == 0) {
|
|
|
JSONArray addCreativeIds = (JSONArray) creativeCreateResult.get("ids");
|
|
|
for (int i = 0; i < addCreativeIds.size(); i++) {
|
|
@@ -2373,76 +2416,76 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
*/
|
|
|
private String getName(String wildcard, AiKuaishouAccountAutoStrategy strategy, Integer videoType,
|
|
|
String materialName, String type, Long campaignId, Long appId, Long targetId, KuaishouChannel channel) {
|
|
|
- if (wildcard.contains("{{渠道号}}") || wildcard.contains("{{渠道号名称}}")) {
|
|
|
+ if (wildcard.contains("-{{渠道号}}-") || wildcard.contains("-{{渠道号名称}}-")) {
|
|
|
if (Check.isNull(channel)) {
|
|
|
- wildcard = wildcard.replace("{{渠道号}}", "");
|
|
|
- wildcard = wildcard.replace("{{渠道号名称}}", "");
|
|
|
+ wildcard = wildcard.replace("-{{渠道号}}-", "");
|
|
|
+ wildcard = wildcard.replace("-{{渠道号名称}}-", "");
|
|
|
} else {
|
|
|
- wildcard = wildcard.replace("{{渠道号}}", channel.getChannelCode());
|
|
|
- wildcard = wildcard.replace("{{渠道号名称}}", channel.getChannelName());
|
|
|
+ wildcard = wildcard.replace("-{{渠道号}}-", channel.getChannelCode());
|
|
|
+ wildcard = wildcard.replace("-{{渠道号名称}}-", channel.getChannelName());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (wildcard.contains("{{定向包名}}")) {
|
|
|
+ if (wildcard.contains("-{{定向包名}}-")) {
|
|
|
AiKuaishouAccountAutoTarget templateTarget = autoTargetService.getById(targetId);
|
|
|
if (!Check.isNull(templateTarget)) {
|
|
|
- wildcard = wildcard.replace("{{定向包名}}", templateTarget.getTargetName());
|
|
|
+ wildcard = wildcard.replace("-{{定向包名}}-", templateTarget.getTargetName());
|
|
|
} else {
|
|
|
- wildcard = wildcard.replace("{{定向包名}}", "");
|
|
|
+ wildcard = wildcard.replace("-{{定向包名}}-", "");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (wildcard.contains("{{应用名称}}") || wildcard.contains("{{应用标记}}") || wildcard.contains("{{应用包名}}")) {
|
|
|
+ if (wildcard.contains("-{{应用名称}}-") || wildcard.contains("-{{应用标记}}-") || wildcard.contains("-{{应用包名}}-")) {
|
|
|
KuaiShouAppList getAppInfo = appListService.getAppInfo(strategy.getAccountId(), appId);
|
|
|
if (!Check.isNull(getAppInfo)) {
|
|
|
- wildcard = wildcard.replace("{{应用名称}}", getAppInfo.getAppName());
|
|
|
- wildcard = wildcard.replace("{{应用标记}}", getAppInfo.getAppVersion());
|
|
|
- wildcard = wildcard.replace("{{应用包名}}", getAppInfo.getPackageName());
|
|
|
+ wildcard = wildcard.replace("-{{应用名称}}-", getAppInfo.getAppName());
|
|
|
+ wildcard = wildcard.replace("-{{应用标记}}-", getAppInfo.getAppVersion());
|
|
|
+ wildcard = wildcard.replace("-{{应用包名}}-", getAppInfo.getPackageName());
|
|
|
} else {
|
|
|
- wildcard = wildcard.replace("{{应用名称}}", "");
|
|
|
- wildcard = wildcard.replace("{{应用标记}}", "");
|
|
|
- wildcard = wildcard.replace("{{应用包名}}", "");
|
|
|
+ wildcard = wildcard.replace("-{{应用名称}}-", "");
|
|
|
+ wildcard = wildcard.replace("-{{应用标记}}-", "");
|
|
|
+ wildcard = wildcard.replace("-{{应用包名}}-", "");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (wildcard.contains("{{创意制作方式}}")) {
|
|
|
+ if (wildcard.contains("-{{创意制作方式}}-")) {
|
|
|
if (strategy.getUnitType() == 4) {
|
|
|
- wildcard = wildcard.replace("{{创意制作方式}}", "自定义");
|
|
|
+ wildcard = wildcard.replace("-{{创意制作方式}}-", "自定义");
|
|
|
} else if (strategy.getUnitType() == 7) {
|
|
|
- wildcard = wildcard.replace("{{创意制作方式}}", "程序化");
|
|
|
+ wildcard = wildcard.replace("-{{创意制作方式}}-", "程序化");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (wildcard.contains("{{广告位置}}")) {
|
|
|
+ if (wildcard.contains("-{{广告位置}}-")) {
|
|
|
String adsence = getAdSenceByParams(strategy.getSceneId());
|
|
|
- wildcard = wildcard.replace("{{广告位置}}", adsence);
|
|
|
+ wildcard = wildcard.replace("-{{广告位置}}-", adsence);
|
|
|
}
|
|
|
|
|
|
- if (wildcard.contains("{{素材名称}}")) {
|
|
|
+ if (wildcard.contains("-{{素材名称}}-")) {
|
|
|
if (Check.isNull(materialName)) {
|
|
|
- wildcard = wildcard.replace("{{素材名称}}", "");
|
|
|
+ wildcard = wildcard.replace("-{{素材名称}}-", "");
|
|
|
} else {
|
|
|
- wildcard = wildcard.replace("{{素材名称}}", materialName);
|
|
|
+ wildcard = wildcard.replace("-{{素材名称}}-", materialName);
|
|
|
}
|
|
|
}
|
|
|
- if (!wildcard.contains("{{自定义}}")) {
|
|
|
- wildcard = wildcard + "-{{自定义}}";
|
|
|
+ if (!wildcard.contains("-{{自定义}}-")) {
|
|
|
+ wildcard = wildcard + "-{{自定义}}-";
|
|
|
}
|
|
|
- String nowDate = DateUtils.formatDate(new Date(), "yy-MMdd");
|
|
|
+ String nowDate = DateUtils.formatDate(new Date(), "yyMMdd");
|
|
|
if ("plan".equals(type)) {
|
|
|
//创意制作方式
|
|
|
if (strategy.getUnitType() == 4) {
|
|
|
- wildcard = wildcard.replace("{{自定义}}", "自定义");
|
|
|
+ wildcard = wildcard.replace("-{{自定义}}-", "自定义新");
|
|
|
} else {
|
|
|
- wildcard = wildcard.replace("{{自定义}}", "程序化");
|
|
|
+ wildcard = wildcard.replace("-{{自定义}}-", "程序化新");
|
|
|
}
|
|
|
- if (wildcard.contains("{{日期}}")) {
|
|
|
- wildcard = wildcard.replace("{{日期}}", nowDate);
|
|
|
+ if (wildcard.contains("-{{日期}}-")) {
|
|
|
+ wildcard = wildcard.replace("-{{日期}}-", nowDate);
|
|
|
} else {
|
|
|
wildcard = wildcard + "-" + nowDate;
|
|
|
}
|
|
|
- if (!wildcard.contains("{{序号}}")) {
|
|
|
- wildcard = wildcard + "{{序号}}";
|
|
|
+ if (!wildcard.contains("-{{序号}}-")) {
|
|
|
+ wildcard = wildcard + "-{{序号}}-";
|
|
|
}
|
|
|
Integer count = 0;
|
|
|
String redisKey = strategy.getAccountId() + "_planCnt";
|
|
@@ -2454,11 +2497,11 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
count = redisValue + 1;
|
|
|
redisUtil.set(redisKey, count);
|
|
|
}
|
|
|
- wildcard = wildcard.replace("{{序号}}", count + "");
|
|
|
+ wildcard = wildcard.replace("-{{序号}}-", count + "");
|
|
|
} else if ("unit".equals(type)) {
|
|
|
String targetName = KuaishouAutoTypeEnum.getNameByType(strategy.getUnitType().toString() + videoType.toString());
|
|
|
- wildcard = wildcard.replace("{{自定义}}", targetName);
|
|
|
- wildcard = wildcard.replace("{{日期}}", nowDate);
|
|
|
+ wildcard = wildcard.replace("-{{自定义}}-", targetName);
|
|
|
+ wildcard = wildcard.replace("-{{日期}}-", nowDate);
|
|
|
}
|
|
|
//组序号,必填
|
|
|
if (!Check.isNull(campaignId)) {
|
|
@@ -2695,4 +2738,18 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
}
|
|
|
return upNewCnt;
|
|
|
}
|
|
|
+
|
|
|
+ public static String getActionBar(String actionBarText) {
|
|
|
+ if (Check.isNull(actionBarText)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String[] split = actionBarText.split(",");
|
|
|
+ int i = getrandom(0, split.length - 1);
|
|
|
+ return split[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int getrandom(int start, int end) {
|
|
|
+ int num = (int) (Math.random() * (end - start + 1) + start);
|
|
|
+ return num;
|
|
|
+ }
|
|
|
}
|