Преглед изворни кода

添加定时获取计划,组,创意

zhaoxian пре 2 година
родитељ
комит
5416a81eef
27 измењених фајлова са 1405 додато и 20 уклоњено
  1. 23 1
      job-live/src/main/java/cn/com/ctop/job/live/controller/LiveController.java
  2. 62 0
      job-live/src/main/java/cn/com/ctop/job/live/entity/KuaishouLiveCampaignList.java
  3. 66 0
      job-live/src/main/java/cn/com/ctop/job/live/entity/KuaishouLiveCreativeList.java
  4. 114 0
      job-live/src/main/java/cn/com/ctop/job/live/entity/KuaishouLiveUnitList.java
  5. 73 0
      job-live/src/main/java/cn/com/ctop/job/live/entity/KuaishouLiveVideoList.java
  6. 1 1
      job-live/src/main/java/cn/com/ctop/job/live/handler/AdAccountReportJob.java
  7. 40 4
      job-live/src/main/java/cn/com/ctop/job/live/handler/AdCampaignReportJob.java
  8. 37 3
      job-live/src/main/java/cn/com/ctop/job/live/handler/AdCreativeReportJob.java
  9. 36 4
      job-live/src/main/java/cn/com/ctop/job/live/handler/AdUnitReportJob.java
  10. 32 0
      job-live/src/main/java/cn/com/ctop/job/live/mapper/KuaishouLiveCampaignListMapper.java
  11. 33 0
      job-live/src/main/java/cn/com/ctop/job/live/mapper/KuaishouLiveCreativeListMapper.java
  12. 35 0
      job-live/src/main/java/cn/com/ctop/job/live/mapper/KuaishouLiveUnitListMapper.java
  13. 31 0
      job-live/src/main/java/cn/com/ctop/job/live/mapper/KuaishouLiveVideoListMapper.java
  14. 78 0
      job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/KuaishouLiveCampaignListMapper.xml
  15. 107 0
      job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/KuaishouLiveCreativeListMapper.xml
  16. 125 0
      job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/KuaishouLiveUnitListMapper.xml
  17. 52 0
      job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/KuaishouLiveVideoListMapper.xml
  18. 34 0
      job-live/src/main/java/cn/com/ctop/job/live/service/IKuaishouLiveCampaignListService.java
  19. 32 0
      job-live/src/main/java/cn/com/ctop/job/live/service/IKuaishouLiveCreativeListService.java
  20. 33 0
      job-live/src/main/java/cn/com/ctop/job/live/service/IKuaishouLiveUnitListService.java
  21. 30 0
      job-live/src/main/java/cn/com/ctop/job/live/service/IKuaishouLiveVideoListService.java
  22. 93 0
      job-live/src/main/java/cn/com/ctop/job/live/service/impl/KuaishouLiveCampaignListServiceImpl.java
  23. 93 0
      job-live/src/main/java/cn/com/ctop/job/live/service/impl/KuaishouLiveCreativeListServiceImpl.java
  24. 94 0
      job-live/src/main/java/cn/com/ctop/job/live/service/impl/KuaishouLiveUnitListServiceImpl.java
  25. 47 0
      job-live/src/main/java/cn/com/ctop/job/live/service/impl/KuaishouLiveVideoListServiceImpl.java
  26. 0 7
      job-live/src/main/java/cn/com/ctop/job/live/utils/DateUtils.java
  27. 4 0
      job-live/src/main/java/cn/com/ctop/job/live/utils/KuaishouAPIConstant.java

+ 23 - 1
job-live/src/main/java/cn/com/ctop/job/live/controller/LiveController.java

@@ -1,8 +1,12 @@
 package cn.com.ctop.job.controller;
 
+import cn.com.ctop.job.live.service.AgentTokenService;
 import cn.com.ctop.job.live.service.IKuaishouLiveAccountReportDailyService;
+import cn.com.ctop.job.live.service.IKuaishouLiveCampaignListService;
 import cn.com.ctop.job.live.service.IKuaishouLiveCampaignReportDailyService;
+import cn.com.ctop.job.live.service.IKuaishouLiveCreativeListService;
 import cn.com.ctop.job.live.service.IKuaishouLiveCreativeReportDailyService;
+import cn.com.ctop.job.live.service.IKuaishouLiveUnitListService;
 import cn.com.ctop.job.live.service.IKuaishouLiveUnitReportDailyService;
 import cn.com.ctop.job.live.utils.Result;
 import io.swagger.annotations.Api;
@@ -19,7 +23,8 @@ import org.springframework.web.bind.annotation.RestController;
 @Slf4j
 public class LiveController {
 
-
+    @Autowired
+    private AgentTokenService tokenService;
     @Autowired
     private IKuaishouLiveAccountReportDailyService accountReportDailyService;
 
@@ -32,6 +37,15 @@ public class LiveController {
     @Autowired
     private IKuaishouLiveCreativeReportDailyService creativeReportDailyService;
 
+    @Autowired
+    private IKuaishouLiveCampaignListService campaignListService;
+
+    @Autowired
+    private IKuaishouLiveUnitListService unitListService;
+
+    @Autowired
+    private IKuaishouLiveCreativeListService creativeListService;
+
 
     /**
      * 清洗昨日直播账户数据
@@ -69,5 +83,13 @@ public class LiveController {
         return creativeReportDailyService.getKuaishouCreativeReport(accountId, token, 1);
     }
 
+    @GetMapping(value = "/getKuaishouCampaign")
+    public Result<Object> getKuaishouCampaign(Long accountId) {
+        String token = tokenService.getByAccountId(accountId);
+        campaignListService.getKuaishouCampaign(accountId, token);
+        unitListService.getKuaishouUnit(accountId, token);
+        return creativeListService.getKuaishouCreative(accountId, token);
+    }
+
 
 }

+ 62 - 0
job-live/src/main/java/cn/com/ctop/job/live/entity/KuaishouLiveCampaignList.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.job.live.entity;
+
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 广告计划对象 kuaishou_live_campaign_list
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+@Data
+public class KuaishouLiveCampaignList {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 账户id
+     */
+    private Long accountId;
+
+    /**
+     * 计划id
+     */
+    private Long campaignId;
+
+    /**
+     * 计划名称
+     */
+    @Excel(name = "计划名称")
+    private String campaignName;
+
+    /**
+     * 计划创建时间
+     */
+    @Excel(name = "计划创建时间")
+    private Long campaignCreateTime;
+
+    /**
+     * 请求时间
+     */
+    @Excel(name = "请求时间")
+    private Long reportDate;
+
+    /**
+     * 计划状态
+     */
+    @Excel(name = "计划状态")
+    private Long viewStatus;
+
+    /**
+     * 今日预算
+     */
+    @Excel(name = "今日预算")
+    private Long dayBudget;
+
+    /**
+     * 营销目标
+     */
+    @Excel(name = "营销目标")
+    private String campaignType;
+
+}

+ 66 - 0
job-live/src/main/java/cn/com/ctop/job/live/entity/KuaishouLiveCreativeList.java

@@ -0,0 +1,66 @@
+package cn.com.ctop.job.live.entity;
+
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 创意对象 kuaishou_live_creative_list
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+@Data
+public class KuaishouLiveCreativeList {
+    private static final long serialVersionUID = 1L;
+
+    /** 账户id */
+    private Long accountId;
+
+    /** 计划id */
+    @Excel(name = "计划id")
+    private Long campaignId;
+
+    /** 计划名称 */
+    @Excel(name = "计划名称")
+    private String campaignName;
+
+    /** 组id */
+    @Excel(name = "组id")
+    private Long unitId;
+
+    /** 组名称 */
+    @Excel(name = "组名称")
+    private String unitName;
+
+    /** 创意id */
+    private Long creativeId;
+
+    /** 创意名称 */
+    @Excel(name = "创意名称")
+    private String creativeName;
+
+    /** 计划创建时间 */
+    @Excel(name = "创意创建时间")
+    private Long creativeCreateTime;
+
+    /** 请求时间 */
+    @Excel(name = "请求时间")
+    private Long reportDate;
+
+    /** 计划状态 */
+    @Excel(name = "计划状态")
+    private Long viewStatus;
+
+    /** 投放方式 */
+    @Excel(name = "投放方式")
+    private Long speed;
+
+    /** 创意样式 */
+    @Excel(name = "创意样式")
+    private String liveCreativeType;
+
+    /** 创意创建方式 */
+    @Excel(name = "创意创建方式")
+    private String creativeSourceTypeStr;
+
+}

+ 114 - 0
job-live/src/main/java/cn/com/ctop/job/live/entity/KuaishouLiveUnitList.java

@@ -0,0 +1,114 @@
+package cn.com.ctop.job.live.entity;
+
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 广告组对象 kuaishou_live_unit_list
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+@Data
+public class KuaishouLiveUnitList {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 账户id
+     */
+    private Long accountId;
+
+    /**
+     * 计划id
+     */
+    private Long campaignId;
+
+    /**
+     * 计划名称
+     */
+    @Excel(name = "计划名称")
+    private String campaignName;
+
+    /**
+     * 组id
+     */
+    private Long unitId;
+
+    /**
+     * 组名称
+     */
+    @Excel(name = "组名称")
+    private String unitName;
+
+    /**
+     * 计划创建时间
+     */
+    @Excel(name = "计划创建时间")
+    private Long unitCreateTime;
+
+    /**
+     * 请求时间
+     */
+    @Excel(name = "请求时间")
+    private Long reportDate;
+
+    /**
+     * 计划状态
+     */
+    @Excel(name = "计划状态")
+    private Long viewStatus;
+
+    /**
+     * 今日预算
+     */
+    @Excel(name = "今日预算")
+    private Long dayBudget;
+
+    /**
+     * 营销目标
+     */
+    @Excel(name = "营销目标")
+    private String campaignType;
+
+    /**
+     * 转化目标
+     */
+    @Excel(name = "转化目标")
+    private Long ocpxActionType;
+
+    /**
+     * 成本上限
+     */
+    @Excel(name = "成本上限")
+    private String bidDetail;
+
+    /**
+     * 创意组成方式
+     */
+    @Excel(name = "创意组成方式")
+    private String creativeBuildTypeStr;
+
+    /**
+     * 投放方式
+     */
+    @Excel(name = "投放方式")
+    private Long speed;
+
+    /**
+     * 探索工具
+     */
+    @Excel(name = "探索工具")
+    private String exploreTools;
+
+    /**
+     * 同时优化目标
+     */
+    @Excel(name = "同时优化目标")
+    private String simultaneousOptimizationType;
+
+    /**
+     * 人群扩量
+     */
+    @Excel(name = "人群扩量")
+    private String targetExtend;
+}

+ 73 - 0
job-live/src/main/java/cn/com/ctop/job/live/entity/KuaishouLiveVideoList.java

@@ -0,0 +1,73 @@
+package cn.com.ctop.job.live.entity;
+
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 素材对象 kuaishou_live_video_list
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+@Data
+public class KuaishouLiveVideoList {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 账户id
+     */
+    private Long accountId;
+
+    /**
+     * 视频名称
+     */
+    @Excel(name = "视频名称")
+    private String photoName;
+
+    /**
+     * 视频id
+     */
+    private Long photoId;
+
+    /**
+     * 视频标签
+     */
+    @Excel(name = "视频标签")
+    private String photoTag;
+
+    /**
+     * 视频时长
+     */
+    @Excel(name = "视频时长")
+    private Long duration;
+
+    /**
+     * 视频创建时间
+     */
+    @Excel(name = "视频创建时间")
+    private String createTime;
+
+    /**
+     * 视频链接
+     */
+    @Excel(name = "视频链接")
+    private String url;
+
+    /**
+     * 视频封面
+     */
+    @Excel(name = "视频封面")
+    private String coverUrl;
+
+    /**
+     * 视频高度
+     */
+    @Excel(name = "视频高度")
+    private Long height;
+
+    /**
+     * 视频宽度
+     */
+    @Excel(name = "视频宽度")
+    private Long width;
+}

+ 1 - 1
job-live/src/main/java/cn/com/ctop/job/live/handler/AdAccountReportJob.java

@@ -74,7 +74,7 @@ public class AdAccountReportJob {
             return;
         }
 
-        dailyExecutorService.submit(
+        hourExecutorService.submit(
                 new Runnable() {
                     @Override
                     public void run() {

+ 40 - 4
job-live/src/main/java/cn/com/ctop/job/live/handler/AdCampaignReportJob.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.job.live.handler;
 
 import cn.com.ctop.job.live.service.AgentTokenService;
+import cn.com.ctop.job.live.service.IKuaishouLiveCampaignListService;
 import cn.com.ctop.job.live.service.IKuaishouLiveCampaignReportDailyService;
 import cn.com.ctop.job.live.utils.Check;
 import com.xxl.job.core.context.XxlJobHelper;
@@ -17,13 +18,17 @@ import java.util.concurrent.Executors;
 public class AdCampaignReportJob {
 
     @Autowired
+    private AgentTokenService tokenService;
+
+    @Autowired
     private IKuaishouLiveCampaignReportDailyService campaignReportDailyService;
 
     @Autowired
-    private AgentTokenService tokenService;
+    private IKuaishouLiveCampaignListService campaignListService;
 
     private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
     private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService liveExecutorService = Executors.newFixedThreadPool(3);
 
     /**
      * 获取广告计划信息
@@ -52,7 +57,6 @@ public class AdCampaignReportJob {
                             campaignReportDailyService.getKuaishouCampaignReport(Long.valueOf(param), token, 1);
                         } catch (Exception e) {
                             log.info(String.valueOf(e));
-                            ;
                         }
                     }
                 });
@@ -75,7 +79,7 @@ public class AdCampaignReportJob {
             return;
         }
 
-        dailyExecutorService.submit(
+        hourExecutorService.submit(
                 new Runnable() {
                     @Override
                     public void run() {
@@ -83,7 +87,39 @@ public class AdCampaignReportJob {
                             campaignReportDailyService.getKuaishouCampaignHourReport(Long.valueOf(param), token, 1);
                         } catch (Exception e) {
                             log.info(String.valueOf(e));
-                            ;
+                        }
+                    }
+                });
+    }
+
+
+    /**
+     * 获取广告计划信息
+     * 前1天
+     *
+     * @throws Exception
+     */
+    @XxlJob("getKuaishouCampaign")
+    public void getKuaishouCampaign() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+
+        liveExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            campaignListService.getKuaishouCampaign(Long.valueOf(param), token);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
                         }
                     }
                 });

+ 37 - 3
job-live/src/main/java/cn/com/ctop/job/live/handler/AdCreativeReportJob.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.job.live.handler;
 
 import cn.com.ctop.job.live.service.AgentTokenService;
+import cn.com.ctop.job.live.service.IKuaishouLiveCreativeListService;
 import cn.com.ctop.job.live.service.IKuaishouLiveCreativeReportDailyService;
 import cn.com.ctop.job.live.utils.Check;
 import com.xxl.job.core.context.XxlJobHelper;
@@ -17,13 +18,16 @@ import java.util.concurrent.Executors;
 public class AdCreativeReportJob {
 
     @Autowired
+    private AgentTokenService tokenService;
+
+    @Autowired
     private IKuaishouLiveCreativeReportDailyService creativeReportDailyService;
 
     @Autowired
-    private AgentTokenService tokenService;
+    private IKuaishouLiveCreativeListService creativeListService;
 
     private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
-    private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService liveExecutorService = Executors.newFixedThreadPool(3);
 
     /**
      * 获取广告创意信息
@@ -52,7 +56,37 @@ public class AdCreativeReportJob {
                             creativeReportDailyService.getKuaishouCreativeReport(Long.valueOf(param), token, 1);
                         } catch (Exception e) {
                             log.info(String.valueOf(e));
-                            ;
+                        }
+                    }
+                });
+    }
+
+    /**
+     * 获取广告创意信息
+     *
+     * @throws Exception
+     */
+    @XxlJob("getKuaishouCreative")
+    public void getKuaishouCreative() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+
+        liveExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            creativeListService.getKuaishouCreative(Long.valueOf(param), token);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
                         }
                     }
                 });

+ 36 - 4
job-live/src/main/java/cn/com/ctop/job/live/handler/AdUnitReportJob.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.job.live.handler;
 
 import cn.com.ctop.job.live.service.AgentTokenService;
+import cn.com.ctop.job.live.service.IKuaishouLiveUnitListService;
 import cn.com.ctop.job.live.service.IKuaishouLiveUnitReportDailyService;
 import cn.com.ctop.job.live.utils.Check;
 import com.xxl.job.core.context.XxlJobHelper;
@@ -17,13 +18,17 @@ import java.util.concurrent.Executors;
 public class AdUnitReportJob {
 
     @Autowired
+    private AgentTokenService tokenService;
+
+    @Autowired
     private IKuaishouLiveUnitReportDailyService unitReportDailyService;
 
     @Autowired
-    private AgentTokenService tokenService;
+    private IKuaishouLiveUnitListService unitListService;
 
     private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
     private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService liveExecutorService = Executors.newFixedThreadPool(3);
 
     /**
      * 获取广告组信息
@@ -52,7 +57,6 @@ public class AdUnitReportJob {
                             unitReportDailyService.getKuaishouUnitReport(Long.valueOf(param), token, 1);
                         } catch (Exception e) {
                             log.info(String.valueOf(e));
-                            ;
                         }
                     }
                 });
@@ -74,7 +78,7 @@ public class AdUnitReportJob {
             return;
         }
 
-        dailyExecutorService.submit(
+        hourExecutorService.submit(
                 new Runnable() {
                     @Override
                     public void run() {
@@ -82,11 +86,39 @@ public class AdUnitReportJob {
                             unitReportDailyService.getKuaishouUnitHourReport(Long.valueOf(param), token, 1);
                         } catch (Exception e) {
                             log.info(String.valueOf(e));
-                            ;
                         }
                     }
                 });
     }
 
 
+    /**
+     * 获取广告组信息(时报)
+     */
+    @XxlJob("getKuaishouUnit")
+    public void getKuaishouUnit() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+
+        liveExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            unitListService.getKuaishouUnit(Long.valueOf(param), token);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
+                        }
+                    }
+                });
+    }
+
 }

+ 32 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/KuaishouLiveCampaignListMapper.java

@@ -0,0 +1,32 @@
+package cn.com.ctop.job.live.mapper;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveCampaignList;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 广告计划Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+public interface KuaishouLiveCampaignListMapper {
+    /**
+     * 查询广告计划
+     *
+     * @param accountId 广告计划主键
+     * @return 广告计划
+     */
+    public KuaishouLiveCampaignList selectKuaishouLiveCampaignListByAccountId(Long accountId);
+
+    /**
+     * 查询广告计划列表
+     *
+     * @param kuaishouLiveCampaignList 广告计划
+     * @return 广告计划集合
+     */
+    public List<KuaishouLiveCampaignList> selectKuaishouLiveCampaignListList(KuaishouLiveCampaignList kuaishouLiveCampaignList);
+
+    void replaceBatch(@Param("list") List<KuaishouLiveCampaignList> list);
+}

+ 33 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/KuaishouLiveCreativeListMapper.java

@@ -0,0 +1,33 @@
+package cn.com.ctop.job.live.mapper;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveCreativeList;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 创意Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+public interface KuaishouLiveCreativeListMapper {
+    /**
+     * 查询创意
+     *
+     * @param accountId 创意主键
+     * @return 创意
+     */
+    public KuaishouLiveCreativeList selectKuaishouLiveCreativeListByAccountId(Long accountId);
+
+    /**
+     * 查询创意列表
+     *
+     * @param kuaishouLiveCreativeList 创意
+     * @return 创意集合
+     */
+    public List<KuaishouLiveCreativeList> selectKuaishouLiveCreativeListList(KuaishouLiveCreativeList kuaishouLiveCreativeList);
+
+    void replaceBatch(@Param("list") List<KuaishouLiveCreativeList> list);
+
+}

+ 35 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/KuaishouLiveUnitListMapper.java

@@ -0,0 +1,35 @@
+package cn.com.ctop.job.live.mapper;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveCampaignList;
+import cn.com.ctop.job.live.entity.KuaishouLiveUnitList;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+/**
+ * 广告组Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+public interface KuaishouLiveUnitListMapper {
+    /**
+     * 查询广告组
+     *
+     * @param accountId 广告组主键
+     * @return 广告组
+     */
+    public KuaishouLiveUnitList selectKuaishouLiveUnitListByAccountId(Long accountId);
+
+    /**
+     * 查询广告组列表
+     *
+     * @param kuaishouLiveUnitList 广告组
+     * @return 广告组集合
+     */
+    public List<KuaishouLiveUnitList> selectKuaishouLiveUnitListList(KuaishouLiveUnitList kuaishouLiveUnitList);
+
+
+    void replaceBatch(@Param("list") List<KuaishouLiveUnitList> list);
+}

+ 31 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/KuaishouLiveVideoListMapper.java

@@ -0,0 +1,31 @@
+package cn.com.ctop.job.live.mapper;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveVideoList;
+
+import java.util.List;
+
+
+/**
+ * 素材Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+public interface KuaishouLiveVideoListMapper {
+    /**
+     * 查询素材
+     *
+     * @param accountId 素材主键
+     * @return 素材
+     */
+    public KuaishouLiveVideoList selectKuaishouLiveVideoListByAccountId(Long accountId);
+
+    /**
+     * 查询素材列表
+     *
+     * @param kuaishouLiveVideoList 素材
+     * @return 素材集合
+     */
+    public List<KuaishouLiveVideoList> selectKuaishouLiveVideoListList(KuaishouLiveVideoList kuaishouLiveVideoList);
+
+}

+ 78 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/KuaishouLiveCampaignListMapper.xml

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.job.live.mapper.KuaishouLiveCampaignListMapper">
+
+    <resultMap type="cn.com.ctop.job.live.entity.KuaishouLiveCampaignList" id="KuaishouLiveCampaignListResult">
+        <result property="accountId" column="account_id"/>
+        <result property="campaignId" column="campaign_id"/>
+        <result property="campaignName" column="campaign_name"/>
+        <result property="campaignCreateTime" column="campaign_create_time"/>
+        <result property="reportDate" column="report_date"/>
+        <result property="viewStatus" column="view_status"/>
+        <result property="dayBudget" column="day_budget"/>
+        <result property="campaignType" column="campaign_type"/>
+    </resultMap>
+
+    <sql id="selectKuaishouLiveCampaignListVo">
+        select account_id,
+               campaign_id,
+               campaign_name,
+               campaign_create_time,
+               report_date,
+               view_status,
+               day_budget,
+               campaign_type
+        from kuaishou_live_campaign_list
+    </sql>
+
+    <select id="selectKuaishouLiveCampaignListList" parameterType="cn.com.ctop.job.live.entity.KuaishouLiveCampaignList"
+            resultMap="KuaishouLiveCampaignListResult">
+        <include refid="selectKuaishouLiveCampaignListVo"/>
+        <where>
+            <if test="campaignName != null  and campaignName != ''">and campaign_name like concat('%', #{campaignName},
+                '%')
+            </if>
+            <if test="campaignCreateTime != null ">and campaign_create_time = #{campaignCreateTime}</if>
+            <if test="reportDate != null ">and report_date = #{reportDate}</if>
+            <if test="viewStatus != null ">and view_status = #{viewStatus}</if>
+            <if test="dayBudget != null ">and day_budget = #{dayBudget}</if>
+            <if test="campaignType != null  and campaignType != ''">and campaign_type = #{campaignType}</if>
+        </where>
+    </select>
+
+    <select id="selectKuaishouLiveCampaignListByAccountId" parameterType="Long"
+            resultMap="KuaishouLiveCampaignListResult">
+        <include refid="selectKuaishouLiveCampaignListVo"/>
+        where account_id = #{accountId}
+    </select>
+
+
+    <insert id="replaceBatch">
+        replace into kuaishou_live_campaign_list(
+        account_id,
+        campaign_id,
+        campaign_name,
+        campaign_create_time,
+        report_date,
+        view_status,
+        day_budget,
+        campaign_type
+        )
+        values
+        <foreach collection="list" item="report" separator=",">
+            (
+            #{report.accountId},
+            #{report.campaignId},
+            #{report.campaignName},
+            #{report.campaignCreateTime},
+            #{report.reportDate},
+            #{report.viewStatus},
+            #{report.dayBudget},
+            #{report.campaignType}
+            )
+        </foreach>
+    </insert>
+
+</mapper>

+ 107 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/KuaishouLiveCreativeListMapper.xml

@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.job.live.mapper.KuaishouLiveCreativeListMapper">
+
+    <resultMap type="cn.com.ctop.job.live.entity.KuaishouLiveCreativeList" id="KuaishouLiveCreativeListResult">
+        <result property="accountId" column="account_id"/>
+        <result property="campaignId" column="campaign_id"/>
+        <result property="campaignName" column="campaign_name"/>
+        <result property="unitId" column="unit_id"/>
+        <result property="unitName" column="unit_name"/>
+        <result property="creativeId" column="creative_id"/>
+        <result property="creativeName" column="creative_name"/>
+        <result property="creativeCreateTime" column="creative_create_time"/>
+        <result property="reportDate" column="report_date"/>
+        <result property="viewStatus" column="view_status"/>
+        <result property="speed" column="speed"/>
+        <result property="liveCreativeType" column="live_creative_type"/>
+        <result property="creativeSourceTypeStr" column="creative_source_type_str"/>
+    </resultMap>
+
+    <sql id="selectKuaishouLiveCreativeListVo">
+        select account_id,
+               campaign_id,
+               campaign_name,
+               unit_id,
+               unit_name,
+               creative_id,
+               creative_name,
+               creative_create_time,
+               report_date,
+               view_status,
+               speed,
+               live_creative_type,
+               creative_source_type_str
+        from kuaishou_live_creative_list
+    </sql>
+
+    <select id="selectKuaishouLiveCreativeListList" resultMap="KuaishouLiveCreativeListResult">
+        <include refid="selectKuaishouLiveCreativeListVo"/>
+        <where>
+            <if test="campaignId != null ">and campaign_id = #{campaignId}</if>
+            <if test="campaignName != null  and campaignName != ''">and campaign_name like concat('%', #{campaignName},
+                '%')
+            </if>
+            <if test="unitId != null ">and unit_id = #{unitId}</if>
+            <if test="unitName != null  and unitName != ''">and unit_name like concat('%', #{unitName}, '%')</if>
+            <if test="creativeName != null  and creativeName != ''">and creative_name like concat('%', #{creativeName},
+                '%')
+            </if>
+            <if test="creativeCreateTime != null ">and creative_create_time = #{creativeCreateTime}</if>
+            <if test="reportDate != null ">and report_date = #{reportDate}</if>
+            <if test="viewStatus != null ">and view_status = #{viewStatus}</if>
+            <if test="speed != null ">and speed = #{speed}</if>
+            <if test="liveCreativeType != null  and liveCreativeType != ''">and live_creative_type =
+                #{liveCreativeType}
+            </if>
+            <if test="creativeSourceTypeStr != null  and creativeSourceTypeStr != ''">and creative_source_type_str =
+                #{creativeSourceTypeStr}
+            </if>
+        </where>
+    </select>
+
+    <select id="selectKuaishouLiveCreativeListByAccountId" parameterType="Long"
+            resultMap="KuaishouLiveCreativeListResult">
+        <include refid="selectKuaishouLiveCreativeListVo"/>
+        where account_id = #{accountId}
+    </select>
+
+    <insert id="replaceBatch">
+        replace into kuaishou_live_creative_list(
+        account_id,
+        campaign_id,
+        campaign_name,
+        unit_id,
+        unit_name,
+        creative_id,
+        creative_name,
+        creative_create_time,
+        report_date,
+        view_status,
+        speed,
+        live_creative_type,
+        creative_source_type_str
+        )
+        values
+        <foreach collection="list" item="report" separator=",">
+            (
+            #{report.accountId},
+            #{report.campaignId},
+            #{report.campaignName},
+            #{report.unitId},
+            #{report.unitName},
+            #{report.creativeId},
+            #{report.creativeName},
+            #{report.creativeCreateTime},
+            #{report.reportDate},
+            #{report.viewStatus},
+            #{report.speed},
+            #{report.liveCreativeType},
+            #{report.creativeSourceTypeStr}
+            )
+        </foreach>
+    </insert>
+
+</mapper>

+ 125 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/KuaishouLiveUnitListMapper.xml

@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.job.live.mapper.KuaishouLiveUnitListMapper">
+
+    <resultMap type="cn.com.ctop.job.live.entity.KuaishouLiveUnitList" id="KuaishouLiveUnitListResult">
+        <result property="accountId" column="account_id"/>
+        <result property="campaignId" column="campaign_id"/>
+        <result property="campaignName" column="campaign_name"/>
+        <result property="unitId" column="unit_id"/>
+        <result property="unitName" column="unit_name"/>
+        <result property="unitCreateTime" column="unit_create_time"/>
+        <result property="reportDate" column="report_date"/>
+        <result property="viewStatus" column="view_status"/>
+        <result property="dayBudget" column="day_budget"/>
+        <result property="campaignType" column="campaign_type"/>
+        <result property="ocpxActionType" column="ocpx_action_type"/>
+        <result property="bidDetail" column="bid_detail"/>
+        <result property="creativeBuildTypeStr" column="creative_build_type_str"/>
+        <result property="speed" column="speed"/>
+        <result property="exploreTools" column="explore_tools"/>
+        <result property="simultaneousOptimizationType" column="simultaneous_optimization_type"/>
+        <result property="targetExtend" column="target_extend"/>
+    </resultMap>
+
+    <sql id="selectKuaishouLiveUnitListVo">
+        select account_id,
+               campaign_id,
+               campaign_name,
+               unit_id,
+               unit_name,
+               unit_create_time,
+               report_date,
+               view_status,
+               day_budget,
+               campaign_type,
+               ocpx_action_type,
+               bid_detail,
+               creative_build_type_str,
+               speed,
+               explore_tools,
+               simultaneous_optimization_type,
+               target_extend
+        from kuaishou_live_unit_list
+    </sql>
+
+    <select id="selectKuaishouLiveUnitListList" resultMap="KuaishouLiveUnitListResult">
+        <include refid="selectKuaishouLiveUnitListVo"/>
+        <where>
+            <if test="campaignName != null  and campaignName != ''">and campaign_name like concat('%', #{campaignName},
+                '%')
+            </if>
+            <if test="unitName != null  and unitName != ''">and unit_name like concat('%', #{unitName}, '%')</if>
+            <if test="unitCreateTime != null ">and unit_create_time = #{unitCreateTime}</if>
+            <if test="reportDate != null ">and report_date = #{reportDate}</if>
+            <if test="viewStatus != null ">and view_status = #{viewStatus}</if>
+            <if test="dayBudget != null ">and day_budget = #{dayBudget}</if>
+            <if test="campaignType != null  and campaignType != ''">and campaign_type = #{campaignType}</if>
+            <if test="ocpxActionType != null ">and ocpx_action_type = #{ocpxActionType}</if>
+            <if test="bidDetail != null  and bidDetail != ''">and bid_detail = #{bidDetail}</if>
+            <if test="creativeBuildTypeStr != null  and creativeBuildTypeStr != ''">and creative_build_type_str =
+                #{creativeBuildTypeStr}
+            </if>
+            <if test="speed != null ">and speed = #{speed}</if>
+            <if test="exploreTools != null  and exploreTools != ''">and explore_tools = #{exploreTools}</if>
+            <if test="simultaneousOptimizationType != null  and simultaneousOptimizationType != ''">and
+                simultaneous_optimization_type = #{simultaneousOptimizationType}
+            </if>
+            <if test="targetExtend != null  and targetExtend != ''">and target_extend = #{targetExtend}</if>
+        </where>
+    </select>
+
+    <select id="selectKuaishouLiveUnitListByAccountId" parameterType="Long" resultMap="KuaishouLiveUnitListResult">
+        <include refid="selectKuaishouLiveUnitListVo"/>
+        where account_id = #{accountId}
+    </select>
+
+
+    <insert id="replaceBatch">
+        replace into kuaishou_live_unit_list(
+        account_id,
+        campaign_id,
+        campaign_name,
+        unit_id,
+        unit_name,
+        unit_create_time,
+        report_date,
+        view_status,
+        day_budget,
+        campaign_type,
+        ocpx_action_type,
+        bid_detail,
+        creative_build_type_str,
+        speed,
+        explore_tools,
+        simultaneous_optimization_type,
+        target_extend
+
+        )
+        values
+        <foreach collection="list" item="report" separator=",">
+            (
+            #{report.accountId},
+            #{report.campaignId},
+            #{report.campaignName},
+            #{report.unitId},
+            #{report.unitName},
+            #{report.unitCreateTime},
+            #{report.reportDate},
+            #{report.viewStatus},
+            #{report.dayBudget},
+            #{report.campaignType},
+            #{report.ocpxActionType},
+            #{report.bidDetail},
+            #{report.creativeBuildTypeStr},
+            #{report.speed},
+            #{report.exploreTools},
+            #{report.simultaneousOptimizationType},
+            #{report.targetExtend}
+            )
+        </foreach>
+    </insert>
+
+</mapper>

+ 52 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/KuaishouLiveVideoListMapper.xml

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.job.live.mapper.KuaishouLiveVideoListMapper">
+
+    <resultMap type="cn.com.ctop.job.live.entity.KuaishouLiveVideoList" id="KuaishouLiveVideoListResult">
+        <result property="accountId" column="account_id"/>
+        <result property="photoName" column="photo_name"/>
+        <result property="photoId" column="photo_id"/>
+        <result property="photoTag" column="photo_tag"/>
+        <result property="createTime" column="create_time"/>
+        <result property="duration" column="duration"/>
+        <result property="url" column="url"/>
+        <result property="coverUrl" column="cover_url"/>
+        <result property="height" column="height"/>
+        <result property="width" column="width"/>
+    </resultMap>
+
+    <sql id="selectKuaishouLiveVideoListVo">
+        select account_id,
+               photo_name,
+               photo_id,
+               photo_tag,
+               create_time,
+               duration,
+               url,
+               cover_url,
+               height,
+               width
+        from kuaishou_live_video_list
+    </sql>
+
+    <select id="selectKuaishouLiveVideoListList" resultMap="KuaishouLiveVideoListResult">
+        <include refid="selectKuaishouLiveVideoListVo"/>
+        <where>
+            <if test="photoName != null  and photoName != ''">and photo_name like concat('%', #{photoName}, '%')</if>
+            <if test="photoTag != null  and photoTag != ''">and photo_tag = #{photoTag}</if>
+            <if test="duration != null ">and duration = #{duration}</if>
+            <if test="url != null  and url != ''">and url = #{url}</if>
+            <if test="coverUrl != null  and coverUrl != ''">and cover_url = #{coverUrl}</if>
+            <if test="height != null ">and height = #{height}</if>
+            <if test="width != null ">and width = #{width}</if>
+        </where>
+    </select>
+
+    <select id="selectKuaishouLiveVideoListByAccountId" parameterType="Long" resultMap="KuaishouLiveVideoListResult">
+        <include refid="selectKuaishouLiveVideoListVo"/>
+        where account_id = #{accountId}
+    </select>
+
+</mapper>

+ 34 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/IKuaishouLiveCampaignListService.java

@@ -0,0 +1,34 @@
+package cn.com.ctop.job.live.service;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveCampaignList;
+import cn.com.ctop.job.live.utils.Result;
+
+import java.util.List;
+
+/**
+ * 广告计划Service接口
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+public interface IKuaishouLiveCampaignListService {
+
+    /**
+     * 查询广告计划
+     *
+     * @param accountId 广告计划主键
+     * @return 广告计划
+     */
+    public KuaishouLiveCampaignList selectKuaishouLiveCampaignListByAccountId(Long accountId);
+
+    /**
+     * 查询广告计划列表
+     *
+     * @param kuaishouLiveCampaignList 广告计划
+     * @return 广告计划集合
+     */
+    public List<KuaishouLiveCampaignList> selectKuaishouLiveCampaignListList(KuaishouLiveCampaignList kuaishouLiveCampaignList);
+
+
+    public Result<Object> getKuaishouCampaign(Long accountId, String token);
+}

+ 32 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/IKuaishouLiveCreativeListService.java

@@ -0,0 +1,32 @@
+package cn.com.ctop.job.live.service;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveCreativeList;
+import cn.com.ctop.job.live.utils.Result;
+
+import java.util.List;
+
+/**
+ * 创意Service接口
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+public interface IKuaishouLiveCreativeListService {
+    /**
+     * 查询创意
+     *
+     * @param accountId 创意主键
+     * @return 创意
+     */
+    public KuaishouLiveCreativeList selectKuaishouLiveCreativeListByAccountId(Long accountId);
+
+    /**
+     * 查询创意列表
+     *
+     * @param kuaishouLiveCreativeList 创意
+     * @return 创意集合
+     */
+    public List<KuaishouLiveCreativeList> selectKuaishouLiveCreativeListList(KuaishouLiveCreativeList kuaishouLiveCreativeList);
+
+    public Result<Object> getKuaishouCreative(Long accountId, String token);
+}

+ 33 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/IKuaishouLiveUnitListService.java

@@ -0,0 +1,33 @@
+package cn.com.ctop.job.live.service;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveUnitList;
+import cn.com.ctop.job.live.utils.Result;
+
+import java.util.List;
+
+/**
+ * 广告组Service接口
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+public interface IKuaishouLiveUnitListService {
+    /**
+     * 查询广告组
+     *
+     * @param accountId 广告组主键
+     * @return 广告组
+     */
+    public KuaishouLiveUnitList selectKuaishouLiveUnitListByAccountId(Long accountId);
+
+    /**
+     * 查询广告组列表
+     *
+     * @param kuaishouLiveUnitList 广告组
+     * @return 广告组集合
+     */
+    public List<KuaishouLiveUnitList> selectKuaishouLiveUnitListList(KuaishouLiveUnitList kuaishouLiveUnitList);
+
+
+    public Result<Object> getKuaishouUnit(Long accountId, String token);
+}

+ 30 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/IKuaishouLiveVideoListService.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.job.live.service;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveVideoList;
+
+import java.util.List;
+
+/**
+ * 素材Service接口
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+public interface IKuaishouLiveVideoListService {
+    /**
+     * 查询素材
+     *
+     * @param accountId 素材主键
+     * @return 素材
+     */
+    public KuaishouLiveVideoList selectKuaishouLiveVideoListByAccountId(Long accountId);
+
+    /**
+     * 查询素材列表
+     *
+     * @param kuaishouLiveVideoList 素材
+     * @return 素材集合
+     */
+    public List<KuaishouLiveVideoList> selectKuaishouLiveVideoListList(KuaishouLiveVideoList kuaishouLiveVideoList);
+
+}

+ 93 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/impl/KuaishouLiveCampaignListServiceImpl.java

@@ -0,0 +1,93 @@
+package cn.com.ctop.job.live.service.impl;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveCampaignList;
+import cn.com.ctop.job.live.mapper.KuaishouLiveCampaignListMapper;
+import cn.com.ctop.job.live.service.IKuaishouLiveCampaignListService;
+import cn.com.ctop.job.live.utils.APIUtil;
+import cn.com.ctop.job.live.utils.Check;
+import cn.com.ctop.job.live.utils.DateUtils;
+import cn.com.ctop.job.live.utils.KuaishouAPIConstant;
+import cn.com.ctop.job.live.utils.Result;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 广告计划Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+@Slf4j
+@Service
+public class KuaishouLiveCampaignListServiceImpl implements IKuaishouLiveCampaignListService {
+    @Autowired
+    private KuaishouLiveCampaignListMapper mapper;
+
+    /**
+     * 查询广告计划
+     *
+     * @param accountId 广告计划主键
+     * @return 广告计划
+     */
+    @Override
+    public KuaishouLiveCampaignList selectKuaishouLiveCampaignListByAccountId(Long accountId) {
+        return mapper.selectKuaishouLiveCampaignListByAccountId(accountId);
+    }
+
+    /**
+     * 查询广告计划列表
+     *
+     * @param kuaishouLiveCampaignList 广告计划
+     * @return 广告计划
+     */
+    @Override
+    public List<KuaishouLiveCampaignList> selectKuaishouLiveCampaignListList(KuaishouLiveCampaignList kuaishouLiveCampaignList) {
+        return mapper.selectKuaishouLiveCampaignListList(kuaishouLiveCampaignList);
+    }
+
+
+    @Override
+    public Result<Object> getKuaishouCampaign(Long accountId, String token) {
+        log.info("调用接口---getKuaishouAccountReport(获取直播账户报表)---账户:{}", accountId);
+        Result<Object> result = new Result<>();
+        Map<String, Object> param = new HashMap<String, Object>();
+        param.put("advertiser_id", accountId);
+        JSONObject params = new JSONObject();
+        params.put("start_time", DateUtils.timeToStamp(DateUtils.getDate() + " 00:00:00"));
+        params.put("end_time", DateUtils.timeToStamp(DateUtils.getDate() + " 23:23:59"));
+        params.put("search_level", 1);
+        JSONObject pageInfo = new JSONObject();
+        pageInfo.put("page", 1);
+        pageInfo.put("page_size", 2000);
+        param.put("page_info", pageInfo);
+        param.put("param", params);
+        JSONObject apiResult = APIUtil.getApiResult(KuaishouAPIConstant.AD_SEARCH, token, param);
+        if (apiResult.getInteger("code") == 0) {
+            apiResult = apiResult.getJSONObject("data");
+            JSONArray data = apiResult.getJSONArray("data");
+            List<KuaishouLiveCampaignList> list = new ArrayList<>();
+            for (int i = 0; i < data.size(); i++) {
+                JSONObject object = data.getJSONObject(i);
+                KuaishouLiveCampaignList accountReport = JSONObject.parseObject(object.toJSONString(), KuaishouLiveCampaignList.class);
+                accountReport.setAccountId(accountId);
+                accountReport.setReportDate(Long.valueOf(object.getString("report_date").replace("-", "")));
+                accountReport.setCampaignCreateTime(Long.valueOf(DateUtils.timestampToStr(object.getLong("campaign_create_time"))));
+                list.add(accountReport);
+            }
+            if (!Check.isNull(list)) {
+                mapper.replaceBatch(list);
+            }
+        } else {
+            log.error("获取直播账户报表,账户{},{}", accountId, apiResult.toJSONString());
+        }
+        return result.success("success");
+    }
+}

+ 93 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/impl/KuaishouLiveCreativeListServiceImpl.java

@@ -0,0 +1,93 @@
+package cn.com.ctop.job.live.service.impl;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveCreativeList;
+import cn.com.ctop.job.live.entity.KuaishouLiveUnitList;
+import cn.com.ctop.job.live.mapper.KuaishouLiveCreativeListMapper;
+import cn.com.ctop.job.live.service.IKuaishouLiveCreativeListService;
+import cn.com.ctop.job.live.utils.APIUtil;
+import cn.com.ctop.job.live.utils.Check;
+import cn.com.ctop.job.live.utils.DateUtils;
+import cn.com.ctop.job.live.utils.KuaishouAPIConstant;
+import cn.com.ctop.job.live.utils.Result;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 创意Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+@Slf4j
+@Service
+public class KuaishouLiveCreativeListServiceImpl implements IKuaishouLiveCreativeListService {
+    @Autowired
+    private KuaishouLiveCreativeListMapper mapper;
+
+    /**
+     * 查询创意
+     *
+     * @param accountId 创意主键
+     * @return 创意
+     */
+    @Override
+    public KuaishouLiveCreativeList selectKuaishouLiveCreativeListByAccountId(Long accountId) {
+        return mapper.selectKuaishouLiveCreativeListByAccountId(accountId);
+    }
+
+    /**
+     * 查询创意列表
+     *
+     * @param kuaishouLiveCreativeList 创意
+     * @return 创意
+     */
+    @Override
+    public List<KuaishouLiveCreativeList> selectKuaishouLiveCreativeListList(KuaishouLiveCreativeList kuaishouLiveCreativeList) {
+        return mapper.selectKuaishouLiveCreativeListList(kuaishouLiveCreativeList);
+    }
+
+    @Override
+    public Result<Object> getKuaishouCreative(Long accountId, String token) {
+        log.info("调用接口---getKuaishouAccountReport(获取直播账户报表)---账户:{}", accountId);
+        Result<Object> result = new Result<>();
+        Map<String, Object> param = new HashMap<String, Object>();
+        param.put("advertiser_id", accountId);
+        JSONObject params = new JSONObject();
+        params.put("start_time", DateUtils.timeToStamp(DateUtils.getDate() + " 00:00:00"));
+        params.put("end_time", DateUtils.timeToStamp(DateUtils.getDate() + " 23:23:59"));
+        params.put("search_level", 3);
+        JSONObject pageInfo = new JSONObject();
+        pageInfo.put("page", 1);
+        pageInfo.put("page_size", 2000);
+        param.put("page_info", pageInfo);
+        param.put("param", params);
+        JSONObject apiResult = APIUtil.getApiResult(KuaishouAPIConstant.AD_SEARCH, token, param);
+        if (apiResult.getInteger("code") == 0) {
+            apiResult = apiResult.getJSONObject("data");
+            JSONArray data = apiResult.getJSONArray("data");
+            List<KuaishouLiveCreativeList> list = new ArrayList<>();
+            for (int i = 0; i < data.size(); i++) {
+                JSONObject object = data.getJSONObject(i);
+                KuaishouLiveCreativeList accountReport = JSONObject.parseObject(object.toJSONString(), KuaishouLiveCreativeList.class);
+                accountReport.setAccountId(accountId);
+                accountReport.setReportDate(Long.valueOf(object.getString("report_date").replace("-", "")));
+                accountReport.setCreativeCreateTime(Long.valueOf(DateUtils.timestampToStr(object.getLong("creative_create_time"))));
+                list.add(accountReport);
+            }
+            if (!Check.isNull(list)) {
+                mapper.replaceBatch(list);
+            }
+        } else {
+            log.error("获取直播账户报表,账户{},{}", accountId, apiResult.toJSONString());
+        }
+        return result.success("success");
+    }
+}

+ 94 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/impl/KuaishouLiveUnitListServiceImpl.java

@@ -0,0 +1,94 @@
+package cn.com.ctop.job.live.service.impl;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveUnitList;
+import cn.com.ctop.job.live.mapper.KuaishouLiveUnitListMapper;
+import cn.com.ctop.job.live.service.IKuaishouLiveUnitListService;
+import cn.com.ctop.job.live.utils.APIUtil;
+import cn.com.ctop.job.live.utils.Check;
+import cn.com.ctop.job.live.utils.DateUtils;
+import cn.com.ctop.job.live.utils.KuaishouAPIConstant;
+import cn.com.ctop.job.live.utils.Result;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 广告组Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+@Slf4j
+@Service
+public class KuaishouLiveUnitListServiceImpl implements IKuaishouLiveUnitListService {
+    @Autowired
+    private KuaishouLiveUnitListMapper mapper;
+
+    /**
+     * 查询广告组
+     *
+     * @param accountId 广告组主键
+     * @return 广告组
+     */
+    @Override
+    public KuaishouLiveUnitList selectKuaishouLiveUnitListByAccountId(Long accountId) {
+        return mapper.selectKuaishouLiveUnitListByAccountId(accountId);
+    }
+
+    /**
+     * 查询广告组列表
+     *
+     * @param kuaishouLiveUnitList 广告组
+     * @return 广告组
+     */
+    @Override
+    public List<KuaishouLiveUnitList> selectKuaishouLiveUnitListList(KuaishouLiveUnitList kuaishouLiveUnitList) {
+        return mapper.selectKuaishouLiveUnitListList(kuaishouLiveUnitList);
+    }
+
+
+    @Override
+    public Result<Object> getKuaishouUnit(Long accountId, String token) {
+        log.info("调用接口---getKuaishouAccountReport(获取直播账户报表)---账户:{}", accountId);
+        Result<Object> result = new Result<>();
+        Map<String, Object> param = new HashMap<String, Object>();
+        param.put("advertiser_id", accountId);
+        JSONObject params = new JSONObject();
+        params.put("start_time", DateUtils.timeToStamp(DateUtils.getDate() + " 00:00:00"));
+        params.put("end_time", DateUtils.timeToStamp(DateUtils.getDate() + " 23:23:59"));
+        params.put("search_level", 2);
+        JSONObject pageInfo = new JSONObject();
+        pageInfo.put("page", 1);
+        pageInfo.put("page_size", 2000);
+        param.put("page_info", pageInfo);
+        param.put("param", params);
+        JSONObject apiResult = APIUtil.getApiResult(KuaishouAPIConstant.AD_SEARCH, token, param);
+        if (apiResult.getInteger("code") == 0) {
+            apiResult = apiResult.getJSONObject("data");
+            JSONArray data = apiResult.getJSONArray("data");
+            List<KuaishouLiveUnitList> list = new ArrayList<>();
+            for (int i = 0; i < data.size(); i++) {
+                JSONObject object = data.getJSONObject(i);
+                KuaishouLiveUnitList accountReport = JSONObject.parseObject(object.toJSONString(), KuaishouLiveUnitList.class);
+                accountReport.setAccountId(accountId);
+                accountReport.setReportDate(Long.valueOf(object.getString("report_date").replace("-", "")));
+                accountReport.setUnitCreateTime(Long.valueOf(DateUtils.timestampToStr(object.getLong("unit_create_time"))));
+                list.add(accountReport);
+            }
+            if (!Check.isNull(list)) {
+                mapper.replaceBatch(list);
+            }
+        } else {
+            log.error("获取直播账户报表,账户{},{}", accountId, apiResult.toJSONString());
+        }
+        return result.success("success");
+    }
+
+}

+ 47 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/impl/KuaishouLiveVideoListServiceImpl.java

@@ -0,0 +1,47 @@
+package cn.com.ctop.job.live.service.impl;
+
+import cn.com.ctop.job.live.entity.KuaishouLiveVideoList;
+import cn.com.ctop.job.live.mapper.KuaishouLiveVideoListMapper;
+import cn.com.ctop.job.live.service.IKuaishouLiveVideoListService;
+import cn.com.ctop.job.live.utils.DateUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 素材Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-07-28
+ */
+@Slf4j
+@Service
+public class KuaishouLiveVideoListServiceImpl implements IKuaishouLiveVideoListService {
+    @Autowired
+    private KuaishouLiveVideoListMapper kuaishouLiveVideoListMapper;
+
+    /**
+     * 查询素材
+     *
+     * @param accountId 素材主键
+     * @return 素材
+     */
+    @Override
+    public KuaishouLiveVideoList selectKuaishouLiveVideoListByAccountId(Long accountId) {
+        return kuaishouLiveVideoListMapper.selectKuaishouLiveVideoListByAccountId(accountId);
+    }
+
+    /**
+     * 查询素材列表
+     *
+     * @param kuaishouLiveVideoList 素材
+     * @return 素材
+     */
+    @Override
+    public List<KuaishouLiveVideoList> selectKuaishouLiveVideoListList(KuaishouLiveVideoList kuaishouLiveVideoList) {
+        return kuaishouLiveVideoListMapper.selectKuaishouLiveVideoListList(kuaishouLiveVideoList);
+    }
+
+}

+ 0 - 7
job-live/src/main/java/cn/com/ctop/job/live/utils/DateUtils.java

@@ -233,13 +233,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return cal.getTime();
     }
 
-    public static void main(String[] args) {
-        //System.out.println(parseDateToStr(YYYY_MM_DD,getBeginDayOfWeek()));
-        // System.out.println(parseDateToStr(YYYY_MM_DD,getEendDayOfWeek()));
-
-        System.out.println(strDateToInt("2022-05"));
-    }
-
     /**
      * 指定模式的时间格式
      */

+ 4 - 0
job-live/src/main/java/cn/com/ctop/job/live/utils/KuaishouAPIConstant.java

@@ -9,6 +9,10 @@ public class KuaishouAPIConstant {
      * 报表查询
      */
     public static final String REPORT_LIST = "/rest/openapi/gw/esp/v1/report/list";
+    /**
+     * 报表查询
+     */
+    public static final String AD_SEARCH  = "/rest/openapi/gw/esp/v1/report/ad/search";
 
 
 }