|
@@ -4,8 +4,7 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.MaterialCutFrame;
|
|
import cn.com.ctop.common.module.entity.MaterialCutFrame;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.IMaterialCutFrameService;
|
|
import cn.com.ctop.common.module.service.IMaterialCutFrameService;
|
|
-import cn.com.ctop.common.module.utils.Check;
|
|
|
|
-import cn.com.ctop.common.module.utils.ListUtils;
|
|
|
|
|
|
+import cn.com.ctop.common.module.utils.*;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMapCreative;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMapCreative;
|
|
@@ -25,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -249,7 +249,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
|
|
|
|
JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j-1), strategy,j);
|
|
JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j-1), strategy,j);
|
|
- createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt());
|
|
|
|
|
|
+ createProgramCreative(token, creativeParams);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -300,6 +300,28 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void createProgramCreative(CtopOauthToken token, JSONObject creativeParams) {
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
|
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, creativeParams.toJSONString(), headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ log.info("创建程序化创意返回结果:{}", resultJson);
|
|
|
|
+ if (Check.isNull(resultJson)) {
|
|
|
|
+ log.error("程序化创意创意异常:api接口返回为空");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ String message = resultJson.getString("message");
|
|
|
|
+ if (null==code||code!=0) {
|
|
|
|
+ log.error("创建程序化创意失败,accountId:{},返回结果:{},入参:{}", token.getAccountId(), message, creativeParams);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ log.info("创建程序化创意成功");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy,Integer creativeCnt) {
|
|
private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy,Integer creativeCnt) {
|
|
JSONObject programJson = new JSONObject();
|
|
JSONObject programJson = new JSONObject();
|
|
programJson.put("advertiser_id", token.getAccountId());
|
|
programJson.put("advertiser_id", token.getAccountId());
|
|
@@ -345,21 +367,22 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
|
|
if (!Check.isNull(strategy.getActionBarText())) {
|
|
if (!Check.isNull(strategy.getActionBarText())) {
|
|
programJson.put("action_bar", strategy.getActionBarText());
|
|
programJson.put("action_bar", strategy.getActionBarText());
|
|
}
|
|
}
|
|
- if (!Check.isNull(programCreativeJson.getJSONArray("captions"))) {
|
|
|
|
- programJson.put("captions", programCreativeJson.getJSONArray("captions"));
|
|
|
|
- }
|
|
|
|
- if (!Check.isNull(programCreativeJson.getString("click_url"))) {
|
|
|
|
- programJson.put("click_url", programCreativeJson.getString("click_url"));
|
|
|
|
|
|
+// if (!Check.isNull(programCreativeJson.getJSONArray("captions"))) {
|
|
|
|
+// programJson.put("captions", programCreativeJson.getJSONArray("captions"));
|
|
|
|
+// }
|
|
|
|
+ if (!Check.isNull(strategy.getClickTrackUrl())) {
|
|
|
|
+ programJson.put("click_url", strategy.getClickTrackUrl());
|
|
}
|
|
}
|
|
- if (!Check.isNull(programCreativeJson.getString("actionbar_click_url"))) {
|
|
|
|
- programJson.put("actionbar_click_url", programCreativeJson.getString("actionbar_click_url"));
|
|
|
|
|
|
+ if (!Check.isNull(strategy.getActionbarClickUrl())) {
|
|
|
|
+ programJson.put("actionbar_click_url", strategy.getActionbarClickUrl());
|
|
}
|
|
}
|
|
- if (!Check.isNull(programCreativeJson.getInteger("creative_category"))) {
|
|
|
|
- programJson.put("creative_category", programCreativeJson.getInteger("creative_category"));
|
|
|
|
|
|
+ if (!Check.isNull(strategy.getCreativeCategory())) {
|
|
|
|
+ programJson.put("creative_category", strategy.getCreativeCategory());
|
|
}
|
|
}
|
|
- if (!Check.isNull(programCreativeJson.getJSONArray("creative_tag"))) {
|
|
|
|
- programJson.put("creative_tag", programCreativeJson.getJSONArray("creative_tag"));
|
|
|
|
|
|
+ if (!Check.isNull(strategy.getCreativeTag())) {
|
|
|
|
+ programJson.put("creative_tag", JSONArray.parseArray(strategy.getCreativeTag()));
|
|
}
|
|
}
|
|
|
|
+ return programJson;
|
|
}
|
|
}
|
|
|
|
|
|
private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy,String startTime,String endTime,AiKuaiShouAppInfo appInfo) {
|
|
private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy,String startTime,String endTime,AiKuaiShouAppInfo appInfo) {
|