|
@@ -78,32 +78,14 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
@Autowired
|
|
|
IAiBytedanceAutocreateLogService iBytedanceAutocreateLogService;
|
|
|
|
|
|
- private synchronized AiBytedanceAdDplinkInfo getlatestDpLinkInfo(AiBytedanceAdvertiserStrategy strategy,int status){
|
|
|
- AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),status);
|
|
|
- if(null == adDplinkInfo){
|
|
|
- adDplinkInfo = new AiBytedanceAdDplinkInfo();
|
|
|
- if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
|
|
|
- adDplinkInfo.setAdBid(strategy.getAdCpaBid());
|
|
|
- }else{
|
|
|
- adDplinkInfo.setAdBid(strategy.getAdMinBid());
|
|
|
- }
|
|
|
- adDplinkInfo.setDpLinkIndex(strategy.getDpLinkStartIndex());
|
|
|
- }else{
|
|
|
- adDplinkInfo.setId(null);
|
|
|
- adDplinkInfo.setDpLinkIndex(adDplinkInfo.getDpLinkIndex()+1);
|
|
|
- }
|
|
|
- return adDplinkInfo;
|
|
|
- }
|
|
|
-
|
|
|
- private synchronized void saveDpLink(AiBytedanceAdDplinkInfo dplinkInfo){
|
|
|
- adDplinkInfoService.save(dplinkInfo);
|
|
|
- }
|
|
|
@Override
|
|
|
- public Long createCreative(CtopOauthToken token, AiBytedanceAdvertiserStrategy strategy, Integer createType, Long videoCnt, String openUrl) {
|
|
|
+ public synchronized Long createCreative(CtopOauthToken token, AiBytedanceAdvertiserStrategy strategy, Integer createType, Long videoCnt, String openUrl) {
|
|
|
UserAllocation userAllocation = userAllocationService.getByAccountId(strategy.getAccountId());
|
|
|
if(null == userAllocation||userAllocation.getAccountStatus()!=0){
|
|
|
log.info("此账户不存在或者已经被关闭=>accountId:{}", token.getAccountId());
|
|
|
- AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(token.getAccountId(), "获取账户",
|
|
|
+ AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
+ token.getAccountId(),
|
|
|
+ "获取账户",
|
|
|
500,
|
|
|
"此账户不存在或者已经被关闭=>accountId:" + token.getAccountId(),
|
|
|
"userAllocationService.getByAccountId => "+ token.getAccountId());
|
|
@@ -151,7 +133,20 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
Integer useDplinkIndex = strategy.getDpLinkIndexUsed();
|
|
|
if(null==useDplinkIndex||useDplinkIndex.equals(0)){
|
|
|
//查看已使用的dp链接
|
|
|
- AiBytedanceAdDplinkInfo adDplinkInfo = getlatestDpLinkInfo(strategy,1);
|
|
|
+ AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),1);
|
|
|
+ if(null == adDplinkInfo){
|
|
|
+ adDplinkInfo = new AiBytedanceAdDplinkInfo();
|
|
|
+ if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
|
|
|
+ adDplinkInfo.setAdBid(strategy.getAdCpaBid());
|
|
|
+ }else{
|
|
|
+ adDplinkInfo.setAdBid(strategy.getAdMinBid());
|
|
|
+ }
|
|
|
+ adDplinkInfo.setDpLinkIndex(strategy.getDpLinkStartIndex());
|
|
|
+ }else{
|
|
|
+ adDplinkInfo.setId(null);
|
|
|
+ adDplinkInfo.setDpLinkIndex(adDplinkInfo.getDpLinkIndex()+1);
|
|
|
+ }
|
|
|
+
|
|
|
//不使用dp链接
|
|
|
String date = DateUtils.formatDate();
|
|
|
//组名称
|
|
@@ -180,18 +175,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(null!=creativeObject.getInteger("code")&&creativeObject.getInteger("code")!=0){
|
|
|
List<Long> adIds = new ArrayList<>();
|
|
|
adIds.add(adId);
|
|
|
- Result resultDeletePlan = marketingService.updPlanStatus(token,adIds,"delete");
|
|
|
- if (!resultDeletePlan.isSuccess()){
|
|
|
- log.info("广告计划删除失败:message==>{}",resultDeletePlan.getMessage());
|
|
|
- AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
- token.getAccountId(),
|
|
|
- "广告计划删除失败",
|
|
|
- resultDeletePlan.getCode(),
|
|
|
- resultDeletePlan.getMessage(),
|
|
|
- "marketingService.updPlanStatus => token:"+ token.toString()+",adIds:"+adIds.toString()+",optstatus:delete");
|
|
|
- iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
- }
|
|
|
-
|
|
|
+ marketingService.updPlanStatus(token,adIds,"delete");
|
|
|
String message = creativeObject.getString("message");
|
|
|
Integer code = creativeObject.getInteger("code");
|
|
|
//创建创意失败
|
|
@@ -211,7 +195,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
adDplinkInfo.setStatus(1);
|
|
|
adDplinkInfo.setStrategyId(strategy.getId());
|
|
|
adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
|
|
|
- saveDpLink(adDplinkInfo);
|
|
|
+ adDplinkInfoService.save(adDplinkInfo);
|
|
|
|
|
|
BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
|
|
|
videoCreativeLogService.saveOrUpdate(creativeLog);
|
|
@@ -221,7 +205,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
}else{
|
|
|
Long dpIndex ;
|
|
|
- AiBytedanceAdDplinkInfo adDplinkInfo = getlatestDpLinkInfo(strategy,1);
|
|
|
+ AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),strategy.getCreativeImageMode(),1);
|
|
|
if(null == adDplinkInfo){
|
|
|
adDplinkInfo = new AiBytedanceAdDplinkInfo();
|
|
|
if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
|
|
@@ -238,15 +222,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
// 超出下标范围
|
|
|
// 已使用dp链接 < 账户配置结束下标 || 已使用dp链接 > 结束下标
|
|
|
if( dpIndex < strategy.getDpLinkStartIndex() || dpIndex > strategy.getDpLinkEndIndex()){
|
|
|
- log.info("此账户策略创建结束===已创建dp链接超过了限制===>账户id:{};策略id:{}", token.getAccountId(),strategy.getId());
|
|
|
- AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
- token.getAccountId(),
|
|
|
- "策略创建结束",
|
|
|
- 500,
|
|
|
- "已创建dp链接超过了限制",
|
|
|
- "token:"+ token.toString()+",策略id:"+strategy.getId()+
|
|
|
- dpIndex+"<" + strategy.getDpLinkStartIndex() +"||" +dpIndex +">" + strategy.getDpLinkEndIndex());
|
|
|
- iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
+ log.info("策略创建结束===dp链接超过了限制===>账户id:{};策略id:{}", token.getAccountId(),strategy.getId());
|
|
|
return 0L;
|
|
|
}
|
|
|
//组名称
|
|
@@ -278,17 +254,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(null!=creativeObject.getInteger("code")&&creativeObject.getInteger("code")!=0){
|
|
|
List<Long> adIds = new ArrayList<>();
|
|
|
adIds.add(adId);
|
|
|
- Result resultDeletePlan = marketingService.updPlanStatus(token,adIds,"delete");
|
|
|
- if (!resultDeletePlan.isSuccess()){
|
|
|
- log.info("广告计划删除失败:message==>{}",resultDeletePlan.getMessage());
|
|
|
- AiBytedanceAutocreateLog iBytedanceAutocreateLog = new AiBytedanceAutocreateLog(
|
|
|
- token.getAccountId(),
|
|
|
- "广告计划删除失败",
|
|
|
- resultDeletePlan.getCode(),
|
|
|
- resultDeletePlan.getMessage(),
|
|
|
- "marketingService.updPlanStatus => token:"+ token.toString()+",adIds:"+adIds.toString()+",optstatus:delete");
|
|
|
- iBytedanceAutocreateLogService.save(iBytedanceAutocreateLog);
|
|
|
- }
|
|
|
+ marketingService.updPlanStatus(token,adIds,"delete");
|
|
|
String message = creativeObject.getString("message");
|
|
|
Integer code = creativeObject.getInteger("code");
|
|
|
//创建创意失败
|
|
@@ -308,7 +274,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
adDplinkInfo.setStatus(1);
|
|
|
adDplinkInfo.setStrategyId(strategy.getId());
|
|
|
adDplinkInfo.setImageMode(strategy.getCreativeImageMode());
|
|
|
- saveDpLink(adDplinkInfo);
|
|
|
+ adDplinkInfoService.save(adDplinkInfo);
|
|
|
BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
|
|
|
videoCreativeLogService.saveOrUpdate(creativeLog);
|
|
|
videoCnt --;
|