Kaynağa Gözat

V1.1.1 自动投放 历史top素材查询接口

yumeng 4 yıl önce
ebeveyn
işleme
6fe14beb6a

+ 69 - 23
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java

@@ -104,9 +104,14 @@ public class KuaiShouMaterialControer {
     }
 
 
+    /**
+     * 历史素材
+     *
+     * @param requestJson
+     * @return
+     */
     @PostMapping(value = "/getHistoryVideoList")
     public JSONObject getHistoryVideoList(@RequestBody JSONObject requestJson) {
-        System.err.println(requestJson);
         JSONObject returnJson = new JSONObject();
         try {
             if (Check.isNull(requestJson)) {
@@ -116,8 +121,6 @@ public class KuaiShouMaterialControer {
             if (Check.isNull(accountId)) {
                 throw new Exception("账户id不能为空");
             }
-
-
             String startDate = requestJson.getString("startDate");
             if (Check.isNull(startDate)) {
                 throw new Exception("请输入开始查询时间");
@@ -127,17 +130,14 @@ public class KuaiShouMaterialControer {
             if (Check.isNull(endDate)) {
                 throw new Exception("请输入结束查询时间");
             }
-
             Integer createCount = requestJson.getInteger("createCount");
             if (Check.isNull(createCount) || createCount == 0) {
                 throw new Exception("请输入最小关联数");
             }
-
             Integer num = requestJson.getInteger("num");
             if (Check.isNull(num) || num == 0) {
                 throw new Exception("请输入查询条数");
             }
-
             Map<String, Object> requestMap = new HashMap<>();
             requestMap.put("startTime", startDate);
             requestMap.put("endTime", endDate);
@@ -174,6 +174,12 @@ public class KuaiShouMaterialControer {
     }
 
 
+    /**
+     * 历史Top素材
+     *
+     * @param requestJson
+     * @return
+     */
     @PostMapping(value = "/getHistoryTopVideoList")
     public JSONObject getHistoryTopVideoList(@RequestBody JSONObject requestJson) {
         JSONObject returnJson = new JSONObject();
@@ -185,35 +191,75 @@ public class KuaiShouMaterialControer {
             if (Check.isNull(accountId)) {
                 throw new Exception("账户id不能为空");
             }
-
-
-            String startDate = requestJson.getString("startDate");
+            String startDate = requestJson.getString("startTime");
             if (Check.isNull(startDate)) {
                 throw new Exception("请输入开始查询时间");
             }
-
-            String endDate = requestJson.getString("endDate");
+            String endDate = requestJson.getString("endTime");
             if (Check.isNull(endDate)) {
                 throw new Exception("请输入结束查询时间");
             }
-
-            Integer createCount = requestJson.getInteger("createCount");
-            if (Check.isNull(createCount) || createCount == 0) {
-                throw new Exception("请输入最小关联数");
-            }
-
             Integer num = requestJson.getInteger("num");
             if (Check.isNull(num) || num == 0) {
                 throw new Exception("请输入查询条数");
             }
-
             Map<String, Object> requestMap = new HashMap<>();
-            requestMap.put("startTime", startDate);
-            requestMap.put("endTime", endDate);
+            requestMap.put("startDate", startDate);
+            requestMap.put("endDate", endDate);
             requestMap.put("accountId", accountId);
             requestMap.put("num", num);
-            requestMap.put("createCount", createCount);
-            List<JSONObject> materialList = relateCreativesService.getVideoListByMap(requestMap);
+            List<JSONObject> materialList = relateCreativesService.getHistoryTopVideoList(requestMap);
+            if (!Check.isNull(materialList)) {
+                for (int i = 0; i < materialList.size(); i++) {
+                    JSONObject materialJson = materialList.get(i);
+                    String signature = materialJson.getString("signature");
+                    List<String> imageList = lastTimeService.getImageListByMd5(signature);
+                    materialJson.put("imageList", imageList);
+
+                }
+                returnJson.put("code", 0);
+                returnJson.put("message", "SUCCESS");
+                returnJson.put("data", materialList);
+            } else {
+                returnJson.put("code", -1);
+                returnJson.put("message", "暂未历史爆量素材");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    /**
+     * 关联创意数为0素材
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/getCreateZeroVideoList")
+    public JSONObject getHistoryCreateVideoList(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("入参不能为空");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+
+            Integer videoCnt = requestJson.getInteger("videoCnt");
+            if (Check.isNull(videoCnt)) {
+                throw new Exception("请输入查询条数");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("accountId", accountId);
+            requestMap.put("creativeCount", 0);
+            requestMap.put("videoCnt", videoCnt);
+            List<JSONObject> materialList = relateCreativesService.getVideoZeroListByMap(requestMap);
             if (!Check.isNull(materialList)) {
                 for (int i = 0; i < materialList.size(); i++) {
                     JSONObject materialJson = materialList.get(i);
@@ -232,7 +278,7 @@ public class KuaiShouMaterialControer {
                 returnJson.put("data", materialList);
             } else {
                 returnJson.put("code", -1);
-                returnJson.put("message", "暂未新上素材");
+                returnJson.put("message", "暂未关联创意数为0素材");
             }
         } catch (Exception e) {
             e.printStackTrace();

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouVideoRelateCreativesMapper.java

@@ -20,4 +20,8 @@ public interface KuaishouVideoRelateCreativesMapper extends BaseMapper<KuaishouV
     void insertBatch(@Param(value = "videolist") List<KuaishouVideoRelateCreatives> videolist);
 
     List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
+
+    List<JSONObject> getVideoZeroListByMap(Map<String, Object> requestMap);
+
+    List<JSONObject> getHistoryTopVideoList(Map<String, Object> requestMap);
 }

+ 55 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouVideoRelateCreativesMapper.xml

@@ -49,4 +49,59 @@
         </if>
         ORDER BY t1.id ASC LIMIT #{num}
     </select>
+
+    <select id="getVideoZeroListByMap" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        photo_id as 'photo_id',
+        stat_date as 'stat_date',
+        creative_count as 'creative_count'
+        FROM ctop_kuaishou_video_relate_creatives
+        where 1 = 1
+        <if test="accountId != null and accountId != '' ">
+            and account_id = #{accountId}
+        </if>
+        <if test="creativeCount != null and creativeCount != '' ">
+            AND creative_count = #{creativeCount}
+        </if>
+        ORDER BY stat_date ASC
+        LIMIT #{videoCnt}
+    </select>
+
+    <select id="getHistoryTopVideoList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t2.photo_id,
+        t2.signature,
+        t1.charge,
+        t2.channel_type,
+        t2.url as 'video_url'
+        FROM
+        (
+        SELECT
+        sum(charge) as 'charge',
+        signature
+        FROM
+        ctop_kuaishou_report_daily_material
+        WHERE
+        signature IN (
+        SELECT DISTINCT
+        (signature)
+        FROM
+        ctop_kuaishou_video_get
+        WHERE
+        account_id = #{accountId}
+        and stat_date &gt;= #{startDate}
+        and stat_date &lt;= #{endDate}
+        and signature is  not  null
+        )
+        GROUP BY
+        signature
+        ORDER BY
+        sum(charge) DESC
+        LIMIT #{num}
+        ) t1
+        LEFT   JOIN ctop_kuaishou_video_get t2 ON t1.signature = t2.signature
+        AND t2.account_id = #{accountId}
+        GROUP BY t2.signature
+        ORDER BY t1.charge DESC
+    </select>
 </mapper>

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouVideoRelateCreativesService.java

@@ -22,4 +22,8 @@ public interface IKuaishouVideoRelateCreativesService extends IService<KuaishouV
     void videoRelateCreatives(Long accountId, JSONArray photoIds, Map<String, Object> statdateMap);
 
     List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
+
+    List<JSONObject> getVideoZeroListByMap(Map<String, Object> requestMap);
+
+    List<JSONObject> getHistoryTopVideoList(Map<String, Object> requestMap);
 }

+ 11 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouVideoRelateCreativesServiceImpl.java

@@ -17,11 +17,7 @@ import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 频库-视频关联创意数查询
@@ -145,4 +141,14 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
     public List<JSONObject> getVideoListByMap(Map<String, Object> requestMap) {
         return kuaishouVideoRelateCreativesMapper.getVideoListByMap(requestMap);
     }
+
+    @Override
+    public List<JSONObject> getVideoZeroListByMap(Map<String, Object> requestMap) {
+        return kuaishouVideoRelateCreativesMapper.getVideoZeroListByMap(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getHistoryTopVideoList(Map<String, Object> requestMap) {
+        return kuaishouVideoRelateCreativesMapper.getHistoryTopVideoList(requestMap);
+    }
 }