|
@@ -2,6 +2,8 @@ package org.jeecg.modules.bytedance.advertise.service.impl;
|
|
|
|
|
|
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;
|
|
@@ -16,19 +18,26 @@ import org.jeecg.modules.bytedance.advertise.service.IAiBytedanceAdvertiserStrat
|
|
|
import org.jeecg.modules.bytedance.advertise.service.IByteDanceVideoInfoService;
|
|
|
import org.jeecg.modules.bytedance.advertise.vo.AdConvertQueryVo;
|
|
|
import org.jeecg.modules.bytedance.advertise.vo.AdGroupSearchVo;
|
|
|
+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.MaterialImageInfo;
|
|
|
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.IUserAllocationService;
|
|
|
+import org.jeecg.modules.bytedance.common.utils.Check;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.spi.LocaleServiceProvider;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 头条智能投放账户配置信息表
|
|
@@ -48,6 +57,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
@Autowired
|
|
|
private IUserAllocationService userAllocationService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IMaterialImageInfoService materialImageInfoService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -141,22 +152,22 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
public Result updStaOrCpaOrBudgetById(UpdAdStaOrCpaOrBudget updAdStaOrCpaOrBudget) {
|
|
|
Result updResult = new Result();
|
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(updAdStaOrCpaOrBudget.getAccountId());
|
|
|
- List<Map<String,Object>> priceList = updAdStaOrCpaOrBudget.getList();
|
|
|
+ List<Map<String,Object>> priceList = new ArrayList<>();
|
|
|
Map<String,Object> mapPrice = new HashMap<>();
|
|
|
//1-修改出价
|
|
|
if (BytedanceConstant.UPDTYPE_BID.equals(updAdStaOrCpaOrBudget.getType())) {
|
|
|
- mapPrice.put("ad_id",updAdStaOrCpaOrBudget.getAdId());
|
|
|
- mapPrice.put("bid",updAdStaOrCpaOrBudget.getBid());
|
|
|
+ mapPrice.put("ad_id",updAdStaOrCpaOrBudget.getAdId());
|
|
|
+ mapPrice.put("bid",updAdStaOrCpaOrBudget.getBId());
|
|
|
priceList.add(mapPrice);
|
|
|
|
|
|
- // api 更新计划出价
|
|
|
- updResult = marketing.updatePlanBid(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
|
|
|
+ // api 更新计划出价 TODO
|
|
|
+ /* updResult = marketing.updatePlanBid(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
|
|
|
if (!"200".equals(updResult.getCode())){
|
|
|
return Result.error(updResult.getMessage());
|
|
|
- }
|
|
|
+ }*/
|
|
|
// 修改 出价
|
|
|
priceList.forEach(map-> {
|
|
|
- aiBytedanceAdvertiserStrategyMapper.updCpaById(updAdStaOrCpaOrBudget.getId(),map.get("bid").toString());
|
|
|
+ aiBytedanceAdvertiserStrategyMapper.updCpaById(updAdStaOrCpaOrBudget.getId(),updAdStaOrCpaOrBudget.getBId());
|
|
|
});
|
|
|
}
|
|
|
//2-修改预算
|
|
@@ -165,13 +176,13 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
mapPrice.put("budget",updAdStaOrCpaOrBudget.getBudget());
|
|
|
priceList.add(mapPrice);
|
|
|
// api 修改计划 预算
|
|
|
- updResult = marketing.updatePlanBudget(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
|
|
|
+ /* updResult = marketing.updatePlanBudget(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
|
|
|
if (!"200".equals(updResult.getCode())){
|
|
|
return Result.error(updResult.getMessage());
|
|
|
- }
|
|
|
- // 修改 预算
|
|
|
+ }*/
|
|
|
+ // 修改 预算 TODO
|
|
|
priceList.forEach(map-> {
|
|
|
- aiBytedanceAdvertiserStrategyMapper.updBudgetById(updAdStaOrCpaOrBudget.getId(),map.get("budget").toString());
|
|
|
+ aiBytedanceAdvertiserStrategyMapper.updBudgetById(updAdStaOrCpaOrBudget.getId(),updAdStaOrCpaOrBudget.getBudget());
|
|
|
});
|
|
|
}
|
|
|
return Result.successMsg("修改"+(BytedanceConstant.UPDTYPE_BID.equals(updAdStaOrCpaOrBudget.getType()) ? "出价" : "预算")+"成功。", updResult.getResult());
|
|
@@ -188,16 +199,57 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
* @return: org.jeecg.common.api.vo.Result
|
|
|
* @author: zianY
|
|
|
*/
|
|
|
- public Result getIndustryList(String accountId,String type) {
|
|
|
+ public Result getIndustryList(String accountId,String type) throws Exception {
|
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
if (null == token) {
|
|
|
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);
|
|
|
+ List<Map<String,Object>> industryListMap = (List<Map<String,Object>>) listResult.getResult();
|
|
|
+ // list map 数据格式 转 list entity 数据格式
|
|
|
+ List<IndustryVo> industryList = Check.convertListMap2ListBean(industryListMap,IndustryVo.class);
|
|
|
+ //所有行业分类 设置 父id
|
|
|
+ industryList.forEach(industryVo -> {
|
|
|
+ if ("1".equals(industryVo.getLevel())){
|
|
|
+ industryVo.setPId("0");
|
|
|
+ }
|
|
|
+ if ("2".equals(industryVo.getLevel())){
|
|
|
+ industryVo.setPId(industryVo.getFirst_industry_id());
|
|
|
+ }
|
|
|
+ if ("3".equals(industryVo.getLevel())){
|
|
|
+ industryVo.setPId(industryVo.getSecond_industry_id());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //行业分类 层级展示
|
|
|
+ List<Map<String,Object>> classificationVos = treeCategoryData(industryList,"0");
|
|
|
+ return Result.successMsg("获取行业列表成功。",classificationVos);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归 行业分类 tree 层级展示
|
|
|
+ * @param allList
|
|
|
+ * @param parentId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Map<String,Object>> treeCategoryData(List<IndustryVo> allList, String parentId) {
|
|
|
+ List<Map<String,Object>> mapList = new ArrayList<>();
|
|
|
+ for (IndustryVo vo : allList) {
|
|
|
+ if (parentId.equals(vo.getPId())){
|
|
|
+ Map<String,Object> map = new HashMap();
|
|
|
+ map.put("industryId", vo.getIndustry_id());
|
|
|
+ map.put("industryName", vo.getIndustry_name());
|
|
|
+ map.put("level", vo.getLevel());
|
|
|
+ map.put("pId", vo.getPId());
|
|
|
+ map.put("children", treeCategoryData(allList,vo.getIndustry_id()));
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return mapList;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -360,8 +412,26 @@ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Result addBytedanceStrategy(AiBytedanceAdvertiserStrategy aiBytedanceAdvertiserStrategy) {
|
|
|
+
|
|
|
+ // 数据入库 string[] 转 string
|
|
|
+ //商品卖点
|
|
|
+ aiBytedanceAdvertiserStrategy.setCreativeProductSellingPoints(StringUtils.join(aiBytedanceAdvertiserStrategy.getProductSellingPoints(), ","));
|
|
|
+ //创意标签
|
|
|
+ aiBytedanceAdvertiserStrategy.setCreativeAdKeywords(StringUtils.join(aiBytedanceAdvertiserStrategy.getAdKeywords(), ","));
|
|
|
+
|
|
|
+ //添加素材信息
|
|
|
+ MaterialImageInfo imageInfo = new MaterialImageInfo();
|
|
|
+ imageInfo.setUrl(aiBytedanceAdvertiserStrategy.getImageUrl());
|
|
|
+ imageInfo.setUserId(aiBytedanceAdvertiserStrategy.getUserId());
|
|
|
+ materialImageInfoService.initImageCode(imageInfo);
|
|
|
+ aiBytedanceAdvertiserStrategyMapper.insert(aiBytedanceAdvertiserStrategy);
|
|
|
+
|
|
|
+ return Result.successMsg("新增成功。",aiBytedanceAdvertiserStrategy);
|
|
|
}
|
|
|
|
|
|
|