|
@@ -5,7 +5,11 @@ 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 com.google.common.base.Joiner;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.collections.Transformer;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.bytedance.advertise.dockapi.MarketingService;
|
|
@@ -31,6 +35,7 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 头条智能投放账户配置信息表
|
|
@@ -464,7 +469,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdCity())){
|
|
|
String[] city = strategy.getAdCity().split(",");
|
|
|
- if(city.length>0){
|
|
|
+ if(null != city&&city.length>0){
|
|
|
params.put("city",city);
|
|
|
}
|
|
|
}
|
|
@@ -522,7 +527,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(!Check.isNull(strategy.getAdActionScene())){
|
|
|
String[] actionScene = strategy.getAdActionScene().split(",");
|
|
|
if(actionScene.length>0){
|
|
|
- params.put("action_scene",actionScene);
|
|
|
+ JSONArray actionSceneArray = new JSONArray();
|
|
|
+ for(int i=0;i<actionScene.length;i++){
|
|
|
+ actionSceneArray.add(actionScene[i]);
|
|
|
+ }
|
|
|
+ params.put("action_scene",actionSceneArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdActionDays())){
|
|
@@ -531,49 +540,81 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(!Check.isNull(strategy.getAdActionCategories())){
|
|
|
String[] actionCategories = strategy.getAdActionCategories().split(",");
|
|
|
if(actionCategories.length>0){
|
|
|
- params.put("action_categories",actionCategories);
|
|
|
+ JSONArray actionCategoriesArray = new JSONArray();
|
|
|
+ for(int i=0;i<actionCategories.length;i++){
|
|
|
+ actionCategoriesArray.add(actionCategories[i]);
|
|
|
+ }
|
|
|
+ params.put("action_categories",actionCategoriesArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdActionWords())){
|
|
|
String[] actionWords = strategy.getAdActionWords().split(",");
|
|
|
if(actionWords.length>0){
|
|
|
- params.put("action_words",actionWords);
|
|
|
+ JSONArray actionWordsArray = new JSONArray();
|
|
|
+ for(int i=0;i<actionWords.length;i++){
|
|
|
+ actionWordsArray.add(actionWords[i]);
|
|
|
+ }
|
|
|
+ params.put("action_words",actionWordsArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdInterestCategories())){
|
|
|
String[] interestCategories = strategy.getAdInterestCategories().split(",");
|
|
|
if(interestCategories.length>0){
|
|
|
- params.put("interest_categories",interestCategories);
|
|
|
+ JSONArray interestCategoriesArray = new JSONArray();
|
|
|
+ for(int i=0;i<interestCategories.length;i++){
|
|
|
+ interestCategoriesArray.add(interestCategories[i]);
|
|
|
+ }
|
|
|
+ params.put("interest_categories",interestCategoriesArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdInterestWords())){
|
|
|
String[] interestWords = strategy.getAdInterestWords().split(",");
|
|
|
if(interestWords.length>0){
|
|
|
- params.put("interest_words",interestWords);
|
|
|
+ JSONArray interestWordsArray = new JSONArray();
|
|
|
+ for(int i=0;i<interestWords.length;i++){
|
|
|
+ interestWordsArray.add(interestWords[i]);
|
|
|
+ }
|
|
|
+ params.put("interest_words",interestWordsArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdAwemeFanBehaviors())){
|
|
|
String[] awemeFanBehaviors = strategy.getAdAwemeFanBehaviors().split(",");
|
|
|
if(awemeFanBehaviors.length>0){
|
|
|
- params.put("aweme_fan_behaviors",awemeFanBehaviors);
|
|
|
+ JSONArray awemeFanBehaviorsArray = new JSONArray();
|
|
|
+ for(int i=0;i<awemeFanBehaviors.length;i++){
|
|
|
+ awemeFanBehaviorsArray.add(awemeFanBehaviors[i]);
|
|
|
+ }
|
|
|
+ params.put("aweme_fan_behaviors",awemeFanBehaviorsArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdAwemeFanCategories())){
|
|
|
String[] awemeFanCategories = strategy.getAdAwemeFanCategories().split(",");
|
|
|
if(awemeFanCategories.length>0){
|
|
|
- params.put("aweme_fan_categories",awemeFanCategories);
|
|
|
+ JSONArray awemeFanCategoriesArray = new JSONArray();
|
|
|
+ for(int i=0;i<awemeFanCategories.length;i++){
|
|
|
+ awemeFanCategoriesArray.add(awemeFanCategories[i]);
|
|
|
+ }
|
|
|
+ params.put("aweme_fan_categories",awemeFanCategoriesArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdAwemeFanAccounts())){
|
|
|
String[] awemeFanAccount = strategy.getAdAwemeFanAccounts().split(",");
|
|
|
if(awemeFanAccount.length>0){
|
|
|
- params.put("aweme_fan_accounts",awemeFanAccount);
|
|
|
+ JSONArray awemeFanAccountArray = new JSONArray();
|
|
|
+ for(int i=0;i<awemeFanAccount.length;i++){
|
|
|
+ awemeFanAccountArray.add(awemeFanAccount[i]);
|
|
|
+ }
|
|
|
+ params.put("aweme_fan_accounts",awemeFanAccountArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdAwemeFansNumbers())){
|
|
|
String[] awemeFansNumbers = strategy.getAdAwemeFansNumbers().split(",");
|
|
|
if(awemeFansNumbers.length>0){
|
|
|
- params.put("aweme_fans_numbers",awemeFansNumbers);
|
|
|
+ JSONArray awemeFansNumbersArray = new JSONArray();
|
|
|
+ for(int i=0;i<awemeFansNumbers.length;i++){
|
|
|
+ awemeFansNumbersArray.add(awemeFansNumbers[i]);
|
|
|
+ }
|
|
|
+ params.put("aweme_fans_numbers",awemeFansNumbersArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdFilterAwemeAbnormalActive())){
|
|
@@ -591,19 +632,31 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(!Check.isNull(strategy.getAdFlowPackage())){
|
|
|
String[] flowPackage = strategy.getAdFlowPackage().split(",");
|
|
|
if(flowPackage.length>0){
|
|
|
- params.put("flow_package",flowPackage);
|
|
|
+ JSONArray flowPackageArray = new JSONArray();
|
|
|
+ for(int i=0;i<flowPackage.length;i++){
|
|
|
+ flowPackageArray.add(flowPackage[i]);
|
|
|
+ }
|
|
|
+ params.put("flow_package",flowPackageArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdExcludeFlowPackage())){
|
|
|
String[] excludeFlowPackage = strategy.getAdExcludeFlowPackage().split(",");
|
|
|
if(excludeFlowPackage.length>0){
|
|
|
- params.put("exclude_flow_package",excludeFlowPackage);
|
|
|
+ JSONArray excludeFlowPackageArray = new JSONArray();
|
|
|
+ for(int i=0;i<excludeFlowPackage.length;i++){
|
|
|
+ excludeFlowPackageArray.add(excludeFlowPackage[i]);
|
|
|
+ }
|
|
|
+ params.put("exclude_flow_package",excludeFlowPackageArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdPlatform())){
|
|
|
String[] platform = strategy.getAdPlatform().split(",");
|
|
|
if(platform.length>0){
|
|
|
- params.put("platform",platform);
|
|
|
+ JSONArray platformArray = new JSONArray();
|
|
|
+ for(int i=0;i<platform.length;i++){
|
|
|
+ platformArray.add(platform[i]);
|
|
|
+ }
|
|
|
+ params.put("platform",platformArray);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -645,7 +698,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(!Check.isNull(strategy.getAdDeviceType())){
|
|
|
String[] deviceType = strategy.getAdDeviceType().split(",");
|
|
|
if(deviceType.length>0){
|
|
|
- params.put("device_type",deviceType);
|
|
|
+ JSONArray deviceTypeArray = new JSONArray();
|
|
|
+ for(int i=0;i<deviceType.length;i++){
|
|
|
+ deviceTypeArray.add(deviceType[i]);
|
|
|
+ }
|
|
|
+ params.put("device_type",deviceTypeArray);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -662,25 +719,41 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(!Check.isNull(strategy.getAdActivateType())){
|
|
|
String[] activateType = strategy.getAdActivateType().split(",");
|
|
|
if(activateType.length>0){
|
|
|
- params.put("activate_type",activateType);
|
|
|
+ JSONArray activateTypeArray = new JSONArray();
|
|
|
+ for(int i=0;i<activateType.length;i++){
|
|
|
+ activateTypeArray.add(activateType[i]);
|
|
|
+ }
|
|
|
+ params.put("activate_type",activateTypeArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdArticleCategory())){
|
|
|
String[] articleCategory = strategy.getAdArticleCategory().split(",");
|
|
|
if(articleCategory.length>0){
|
|
|
- params.put("article_category",articleCategory);
|
|
|
+ JSONArray articleCategoryArray = new JSONArray();
|
|
|
+ for(int i=0;i<articleCategory.length;i++){
|
|
|
+ articleCategoryArray.add(articleCategory[i]);
|
|
|
+ }
|
|
|
+ params.put("article_category",articleCategoryArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdDeviceBrand())){
|
|
|
String[] deviceBrand = strategy.getAdDeviceBrand().split(",");
|
|
|
if(deviceBrand.length>0){
|
|
|
- params.put("device_brand",deviceBrand);
|
|
|
+ JSONArray deviceBrandArray = new JSONArray();
|
|
|
+ for(int i=0;i<deviceBrand.length;i++){
|
|
|
+ deviceBrandArray.add(deviceBrand[i]);
|
|
|
+ }
|
|
|
+ params.put("device_brand",deviceBrandArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdLaunchPrice())){
|
|
|
String[] launchPrice = strategy.getAdLaunchPrice().split(",");
|
|
|
if(launchPrice.length>0){
|
|
|
- params.put("launch_price",launchPrice);
|
|
|
+ JSONArray launchPriceArray = new JSONArray();
|
|
|
+ for(int i=0;i<launchPrice.length;i++){
|
|
|
+ launchPriceArray.add(launchPrice[i]);
|
|
|
+ }
|
|
|
+ params.put("launch_price",launchPriceArray);
|
|
|
}
|
|
|
}
|
|
|
if(!Check.isNull(strategy.getAdAutoExtendEnabled())){
|
|
@@ -689,7 +762,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
if(!Check.isNull(strategy.getAdAutoExtendTargets())){
|
|
|
String[] autoExtendTargets = strategy.getAdAutoExtendTargets().split(",");
|
|
|
if(autoExtendTargets.length>0){
|
|
|
- params.put("auto_extend_targets",autoExtendTargets);
|
|
|
+ JSONArray autoExtendTargetsArray = new JSONArray();
|
|
|
+ for(int i=0;i<autoExtendTargets.length;i++){
|
|
|
+ autoExtendTargetsArray.add(autoExtendTargets[i]);
|
|
|
+ }
|
|
|
+ params.put("auto_extend_targets",autoExtendTargetsArray);
|
|
|
}
|
|
|
}
|
|
|
//预算与出价
|
|
@@ -1182,6 +1259,52 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @description: 获取定向包
|
|
|
+ *
|
|
|
+ * @param accountId 广告主id
|
|
|
+ * @param landingType 投放目标
|
|
|
+ * @param deliveryRange
|
|
|
+ * @return: org.jeecg.common.api.vo.Result
|
|
|
+ * @author: zianY
|
|
|
+ */
|
|
|
+ public Result getAdAudiencePackage(String accountId, String landingType, String deliveryRange){
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
+ Result list = marketingService.getAudiencePackage(token,landingType,deliveryRange);
|
|
|
+ JSONObject jsonObject = (JSONObject)list.getResult();
|
|
|
+ return Result.successMsg("成功。",jsonObject.getJSONArray("audience_packages"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @description: 获取人群包列表信息
|
|
|
+ *
|
|
|
+ * @param accountId
|
|
|
+ * @return: org.jeecg.common.api.vo.Result
|
|
|
+ * @author: zianY
|
|
|
+ */
|
|
|
+ public Result getDMPCustomAudience(String accountId){
|
|
|
+
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
+ // 获取人群包列表
|
|
|
+ Result list = marketingService.selectCustomAudience(token);
|
|
|
+ List<Map<String,Object>> listMap = (List<Map<String, Object>>) list.getResult();
|
|
|
+ //获取人群包id List
|
|
|
+ List<Object> packageList = listMap.stream().map(map -> map.get("custom_audience_id")).collect(Collectors.toList());
|
|
|
+ String idStr = Joiner.on(",").join(packageList);
|
|
|
+ List<Integer> idsIntList = Arrays.asList(idStr.split(",")).stream().map(id -> Integer.valueOf(id.trim())).collect(Collectors.toList());
|
|
|
+ //获取人群包详细信息
|
|
|
+ Result packageInfoList = marketingService.getAudiencePackageRead(token,accountId,idsIntList);
|
|
|
+ List<Map<String,Object>> listInfoMap = (List<Map<String, Object>>) packageInfoList.getResult();
|
|
|
+ //人群包是否被删除 "1":已删除,"0":未删除
|
|
|
+ //人群包可投放状态,只有当状态为CUSTOM_AUDIENCE_DELIVERY_STATUS_AVAILABLE时才可进行投放使用
|
|
|
+ List<Map<String,Object>> filterList = listInfoMap.stream()
|
|
|
+ .filter(info -> Integer.valueOf(info.get("isdel")+"") == 0)
|
|
|
+ .filter(info -> "CUSTOM_AUDIENCE_DELIVERY_STATUS_AVAILABLE".equalsIgnoreCase(info.get("delivery_status")+""))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return Result.successMsg("人群包获取成功。",filterList);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|