|
@@ -83,6 +83,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
log.info("此账户不存在或者已经被关闭=>accountId:{}", token.getAccountId());
|
|
log.info("此账户不存在或者已经被关闭=>accountId:{}", token.getAccountId());
|
|
return videoCnt;
|
|
return videoCnt;
|
|
}
|
|
}
|
|
|
|
+ //获取全量广告组数据
|
|
|
|
+ campaignService.getAdvertiserCampaign(token, null, null);
|
|
//查询相应的素材信息
|
|
//查询相应的素材信息
|
|
Long timeStart = BytedanceCreativeMatTypeEnum.getStartTimeByType(createType.toString());
|
|
Long timeStart = BytedanceCreativeMatTypeEnum.getStartTimeByType(createType.toString());
|
|
Long timeEnd = BytedanceCreativeMatTypeEnum.getEndTimeByType(createType.toString());
|
|
Long timeEnd = BytedanceCreativeMatTypeEnum.getEndTimeByType(createType.toString());
|
|
@@ -106,64 +108,121 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
if(null == slogenInfos||slogenInfos.isEmpty()){
|
|
if(null == slogenInfos||slogenInfos.isEmpty()){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- // 2:创建计划
|
|
|
|
- Long dpIndex ;
|
|
|
|
- AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),1);
|
|
|
|
- if(null == adDplinkInfo){
|
|
|
|
- adDplinkInfo = new AiBytedanceAdDplinkInfo();
|
|
|
|
- if("FIX".equalsIgnoreCase(strategy.getAdBidCreateType())){
|
|
|
|
- adDplinkInfo.setAdBid(strategy.getAdCpaBid());
|
|
|
|
|
|
+ Integer useDplinkIndex = strategy.getDpLinkIndexUsed();
|
|
|
|
+ if(null==useDplinkIndex||useDplinkIndex.equals(0)){
|
|
|
|
+ Long dpIndex ;
|
|
|
|
+ AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),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{
|
|
}else{
|
|
- adDplinkInfo.setAdBid(strategy.getAdMinBid());
|
|
|
|
|
|
+ adDplinkInfo.setId(null);
|
|
|
|
+ adDplinkInfo.setDpLinkIndex(adDplinkInfo.getDpLinkIndex()+1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //不使用dp链接
|
|
|
|
+ String date = DateUtils.formatDate();
|
|
|
|
+ String campaignName = getCampaignName(strategy,null,date);
|
|
|
|
+ Long campaignId = getCampaignId(strategy,campaignName,token);
|
|
|
|
+ if(null == campaignId){
|
|
|
|
+ return videoCnt;
|
|
|
|
+ }
|
|
|
|
+ //计划名称
|
|
|
|
+ String adName = getAdName(strategy,null,video);
|
|
|
|
+ //计算本次出价
|
|
|
|
+ BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid());
|
|
|
|
+ JSONObject adParams = getAdParams(strategy,adName,campaignId,currentCpaBid);
|
|
|
|
+ Long adId = createAdInfo(token,strategy,adParams);
|
|
|
|
+ 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);
|
|
|
|
+ if(null!=creativeObject.getInteger("code")&&creativeObject.getInteger("code")!=0){
|
|
|
|
+ String message = creativeObject.getString("message");
|
|
|
|
+ Integer code = creativeObject.getInteger("code");
|
|
|
|
+ //创建创意失败
|
|
|
|
+ log.info("创意创建失败:code==>{};message==>{}",code,message);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ videoCnt --;
|
|
|
|
+ if(videoCnt<=0){
|
|
|
|
+ return 0L;
|
|
}
|
|
}
|
|
- adDplinkInfo.setDpLinkIndex(strategy.getDpLinkStartIndex());
|
|
|
|
}else{
|
|
}else{
|
|
- adDplinkInfo.setId(null);
|
|
|
|
- adDplinkInfo.setDpLinkIndex(adDplinkInfo.getDpLinkIndex()+1);
|
|
|
|
- }
|
|
|
|
- dpIndex = adDplinkInfo.getDpLinkIndex();
|
|
|
|
- if(dpIndex>strategy.getDpLinkEndIndex()){
|
|
|
|
- log.info("此账户策略创建结束=>账户id:{};策略id:{}", token.getAccountId(),strategy.getId());
|
|
|
|
- return 0L;
|
|
|
|
- }
|
|
|
|
- String campaignName = getCampaignName(strategy,dpIndex);
|
|
|
|
- Long campaignId = getCampaignId(strategy,campaignName,token);
|
|
|
|
- if(null == campaignId){
|
|
|
|
- return videoCnt;
|
|
|
|
- }
|
|
|
|
- strategy.setAdOpenUrl(openUrl.replace("{{dp链接下标}}",dpIndex.toString()));
|
|
|
|
- String dplinkCode = StringUtils.getParamFromUrl(strategy.getAdOpenUrl(),"bc_fl_src");
|
|
|
|
- String adName = getAdName(strategy,dplinkCode,video);
|
|
|
|
- //计算本次出价
|
|
|
|
- BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid());
|
|
|
|
- adDplinkInfo.setAdBid(currentCpaBid);
|
|
|
|
- JSONObject adParams = getAdParams(strategy,adName,campaignId,currentCpaBid);
|
|
|
|
- Long adId = createAdInfo(token,strategy,adParams);
|
|
|
|
- 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);
|
|
|
|
- if(null!=creativeObject.getInteger("code")&&creativeObject.getInteger("code")!=0){
|
|
|
|
- String message = creativeObject.getString("message");
|
|
|
|
- Integer code = creativeObject.getInteger("code");
|
|
|
|
- //创建创意失败
|
|
|
|
- log.info("创意创建失败:code==>{};message==>{}",code,message);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- videoCnt --;
|
|
|
|
- if(videoCnt<=0){
|
|
|
|
- return 0L;
|
|
|
|
|
|
+ Long dpIndex ;
|
|
|
|
+ AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),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);
|
|
|
|
+ }
|
|
|
|
+ dpIndex = adDplinkInfo.getDpLinkIndex();
|
|
|
|
+ if(dpIndex>strategy.getDpLinkEndIndex()){
|
|
|
|
+ log.info("此账户策略创建结束=>账户id:{};策略id:{}", token.getAccountId(),strategy.getId());
|
|
|
|
+ return 0L;
|
|
|
|
+ }
|
|
|
|
+ //组名称
|
|
|
|
+ String campaignName = getCampaignName(strategy,dpIndex,null);
|
|
|
|
+ Long campaignId = getCampaignId(strategy,campaignName,token);
|
|
|
|
+ if(null == campaignId){
|
|
|
|
+ return videoCnt;
|
|
|
|
+ }
|
|
|
|
+ strategy.setAdOpenUrl(openUrl.replace("{{dp链接下标}}",dpIndex.toString()));
|
|
|
|
+ String dplinkCode = StringUtils.getParamFromUrl(strategy.getAdOpenUrl(),"bc_fl_src");
|
|
|
|
+ //计划名称
|
|
|
|
+ String adName = getAdName(strategy,dplinkCode,video);
|
|
|
|
+ //计算本次出价
|
|
|
|
+ BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid());
|
|
|
|
+ adDplinkInfo.setAdBid(currentCpaBid);
|
|
|
|
+ JSONObject adParams = getAdParams(strategy,adName,campaignId,currentCpaBid);
|
|
|
|
+ Long adId = createAdInfo(token,strategy,adParams);
|
|
|
|
+ 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);
|
|
|
|
+ if(null!=creativeObject.getInteger("code")&&creativeObject.getInteger("code")!=0){
|
|
|
|
+ String message = creativeObject.getString("message");
|
|
|
|
+ Integer code = creativeObject.getInteger("code");
|
|
|
|
+ //创建创意失败
|
|
|
|
+ log.info("创意创建失败:code==>{};message==>{}",code,message);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ videoCnt --;
|
|
|
|
+ if(videoCnt<=0){
|
|
|
|
+ return 0L;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return videoCnt;
|
|
return videoCnt;
|
|
|
|
+
|
|
}
|
|
}
|
|
private JSONObject getCreativeParams(AiBytedanceAdvertiserStrategy strategy, Long adId,ByteDanceVideoInfo videoInfo,CtopOauthToken token) {
|
|
private JSONObject getCreativeParams(AiBytedanceAdvertiserStrategy strategy, Long adId,ByteDanceVideoInfo videoInfo,CtopOauthToken token) {
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
@@ -794,12 +853,12 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
String date = DateUtils.formatDate(new Date(),"yyyyMMdd");
|
|
String date = DateUtils.formatDate(new Date(),"yyyyMMdd");
|
|
adName = adName.replace("{{日期}}",date);
|
|
adName = adName.replace("{{日期}}",date);
|
|
}
|
|
}
|
|
- if(adName.contains("{{dp链接标识}}")){
|
|
|
|
|
|
+ if(adName.contains("{{dp链接标识}}")&&null!=dplinkCode){
|
|
adName = adName.replace("{{dp链接标识}}",dplinkCode);
|
|
adName = adName.replace("{{dp链接标识}}",dplinkCode);
|
|
}
|
|
}
|
|
if(adName.contains("{{出价方式}}")){
|
|
if(adName.contains("{{出价方式}}")){
|
|
String pricing = strategy.getAdPricing().replace("PRICING_","");
|
|
String pricing = strategy.getAdPricing().replace("PRICING_","");
|
|
- adName = adName.replace("{{出价方式}}",pricing);
|
|
|
|
|
|
+ adName = adName.replace("{{出价方式}}",pricing).toLowerCase(Locale.ROOT);
|
|
}
|
|
}
|
|
if(adName.contains("{{素材名称}}")){
|
|
if(adName.contains("{{素材名称}}")){
|
|
MaterialInfo info = materialInfoService.getParams(videoInfo.getSignature(),null);
|
|
MaterialInfo info = materialInfoService.getParams(videoInfo.getSignature(),null);
|
|
@@ -849,9 +908,16 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
return (Long)campaignData.getResult();
|
|
return (Long)campaignData.getResult();
|
|
}
|
|
}
|
|
|
|
|
|
- private String getCampaignName(AiBytedanceAdvertiserStrategy strategy,Long dplinkIndex) {
|
|
|
|
- String campaignSufix = getRangeIndex(strategy.getDpLinkStartIndex(),strategy.getDpLinkEndIndex(),strategy.getCampaignAdCnt(),dplinkIndex);
|
|
|
|
- return strategy.getCampaignName()+campaignSufix;
|
|
|
|
|
|
+ private String getCampaignName(AiBytedanceAdvertiserStrategy strategy,Long dplinkIndex,String date) {
|
|
|
|
+ String result = strategy.getCampaignName();
|
|
|
|
+ if(null!=dplinkIndex&&dplinkIndex!=0){
|
|
|
|
+ String campaignSufix = getRangeIndex(strategy.getDpLinkStartIndex(),strategy.getDpLinkEndIndex(),strategy.getCampaignAdCnt(),dplinkIndex);
|
|
|
|
+ result = result+campaignSufix;
|
|
|
|
+ }
|
|
|
|
+ if(null!=date&&!date.trim().equals("")){
|
|
|
|
+ result = result +"-"+date;
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
private String getRangeIndex(Long dpLinkStartIndex,Long dpLinkEndIndex, Long campaignAdCnt, Long dpIndex) {
|
|
private String getRangeIndex(Long dpLinkStartIndex,Long dpLinkEndIndex, Long campaignAdCnt, Long dpIndex) {
|
|
@@ -1136,8 +1202,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
* @description: 添加配置 信息
|
|
* @description: 添加配置 信息
|
|
*
|
|
*
|
|
* @param aiBytedanceAdvertiserStrategy
|
|
* @param aiBytedanceAdvertiserStrategy
|
|
- * @return: org.jeecg.common.api.vo.Result
|
|
|
|
- * @author: zianY
|
|
|
|
|
|
+ * @return org.jeecg.common.api.vo.Result
|
|
|
|
+ * @author zianY
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Result addBytedanceStrategy(AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
|
|
public Result addBytedanceStrategy(AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
|
|
@@ -1225,7 +1291,13 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
@Override
|
|
@Override
|
|
public Result getAdActionText(String accountId, String landingType, String advancedCreativeType) throws Exception{
|
|
public Result getAdActionText(String accountId, String landingType, String advancedCreativeType) throws Exception{
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
- return marketingService.getActionText(token,landingType,advancedCreativeType);
|
|
|
|
|
|
+ // return marketingService.getActionText(token,landingType,advancedCreativeType);
|
|
|
|
+ //行动号召 不使用 api接口获取 使用自定义
|
|
|
|
+ String actionText[] = {"购买同款","专属优惠","抢抢看","去看看","立即下单",
|
|
|
|
+ "获取优惠","查看详情","更多精彩","查看惊喜","领取好礼",
|
|
|
|
+ "去逛逛","领取福利","来拼一拼","立即抢购","更多秒杀",
|
|
|
|
+ "更多优惠","了解更多","了解详情","点击抢购"};
|
|
|
|
+ return Result.successMsg("返回行动号召成功。", actionText);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1234,13 +1306,13 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
- * @description: 获取定向包
|
|
|
|
|
|
+ * 获取定向包
|
|
*
|
|
*
|
|
* @param accountId 广告主id
|
|
* @param accountId 广告主id
|
|
* @param landingType 投放目标
|
|
* @param landingType 投放目标
|
|
* @param deliveryRange
|
|
* @param deliveryRange
|
|
- * @return: org.jeecg.common.api.vo.Result
|
|
|
|
- * @author: zianY
|
|
|
|
|
|
+ * @return org.jeecg.common.api.vo.Result
|
|
|
|
+ * @author zianY
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Result getAdAudiencePackage(String accountId, String landingType, String deliveryRange){
|
|
public Result getAdAudiencePackage(String accountId, String landingType, String deliveryRange){
|
|
@@ -1273,11 +1345,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
- * @description: 获取人群包列表信息
|
|
|
|
|
|
+ * 获取人群包列表信息
|
|
*
|
|
*
|
|
* @param accountId
|
|
* @param accountId
|
|
- * @return: org.jeecg.common.api.vo.Result
|
|
|
|
- * @author: zianY
|
|
|
|
|
|
+ * @return org.jeecg.common.api.vo.Result
|
|
|
|
+ * @author zianY
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Result getDMPCustomAudience(String accountId){
|
|
public Result getDMPCustomAudience(String accountId){
|
|
@@ -1308,6 +1380,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
public Result createAudiencePackage(String accountId){
|
|
public Result createAudiencePackage(String accountId){
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
Result list = marketingService.createAudiencePackage(token);
|
|
Result list = marketingService.createAudiencePackage(token);
|