|
@@ -364,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);
|
|
@@ -382,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);
|
|
@@ -541,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;
|
|
@@ -1074,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);
|
|
@@ -1615,7 +1615,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
|
|
|
//行动号召按钮
|
|
|
if (!Check.isNull(strategy.getActionBarText())) {
|
|
|
- programJson.put("action_bar", strategy.getActionBarText());
|
|
|
+ programJson.put("action_bar", getActionBar(strategy.getActionBarText()));
|
|
|
}
|
|
|
|
|
|
//第三方点击检测链接
|
|
@@ -1776,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();
|
|
|
//组数
|
|
@@ -1784,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;
|
|
@@ -1833,7 +1833,7 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
//添加创建记录
|
|
|
AiKuaishouCampaignLevelOperationRecord record = new AiKuaishouCampaignLevelOperationRecord(strategy, null, code, message, campaignName, uuid);
|
|
|
if (code != 0) {
|
|
|
- if (strategy.getCampaignName().contains("-{{序号}}-")) {
|
|
|
+ if (strategy.getCampaignName().contains("{{序号}}")) {
|
|
|
String redisKey = token.getAccountId() + "_planCnt";
|
|
|
Integer redisValue = (Integer) redisUtil.get(redisKey);
|
|
|
redisUtil.set(redisKey, redisValue - 1);
|
|
@@ -1971,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());
|
|
@@ -1979,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())) {
|
|
@@ -2308,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++) {
|
|
@@ -2323,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));
|
|
@@ -2371,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");
|
|
@@ -2384,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++) {
|
|
@@ -2465,13 +2471,13 @@ public class AiKuaishouAccountAutoDoServiceImpl implements IAiKuaishouAccountAut
|
|
|
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);
|
|
@@ -2732,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;
|
|
|
+ }
|
|
|
}
|