|
@@ -35,6 +35,7 @@ import javax.transaction.Transactional;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAutocreateLog;
|
|
|
|
|
|
/**
|
|
|
* 头条智能投放账户配置信息表
|
|
@@ -75,17 +76,33 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
ByteDanceGeneralCopywriterMapper byteDanceGeneralCopywriterMapper;
|
|
|
@Resource
|
|
|
BytedanceMaterialRejectReasonMapper bytedanceMaterialRejectReasonMapper;
|
|
|
+ @Autowired
|
|
|
+ IAiBytedanceAutocreateLogService iBytedanceAutocreateLogService;
|
|
|
@Override
|
|
|
public Long createCreative(AiBytedanceAdvertiserStrategy strategy, Integer createType, Long videoCnt, String openUrl) {
|
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(strategy.getAccountId()+"");
|
|
|
if (null == token) {
|
|
|
log.info("token获取失败=>accountId:{}", strategy.getAccountId());
|
|
|
+ AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
+ strategy.getAccountId(),
|
|
|
+ "获取token",
|
|
|
+ 500,
|
|
|
+ "token获取失败=>accountId:" + strategy.getAccountId(),
|
|
|
+ "tokenService.getOauthTokenByAccountId => "+ strategy.getAccountId());
|
|
|
+ iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
return videoCnt;
|
|
|
}
|
|
|
|
|
|
UserAllocation userAllocation = userAllocationService.getByAccountId(strategy.getAccountId());
|
|
|
if(null == userAllocation||userAllocation.getAccountStatus()!=0){
|
|
|
log.info("此账户不存在或者已经被关闭=>accountId:{}", token.getAccountId());
|
|
|
+ AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
+ token.getAccountId(),
|
|
|
+ "获取账户",
|
|
|
+ 500,
|
|
|
+ "此账户不存在或者已经被关闭=>accountId:" + token.getAccountId(),
|
|
|
+ "userAllocationService.getByAccountId => "+ token.getAccountId());
|
|
|
+ iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
return videoCnt;
|
|
|
}
|
|
|
//获取全量广告组数据
|
|
@@ -105,13 +122,20 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
List<ByteDanceVideoInfo> videoInfos = getVideoInfoByCreateType(userAllocation.getProjectId(),strategy,startTime,endTime,createType,videoCnt);
|
|
|
if(null == videoInfos||videoInfos.isEmpty()){
|
|
|
log.info("获取{}视频素材为空=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),token.getAccountId());
|
|
|
+ AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
+ token.getAccountId(),
|
|
|
+ "获取视频素材",
|
|
|
+ 500,
|
|
|
+ "获取"+BytedanceCreativeMatTypeEnum.getNameByType(createType+"")+"视频素材为空=>accountId:" + token.getAccountId(),
|
|
|
+ "AiBytedanceAdvertiserStrategyService.getVideoInfoByCreateType => projectId:"+userAllocation.getProjectId()+",strategy:"+strategy.toString()+",startTime:"+startTime+",endTime:"+endTime+",createType:"+createType+",videoCnt:"+videoCnt);
|
|
|
+ iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
return videoCnt;
|
|
|
}
|
|
|
log.info("获取{}视频素材个数:{}=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),videoInfos.size(),token.getAccountId());
|
|
|
|
|
|
for (ByteDanceVideoInfo video:videoInfos) {
|
|
|
Integer isLowQuality = bytedanceMaterialRejectReasonMapper.getIsLowQualityByVideoId(video.getVid()); //判断次视频是否是低质视频,为1跳过
|
|
|
- if(1 == isLowQuality){
|
|
|
+ if(!Check.isNull(isLowQuality) && 1 == isLowQuality){
|
|
|
continue;
|
|
|
}
|
|
|
Integer useDplinkIndex = strategy.getDpLinkIndexUsed();
|
|
@@ -159,12 +183,26 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
Result resultDeletePlan = marketingService.updPlanStatus(token,adIds,"delete");
|
|
|
if (!resultDeletePlan.isSuccess()){
|
|
|
log.info("广告计划删除失败:message==>{}",resultDeletePlan.getMessage());
|
|
|
+ AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
+ token.getAccountId(),
|
|
|
+ "删除广告计划",
|
|
|
+ resultDeletePlan.getCode(),
|
|
|
+ "广告计划删除失败 => message:" + resultDeletePlan.getMessage(),
|
|
|
+ "marketingService.updPlanStatus => token:"+ token.toString()+",adIds:"+adIds+",optstatus:delete");
|
|
|
+ iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
}
|
|
|
|
|
|
String message = creativeObject.getString("message");
|
|
|
Integer code = creativeObject.getInteger("code");
|
|
|
//创建创意失败
|
|
|
log.info("账户id:{};创意创建失败:code==>{};message==>{}",strategy.getAccountId(),code,message);
|
|
|
+ AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
+ strategy.getAccountId(),
|
|
|
+ "创建创意",
|
|
|
+ code,
|
|
|
+ "创意创建失败 => message:" + message,
|
|
|
+ "marketingService.creativeCreate => token:"+ token.toString()+",adIds:"+adIds+",creativeParams:"+creativeParams.toJSONString());
|
|
|
+ iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -231,11 +269,25 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
Result resultDeletePlan = marketingService.updPlanStatus(token,adIds,"delete");
|
|
|
if (!resultDeletePlan.isSuccess()){
|
|
|
log.info("广告计划删除失败:message==>{}",resultDeletePlan.getMessage());
|
|
|
+ AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
+ token.getAccountId(),
|
|
|
+ "删除广告计划",
|
|
|
+ resultDeletePlan.getCode(),
|
|
|
+ "广告计划删除失败 => message:" + resultDeletePlan.getMessage(),
|
|
|
+ "marketingService.updPlanStatus => token:"+ token.toString()+",adIds:"+adIds+",optstatus:delete");
|
|
|
+ iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
}
|
|
|
String message = creativeObject.getString("message");
|
|
|
Integer code = creativeObject.getInteger("code");
|
|
|
//创建创意失败
|
|
|
log.info("账户id:{};创意创建失败:code==>{};message==>{}",strategy.getAccountId(),code,message);
|
|
|
+ AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
+ strategy.getAccountId(),
|
|
|
+ "创建创意",
|
|
|
+ code,
|
|
|
+ "创意创建失败 => message:" + message,
|
|
|
+ "marketingService.creativeCreate => token:"+ token.toString()+",adIds:"+adIds+",creativeParams:"+creativeParams.toJSONString());
|
|
|
+ iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
continue;
|
|
|
}
|
|
|
|