|
@@ -13,6 +13,7 @@ import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IBatchService;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -35,6 +36,8 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
private KuaiShouCampaignMapper campaignMapper;
|
|
|
@Autowired
|
|
|
private UserAllocationMapper userAllocationMapper;
|
|
|
+ @Autowired
|
|
|
+ private IKuaiShouUpdateService updateService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -141,7 +144,6 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
|
|
|
@Override
|
|
|
public JSONObject createUnit(JSONObject requestJson) throws Exception {
|
|
|
- System.err.println(requestJson);
|
|
|
Long accountId = requestJson.getLong("accountId");
|
|
|
CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
if (Check.isNull(oauthToken)) {
|
|
@@ -157,35 +159,35 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
unitJson.put("campaign_id", campaignId);
|
|
|
|
|
|
// 资源位置
|
|
|
- JSONArray scene_id = requestJson.getJSONArray("scene_id");
|
|
|
+ JSONArray scene_id = requestJson.getJSONArray("sceneId");
|
|
|
if (!Check.isNull(scene_id)) {
|
|
|
unitJson.put("scene_id", scene_id);
|
|
|
}
|
|
|
|
|
|
// 资源创作方式
|
|
|
- if (!Check.isNull(requestJson.getInteger("unit_type"))) {
|
|
|
- unitJson.put("unit_type", requestJson.getInteger("unit_type"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("unitType"))) {
|
|
|
+ unitJson.put("unit_type", requestJson.getInteger("unitType"));
|
|
|
}
|
|
|
|
|
|
//投放开始时间
|
|
|
- if (!Check.isNull(requestJson.getString("begin_time"))) {
|
|
|
- unitJson.put("begin_time", requestJson.getString("begin_time"));
|
|
|
+ if (!Check.isNull(requestJson.getString("beginTime"))) {
|
|
|
+ unitJson.put("begin_time", requestJson.getString("beginTime"));
|
|
|
}
|
|
|
// 投放结束时间
|
|
|
- if (!Check.isNull(requestJson.getString("end_time"))) {
|
|
|
- unitJson.put("end_time", requestJson.getString("end_time"));
|
|
|
+ if (!Check.isNull(requestJson.getString("endTime"))) {
|
|
|
+ unitJson.put("end_time", requestJson.getString("endTime"));
|
|
|
}
|
|
|
// 投放时间段
|
|
|
- if (!Check.isNull(requestJson.getString("schedule_time"))) {
|
|
|
- unitJson.put("schedule_time", requestJson.getString("schedule_time"));
|
|
|
+ if (!Check.isNull(requestJson.getString("scheduleTime"))) {
|
|
|
+ unitJson.put("schedule_time", requestJson.getString("scheduleTime"));
|
|
|
}
|
|
|
// 广告组单日预算
|
|
|
- if (!Check.isNull(requestJson.getLong("day_budget"))) {
|
|
|
- unitJson.put("day_budget", requestJson.getLong("day_budget"));
|
|
|
+ if (!Check.isNull(requestJson.getLong("dayBudget"))) {
|
|
|
+ unitJson.put("day_budget", requestJson.getLong("dayBudget"));
|
|
|
}
|
|
|
// url类型
|
|
|
- if (!Check.isNull(requestJson.getInteger("url_type"))) {
|
|
|
- unitJson.put("url_type", requestJson.getInteger("url_type"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("urlType"))) {
|
|
|
+ unitJson.put("url_type", requestJson.getInteger("urlType"));
|
|
|
}
|
|
|
// url
|
|
|
if (!Check.isNull(requestJson.getString("url"))) {
|
|
@@ -196,8 +198,8 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
unitJson.put("app_id", requestJson.getLong("appId"));
|
|
|
}
|
|
|
// 创意展现方式
|
|
|
- if (!Check.isNull(requestJson.getInteger("show_mode"))) {
|
|
|
- unitJson.put("show_mode", requestJson.getInteger("show_mode"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("showMode"))) {
|
|
|
+ unitJson.put("show_mode", requestJson.getInteger("showMode"));
|
|
|
}
|
|
|
if (!Check.isNull(requestJson.getInteger("speed"))) {
|
|
|
unitJson.put("speed", requestJson.getInteger("speed"));
|
|
@@ -221,87 +223,87 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
targetJson.put("age", ageJson);
|
|
|
}
|
|
|
// 固定年龄段
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("ages_range"))) {
|
|
|
- targetJson.put("ages_range", requestJson.getJSONArray("ages_range"));
|
|
|
+ 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("platform_os"))) {
|
|
|
- targetJson.put("platform_os", requestJson.getInteger("platform_os"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("platformOs"))) {
|
|
|
+ targetJson.put("platform_os", requestJson.getInteger("platformOs"));
|
|
|
}
|
|
|
//Android版本
|
|
|
- if (!Check.isNull(requestJson.getInteger("android_osv"))) {
|
|
|
- targetJson.put("android_osv", requestJson.getInteger("android_osv"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
|
|
|
+ targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
|
|
|
}
|
|
|
// iOS版本
|
|
|
- if (!Check.isNull(requestJson.getInteger("ios_osv"))) {
|
|
|
- targetJson.put("ios_osv", requestJson.getInteger("ios_osv"));
|
|
|
+ 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("device_brand"))) {
|
|
|
- targetJson.put("device_brand", requestJson.getJSONArray("device_brand"));
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
|
|
|
+ targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
|
|
|
}
|
|
|
//设备价格
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("device_price"))) {
|
|
|
- targetJson.put("device_price", requestJson.getJSONArray("device_price"));
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
|
|
|
+ targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
|
|
|
}
|
|
|
//商业兴趣类型
|
|
|
- if (!Check.isNull(requestJson.getInteger("business_interest_type"))) {
|
|
|
- targetJson.put("business_interest_type", requestJson.getInteger("business_interest_type"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
|
|
|
+ targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
|
|
|
}
|
|
|
// 商业兴趣
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("business_interest"))) {
|
|
|
- targetJson.put("business_interest", requestJson.getJSONArray("business_interest"));
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
|
|
|
+ targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
|
|
|
}
|
|
|
//网红粉丝
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("fans_star"))) {
|
|
|
- targetJson.put("fans_star", requestJson.getJSONArray("fans_star"));
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
|
|
|
+ targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
|
|
|
}
|
|
|
//兴趣视频用户
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("interest_video"))) {
|
|
|
- targetJson.put("interest_video", requestJson.getJSONArray("interest_video"));
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
|
|
|
+ targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
|
|
|
}
|
|
|
// APP行为-按分类
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("app_interest"))) {
|
|
|
- targetJson.put("app_interest", requestJson.getJSONArray("app_interest"));
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
|
|
|
+ targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
|
|
|
}
|
|
|
// APP行为-按APP名称
|
|
|
- if (!Check.isNull(requestJson.getJSONArray("app_ids"))) {
|
|
|
- targetJson.put("app_ids", requestJson.getJSONArray("app_ids"));
|
|
|
+ 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("exclude_population"))) {
|
|
|
- targetJson.put("exclude_population", requestJson.getJSONArray("exclude_population"));
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
|
|
|
+ targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
|
|
|
}
|
|
|
|
|
|
JSONObject intelliExtendJson = new JSONObject();
|
|
|
|
|
|
// 开启智能扩量
|
|
|
- if (!Check.isNull(requestJson.getInteger("is_open"))) {
|
|
|
- intelliExtendJson.put("is_open", requestJson.getInteger("is_open"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("isOpen"))) {
|
|
|
+ intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
|
|
|
}
|
|
|
//不可突破年龄
|
|
|
- if (!Check.isNull(requestJson.getInteger("no_age_break"))) {
|
|
|
- intelliExtendJson.put("no_age_break", requestJson.getInteger("no_age_break"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
|
|
|
+ intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
|
|
|
}
|
|
|
//不可突破性别
|
|
|
- if (!Check.isNull(requestJson.getInteger("no_gender_break"))) {
|
|
|
- intelliExtendJson.put("no_gender_break", requestJson.getInteger("no_gender_break"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
|
|
|
+ intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
|
|
|
}
|
|
|
// 不可突破地域
|
|
|
- if (!Check.isNull(requestJson.getInteger("no_area_break"))) {
|
|
|
- intelliExtendJson.put("no_area_break", requestJson.getInteger("no_area_break"));
|
|
|
+ if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
|
|
|
+ intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
|
|
|
}
|
|
|
if (!Check.isNull(intelliExtendJson)) {
|
|
|
targetJson.put("intelli_extend", intelliExtendJson);
|
|
@@ -330,24 +332,24 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
unitJson.put("bid", groupJson.getLong("bid"));
|
|
|
}
|
|
|
// 出价类型
|
|
|
- Integer bidType = groupJson.getInteger("bid_type");
|
|
|
+ Integer bidType = groupJson.getInteger("bidType");
|
|
|
if (!Check.isNull(bidType)) {
|
|
|
unitJson.put("bid_type", bidType);
|
|
|
}
|
|
|
// 深度转化出价
|
|
|
- if (!Check.isNull(groupJson.getLong("cpa_bid"))) {
|
|
|
- unitJson.put("cpa_bid", groupJson.getLong("cpa_bid"));
|
|
|
+ if (!Check.isNull(groupJson.getLong("cpaBid"))) {
|
|
|
+ unitJson.put("cpa_bid", groupJson.getLong("cpaBid"));
|
|
|
}
|
|
|
// 深度转化目标出价
|
|
|
- if (!Check.isNull(groupJson.getLong("deep_conversion_bid"))) {
|
|
|
- unitJson.put("deep_conversion_bid", groupJson.getLong("deep_conversion_bid"));
|
|
|
+ if (!Check.isNull(groupJson.getLong("deepConversionBid"))) {
|
|
|
+ unitJson.put("deep_conversion_bid", groupJson.getLong("deepConversionBid"));
|
|
|
}
|
|
|
// 深度转化目标
|
|
|
- if (!Check.isNull(groupJson.getInteger("deep_conversion_type"))) {
|
|
|
- unitJson.put("deep_conversion_type", groupJson.getInteger("deep_conversion_type"));
|
|
|
+ if (!Check.isNull(groupJson.getInteger("deepConversionType"))) {
|
|
|
+ unitJson.put("deep_conversion_type", groupJson.getInteger("deepConversionType"));
|
|
|
}
|
|
|
// 优化目标
|
|
|
- Integer ocpx_action_type = groupJson.getInteger("ocpx_action_type");
|
|
|
+ Integer ocpx_action_type = groupJson.getInteger("ocpxActionType");
|
|
|
if (!Check.isNull(ocpx_action_type)) {
|
|
|
unitJson.put("ocpx_action_type", ocpx_action_type);
|
|
|
}
|
|
@@ -361,14 +363,14 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
|
if (code == 0) {
|
|
|
JSONObject successJson = new JSONObject();
|
|
|
- successJson.put("unit_id", returnUnitMap.get("unitId"));
|
|
|
- successJson.put("unit_name", unitName);
|
|
|
- successJson.put("scene_id", scene_id);
|
|
|
- successJson.put("ocpx_action_type", ocpx_action_type);
|
|
|
+ successJson.put("unitId", returnUnitMap.get("unitId"));
|
|
|
+ successJson.put("unitName", unitName);
|
|
|
+ successJson.put("sceneId", scene_id);
|
|
|
+ successJson.put("ocpxActionType", ocpx_action_type);
|
|
|
successArr.add(successJson);
|
|
|
} else {
|
|
|
JSONObject failJson = new JSONObject();
|
|
|
- failJson.put("unit_name", unitName);
|
|
|
+ failJson.put("unitName", unitName);
|
|
|
failJson.put("failMessage", returnUnitMap.get("message"));
|
|
|
failArr.add(failJson);
|
|
|
}
|
|
@@ -414,8 +416,6 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
*/
|
|
|
@Override
|
|
|
public JSONObject createCreative(JSONObject requestJson) throws Exception {
|
|
|
- System.err.println(requestJson);
|
|
|
-
|
|
|
if (Check.isNull(requestJson)) {
|
|
|
throw new Exception("入参为空");
|
|
|
}
|
|
@@ -438,21 +438,18 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
|
|
|
|
|
|
JSONObject creativeJson = new JSONObject();
|
|
|
-
|
|
|
-
|
|
|
creativeJson.put("advertiser_id", accountId);
|
|
|
-
|
|
|
creativeJson.put("unit_id", unitId);
|
|
|
|
|
|
// 素材类型
|
|
|
- if (!Check.isNull(requestJson.get("creative_material_type"))) {
|
|
|
- creativeJson.put("creative_material_type", requestJson.get("creative_material_type"));
|
|
|
+ if (!Check.isNull(requestJson.get("creativeMaterialType"))) {
|
|
|
+ creativeJson.put("creative_material_type", requestJson.get("creativeMaterialType"));
|
|
|
}
|
|
|
|
|
|
- String action_bar_text = requestJson.getString("action_bar_text");
|
|
|
+ String action_bar_text = requestJson.getString("actionBarText");
|
|
|
// 视频id
|
|
|
|
|
|
- String click_track_url = requestJson.getString("click_track_url");
|
|
|
+ String click_track_url = requestJson.getString("clickTrackUrl");
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
JSONArray successArr = new JSONArray();
|
|
|
JSONArray failArr = new JSONArray();
|
|
@@ -462,8 +459,8 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
JSONObject dataJson = dataJsons.getJSONObject(i);
|
|
|
if (!Check.isNull(dataJsons)) {
|
|
|
String description = dataJson.getString("description");
|
|
|
- String photo_id = dataJson.getString("photo_id");
|
|
|
- JSONArray imageTokens = dataJson.getJSONArray("image_tokens");
|
|
|
+ String photo_id = dataJson.getString("photoId");
|
|
|
+ JSONArray imageTokens = dataJson.getJSONArray("imageTokens");
|
|
|
if (!Check.isNull(imageTokens)) {
|
|
|
for (int j = 0; j < imageTokens.size(); j++) {
|
|
|
JSONObject imageJson = imageTokens.getJSONObject(j);
|
|
@@ -482,12 +479,11 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
|
if (code == 0) {
|
|
|
JSONObject successJson = new JSONObject();
|
|
|
- successJson.put("creative_name", name);
|
|
|
-
|
|
|
+ successJson.put("creativeName", name);
|
|
|
successArr.add(successJson);
|
|
|
} else {
|
|
|
JSONObject failJson = new JSONObject();
|
|
|
- failJson.put("creative_name", name);
|
|
|
+ failJson.put("creativeName", name);
|
|
|
failJson.put("failMessage", returnUnitMap.get("message"));
|
|
|
failArr.add(failJson);
|
|
|
}
|
|
@@ -496,9 +492,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
returnJson.put("success", successArr);
|
|
@@ -529,6 +523,310 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改计划信息
|
|
|
+ *
|
|
|
+ * @param requestJson
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public JSONObject updateCampaign(JSONObject requestJson) throws Exception {
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
+ if (Check.isNull(oauthToken)) {
|
|
|
+ throw new Exception("未获取到账户信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject campaignJson = new JSONObject();
|
|
|
+ campaignJson.put("advertiser_id", accountId);
|
|
|
+ Long campaignId = requestJson.getLong("campaignId");
|
|
|
+ if (Check.isNull(campaignId)) {
|
|
|
+ throw new Exception("请选择广告计划");
|
|
|
+ }
|
|
|
+ campaignJson.put("campaign_id", campaignId);
|
|
|
+ if (!Check.isNull(requestJson.getString("campaignName"))) {
|
|
|
+ campaignJson.put("campaign_name", requestJson.getString("campaignName"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(requestJson.getString("dayBudget"))) {
|
|
|
+ campaignJson.put("day_budget", requestJson.getString("dayBudget"));
|
|
|
+ }
|
|
|
+ JSONObject returnJson = updateService.updateCampaign(oauthToken.getAccessToken(), campaignJson);
|
|
|
+ return returnJson;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改广告组
|
|
|
+ *
|
|
|
+ * @param requestJson
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public JSONObject updateUnit(JSONObject requestJson) throws Exception {
|
|
|
+
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
+ if (Check.isNull(oauthToken)) {
|
|
|
+ throw new Exception("未获取到账户信息");
|
|
|
+ }
|
|
|
+ JSONObject unitJson = new JSONObject();
|
|
|
+ unitJson.put("advertiser_id", accountId);
|
|
|
+
|
|
|
+ Long unitId = requestJson.getLong("unitId");
|
|
|
+ if (Check.isNull(unitId)) {
|
|
|
+ throw new Exception("请选择广告组");
|
|
|
+ }
|
|
|
+
|
|
|
+ unitJson.put("unit_id", unitId);
|
|
|
+ // 广告组名称
|
|
|
+ if (!Check.isNull(requestJson.getString("unitName"))) {
|
|
|
+ unitJson.put("unit_name", requestJson.getString("unitName"));
|
|
|
+ }
|
|
|
+ // 出价
|
|
|
+ if (!Check.isNull(requestJson.getLong("bid"))) {
|
|
|
+ unitJson.put("bid", requestJson.getLong("bid"));
|
|
|
+ }
|
|
|
+ // 深度转化出价
|
|
|
+ if (!Check.isNull(requestJson.getLong("cpaBid"))) {
|
|
|
+ unitJson.put("cpa_bid", requestJson.getLong("cpaBid"));
|
|
|
+ }
|
|
|
+ // 深度转化目标出价
|
|
|
+ if (!Check.isNull(requestJson.getLong("deepConversionBid"))) {
|
|
|
+ unitJson.put("deep_conversion_bid", requestJson.getLong("deepConversionBid"));
|
|
|
+ }
|
|
|
+ //投放开始时间
|
|
|
+ if (!Check.isNull(requestJson.getString("beginTime"))) {
|
|
|
+ unitJson.put("begin_time", requestJson.getString("beginTime"));
|
|
|
+ }
|
|
|
+ // 投放结束时间
|
|
|
+ if (!Check.isNull(requestJson.getString("endTime"))) {
|
|
|
+ unitJson.put("end_time", requestJson.getString("endTime"));
|
|
|
+ }
|
|
|
+ // 投放时间段
|
|
|
+ if (!Check.isNull(requestJson.getString("scheduleTime"))) {
|
|
|
+ unitJson.put("schedule_time", requestJson.getString("scheduleTime"));
|
|
|
+ }
|
|
|
+ // 广告组单日预算
|
|
|
+ if (!Check.isNull(requestJson.getLong("dayBudget"))) {
|
|
|
+ unitJson.put("day_budget", requestJson.getLong("dayBudget"));
|
|
|
+ }
|
|
|
+ // url类型
|
|
|
+ if (!Check.isNull(requestJson.getInteger("urlType"))) {
|
|
|
+ unitJson.put("url_type", requestJson.getInteger("urlType"));
|
|
|
+ }
|
|
|
+ // url
|
|
|
+ if (!Check.isNull(requestJson.getString("url"))) {
|
|
|
+ unitJson.put("url", requestJson.getString("url"));
|
|
|
+ }
|
|
|
+ // appId
|
|
|
+ if (!Check.isNull(requestJson.getLong("appId"))) {
|
|
|
+ unitJson.put("app_id", requestJson.getLong("appId"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创意展现方式
|
|
|
+ if (!Check.isNull(requestJson.getInteger("showMode"))) {
|
|
|
+ unitJson.put("show_mode", requestJson.getInteger("showMode"));
|
|
|
+ }
|
|
|
+ //投放方式
|
|
|
+ if (!Check.isNull(requestJson.getInteger("speed"))) {
|
|
|
+ unitJson.put("speed", requestJson.getInteger("speed"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // -----------------用户定向-----------
|
|
|
+ JSONObject targetJson = new JSONObject();
|
|
|
+
|
|
|
+ // 地域
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("region"))) {
|
|
|
+ targetJson.put("region", requestJson.getJSONArray("region"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 自定义年龄段
|
|
|
+ JSONArray ageArr = requestJson.getJSONArray("age");
|
|
|
+ if (!Check.isNull(ageArr)) {
|
|
|
+ JSONObject ageJson = new JSONObject();
|
|
|
+ ageJson.put("min", ageArr.get(0));
|
|
|
+ ageJson.put("max", ageArr.get(1));
|
|
|
+ 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.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"));
|
|
|
+ }
|
|
|
+ // APP行为-按分类
|
|
|
+ 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"));
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ unitJson.put("target", targetJson);
|
|
|
+
|
|
|
+ JSONObject returnJson = updateService.updateUnit(oauthToken.getAccessToken(), unitJson);
|
|
|
+ return returnJson;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改广告创意
|
|
|
+ *
|
|
|
+ * @param requestJson
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public JSONObject updateCreative(JSONObject requestJson) throws Exception {
|
|
|
+ if (Check.isNull(requestJson)) {
|
|
|
+ throw new Exception("入参为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
+ if (Check.isNull(accountId)) {
|
|
|
+ throw new Exception("请输入需创建账号");
|
|
|
+ }
|
|
|
+ JSONObject creativeJson = new JSONObject();
|
|
|
+ creativeJson.put("advertiser_id", accountId);
|
|
|
+
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
+ if (Check.isNull(oauthToken)) {
|
|
|
+ throw new Exception("未获取到账户信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long creativeId = requestJson.getLong("creativeId");
|
|
|
+ if (Check.isNull(creativeId)) {
|
|
|
+ throw new Exception("请选择广告创意");
|
|
|
+ }
|
|
|
+ creativeJson.put("creative_id", creativeId);
|
|
|
+
|
|
|
+
|
|
|
+ // 创意名称
|
|
|
+ if (!Check.isNull(requestJson.get("creativeName"))) {
|
|
|
+ creativeJson.put("creative_name", requestJson.get("creativeName"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //封面
|
|
|
+ if (!Check.isNull(requestJson.get("photoId"))) {
|
|
|
+ creativeJson.put("photo_id", requestJson.get("photoId"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 视频id
|
|
|
+ if (!Check.isNull(requestJson.get("imageToken"))) {
|
|
|
+ creativeJson.put("image_token", requestJson.get("imageToken"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 行动号召按钮
|
|
|
+ if (!Check.isNull(requestJson.get("actionBarText"))) {
|
|
|
+ creativeJson.put("action_bar_text", requestJson.get("actionBarText"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 广告语
|
|
|
+ if (!Check.isNull(requestJson.get("description"))) {
|
|
|
+ creativeJson.put("description", requestJson.get("description"));
|
|
|
+ }
|
|
|
+ // 封面标题
|
|
|
+ if (!Check.isNull(requestJson.get("stickerTitle"))) {
|
|
|
+ creativeJson.put("sticker_title", requestJson.get("stickerTitle"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 贴纸样式
|
|
|
+ if (!Check.isNull(requestJson.get("overlayType"))) {
|
|
|
+ creativeJson.put("overlay_type", requestJson.get("overlayType"));
|
|
|
+ }
|
|
|
+ // 第三方检测链接
|
|
|
+ if (!Check.isNull(requestJson.get("clickTrackUrl"))) {
|
|
|
+ creativeJson.put("click_track_url", requestJson.get("clickTrackUrl"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 后贴片 第三方检测链接
|
|
|
+ if (!Check.isNull(requestJson.get("adPhotoPlayedT3sUrl"))) {
|
|
|
+ creativeJson.put("ad_photo_played_t3s_url", requestJson.get("adPhotoPlayedT3sUrl"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 后贴片 第三方检测链接
|
|
|
+ if (!Check.isNull(requestJson.get("impressionUrl"))) {
|
|
|
+ creativeJson.put("impression_url", requestJson.get("impressionUrl"));
|
|
|
+ }
|
|
|
+ JSONObject returnJson = updateService.updateCreative(oauthToken.getAccessToken(), creativeJson);
|
|
|
+
|
|
|
+ return returnJson;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|