|
@@ -145,22 +145,32 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(null == adId){
|
|
|
continue;
|
|
|
}
|
|
|
- adDplinkInfo.setAdId(adId);
|
|
|
- adDplinkInfo.setAccountId(strategy.getAccountId());
|
|
|
- adDplinkInfo.setStatus(1);
|
|
|
- adDplinkInfo.setStrategyId(strategy.getId());
|
|
|
- adDplinkInfoService.save(adDplinkInfo);
|
|
|
+
|
|
|
//3:创建创意
|
|
|
JSONObject creativeParams = getCreativeParams(strategy,adId,video,token);
|
|
|
log.info("账户id:{};创意创建参数:{}",strategy.getAccountId(),creativeParams);
|
|
|
JSONObject creativeObject = marketingService.creativeCreate(token,adId,creativeParams);
|
|
|
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());
|
|
|
+ }
|
|
|
+
|
|
|
String message = creativeObject.getString("message");
|
|
|
Integer code = creativeObject.getInteger("code");
|
|
|
//创建创意失败
|
|
|
log.info("账户id:{};创意创建失败:code==>{};message==>{}",strategy.getAccountId(),code,message);
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ adDplinkInfo.setAdId(adId);
|
|
|
+ adDplinkInfo.setAccountId(strategy.getAccountId());
|
|
|
+ adDplinkInfo.setStatus(1);
|
|
|
+ adDplinkInfo.setStrategyId(strategy.getId());
|
|
|
+ adDplinkInfoService.save(adDplinkInfo);
|
|
|
+
|
|
|
BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
|
|
|
videoCreativeLogService.saveOrUpdate(creativeLog);
|
|
|
videoCnt --;
|
|
@@ -207,23 +217,30 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(null == adId){
|
|
|
continue;
|
|
|
}
|
|
|
- adDplinkInfo.setAdId(adId);
|
|
|
- adDplinkInfo.setAccountId(strategy.getAccountId());
|
|
|
- adDplinkInfo.setStatus(1);
|
|
|
- adDplinkInfo.setStrategyId(strategy.getId());
|
|
|
- adDplinkInfoService.save(adDplinkInfo);
|
|
|
//3:创建创意
|
|
|
JSONObject creativeParams = getCreativeParams(strategy,adId,video,token);
|
|
|
log.info("创意创建参数:{}",creativeParams);
|
|
|
JSONObject creativeObject = marketingService.creativeCreate(token,adId,creativeParams);
|
|
|
log.info("创意创建返回数据:{}",creativeObject);
|
|
|
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());
|
|
|
+ }
|
|
|
String message = creativeObject.getString("message");
|
|
|
Integer code = creativeObject.getInteger("code");
|
|
|
//创建创意失败
|
|
|
log.info("账户id:{};创意创建失败:code==>{};message==>{}",strategy.getAccountId(),code,message);
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ adDplinkInfo.setAdId(adId);
|
|
|
+ adDplinkInfo.setAccountId(strategy.getAccountId());
|
|
|
+ adDplinkInfo.setStatus(1);
|
|
|
+ adDplinkInfo.setStrategyId(strategy.getId());
|
|
|
+ adDplinkInfoService.save(adDplinkInfo);
|
|
|
BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
|
|
|
videoCreativeLogService.saveOrUpdate(creativeLog);
|
|
|
videoCnt --;
|
|
@@ -368,6 +385,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
params.put("action_text",actionText);
|
|
|
}
|
|
|
|
|
|
+ //搭配试玩素材url
|
|
|
String playableUrl = strategy.getCreativePlayableUrl();
|
|
|
if(!Check.isNull(playableUrl)){
|
|
|
params.put("playable_url",playableUrl);
|
|
@@ -510,7 +528,9 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
//竞价策略 默认优先跑量
|
|
|
params.put("flow_control_mode","FLOW_CONTROL_MODE_FAST");
|
|
|
//投放范围
|
|
|
- params.put("delivery_range",strategy.getAdDeliveryRange());
|
|
|
+ if(null!=strategy.getAdDeliveryRange()&&!"".equals(strategy.getAdDeliveryRange().trim())){
|
|
|
+ params.put("delivery_range",strategy.getAdDeliveryRange());
|
|
|
+ }
|
|
|
if(!Check.isNull(strategy.getAdUnionVideoType())){
|
|
|
params.put("union_video_type",strategy.getAdUnionVideoType());
|
|
|
}
|
|
@@ -718,6 +738,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
params.put("exclude_flow_package",excludeFlowPackage);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if(!Check.isNull(strategy.getAdPlatform())){
|
|
|
String[] platform = strategy.getAdPlatform().split(",");
|
|
|
if(platform.length>0){
|
|
@@ -825,6 +846,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(!Check.isNull(strategy.getAdAutoExtendEnabled())){
|
|
|
params.put("auto_extend_enabled",strategy.getAdAutoExtendEnabled());
|
|
|
}
|
|
|
+ //可放开定向
|
|
|
if(!Check.isNull(strategy.getAdAutoExtendTargets())){
|
|
|
String[] autoExtendTargets = strategy.getAdAutoExtendTargets().split(",");
|
|
|
if(autoExtendTargets.length>0){
|
|
@@ -982,7 +1004,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(result.contains("{{序号}}")){
|
|
|
//查询当天已有计划数量
|
|
|
int i = adDplinkInfoService.getDpLinkInfoCount(strategy.getAccountId());
|
|
|
- Long num = GetCampaignNum.getCampaignNameNum(strategy.getCampaignCnt(),strategy.getCampaignAdCnt(),i);
|
|
|
+ Long num = GetCampaignNum.getCampaignNameNum(strategy.getCampaignCnt(),strategy.getCampaignAdCnt(), i == 0 ? i+1 : i);
|
|
|
result = result.replace("{{序号}}",String.valueOf(num));
|
|
|
}
|
|
|
|
|
@@ -1069,6 +1091,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
*/
|
|
|
@Override
|
|
|
public Result updStaOrCpaOrBudgetById(UpdAdStaOrCpaOrBudget updAdStaOrCpaOrBudget) {
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(updAdStaOrCpaOrBudget.getAccountId()));
|
|
|
//1-修改出价
|
|
|
if (BytedanceConstant.UPDTYPE_BID.equals(updAdStaOrCpaOrBudget.getType())) {
|
|
|
//查询计划预算
|
|
@@ -1105,6 +1128,16 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
}
|
|
|
aiBytedanceAdvertiserStrategyMapper.updBudgetById(updAdStaOrCpaOrBudget.getId(), updAdStaOrCpaOrBudget.getBudget(),updAdStaOrCpaOrBudget.getBudgetType());
|
|
|
+
|
|
|
+ //账户预算 同步 头条
|
|
|
+ //BUDGET_MODE_DAY-日预算
|
|
|
+ // BUDGET_MODE_INFINITE-不限
|
|
|
+ String accountBudgetMode = updAdStaOrCpaOrBudget.getBudgetType().equals("1") ? "BUDGET_MODE_INFINITE" : "BUDGET_MODE_DAY";
|
|
|
+ Result resultBudget = marketingService.updateBudget(token,accountBudgetMode,new BigDecimal(updAdStaOrCpaOrBudget.getBudget()));
|
|
|
+ /* if (!resultBudget.isSuccess()){
|
|
|
+ return Result.error(resultBudget.getMessage());
|
|
|
+ }*/
|
|
|
+
|
|
|
}
|
|
|
return Result.successMsg("修改"+(BytedanceConstant.UPDTYPE_BID.equals(updAdStaOrCpaOrBudget.getType()) ? "出价" : "预算")+"成功。",null);
|
|
|
}
|
|
@@ -1314,7 +1347,9 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
* @author zianY
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Result addBytedanceStrategy(AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(aiBytedanceAdvertiserStrategy.getAccountId()));
|
|
|
//预算金额不能低于当前已消费金额的105%
|
|
|
QueryWrapper<RuleDataAccount> ruleDataAccountQueryWrapper = new QueryWrapper<>();
|
|
|
ruleDataAccountQueryWrapper.eq("account_id",aiBytedanceAdvertiserStrategy.getAccountId());
|
|
@@ -1330,7 +1365,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 数据入库 string[] 转 string
|
|
|
//商品卖点
|
|
|
aiBytedanceAdvertiserStrategy.setCreativeProductSellingPoints(org.apache.commons.lang3.StringUtils.join(aiBytedanceAdvertiserStrategy.getProductSellingPoints(), ","));
|
|
@@ -1356,6 +1390,15 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
|
|
|
aiBytedanceAdvertiserStrategyMapper.insert(aiBytedanceAdvertiserStrategy);
|
|
|
|
|
|
+
|
|
|
+ //账户预算 同步 头条
|
|
|
+ //BUDGET_MODE_DAY-日预算
|
|
|
+ // BUDGET_MODE_INFINITE-不限
|
|
|
+ String accountBudgetMode = aiBytedanceAdvertiserStrategy.getAccountBudgetMode().equals("1") ? "BUDGET_MODE_INFINITE" : "BUDGET_MODE_DAY";
|
|
|
+ Result resultBudget = marketingService.updateBudget(token,accountBudgetMode,aiBytedanceAdvertiserStrategy.getAccountBudget());
|
|
|
+ /* if (!resultBudget.isSuccess()){
|
|
|
+ return Result.error(resultBudget.getMessage());
|
|
|
+ }*/
|
|
|
return Result.successMsg("新增成功。",aiBytedanceAdvertiserStrategy);
|
|
|
}
|
|
|
|
|
@@ -1376,32 +1419,36 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
private IByteDanceAdvertisePlanService planService;
|
|
|
@Override
|
|
|
public void customCreativeSupplement(AiBytedanceAdvertiserStrategy strategy, Integer hour,String openUrl) {
|
|
|
- Long customUnitCnt = strategy.getCampaignAdCnt()*strategy.getCampaignCnt();
|
|
|
- Long unitNum = customUnitCnt * hour / 19;
|
|
|
- log.info("{}当前时间内需要创建计划总数:{}", strategy.getAccountId(), unitNum);
|
|
|
- //查询当前账户创建自定义类型计划数量
|
|
|
- int unitCreateCnt = planService.queryToDayBuiltCount(strategy.getAccountId());
|
|
|
- log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
|
|
|
- long remindCnt = unitNum - unitCreateCnt;
|
|
|
- if (remindCnt >= 1) {
|
|
|
- log.info("{}计划创建不足,剩余需要创建个数{},使用上新素材创建", strategy.getAccountId(), remindCnt);
|
|
|
- //优先创建历史遗漏素材
|
|
|
- remindCnt = this.createCreative(strategy, 1, remindCnt,openUrl);
|
|
|
- }
|
|
|
- if (remindCnt >= 1) {
|
|
|
- log.info("{}计划创建不足,剩余需要创建个数{},使用历史遗漏素材创建", strategy.getAccountId(), remindCnt);
|
|
|
- //优先创建历史遗漏素材
|
|
|
- remindCnt = this.createCreative(strategy, 3, remindCnt,openUrl);
|
|
|
- }
|
|
|
- if (remindCnt >= 1) {
|
|
|
- log.info("{}计划创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
|
|
|
- //高质量素材
|
|
|
- remindCnt = this.createCreative(strategy, 2, remindCnt,openUrl);
|
|
|
- }
|
|
|
- if (remindCnt >= 1) {
|
|
|
- //历史打捞素材
|
|
|
- log.info("{}计划创建不足,剩余需要创建个数{},使用历史打捞素材创建", strategy.getAccountId(), remindCnt);
|
|
|
- this.createCreative(strategy, 4, remindCnt,openUrl);
|
|
|
+ try{
|
|
|
+ Long customUnitCnt = strategy.getCampaignAdCnt()*strategy.getCampaignCnt();
|
|
|
+ Long unitNum = customUnitCnt * hour / 19;
|
|
|
+ log.info("{}当前时间内需要创建计划总数:{}", strategy.getAccountId(), unitNum);
|
|
|
+ //查询当前账户创建自定义类型计划数量
|
|
|
+ int unitCreateCnt = planService.queryToDayBuiltCount(strategy.getAccountId());
|
|
|
+ log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
|
|
|
+ long remindCnt = unitNum - unitCreateCnt;
|
|
|
+ if (remindCnt >= 1) {
|
|
|
+ log.info("{}计划创建不足,剩余需要创建个数{},使用上新素材创建", strategy.getAccountId(), remindCnt);
|
|
|
+ //优先创建历史遗漏素材
|
|
|
+ remindCnt = this.createCreative(strategy, 1, remindCnt,openUrl);
|
|
|
+ }
|
|
|
+ if (remindCnt >= 1) {
|
|
|
+ log.info("{}计划创建不足,剩余需要创建个数{},使用历史遗漏素材创建", strategy.getAccountId(), remindCnt);
|
|
|
+ //优先创建历史遗漏素材
|
|
|
+ remindCnt = this.createCreative(strategy, 3, remindCnt,openUrl);
|
|
|
+ }
|
|
|
+ if (remindCnt >= 1) {
|
|
|
+ log.info("{}计划创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
|
|
|
+ //高质量素材
|
|
|
+ remindCnt = this.createCreative(strategy, 2, remindCnt,openUrl);
|
|
|
+ }
|
|
|
+ if (remindCnt >= 1) {
|
|
|
+ //历史打捞素材
|
|
|
+ log.info("{}计划创建不足,剩余需要创建个数{},使用历史打捞素材创建", strategy.getAccountId(), remindCnt);
|
|
|
+ this.createCreative(strategy, 4, remindCnt,openUrl);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|