|
@@ -15,6 +15,7 @@ import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalTemplateRelSe
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateMapper;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -63,6 +64,8 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
|
|
@Autowired
|
|
@Autowired
|
|
private KuaiShouGroupMapper groupMapper;
|
|
private KuaiShouGroupMapper groupMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouGroupTemplateService groupTemplateService;
|
|
static ExecutorService executorService = null;
|
|
static ExecutorService executorService = null;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -141,192 +144,23 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
|
|
throw new Exception("未获取到组信息");
|
|
throw new Exception("未获取到组信息");
|
|
}
|
|
}
|
|
CtopOauthToken token = oauthTokenService.getTokenByAccountId(kuaiShouGroup.getAccountId());
|
|
CtopOauthToken token = oauthTokenService.getTokenByAccountId(kuaiShouGroup.getAccountId());
|
|
- String sceneId = kuaiShouGroup.getSceneId();
|
|
|
|
- if (Check.isNull(sceneId)) {
|
|
|
|
|
|
+ String sceneIdStr = kuaiShouGroup.getSceneId();
|
|
|
|
+ if (Check.isNull(sceneIdStr)) {
|
|
throw new Exception("未获取资源位置");
|
|
throw new Exception("未获取资源位置");
|
|
}
|
|
}
|
|
- Integer scene = (Integer) JSONArray.parseArray(sceneId).get(0);
|
|
|
|
|
|
+ Integer sceneId = (Integer) JSONArray.parseArray(sceneIdStr).get(0);
|
|
JSONObject unitJson = new JSONObject();
|
|
JSONObject unitJson = new JSONObject();
|
|
- unitJson.put("advertiser_id", token.getAccountId());
|
|
|
|
|
|
+ unitJson.put("advertiser_id", kuaiShouGroup.getAccountId());
|
|
unitJson.put("unit_id", unitId);
|
|
unitJson.put("unit_id", unitId);
|
|
- // 广告组名称
|
|
|
|
- unitJson.put("unit_name", kuaiShouGroup.getUnitName());
|
|
|
|
- // 资源位置
|
|
|
|
- unitJson.put("scene_id", JSONArray.parseArray(sceneId));
|
|
|
|
- //投放开始时间
|
|
|
|
- String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
- boolean beginTimeBoolean = DateUtils.compare(kuaiShouGroup.getBeginTime(), nowDate);
|
|
|
|
- if (beginTimeBoolean) {
|
|
|
|
- unitJson.put("begin_time", nowDate);
|
|
|
|
|
|
+ if (sceneId != 5) {
|
|
|
|
+ unitJson.put("template_id", unit.getLong("template_id"));
|
|
} else {
|
|
} else {
|
|
- unitJson.put("begin_time", kuaiShouGroup.getBeginTime());
|
|
|
|
- }
|
|
|
|
- // 创意展现方式
|
|
|
|
- unitJson.put("show_mode", kuaiShouGroup.getShowMode());
|
|
|
|
- //投放方式
|
|
|
|
- unitJson.put("speed", kuaiShouGroup.getSpeed());
|
|
|
|
-
|
|
|
|
- // -----------------修改组非必填参数-----------
|
|
|
|
- // 出价
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getBid())) {
|
|
|
|
- unitJson.put("bid", kuaiShouGroup.getBid());
|
|
|
|
- }
|
|
|
|
- // 深度转化出价
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getCpaBid())) {
|
|
|
|
- unitJson.put("cpa_bid", kuaiShouGroup.getCpaBid());
|
|
|
|
- }
|
|
|
|
- // 深度转化目标出价
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getDeepConversionBid())) {
|
|
|
|
- unitJson.put("deep_conversion_bid", kuaiShouGroup.getDeepConversionBid());
|
|
|
|
- }
|
|
|
|
- // 投放结束时间
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getEndTime())) {
|
|
|
|
- unitJson.put("end_time", kuaiShouGroup.getEndTime());
|
|
|
|
- }
|
|
|
|
- // 投放时间段
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getScheduleTime())) {
|
|
|
|
- unitJson.put("schedule_time", kuaiShouGroup.getScheduleTime());
|
|
|
|
- }
|
|
|
|
- // 广告组单日预算
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getDayBudget())) {
|
|
|
|
- unitJson.put("day_budget", kuaiShouGroup.getDayBudget());
|
|
|
|
- }
|
|
|
|
- // url类型
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getUrlType())) {
|
|
|
|
- unitJson.put("url_type", kuaiShouGroup.getUrlType());
|
|
|
|
- }
|
|
|
|
- // url
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getUrl())) {
|
|
|
|
- unitJson.put("url", kuaiShouGroup.getUrl());
|
|
|
|
- }
|
|
|
|
- // appId
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getAppId())) {
|
|
|
|
- unitJson.put("app_id", kuaiShouGroup.getAppId());
|
|
|
|
- }
|
|
|
|
- // 优先从系统应用商店下载
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getUseAppMarket())) {
|
|
|
|
- unitJson.put("use_app_market", kuaiShouGroup.getUseAppMarket());
|
|
|
|
- }
|
|
|
|
- // 应用商店列表
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getAppStore())) {
|
|
|
|
- unitJson.put("app_store", JSONArray.parseArray(kuaiShouGroup.getAppStore()));
|
|
|
|
- }
|
|
|
|
- // 转化目标
|
|
|
|
- if (!Check.isNull(kuaiShouGroup.getConvertId())) {
|
|
|
|
- unitJson.put("convert_id", kuaiShouGroup.getConvertId());
|
|
|
|
- }
|
|
|
|
- // -----------------用户定向-----------
|
|
|
|
- JSONObject targetJson = new JSONObject();
|
|
|
|
-
|
|
|
|
- // 地域
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("region"))) {
|
|
|
|
- targetJson.put("region", requestJson.getJSONArray("region"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 自定义年龄段
|
|
|
|
-
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("min")) && !Check.isNull(requestJson.getInteger("max"))) {
|
|
|
|
- JSONObject ageJson = new JSONObject();
|
|
|
|
- ageJson.put("min", requestJson.getInteger("min"));
|
|
|
|
- ageJson.put("max", requestJson.getInteger("max"));
|
|
|
|
- targetJson.put("age", ageJson);
|
|
|
|
- }
|
|
|
|
- // 固定年龄段
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
|
|
|
|
- targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
|
|
|
|
- }
|
|
|
|
- // 性别
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("gender"))) {
|
|
|
|
- targetJson.put("gender", requestJson.getInteger("gender"));
|
|
|
|
- }
|
|
|
|
- //操作系统
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("platformOs"))) {
|
|
|
|
- targetJson.put("platform_os", requestJson.getInteger("platformOs"));
|
|
|
|
- }
|
|
|
|
- //Android版本
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
|
|
|
|
- targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
|
|
|
|
- }
|
|
|
|
- // iOS版本
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
|
|
|
|
- targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
|
|
|
|
- }
|
|
|
|
- //网络环境
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("network"))) {
|
|
|
|
- targetJson.put("network", requestJson.getInteger("network"));
|
|
|
|
- }
|
|
|
|
- // 设备品牌
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
|
|
|
|
- targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
|
|
|
|
- }
|
|
|
|
- // 设备价格
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
|
|
|
|
- targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
|
|
|
|
- targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
|
|
|
|
- }
|
|
|
|
- // APP行为-按APP名称
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
|
|
|
|
- targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
|
|
|
|
- }
|
|
|
|
- // 人群包
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("population"))) {
|
|
|
|
- targetJson.put("population", requestJson.getJSONArray("population"));
|
|
|
|
- }
|
|
|
|
- // 人群包排除
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
|
|
|
|
- targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
|
|
|
|
- }
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("thirdPlatformCode"))) {
|
|
|
|
- targetJson.put("third_platform_code", requestJson.getJSONArray("thirdPlatformCode"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (scene != 5) {
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("filterConvertedLevel"))) {
|
|
|
|
- targetJson.put("filter_converted_level", requestJson.getInteger("filterConvertedLevel"));
|
|
|
|
- }
|
|
|
|
- //商业兴趣类型
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
|
|
|
|
- targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
|
|
|
|
- }
|
|
|
|
- // 商业兴趣
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
|
|
|
|
- targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
|
|
|
|
- }
|
|
|
|
- //网红粉丝
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
|
|
|
|
- targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
|
|
|
|
- }
|
|
|
|
- //兴趣视频用户
|
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
|
|
|
|
- targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (scene != 5) {
|
|
|
|
- JSONObject intelliExtendJson = new JSONObject();
|
|
|
|
- // 开启智能扩量
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("isOpen"))) {
|
|
|
|
- intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
|
|
|
|
- }
|
|
|
|
- //不可突破年龄
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
|
|
|
|
- intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
|
|
|
|
- }
|
|
|
|
- //不可突破性别
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
|
|
|
|
- intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
|
|
|
|
- }
|
|
|
|
- // 不可突破地域
|
|
|
|
- if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
|
|
|
|
- intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
|
|
|
|
- }
|
|
|
|
- if (!Check.isNull(intelliExtendJson)) {
|
|
|
|
- targetJson.put("intelli_extend", intelliExtendJson);
|
|
|
|
|
|
+ JSONObject unionJson = groupTemplateService.getUnionJson(unit.getLong("template_id"));
|
|
|
|
+ if (Check.isNullMap(unionJson)) {
|
|
|
|
+ throw new Exception("根据定向模板未获取到相关信息");
|
|
}
|
|
}
|
|
|
|
+ unitJson.put("target", unionJson);
|
|
}
|
|
}
|
|
- unitJson.put("target", targetJson);
|
|
|
|
JSONObject jsonObject = updateService.updateUnit(token.getAccessToken(), unitJson);
|
|
JSONObject jsonObject = updateService.updateUnit(token.getAccessToken(), unitJson);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("修改广告组定向异常", e);
|
|
log.error("修改广告组定向异常", e);
|
|
@@ -639,6 +473,7 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
|
|
if (!Check.isNull(targetJson)) {
|
|
if (!Check.isNull(targetJson)) {
|
|
param.put("target", targetJson);
|
|
param.put("target", targetJson);
|
|
}
|
|
}
|
|
|
|
+ //-------------兴趣行为定向
|
|
JSONObject behaviorInterest = new JSONObject();
|
|
JSONObject behaviorInterest = new JSONObject();
|
|
JSONObject behavior = new JSONObject();
|
|
JSONObject behavior = new JSONObject();
|
|
JSONObject interest = new JSONObject();
|
|
JSONObject interest = new JSONObject();
|