|
@@ -346,8 +346,12 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
|
|
|
}
|
|
|
|
|
|
JSONObject param = new JSONObject();
|
|
|
+ param.put("template_id", requestJson.getLong("templateId"));
|
|
|
param.put("advertiser_id", accountId);
|
|
|
- param.put("template_name", requestJson.getString("templateName"));
|
|
|
+ if(!Check.isNull(requestJson.getString("templateName"))){
|
|
|
+ param.put("template_name", requestJson.getString("templateName"));
|
|
|
+ }
|
|
|
+
|
|
|
JSONObject targetJson = new JSONObject();
|
|
|
if (!Check.isNull(requestJson.getJSONArray("region"))) {
|
|
|
targetJson.put("region", requestJson.getJSONArray("region"));
|
|
@@ -362,14 +366,11 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
|
|
|
targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
|
|
|
}
|
|
|
|
|
|
- JSONObject ageJson = new JSONObject();
|
|
|
- if (!Check.isNull(requestJson.getInteger("min"))) {
|
|
|
+
|
|
|
+ if (!Check.isNull(requestJson.getInteger("min")) && !Check.isNull(requestJson.getInteger("max"))) {
|
|
|
+ JSONObject ageJson = new JSONObject();
|
|
|
ageJson.put("min", requestJson.getInteger("min"));
|
|
|
- }
|
|
|
- if (!Check.isNull(requestJson.getInteger("max"))) {
|
|
|
ageJson.put("max", requestJson.getInteger("max"));
|
|
|
- }
|
|
|
- if (!Check.isNull(ageJson)) {
|
|
|
targetJson.put("age", ageJson);
|
|
|
}
|
|
|
|
|
@@ -424,23 +425,27 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
|
|
|
if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
|
|
|
targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
|
|
|
}
|
|
|
- JSONObject intelliExtendJson = new JSONObject();
|
|
|
+
|
|
|
|
|
|
if (!Check.isNull(requestJson.getInteger("isOpen"))) {
|
|
|
+ JSONObject intelliExtendJson = new JSONObject();
|
|
|
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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- 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);
|
|
|
- }
|
|
|
+
|
|
|
if (!Check.isNull(targetJson)) {
|
|
|
param.put("target", targetJson);
|
|
|
}
|
|
@@ -448,9 +453,11 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
|
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
headers.put("Content-Type", " application/json");
|
|
|
- String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
|
|
|
+ System.err.println("入参:" + param.toJSONString());
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
|
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ System.err.println("返回:" + resultJson.toJSONString());
|
|
|
if (!Check.isNull(resultJson)) {
|
|
|
Integer code = resultJson.getInteger("code");
|
|
|
if (code == 0) {
|