瀏覽代碼

快手自动投放账户程序化创意创建

syh 4 年之前
父節點
當前提交
3fd400daa6

+ 1 - 1
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -624,7 +624,7 @@ public class SampleTest {
 
     @Test
     public void etlKuaishouVideoInfo() {
-        Date startDate = DateUtils.parseDate("2020-09-11", "yyyy-MM-dd");
+        Date startDate = DateUtils.parseDate("2021-03-01", "yyyy-MM-dd");
         for (int i = 0; i < 365; i++) {
 //            dailyService.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
             videoEtlInfoService.etlKuaishouVideoInfo(DateUtils.formatDate(DateUtils.addDay(startDate, i)));

+ 37 - 14
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -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.service.ICtopOauthTokenService;
 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.AiKuaishouAdvertiserStrategy;
 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 java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -249,7 +249,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         }
 
                         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) {
         JSONObject programJson = new JSONObject();
         programJson.put("advertiser_id", token.getAccountId());
@@ -345,21 +367,22 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (!Check.isNull(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) {

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouNewCreateCampaignServiceImpl.java

@@ -82,7 +82,7 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
             //单一应用
         }
         // 3、获取5分钟内,ctop_kuaishou_video_get 的视频数据,记为 N,如果有数据则执行下面步骤
-        List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId,startTime,endTime,strategy.getChannelType(),null);
+        List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId,startTime,endTime,strategy.getChannelType(),null,null);
         int newVideosCnt = newVideos.size();
         if (newVideosCnt == 0){
             log.info("账户:{},{} 到 {} 这段时间没有上新素材",accountId, startTime, endTime);
@@ -181,7 +181,7 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
         String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
         String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
         // 3、获取5分钟内,ctop_kuaishou_video_get 的视频数据,记为 N,如果有数据则执行下面步骤
-        List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId,startTime,endTime,strategy.getChannelType(),null);
+        List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId,startTime,endTime,strategy.getChannelType(),null,null);
         int newVideosCnt = newVideos.size();
         if (newVideosCnt == 0){
             log.info("账户:{},{} 到 {} 这段时间没有上新素材",accountId, startTime, endTime);

+ 2 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/EtlKuaishouVideoInfoServiceImpl.java

@@ -82,11 +82,8 @@ public class EtlKuaishouVideoInfoServiceImpl extends ServiceImpl<EtlKuaishouVide
                                 //根据id查询剪辑所属的设计负责人
                                 SysUser user = sysUserService.getById(clipId);
                                 if(null!=user){
-                                    SysUser designTeamLeader = sysUserService.getDesignerTeamLeaderBy(user.getOrgCode());
-                                    if(null!=designTeamLeader){
-                                        etlKuaishouVideoInfo.setDesignTeamLeaderId(designTeamLeader.getId());
-                                        etlKuaishouVideoInfo.setDesignTeamLeaderName(designTeamLeader.getRealname());
-                                    }
+                                    etlKuaishouVideoInfo.setDesignTeamLeaderId(user.getLeaderId());
+                                    etlKuaishouVideoInfo.setDesignTeamLeaderName(user.getLeaderName());
                                 }
                             }
                             String clipName = ascription.getString("clipName");