|
@@ -3,10 +3,9 @@ package org.jeecg.modules.bytedance.advertise.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.bytedance.advertise.dockapi.Marketing;
|
|
@@ -20,27 +19,17 @@ import org.jeecg.modules.bytedance.advertise.vo.IndustryVo;
|
|
|
import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
|
|
|
import org.jeecg.modules.bytedance.common.constant.BytedanceConstant;
|
|
|
import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
|
|
|
-import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
|
|
|
import org.jeecg.modules.bytedance.common.entity.MaterialImageInfo;
|
|
|
+import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
|
|
|
import org.jeecg.modules.bytedance.common.entity.UserAllocation;
|
|
|
-import org.jeecg.modules.bytedance.common.service.ICtopOauthTokenService;
|
|
|
-import org.jeecg.modules.bytedance.common.service.IMaterialImageInfoService;
|
|
|
-import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
|
|
|
-import org.jeecg.modules.bytedance.common.service.IUserAllocationService;
|
|
|
-import org.jeecg.modules.bytedance.common.utils.Check;
|
|
|
+import org.jeecg.modules.bytedance.common.service.*;
|
|
|
import org.jeecg.modules.bytedance.common.utils.Check;
|
|
|
import org.jeecg.modules.bytedance.common.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.spi.LocaleServiceProvider;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 头条智能投放账户配置信息表
|
|
@@ -51,18 +40,28 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiBytedanceAdvertiserStrategyMapper, AiBytedanceAdvertiserStrategy> implements IAiBytedanceAdvertiserStrategyService {
|
|
|
-
|
|
|
@Autowired
|
|
|
- private ICtopOauthTokenService tokenService;
|
|
|
-
|
|
|
+ private IBytedanceVideoSlogenInfoService slogenInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IFileInfoService fileInfoService;
|
|
|
@Resource
|
|
|
private AiBytedanceAdvertiserStrategyMapper aiBytedanceAdvertiserStrategyMapper;
|
|
|
@Autowired
|
|
|
- private IUserAllocationService userAllocationService;
|
|
|
-
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
@Autowired
|
|
|
private IMaterialImageInfoService materialImageInfoService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IUserAllocationService userAllocationService;
|
|
|
+ @Autowired
|
|
|
+ private IBytedanceImageInfoService bytedanceImageInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IMaterialInfoService materialInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceCampaignService campaignService;
|
|
|
+ @Autowired
|
|
|
+ private IAiBytedanceAdDplinkInfoService adDplinkInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceVideoInfoService videoInfoService;
|
|
|
|
|
|
@Override
|
|
|
public Long createCreative(AiBytedanceAdvertiserStrategy strategy,Integer createType, Long videoCnt) {
|
|
@@ -88,25 +87,12 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
log.info("获取视频素材为空=>accountId:{}", token.getAccountId());
|
|
|
return videoCnt;
|
|
|
}
|
|
|
- //
|
|
|
/**
|
|
|
* 1:创建组
|
|
|
* 查询当前账户排列到的dp链接标识号
|
|
|
- *
|
|
|
*/
|
|
|
- Long dpIndex ;
|
|
|
- AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),1);
|
|
|
- if(null == adDplinkInfo){
|
|
|
- dpIndex = strategy.getDpLinkStartIndex();
|
|
|
- }else{
|
|
|
- dpIndex = adDplinkInfo.getDpLinkIndex()+1;
|
|
|
- }
|
|
|
- if(dpIndex>strategy.getDpLinkEndIndex()){
|
|
|
- log.info("此账户策略创建结束=>账户id:{};策略id:{}", token.getAccountId(),strategy.getId());
|
|
|
- return 0L;
|
|
|
- }
|
|
|
//根据dpLink获取组名称
|
|
|
- String campaignName = getCampaignName(dpIndex,strategy);
|
|
|
+ String campaignName = getCampaignName(strategy);
|
|
|
Long campaignId = getCampaignId(strategy,campaignName,token);
|
|
|
if(null == campaignId){
|
|
|
return videoCnt;
|
|
@@ -115,7 +101,20 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
/**
|
|
|
* 2:创建计划
|
|
|
*/
|
|
|
- //1:应用直达链接
|
|
|
+ Long dpIndex ;
|
|
|
+ AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),1);
|
|
|
+ if(null == adDplinkInfo){
|
|
|
+ adDplinkInfo = new AiBytedanceAdDplinkInfo();
|
|
|
+ adDplinkInfo.setDpLinkIndex(strategy.getDpLinkStartIndex());
|
|
|
+ }else{
|
|
|
+ adDplinkInfo.setId(null);
|
|
|
+ adDplinkInfo.setDpLinkIndex(adDplinkInfo.getDpLinkIndex()+1);
|
|
|
+ }
|
|
|
+ dpIndex = strategy.getDpLinkStartIndex();
|
|
|
+ if(dpIndex>strategy.getDpLinkEndIndex()){
|
|
|
+ log.info("此账户策略创建结束=>账户id:{};策略id:{}", token.getAccountId(),strategy.getId());
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
strategy.setAdOpenUrl(strategy.getAdOpenUrl().replace("{{dp链接下标}}",dpIndex.toString()));
|
|
|
String dplinkCode = StringUtils.getParamFromUrl(strategy.getAdOpenUrl(),"bc_fl_src");
|
|
|
String adName = getAdName(strategy,dplinkCode,video);
|
|
@@ -124,13 +123,27 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(null == adId){
|
|
|
continue;
|
|
|
}
|
|
|
+ adDplinkInfo.setAdId(adId);
|
|
|
+ adDplinkInfo.setAccountId(strategy.getAccountId());
|
|
|
+ adDplinkInfo.setStatus(1);
|
|
|
+ adDplinkInfo.setStratrgyId(strategy.getId());
|
|
|
+ adDplinkInfoService.save(adDplinkInfo);
|
|
|
//3:创建创意
|
|
|
JSONObject creativeParams = getCreativeParams(strategy,adId,video,token);
|
|
|
-
|
|
|
+ JSONObject creativeObject = Marketing.creativeCreate(token,adId,creativeParams);
|
|
|
+ if(null!=creativeObject.getInteger("code")&&creativeObject.getInteger("code")!=0){
|
|
|
+ String message = creativeObject.getString("message");
|
|
|
+ //创建创意失败
|
|
|
+ log.info("创意创建失败:message==>{}",message);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ videoCnt --;
|
|
|
+ if(videoCnt<=0){
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
}
|
|
|
return videoCnt;
|
|
|
}
|
|
|
-
|
|
|
private JSONObject getCreativeParams(AiBytedanceAdvertiserStrategy strategy, Long adId,ByteDanceVideoInfo videoInfo,CtopOauthToken token) {
|
|
|
JSONObject params = new JSONObject();
|
|
|
params.put("advertiser_id",strategy.getAccountId());
|
|
@@ -253,15 +266,105 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
// params.put("ad_download_status",adDownloadStatus);
|
|
|
// }
|
|
|
//商品推广卡片
|
|
|
-
|
|
|
+ String imageCode = strategy.getCreativeProductImageCode();
|
|
|
+ if(!Check.isNull(imageCode)){
|
|
|
+ //1:根据imageCode获取图片id
|
|
|
+ JSONObject promotionCard = new JSONObject();
|
|
|
+ String iconImageId = getBytedanceImageIdByCode(imageCode,strategy,token);
|
|
|
+ if(!Check.isNull(iconImageId)){
|
|
|
+ promotionCard.put("product_image_id",iconImageId);
|
|
|
+ }
|
|
|
+ String productSellingPoints = strategy.getCreativeProductSellingPoints();
|
|
|
+ if(!Check.isNull(productSellingPoints)){
|
|
|
+ JSONArray pointArray = JSON.parseArray(productSellingPoints);
|
|
|
+ if(null!=pointArray&&pointArray.size()>0){
|
|
|
+ promotionCard.put("product_selling_points",pointArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String productDescription = strategy.getCreativeProductDescription();
|
|
|
+ if(Check.isNull(productDescription)){
|
|
|
+ promotionCard.put("product_description",productDescription);
|
|
|
+ }
|
|
|
+ Boolean enableStorePack = strategy.getCreativeEnablePersonalAction();
|
|
|
+ if(null!=enableStorePack){
|
|
|
+ promotionCard.put("enable_store_pack",enableStorePack);
|
|
|
+ }
|
|
|
+ String callToAction = strategy.getCreativeCallToAction();
|
|
|
+ if(!Check.isNull(callToAction)){
|
|
|
+ promotionCard.put("call_to_action",callToAction);
|
|
|
+ }
|
|
|
+ Boolean enablePersonalAction = strategy.getCreativeEnablePersonalAction();
|
|
|
+ if(null!=enablePersonalAction){
|
|
|
+ promotionCard.put("enable_personal_action",enablePersonalAction);
|
|
|
+ }
|
|
|
+ params.put("promotion_card",promotionCard);
|
|
|
+ }
|
|
|
+ //行业类别
|
|
|
+ String thirdIndustryId = strategy.getCreativeThirdIndustryId();
|
|
|
+ if(!Check.isNull(thirdIndustryId)){
|
|
|
+ params.put("third_industry_id",thirdIndustryId);
|
|
|
+ }
|
|
|
+ String adKeywords = strategy.getCreativeAdKeywords();
|
|
|
+ if(!Check.isNull(adKeywords)){
|
|
|
+ String [] keywords = adKeywords.split(",");
|
|
|
+ if(keywords.length>0){
|
|
|
+ JSONArray adkeywordsArray = new JSONArray();
|
|
|
+ for(int i=0;i<keywords.length;i++){
|
|
|
+ adkeywordsArray.add(keywords[i]);
|
|
|
+ }
|
|
|
+ params.put("ad_keywords",adkeywordsArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String trackUrl = strategy.getCreativeTrackUrl();
|
|
|
+ if(!Check.isNull(trackUrl)){
|
|
|
+ params.put("track_url",trackUrl);
|
|
|
+ }
|
|
|
+ String actionTrackUrl = strategy.getCreativeActionTrackUrl();
|
|
|
+ if(!Check.isNull(actionTrackUrl)){
|
|
|
+ params.put("action_track_url",actionTrackUrl);
|
|
|
+ }
|
|
|
+ String videoPlayEffectiveTrackUrl = strategy.getCreativeVideoPlayEffectiveTrackUrl();
|
|
|
+ if(!Check.isNull(videoPlayEffectiveTrackUrl)){
|
|
|
+ params.put("video_play_effective_track_url",videoPlayEffectiveTrackUrl);
|
|
|
+ }
|
|
|
+// String videoPlayDoneTrackUrl = strategy.getCreativeVideoPlayDoneTrackUrl();
|
|
|
+// if(!Check.isNull(videoPlayDoneTrackUrl)){
|
|
|
+// params.put("video_play_done_track_url",videoPlayDoneTrackUrl);
|
|
|
+// }
|
|
|
+ String videoPlayTrackUrl = strategy.getCreativeVideoPlayTrackUrl();
|
|
|
+ if(!Check.isNull(videoPlayTrackUrl)){
|
|
|
+ params.put("video_play_track_url",videoPlayTrackUrl);
|
|
|
+ }
|
|
|
return params;
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- private IBytedanceVideoSlogenInfoService slogenInfoService;
|
|
|
- private String getSuggestImageId(CtopOauthToken token, String vid) {
|
|
|
+ private String getBytedanceImageIdByCode(String imageCode, AiBytedanceAdvertiserStrategy strategy,CtopOauthToken token) {
|
|
|
+ //1:根据code获取图片信息
|
|
|
+ BytedanceImageInfo bytedanceImageInfo = bytedanceImageInfoService.getByParams(imageCode);
|
|
|
+ if(null!=bytedanceImageInfo){
|
|
|
+ return bytedanceImageInfo.getId();
|
|
|
+ }
|
|
|
+ //2:根据code查询图片素材信息
|
|
|
+ MaterialImageInfo imageInfo = materialImageInfoService.getByCode(imageCode);
|
|
|
+ if(null == imageInfo){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Map<String, Object> result = fileInfoService.uploadImageToBytedance(token.getAccountId().toString(),imageInfo.getUrl());
|
|
|
+ Integer code = (Integer) result.get("code");
|
|
|
+ if(null == code||code!=0){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ BytedanceImageInfo info = (BytedanceImageInfo)result.get("data");
|
|
|
+ if(null != info&&null!=info.getId()){
|
|
|
+ return info.getId();
|
|
|
+ }
|
|
|
return null;
|
|
|
+ //图片上传头条巨量后台
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getSuggestImageId(CtopOauthToken token, String vid) {
|
|
|
+ return fileInfoService.getSuggestImageId(token,vid);
|
|
|
}
|
|
|
|
|
|
private Long createAdInfo(CtopOauthToken token, AiBytedanceAdvertiserStrategy strategy, JSONObject adParams) {
|
|
@@ -597,11 +700,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return adName;
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- private IMaterialInfoService materialInfoService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IByteDanceCampaignService campaignService;
|
|
|
private Long getCampaignId(AiBytedanceAdvertiserStrategy strategy, String campaignName,CtopOauthToken token) {
|
|
|
ByteDanceCampaign campaign = campaignService.getOneByParams(strategy.getAccountId(),campaignName);
|
|
|
if(null != campaign){
|
|
@@ -630,15 +729,10 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return (Long)campaignData.getResult();
|
|
|
}
|
|
|
|
|
|
- private String getCampaignName(Long dpIndex, AiBytedanceAdvertiserStrategy strategy) {
|
|
|
- Long unitCreativeNum = strategy.getCampaignAdCnt();
|
|
|
- return null;
|
|
|
+ private String getCampaignName(AiBytedanceAdvertiserStrategy strategy) {
|
|
|
+ String campaignName = strategy.getCampaignName();
|
|
|
+ return campaignName+"-("+strategy.getDpLinkStartIndex()+"/"+strategy.getDpLinkEndIndex()+")";
|
|
|
}
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IAiBytedanceAdDplinkInfoService adDplinkInfoService;
|
|
|
- @Autowired
|
|
|
- private IByteDanceVideoInfoService videoInfoService;
|
|
|
private List<ByteDanceVideoInfo> getVideoInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
|
|
|
//1:上新素材 2:跑量素材 3:遗漏素材 4:打捞素材
|
|
|
if(createType == 1||createType == 3){
|
|
@@ -652,11 +746,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- String url = "taobaolite://m.ltao.com/open/index.html?action=ali.open.nav&module=h5&bootImage=0&source=toutiao&packageName=com.taobao.litetao&h5Url=https%3A%2F%2Fpages.tmall.com%2Fwow%2Fz%2Fsale%2FdynamicSolution%2Fsfbthp%3FdisableNav%3DYES%26wh_kangarooprefetch%3Dtrue%26needLogin%3Dtrue&bc_fl_src=sf_jrtt_huichuangzh_ptbt_{{dp链接下标}}&backurl=__back_url__";
|
|
|
- System.out.println(StringUtils.getParamFromUrl(url,"bc_fl_src"));
|
|
|
- }
|
|
|
/**
|
|
|
* 修改状态 (0开-1关)
|
|
|
* @param
|
|
@@ -707,7 +796,6 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if (!"200".equals(updResult.getCode())){
|
|
|
return Result.error(updResult.getMessage());
|
|
|
}*/
|
|
|
- // 修改 预算 TODO
|
|
|
priceList.forEach(map-> {
|
|
|
aiBytedanceAdvertiserStrategyMapper.updBudgetById(updAdStaOrCpaOrBudget.getId(),updAdStaOrCpaOrBudget.getBudget());
|
|
|
});
|
|
@@ -719,12 +807,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
- * @description: 获取行业类别
|
|
|
- *
|
|
|
+ * 获取行业类别
|
|
|
* @param accountId 广告主id
|
|
|
* @param type 行业类别
|
|
|
- * @return: org.jeecg.common.api.vo.Result
|
|
|
- * @author: zianY
|
|
|
+ * @return org.jeecg.common.api.vo.Result
|
|
|
+ * @author zianY
|
|
|
*/
|
|
|
public Result getIndustryList(String accountId,String type) throws Exception {
|
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
@@ -732,12 +819,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
log.info("token获取失败=>accountId:{}", token.getAccountId());
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
- // 获取行业列表
|
|
|
- Result industryList = Marketing.getToolIndustryList(token,type);
|
|
|
- log.error("行业列表=======>>>>>>>>>>>", industryList.getResult());
|
|
|
- return Result.successMsg("获取行业列表成功。", industryList.getResult());
|
|
|
// api 获取行业列表
|
|
|
- Result listResult = marketing.getToolIndustryList(token,type);
|
|
|
+ Result listResult = Marketing.getToolIndustryList(token,type);
|
|
|
List<Map<String,Object>> industryListMap = (List<Map<String,Object>>) listResult.getResult();
|
|
|
// list map 数据格式 转 list entity 数据格式
|
|
|
List<IndustryVo> industryList = Check.convertListMap2ListBean(industryListMap,IndustryVo.class);
|
|
@@ -804,7 +887,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
// 获取广告组
|
|
|
- Result industryList = marketing.getCampaignGroupList(token,accountId,adGroupSearchVoList,pageNo,pageSize);
|
|
|
+ Result industryList = Marketing.getCampaignGroupList(token,accountId,adGroupSearchVoList,pageNo,pageSize);
|
|
|
log.error("获取广告组=======>>>>>>>>>>>", industryList.getResult());
|
|
|
return Result.successMsg("获取广告组成功。", industryList.getResult());
|
|
|
}
|
|
@@ -813,25 +896,25 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
- * @description: 获取广告计划
|
|
|
+ * @description 获取广告计划
|
|
|
*
|
|
|
* @param accountId 广告主id
|
|
|
* @param adGroupSearchVoList
|
|
|
- * @param pageNo
|
|
|
- * @param pageSize
|
|
|
- * @return: org.jeecg.common.api.vo.Result
|
|
|
- * @author: zianY
|
|
|
+ * @param pageNo 页数
|
|
|
+ * @param pageSize 每页条数
|
|
|
+ * @return org.jeecg.common.api.vo.Result
|
|
|
+ * @author zianY
|
|
|
*/
|
|
|
public Result getCampaignPlan(String accountId, List<PlanSearchVo> adGroupSearchVoList, Integer pageNo, Integer pageSize) {
|
|
|
|
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
if (null == token) {
|
|
|
- log.info("token获取失败=>accountId:{}", token.getAccountId());
|
|
|
- return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
+ log.info("token获取失败=>accountId:{}", accountId);
|
|
|
+ return Result.error("token获取失败====>>>>accountId:"+accountId );
|
|
|
}
|
|
|
// 获取计划
|
|
|
- Result industryList = marketing.getPlanList(token,adGroupSearchVoList,pageNo,pageSize);
|
|
|
- log.error("获取广告计划=======>>>>>>>>>>>", industryList.getResult());
|
|
|
+ Result industryList = Marketing.getPlanList(token,adGroupSearchVoList,pageNo,pageSize);
|
|
|
+ log.error("获取广告计划=======>>>>>>>>>>>{}", industryList.getResult());
|
|
|
return Result.successMsg("获取广告计划成功。", industryList.getResult());
|
|
|
}
|
|
|
|
|
@@ -902,9 +985,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
log.info("token获取失败=>accountId:{}", token.getAccountId());
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
- Result resultCampaign = Marketing.getToolConvertQuery(token,adConvertQueryVo);
|
|
|
- return Result.successMsg("查询广告计划可用转化目标成功。", resultCampaign.getResult());
|
|
|
- return marketing.getToolConvertQuery(token,adConvertQueryVo);
|
|
|
+ return Marketing.getToolConvertQuery(token,adConvertQueryVo);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -920,11 +1001,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
public Result addBytedanceStrategy(AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
|
|
|
// 数据入库 string[] 转 string
|
|
|
//商品卖点
|
|
|
- aiBytedanceAdvertiserStrategy.setCreativeProductSellingPoints(StringUtils.join(aiBytedanceAdvertiserStrategy.getProductSellingPoints(), ","));
|
|
|
+ aiBytedanceAdvertiserStrategy.setCreativeProductSellingPoints(org.apache.commons.lang3.StringUtils.join(aiBytedanceAdvertiserStrategy.getProductSellingPoints(), ","));
|
|
|
//广告位置
|
|
|
- aiBytedanceAdvertiserStrategy.setCreativeInventoryType(StringUtils.join(aiBytedanceAdvertiserStrategy.getCreativeInventoryTypes(), ","));
|
|
|
+ aiBytedanceAdvertiserStrategy.setCreativeInventoryType(org.apache.commons.lang3.StringUtils.join(aiBytedanceAdvertiserStrategy.getCreativeInventoryTypes(), ","));
|
|
|
//创意标签
|
|
|
- aiBytedanceAdvertiserStrategy.setCreativeAdKeywords(StringUtils.join(aiBytedanceAdvertiserStrategy.getAdKeywords(), ","));
|
|
|
+ aiBytedanceAdvertiserStrategy.setCreativeAdKeywords(org.apache.commons.lang3.StringUtils.join(aiBytedanceAdvertiserStrategy.getAdKeywords(), ","));
|
|
|
|
|
|
//添加素材信息
|
|
|
MaterialImageInfo imageInfo = new MaterialImageInfo();
|
|
@@ -936,9 +1017,46 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return Result.successMsg("新增成功。",aiBytedanceAdvertiserStrategy);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AiBytedanceAdvertiserStrategy getByAccountId(Long accountId,Integer status) {
|
|
|
+ QueryWrapper<AiBytedanceAdvertiserStrategy> queryWrapper = new QueryWrapper<>();
|
|
|
+ if(null!=accountId){
|
|
|
+ queryWrapper.eq("account_id",accountId);
|
|
|
+ }
|
|
|
+ if(null!=status){
|
|
|
+ queryWrapper.eq("status",status);
|
|
|
+ }
|
|
|
+ queryWrapper.orderByDesc("id").last("limit 1");
|
|
|
+ return this.getOne(queryWrapper);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceAdvertisePlanService planService;
|
|
|
+ @Override
|
|
|
+ public void customCreativeSupplement(AiBytedanceAdvertiserStrategy strategy, Integer hour) {
|
|
|
+ Long customUnitCnt = strategy.getCampaignAdCnt()*strategy.getCampaignCnt();
|
|
|
+ Long unitNum = customUnitCnt * hour / 15;
|
|
|
+ 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, 3, remindCnt);
|
|
|
+ }
|
|
|
+ if (remindCnt >= 1) {
|
|
|
+ log.info("{}计划创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
|
|
|
+ //高质量素材
|
|
|
+ remindCnt = this.createCreative(strategy, 2, remindCnt);
|
|
|
+ }
|
|
|
+ if (remindCnt >= 1) {
|
|
|
+ //历史打捞素材
|
|
|
+ log.info("{}计划创建不足,剩余需要创建个数{},使用历史打捞素材创建", strategy.getAccountId(), remindCnt);
|
|
|
+ this.createCreative(strategy, 4, remindCnt);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|