|
@@ -170,16 +170,12 @@ public class BatchServiceImpl implements IBatchService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public JSONObject createUnit(JSONObject requestJson, CtopOauthToken oauthToken) throws Exception {
|
|
public JSONObject createUnit(JSONObject requestJson, CtopOauthToken oauthToken) throws Exception {
|
|
-
|
|
|
|
-
|
|
|
|
JSONObject unitJson = new JSONObject();
|
|
JSONObject unitJson = new JSONObject();
|
|
-
|
|
|
|
Long campaignId = requestJson.getLong("campaignId");
|
|
Long campaignId = requestJson.getLong("campaignId");
|
|
if (Check.isNull(campaignId)) {
|
|
if (Check.isNull(campaignId)) {
|
|
throw new Exception("请选择广告计划");
|
|
throw new Exception("请选择广告计划");
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
String type = requestJson.getString("type");
|
|
String type = requestJson.getString("type");
|
|
if ("copy".equals(type) && !Check.isNull(type)) {
|
|
if ("copy".equals(type) && !Check.isNull(type)) {
|
|
unitJson.put("campaign_id", requestJson.getLong("copyToCampaignId"));
|
|
unitJson.put("campaign_id", requestJson.getLong("copyToCampaignId"));
|
|
@@ -404,7 +400,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
unitJson.put("unit_name", unitName);
|
|
unitJson.put("unit_name", unitName);
|
|
}
|
|
}
|
|
|
|
|
|
- Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson,1);
|
|
|
|
|
|
+ Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson, 1);
|
|
if (!Check.isNullMap(returnUnitMap)) {
|
|
if (!Check.isNullMap(returnUnitMap)) {
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
@@ -453,6 +449,292 @@ public class BatchServiceImpl implements IBatchService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 批量创建广告组
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject copyUpdateUnit(JSONObject requestJson, CtopOauthToken oauthToken) {
|
|
|
|
+
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ JSONObject unitJson = new JSONObject();
|
|
|
|
+ Long campaignId = requestJson.getLong("campaignId");
|
|
|
|
+ if (Check.isNull(campaignId)) {
|
|
|
|
+ throw new Exception("请选择广告计划");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String type = requestJson.getString("type");
|
|
|
|
+ if ("copy".equals(type) && !Check.isNull(type)) {
|
|
|
|
+ unitJson.put("campaign_id", requestJson.getLong("copyToCampaignId"));
|
|
|
|
+ } else {
|
|
|
|
+ unitJson.put("campaign_id", campaignId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 资源位置
|
|
|
|
+ JSONArray scene_id = requestJson.getJSONArray("sceneId");
|
|
|
|
+ if (!Check.isNull(scene_id)) {
|
|
|
|
+ unitJson.put("scene_id", scene_id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 资源创作方式
|
|
|
|
+ if (!Check.isNull(requestJson.getInteger("unitType"))) {
|
|
|
|
+ unitJson.put("unit_type", requestJson.getInteger("unitType"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 转化目标id
|
|
|
|
+ if (!Check.isNull(requestJson.getInteger("convertId"))) {
|
|
|
|
+ unitJson.put("convert_id", requestJson.getInteger("convertId"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 优先从系统应用商店下载
|
|
|
|
+ if (!Check.isNull(requestJson.getInteger("useAppMarket"))) {
|
|
|
|
+ unitJson.put("use_app_market", requestJson.getInteger("useAppMarket"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //投放开始时间
|
|
|
|
+ if (!Check.isNull(requestJson.getString("beginTime"))) {
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ boolean beginTimeBoolean = DateUtils.compare(requestJson.getString("beginTime"), nowDate);
|
|
|
|
+ if (beginTimeBoolean) {
|
|
|
|
+ unitJson.put("begin_time", nowDate);
|
|
|
|
+ } else {
|
|
|
|
+ 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 groupJson = requestJson.getJSONObject("groupArr");
|
|
|
|
+ if (Check.isNull(groupJson)) {
|
|
|
|
+ throw new Exception("请输入需要创建的广告组");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 创建条数
|
|
|
|
+
|
|
|
|
+ JSONArray successArr = new JSONArray();
|
|
|
|
+ JSONArray failArr = new JSONArray();
|
|
|
|
+
|
|
|
|
+ if (!Check.isNull(groupJson)) {
|
|
|
|
+
|
|
|
|
+ // 出价
|
|
|
|
+ if (!Check.isNull(groupJson.getLong("bid"))) {
|
|
|
|
+ unitJson.put("bid", groupJson.getLong("bid"));
|
|
|
|
+ }
|
|
|
|
+ // 出价类型
|
|
|
|
+ Integer bidType = groupJson.getInteger("bidType");
|
|
|
|
+ if (!Check.isNull(bidType)) {
|
|
|
|
+ unitJson.put("bid_type", bidType);
|
|
|
|
+ }
|
|
|
|
+ // 深度转化出价
|
|
|
|
+ if (!Check.isNull(groupJson.getLong("cpaBid"))) {
|
|
|
|
+ unitJson.put("cpa_bid", groupJson.getLong("cpaBid"));
|
|
|
|
+ }
|
|
|
|
+ // 深度转化目标出价
|
|
|
|
+ if (!Check.isNull(groupJson.getLong("deepConversionBid"))) {
|
|
|
|
+ unitJson.put("deep_conversion_bid", groupJson.getLong("deepConversionBid"));
|
|
|
|
+ }
|
|
|
|
+ // 深度转化目标
|
|
|
|
+ if (!Check.isNull(groupJson.getInteger("deepConversionType"))) {
|
|
|
|
+ unitJson.put("deep_conversion_type", groupJson.getInteger("deepConversionType"));
|
|
|
|
+ }
|
|
|
|
+ // 优化目标
|
|
|
|
+ Integer ocpx_action_type = groupJson.getInteger("ocpxActionType");
|
|
|
|
+ if (!Check.isNull(ocpx_action_type)) {
|
|
|
|
+ unitJson.put("ocpx_action_type", ocpx_action_type);
|
|
|
|
+ }
|
|
|
|
+ String unitName = groupJson.getString("unitName");
|
|
|
|
+ if (!Check.isNull(unitName)) {
|
|
|
|
+ unitJson.put("unit_name", unitName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson, 1);
|
|
|
|
+
|
|
|
|
+ if (!Check.isNullMap(returnUnitMap)) {
|
|
|
|
+ Integer code = (Integer) returnUnitMap.get("code");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+
|
|
|
|
+ Long unitId = (Long) returnUnitMap.get("unitId");
|
|
|
|
+ returnJson.put("code", 0);
|
|
|
|
+ returnJson.put("unitId", unitId);
|
|
|
|
+
|
|
|
|
+ if (!Check.isNull(type) && "copy".equals(type)) {
|
|
|
|
+ Long copyUnitId = requestJson.getLong("copyUnitId");
|
|
|
|
+ if (!Check.isNull(unitId) && !Check.isNull(copyUnitId)) {
|
|
|
|
+ Thread thread = new Thread() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ try {
|
|
|
|
+ copyCreative(oauthToken.getAccountId(), unitId, copyUnitId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ thread.start();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ returnJson.put("code", -1);
|
|
|
|
+ returnJson.put("unitName", unitName);
|
|
|
|
+ returnJson.put("message", returnUnitMap.get("message"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ returnJson.put("code", -1);
|
|
|
|
+ returnJson.put("message", "系统异常");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return returnJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 复制组
|
|
* 复制组
|
|
*
|
|
*
|
|
* @param
|
|
* @param
|
|
@@ -683,7 +965,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
unitJson.put("unit_name", unitName);
|
|
unitJson.put("unit_name", unitName);
|
|
}
|
|
}
|
|
|
|
|
|
- Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), group.getAccountId(), unitJson,1);
|
|
|
|
|
|
+ Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), group.getAccountId(), unitJson, 1);
|
|
if (!Check.isNullMap(returnUnitMap)) {
|
|
if (!Check.isNullMap(returnUnitMap)) {
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
@@ -786,7 +1068,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
}*/
|
|
}*/
|
|
|
|
|
|
|
|
|
|
- Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson,1);
|
|
|
|
|
|
+ Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson, 1);
|
|
if (!Check.isNullMap(returnCreativeMap)) {
|
|
if (!Check.isNullMap(returnCreativeMap)) {
|
|
Integer code = (Integer) returnCreativeMap.get("code");
|
|
Integer code = (Integer) returnCreativeMap.get("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
@@ -908,7 +1190,7 @@ public class BatchServiceImpl implements IBatchService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
creativeJson.put("image_token", imageToken);
|
|
creativeJson.put("image_token", imageToken);
|
|
- Map<String, Object> returnUnitMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson,1);
|
|
|
|
|
|
+ Map<String, Object> returnUnitMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson, 1);
|
|
if (!Check.isNullMap(returnUnitMap)) {
|
|
if (!Check.isNullMap(returnUnitMap)) {
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
Integer code = (Integer) returnUnitMap.get("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|