|
@@ -38,6 +38,7 @@ 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;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -289,11 +290,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
} else {
|
|
|
//单一应用
|
|
|
String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
- List<KuaiShouVideoGet> newVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
|
|
|
- if (null == newVideos || newVideos.isEmpty()) {
|
|
|
- log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
|
|
|
- return videoCnt;
|
|
|
- }
|
|
|
Long appId = null;
|
|
|
String appName = null;
|
|
|
if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
|
|
@@ -312,7 +308,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
KuaishouChannel channel = null;
|
|
|
if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
|
|
|
try {
|
|
|
- Result<Object> result = channelService.queryChannel(accountId, level, appName);
|
|
|
+ Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
|
|
|
Integer code = result.getCode();
|
|
|
if (code == 200) {
|
|
|
channel = (KuaishouChannel) result.getResult();
|
|
@@ -334,6 +330,29 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
@@ -355,26 +374,26 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
//获取组级渠道号
|
|
|
if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
|
|
|
try {
|
|
|
- Result<Object> result = channelService.queryChannel(accountId, level, appName);
|
|
|
+ Result<Object> result = channelService.queryChannel(accountId, level, appName, videoItem.getPhotoName());
|
|
|
Integer code = result.getCode();
|
|
|
if (code == 200) {
|
|
|
- channel = (KuaishouChannel) result.getResult();
|
|
|
- if (Check.isNull(channel)) {
|
|
|
- log.info("(组级)账户:{},{}", accountId, result.getMessage());
|
|
|
+ usedchannel = (KuaishouChannel) result.getResult();
|
|
|
+ if (Check.isNull(usedchannel)) {
|
|
|
+ log.info("(组级)账户:{}素材名称({}),{}",accountId,videoItem.getPhotoName(), result.getMessage());
|
|
|
continue;
|
|
|
} else {
|
|
|
- log.info("(组级)获取到渠道号:{}", channel.getChannelCode());
|
|
|
+ log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
|
|
|
}
|
|
|
} else {
|
|
|
- log.error("(组级)通过账户(" + accountId + ")未获取到渠道号!!!");
|
|
|
+ log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!",accountId,videoItem.getPhotoName());
|
|
|
continue;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, channel);
|
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, channel);
|
|
|
+ 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");
|
|
@@ -394,8 +413,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (unitCode != 0) {
|
|
|
log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
- if (!Check.isNull(channel)) {
|
|
|
- channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null,0);
|
|
|
+ if (!Check.isNull(usedchannel)) {
|
|
|
+ channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
@@ -403,10 +422,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
videoCnt--;
|
|
|
- if (!Check.isNull(channel)) {
|
|
|
- channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId,1);
|
|
|
+ if (!Check.isNull(usedchannel)) {
|
|
|
+ channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
|
|
|
}
|
|
|
- JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, channel);//TODO 添加素材
|
|
|
+ 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;
|
|
@@ -624,10 +643,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
} else {
|
|
|
String replaceString = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString() + createType.toString());
|
|
|
//单一应用
|
|
|
- List<KuaiShouVideoGet> allVideos = getVideosByParams(strategy, startTime, endTime, null, createType, videoCnt);
|
|
|
- if (null == allVideos) {
|
|
|
- return;
|
|
|
- }
|
|
|
Long appId = null;
|
|
|
String appName = null;
|
|
|
String appIdString = strategy.getAppIdArray();
|
|
@@ -649,7 +664,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
KuaishouChannel channel = null;
|
|
|
if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
|
|
|
try {
|
|
|
- Result<Object> result = channelService.queryChannel(accountId, level, appName);
|
|
|
+ Result<Object> result = channelService.queryChannel(accountId, level, appName, null);
|
|
|
Integer code = result.getCode();
|
|
|
if (code == 200) {
|
|
|
channel = (KuaishouChannel) result.getResult();
|
|
@@ -671,6 +686,28 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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++) {
|
|
@@ -691,18 +728,22 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
//获取组级渠道号
|
|
|
if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
|
|
|
try {
|
|
|
- Result<Object> result = channelService.queryChannel(accountId, level, appName);
|
|
|
+ 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) {
|
|
|
- channel = (KuaishouChannel) result.getResult();
|
|
|
- if (Check.isNull(channel)) {
|
|
|
- log.info("(组级)账户:{},{}", accountId, result.getMessage());
|
|
|
+ usedchannel = (KuaishouChannel) result.getResult();
|
|
|
+ if (Check.isNull(usedchannel)) {
|
|
|
+ log.info("(组级)账户:{}素材名称({}),{}",accountId,videoGet.getPhotoName(), result.getMessage());
|
|
|
continue;
|
|
|
} else {
|
|
|
- log.info("(组级)获取到渠道号:{}", channel.getChannelCode());
|
|
|
+ log.info("(组级)获取到渠道号:{}", usedchannel.getChannelCode());
|
|
|
}
|
|
|
} else {
|
|
|
- log.error("(组级)通过账户(" + accountId + ")未获取到渠道号!!!");
|
|
|
+ log.error("(组级)账户:{}素材名称({}),未获取到渠道号!!!",accountId,videoGet.getPhotoName());
|
|
|
continue;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -711,8 +752,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
}
|
|
|
|
|
|
//创建组
|
|
|
- String unitName = getName(strategy.getGroupName(), strategy, createType, null, "unit", newCampaignId, appId, channel);
|
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, channel);
|
|
|
+ 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");
|
|
@@ -732,8 +773,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
if (unitCode != 0) {
|
|
|
log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
- if (!Check.isNull(channel)) {
|
|
|
- channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null,0);
|
|
|
+ if (!Check.isNull(usedchannel)) {
|
|
|
+ channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -741,9 +782,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
unitLevelOperationRecord.setUnitId(unitId);
|
|
|
unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
|
|
|
if (!Check.isNull(channel)) {
|
|
|
- channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId,1);
|
|
|
+ channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, unitId, 1);
|
|
|
}
|
|
|
- JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, channel);
|
|
|
+ JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
|
|
|
createProgramCreative(token, creativeParams, strategy);
|
|
|
}
|
|
|
}
|
|
@@ -1090,8 +1131,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
|
aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
campaignId = (Long) campaignCreateResult.get("campaignId");
|
|
|
+ if (!Check.isNull(channel)) {
|
|
|
+ channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null, 1);
|
|
|
+ }
|
|
|
record.setCampaignId(campaignId);
|
|
|
aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);
|
|
|
Integer campaignStatus = strategy.getCampaignStatus();
|