|
@@ -102,21 +102,30 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(timeEnd != 0){
|
|
|
endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
|
|
|
}
|
|
|
- List<ByteDanceVideoInfo> videoInfos = getVideoInfoByCreateType(userAllocation.getProjectId(),strategy,startTime,endTime,createType,videoCnt);
|
|
|
+ //List<ByteDanceVideoInfo> videoInfos = getVideoInfoByCreateType(userAllocation.getProjectId(),strategy,startTime,endTime,createType,videoCnt);
|
|
|
+ List<ByteDanceVideoInfo> videoInfos = getvideoOrImageInfoByCreateType(userAllocation.getProjectId(),strategy,startTime,endTime,createType,videoCnt);
|
|
|
+
|
|
|
if(null == videoInfos||videoInfos.isEmpty()){
|
|
|
- log.info("获取{}视频素材为空=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),token.getAccountId());
|
|
|
+ log.info("获取{}素材{}为空=>accountId:{}===》素材类型{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),strategy.getCreativeImageMode(),token.getAccountId(),BytedanceCreativeMatTypeEnum.getImageModeByType(strategy.getCreativeImageMode()));
|
|
|
return videoCnt;
|
|
|
}
|
|
|
- log.info("获取{}视频素材个数:{}=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),videoInfos.size(),token.getAccountId());
|
|
|
+ log.info("获取{}素材个数:{}=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),videoInfos.size(),token.getAccountId());
|
|
|
+
|
|
|
|
|
|
for (ByteDanceVideoInfo video:videoInfos) {
|
|
|
- Integer isLowQuality = bytedanceMaterialRejectReasonMapper.getIsLowQualityByVideoId(video.getVid()); //判断次视频是否是低质视频,为1跳过
|
|
|
- if(1 == isLowQuality){
|
|
|
- continue;
|
|
|
+ //判断此素材为视频
|
|
|
+ if ("video".equalsIgnoreCase(video.getMaterialType())){
|
|
|
+ //视频是否是低质视频,为1跳过
|
|
|
+ Integer isLowQuality = bytedanceMaterialRejectReasonMapper.getIsLowQualityByVideoId(video.getVid());
|
|
|
+ if(1 == isLowQuality){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
Integer useDplinkIndex = strategy.getDpLinkIndexUsed();
|
|
|
if(null==useDplinkIndex||useDplinkIndex.equals(0)){
|
|
|
- AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),1);
|
|
|
+ //查看已使用的dp链接
|
|
|
+ AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),1);
|
|
|
if(null == adDplinkInfo){
|
|
|
adDplinkInfo = new AiBytedanceAdDplinkInfo();
|
|
|
if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
|
|
@@ -140,7 +149,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return videoCnt;
|
|
|
}
|
|
|
//计划名称
|
|
|
- String adName = getAdName(strategy,null,video);
|
|
|
+ String adName = getAdName(strategy,null,video,userAllocation.getProjectId());
|
|
|
//计算本次出价
|
|
|
BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid(),strategy.getAdCpaBid());
|
|
|
JSONObject adParams = getAdParams(strategy,adName,campaignId,currentCpaBid);
|
|
@@ -172,6 +181,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
adDplinkInfo.setAccountId(strategy.getAccountId());
|
|
|
adDplinkInfo.setStatus(1);
|
|
|
adDplinkInfo.setStrategyId(strategy.getId());
|
|
|
+ adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
|
|
|
adDplinkInfoService.save(adDplinkInfo);
|
|
|
|
|
|
BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
|
|
@@ -182,7 +192,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
}else{
|
|
|
Long dpIndex ;
|
|
|
- AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),1);
|
|
|
+ AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),1);
|
|
|
if(null == adDplinkInfo){
|
|
|
adDplinkInfo = new AiBytedanceAdDplinkInfo();
|
|
|
if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
|
|
@@ -211,7 +221,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
strategy.setAdOpenUrl(openUrl.replace("{{dp链接下标}}",dpIndex.toString()));
|
|
|
String dplinkCode = StringUtils.getParamFromUrl(strategy.getAdOpenUrl(),"bc_fl_src");
|
|
|
//计划名称
|
|
|
- String adName = getAdName(strategy,dplinkCode,video);
|
|
|
+ String adName = getAdName(strategy,dplinkCode,video,userAllocation.getProjectId());
|
|
|
//计算本次出价
|
|
|
BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid(),strategy.getAdCpaBid());
|
|
|
adDplinkInfo.setAdBid(currentCpaBid);
|
|
@@ -243,6 +253,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
adDplinkInfo.setAccountId(strategy.getAccountId());
|
|
|
adDplinkInfo.setStatus(1);
|
|
|
adDplinkInfo.setStrategyId(strategy.getId());
|
|
|
+ adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
|
|
|
adDplinkInfoService.save(adDplinkInfo);
|
|
|
BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
|
|
|
videoCreativeLogService.saveOrUpdate(creativeLog);
|
|
@@ -289,21 +300,25 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
//视频素材
|
|
|
JSONArray imageArray = new JSONArray();
|
|
|
JSONObject imageObject = new JSONObject();
|
|
|
- //视频类型
|
|
|
- if(videoInfo.getType() == 1){
|
|
|
- //竖版视频
|
|
|
- imageObject.put("image_mode","CREATIVE_IMAGE_MODE_VIDEO_VERTICAL");
|
|
|
- }
|
|
|
- if(videoInfo.getType() == 2){
|
|
|
- //横版视频
|
|
|
- imageObject.put("image_mode","CREATIVE_IMAGE_MODE_VIDEO");
|
|
|
- }
|
|
|
- imageObject.put("video_id",videoInfo.getVid());
|
|
|
- //获取视频封面id
|
|
|
- String imageId = getSuggestImageId(token,videoInfo.getVid());
|
|
|
- if(!Check.isNull(imageId)){
|
|
|
- imageObject.put("image_id",imageId);
|
|
|
+
|
|
|
+ if ("video".equalsIgnoreCase(videoInfo.getMaterialType())){
|
|
|
+ //视频类型
|
|
|
+ //1-竖版视频 2-横版视频
|
|
|
+ String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_VIDEO_VERTICAL" : "CREATIVE_IMAGE_MODE_VIDEO";
|
|
|
+ imageObject.put("image_mode",imageMode);
|
|
|
+ imageObject.put("video_id",videoInfo.getVid());
|
|
|
+ //获取视频封面id
|
|
|
+ String imageId = getSuggestImageId(token,videoInfo.getVid());
|
|
|
+ if(!Check.isNull(imageId)){
|
|
|
+ imageObject.put("image_id",imageId);
|
|
|
+ }
|
|
|
+ }else if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
|
|
|
+ //1-大图横图; 2-大图竖图
|
|
|
+ String imageMode = videoInfo.getType() == 1 ? "CREATIVE_IMAGE_MODE_LARGE" : "CREATIVE_IMAGE_MODE_LARGE_VERTICAL";
|
|
|
+ imageObject.put("image_mode",imageMode);
|
|
|
+ imageObject.put("image_ids",new String[]{videoInfo.getId()});
|
|
|
}
|
|
|
+
|
|
|
imageArray.add(imageObject);
|
|
|
params.put("image_list",imageArray);
|
|
|
JSONArray titleArray = new JSONArray();
|
|
@@ -925,7 +940,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return params;
|
|
|
}
|
|
|
|
|
|
- private String getAdName(AiBytedanceAdvertiserStrategy strategy, String dplinkCode, ByteDanceVideoInfo videoInfo) {
|
|
|
+ private String getAdName(AiBytedanceAdvertiserStrategy strategy, String dplinkCode, ByteDanceVideoInfo videoInfo,Long projectId) {
|
|
|
String adName = strategy.getAdName();
|
|
|
if(null == adName|| "".equals(adName.trim())){
|
|
|
return null;
|
|
@@ -944,14 +959,20 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
String pricing = strategy.getAdPricing().replace("PRICING_","").toLowerCase(Locale.ROOT);
|
|
|
adName = adName.replace("{{出价方式}}",pricing);
|
|
|
}
|
|
|
+
|
|
|
if(adName.contains("{{素材名称}}")){
|
|
|
- MaterialInfo info = materialInfoService.getParams(videoInfo.getSignature(),null);
|
|
|
- if(null!=info&&null!=info.getMaterialName()){
|
|
|
- adName = adName.replace("{{素材名称}}",info.getMaterialName());
|
|
|
+ if ("video".equals(videoInfo.getMaterialType())){
|
|
|
+ MaterialInfo info = materialInfoService.getParams(videoInfo.getSignature(),null,projectId);
|
|
|
+ if(null!=info&&null!=info.getMaterialName()){
|
|
|
+ adName = adName.replace("{{素材名称}}",info.getMaterialName());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ adName = adName.replace("{{素材名称}}",videoInfo.getFilename());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if(adName.contains("{{序号}}")){
|
|
|
- int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
|
|
|
+ int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId(),strategy.getCreativeImageMode());
|
|
|
adName = adName.replace("{{序号}}",String.valueOf(i+1));
|
|
|
}
|
|
|
|
|
@@ -1018,8 +1039,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
|
|
|
if(result.contains("{{序号}}")){
|
|
|
- //查询当天已有计划数量
|
|
|
- int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
|
|
|
+ //查询同素材类型当天已有计划数量
|
|
|
+ int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId(),strategy.getCreativeImageMode());
|
|
|
Long num = GetCampaignNum.getCampaignNameNum(strategy.getCampaignCnt(),strategy.getCampaignAdCnt(), i == 0 ? i+1 : i);
|
|
|
result = result.replace("{{序号}}",String.valueOf(num));
|
|
|
}
|
|
@@ -1062,18 +1083,61 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
//TODO -- 高质量素材 一天只能创建一次 两周内总消耗》=500
|
|
|
//TODO -- 打捞素材 两周消耗 <500 并且总关联创意数<20
|
|
|
private List<ByteDanceVideoInfo> getVideoInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
|
|
|
+ //根据 imageMode 获取素材类型
|
|
|
+ //1-竖版视频 2-横板视频
|
|
|
+ String imageMode = BytedanceCreativeMatTypeEnum.getNameByType(strategy.getCreativeImageMode());
|
|
|
//1:上新素材 2:跑量素材 3:遗漏素材 4:打捞素材
|
|
|
if(createType == 1||createType == 3){
|
|
|
- return videoInfoService.listByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt,0);
|
|
|
+ return videoInfoService.listByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt,0);
|
|
|
}else if(createType == 2){
|
|
|
startTime = startTime.substring(0,10);
|
|
|
endTime = endTime.substring(0,10);
|
|
|
- return videoInfoService.topMatByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt);
|
|
|
+ return videoInfoService.topMatByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt);
|
|
|
+ }else if(createType == 4){
|
|
|
+ return videoInfoService.historyMatByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 图片素材
|
|
|
+ */
|
|
|
+ private List<ByteDanceVideoInfo> getImageInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
|
|
|
+ //根据 imageMode 获取素材类型
|
|
|
+ //1-大图横图; 2-大图竖图
|
|
|
+ String imageMode = BytedanceCreativeMatTypeEnum.getNameByType(strategy.getCreativeImageMode());
|
|
|
+ //1:上新素材 2:跑量素材 3:遗漏素材 4:打捞素材
|
|
|
+ if(createType == 1||createType == 3){
|
|
|
+ return videoInfoService.imageListByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt,0);
|
|
|
+ }else if(createType == 2){
|
|
|
+ return videoInfoService.imageTopMatByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt);
|
|
|
}else if(createType == 4){
|
|
|
- return videoInfoService.listByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt,20);
|
|
|
+ return videoInfoService.imageHistoryMatByParams(projectId,strategy.getAccountId(),imageMode,startTime,endTime,videoCnt);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ private List<ByteDanceVideoInfo> getvideoOrImageInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
|
|
|
+ //横板视频 || 竖版视频
|
|
|
+ if (strategy.getCreativeImageMode().equalsIgnoreCase("CREATIVE_IMAGE_MODE_VIDEO")
|
|
|
+ || strategy.getCreativeImageMode().equalsIgnoreCase("CREATIVE_IMAGE_MODE_VIDEO_VERTICAL")){
|
|
|
+ //获取 视频 素材
|
|
|
+ return getVideoInfoByCreateType(projectId,strategy,startTime,endTime,createType,videoCnt);
|
|
|
+ }
|
|
|
+ //获取 图片 素材
|
|
|
+ return getImageInfoByCreateType(projectId,strategy,startTime,endTime,createType,videoCnt);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 修改状态 (0开-1关)
|
|
|
* 同一账户下只能有一条数据信息为开启,可以全部关闭
|