瀏覽代碼

骄阳topItem

yumeng 1 年之前
父節點
當前提交
e1d83de138

+ 10 - 49
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -168,59 +168,20 @@ public class TestController {
     @GetMapping(value = "/getData")
     @GetMapping(value = "/getData")
     public void getDate(String startDate, String endDate) throws Exception {
     public void getDate(String startDate, String endDate) throws Exception {
 
 
-        List<JSONObject> cookies = jiaoYangFenXiaoService.getCookie();
-        if (Check.isNull(cookies)) {
+        String cookie = jiaoYangFenXiaoService.getCookieById(341063986L);
+        if (Check.isNull(cookie)) {
             log.error("cookie数据为空");
             log.error("cookie数据为空");
             return;
             return;
         }
         }
-        String date = DateUtils.getNowDate("yyyy-MM-dd");
-        Long statDate = Long.valueOf(date.replace("-", ""));
-
-        List<Integer>  statusList = new ArrayList();
-        statusList.add(1);
-        statusList.add(2);
-        statusList.add(3);
-
-
-
-        for (int p = 0; p < cookies.size(); p++) {
-            JSONObject cookieJson = cookies.get(p);
-            String cookie = cookieJson.getString("cookie");
-            for (int i = 0; i < statusList.size(); i++) {
-                Integer status = statusList.get(i);
-                jiaoYangFenXiaoService.getClipCooperation(cookie, 0, statDate,status);
-            }
-
-        }
-
-      /*  List<JSONObject> cookies = jiaoYangFenXiaoService.getCookie();
-        if (Check.isNull(cookies)) {
-            log.error("cookie数据为空");
-            return;
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        Long statDate = Long.valueOf(nowDate.replace("-", ""));
+        List<JSONObject> accountList = jiaoYangFenXiaoService.getAccountList();
+        for (int i = 0; i < accountList.size(); i++) {
+            JSONObject jsonObject = accountList.get(i);
+            Long id = jsonObject.getLong("id");
+            String name = jsonObject.getString("name");
+            jiaoYangFenXiaoService.getItemTop(cookie,statDate, id, name, 0);
         }
         }
-        String date = DateUtils.getNowDate("yyyy-MM-dd");
-        JSONArray hourList = KuaishouHourEnum.getHourList();
-        JSONArray minSecList = KuaishouMinSecEnum.getMinSecList();
-        for (int i = 0; i < hourList.size(); i++) {
-            String hour = hourList.getString(i);
-            for (int j = 0; j < minSecList.size(); j++) {
-                JSONObject minSecJson = minSecList.getJSONObject(j);
-                String startTime = minSecJson.getString("startTime");
-                String endTime = minSecJson.getString("endTime");
-                String start = date + hour + startTime;
-                String end = date + hour + endTime;
-                System.err.println("开始时间:" + start);
-                System.err.println("结束时间:" + end);
-                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                Long orderCreateTimeStart = sdf.parse(start).getTime();
-                Long orderCreateTimeEnd = sdf.parse(end).getTime();
-                for (int p = 0; p < cookies.size(); p++) {
-                    JSONObject cookieJson = cookies.get(p);
-                    String cookie = cookieJson.getString("cookie");
-                    jiaoYangFenXiaoService.getOrderList(cookie, 0, orderCreateTimeStart, orderCreateTimeEnd);
-                }
-            }
-        }*/
     }
     }
 
 
 
 

+ 24 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/JiaoYangFenXiaoJob.java

@@ -32,6 +32,30 @@ public class JiaoYangFenXiaoJob {
      *
      *
      * @throws Exception
      * @throws Exception
      */
      */
+    @XxlJob("jyTopItem")
+    public void jyTopItem() throws Exception {
+        String cookie = jiaoYangFenXiaoService.getCookieById(341063986L);
+        if (Check.isNull(cookie)) {
+            log.error("cookie数据为空");
+            return;
+        }
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        Long statDate = Long.valueOf(nowDate.replace("-", ""));
+        List<JSONObject> accountList = jiaoYangFenXiaoService.getAccountList();
+        for (int i = 0; i < accountList.size(); i++) {
+            JSONObject jsonObject = accountList.get(i);
+            Long id = jsonObject.getLong("id");
+            String name = jsonObject.getString("name");
+            jiaoYangFenXiaoService.getItemTop(cookie,statDate, id, name, 0);
+        }
+    }
+
+
+    /**
+     * 获取二创信息
+     *
+     * @throws Exception
+     */
     @XxlJob("jyClipCooperation")
     @XxlJob("jyClipCooperation")
     public void jyClipCooperation() throws Exception {
     public void jyClipCooperation() throws Exception {
 
 
@@ -62,7 +86,6 @@ public class JiaoYangFenXiaoJob {
     }
     }
 
 
 
 
-
     /**
     /**
      * 当前小时数据获取
      * 当前小时数据获取
      **/
      **/
@@ -107,7 +130,6 @@ public class JiaoYangFenXiaoJob {
     }
     }
 
 
 
 
-
     /**
     /**
      * 当天前前小时数据获取
      * 当天前前小时数据获取
      **/
      **/

+ 116 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/JyClipTopList.java

@@ -0,0 +1,116 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+public class JyClipTopList {
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+    private Long clipId;
+    private String clipName;
+    private Long itemId;
+    private String itemName;
+    private String itemImgUrl;
+    private String itemPrice;
+    private Long promotionVolume;
+    private Long promotionPromoterCount;
+    private Long statDate;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getClipId() {
+        return clipId;
+    }
+
+    public void setClipId(Long clipId) {
+        this.clipId = clipId;
+    }
+
+    public String getClipName() {
+        return clipName;
+    }
+
+    public void setClipName(String clipName) {
+        this.clipName = clipName;
+    }
+
+    public Long getItemId() {
+        return itemId;
+    }
+
+    public void setItemId(Long itemId) {
+        this.itemId = itemId;
+    }
+
+    public String getItemName() {
+        return itemName;
+    }
+
+    public void setItemName(String itemName) {
+        this.itemName = itemName;
+    }
+
+    public String getItemImgUrl() {
+        return itemImgUrl;
+    }
+
+    public void setItemImgUrl(String itemImgUrl) {
+        this.itemImgUrl = itemImgUrl;
+    }
+
+    public String getItemPrice() {
+        return itemPrice;
+    }
+
+    public void setItemPrice(String itemPrice) {
+        this.itemPrice = itemPrice;
+    }
+
+    public Long getPromotionVolume() {
+        return promotionVolume;
+    }
+
+    public void setPromotionVolume(Long promotionVolume) {
+        this.promotionVolume = promotionVolume;
+    }
+
+    public Long getPromotionPromoterCount() {
+        return promotionPromoterCount;
+    }
+
+    public void setPromotionPromoterCount(Long promotionPromoterCount) {
+        this.promotionPromoterCount = promotionPromoterCount;
+    }
+
+    public Long getStatDate() {
+        return statDate;
+    }
+
+    public void setStatDate(Long statDate) {
+        this.statDate = statDate;
+    }
+
+    @Override
+    public String toString() {
+        return "JyClipTopList{" +
+                "id=" + id +
+                ", clipId=" + clipId +
+                ", clipName='" + clipName + '\'' +
+                ", itemId=" + itemId +
+                ", itemName='" + itemName + '\'' +
+                ", itemImgUrl='" + itemImgUrl + '\'' +
+                ", itemPrice='" + itemPrice + '\'' +
+                ", promotionVolume=" + promotionVolume +
+                ", promotionPromoterCount=" + promotionPromoterCount +
+                ", statDate=" + statDate +
+                '}';
+    }
+}

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

@@ -1,7 +1,9 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 
 import cn.com.ctop.kuaishou.modules.batch.entity.JyClipCooperation;
 import cn.com.ctop.kuaishou.modules.batch.entity.JyClipCooperation;
+import cn.com.ctop.kuaishou.modules.batch.entity.JyClipTopList;
 import cn.com.ctop.kuaishou.modules.batch.entity.JyOrderList;
 import cn.com.ctop.kuaishou.modules.batch.entity.JyOrderList;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
@@ -13,4 +15,10 @@ public interface JiaoYangFenXiaoMapper {
     void replace(@Param("adds") List<JyOrderList> adds);
     void replace(@Param("adds") List<JyOrderList> adds);
 
 
     void replaceClipCooperation(@Param("adds") List<JyClipCooperation> adds);
     void replaceClipCooperation(@Param("adds") List<JyClipCooperation> adds);
+
+    String getCookieById(@Param("id") Long id);
+
+    List<JSONObject> getAccountList();
+
+    void replaceTopItem(@Param("adds") List<JyClipTopList>  adds);
 }
 }

+ 53 - 19
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/JiaoYangFenXiaoMapper.xml

@@ -96,30 +96,58 @@
         )
         )
         values
         values
         <foreach collection="adds" item="add" separator=",">
         <foreach collection="adds" item="add" separator=",">
-        (
-        #{add.clipId},
-        #{add.clipName},
-        #{add.headImg},
-        #{add.commissionRate},
-        #{add.fansNum},
-        #{add.gmv30d},
-        #{add.startTime},
-        #{add.endTime},
-        #{add.status},
-        #{add.terminationReason},
-        #{add.commissionRateView},
-        #{add.shopScore},
-        #{add.clipGmv30d},
-        #{add.authItemGmv30d},
-        #{add.videoCount},
-        #{add.videoShow},
-        #{add.statDate}
+            (
+            #{add.clipId},
+            #{add.clipName},
+            #{add.headImg},
+            #{add.commissionRate},
+            #{add.fansNum},
+            #{add.gmv30d},
+            #{add.startTime},
+            #{add.endTime},
+            #{add.status},
+            #{add.terminationReason},
+            #{add.commissionRateView},
+            #{add.shopScore},
+            #{add.clipGmv30d},
+            #{add.authItemGmv30d},
+            #{add.videoCount},
+            #{add.videoShow},
+            #{add.statDate}
 
 
-        )
+            )
         </foreach>
         </foreach>
 
 
 
 
     </insert>
     </insert>
+    <insert id="replaceTopItem">
+        replace into ruixuan.jy_clip_top_list(
+        clip_id,
+        clip_name,
+        item_id,
+        item_name,
+        item_price,
+        promotion_volume,
+        promotion_promoter_count,
+        item_img_url,
+        stat_date
+        )
+        values
+        <foreach collection="adds" item="add" separator=",">
+            (
+            #{add.clipId},
+            #{add.clipName},
+            #{add.itemId},
+            #{add.itemName},
+            #{add.itemPrice},
+            #{add.promotionVolume},
+            #{add.promotionPromoterCount},
+            #{add.itemImgUrl},
+            #{add.statDate}
+            )
+        </foreach>
+
+    </insert>
 
 
 
 
     <select id="getCookie" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getCookie" resultType="com.alibaba.fastjson.JSONObject">
@@ -127,4 +155,10 @@
 
 
 
 
     </select>
     </select>
+    <select id="getCookieById" resultType="java.lang.String" parameterType="java.lang.Long">
+        select  cookie as 'cookie' from ruixuan.jy_fx_cookie where id = #{id}
+    </select>
+    <select id="getAccountList" resultType="com.alibaba.fastjson.JSONObject">
+        select id as 'id', name as 'name'  from ruixuan.jy_fx_top_item_config
+    </select>
 </mapper>
 </mapper>

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

@@ -10,4 +10,10 @@ public interface IJiaoYangFenXiaoService {
     void getOrderList(String cookie, Integer offset, Long orderCreateTimeStart, Long orderCreateTimeEnd) throws Exception;
     void getOrderList(String cookie, Integer offset, Long orderCreateTimeStart, Long orderCreateTimeEnd) throws Exception;
 
 
     void getClipCooperation(String cookie, Integer offset, Long statDate,Integer status) throws Exception;
     void getClipCooperation(String cookie, Integer offset, Long statDate,Integer status) throws Exception;
+
+    String getCookieById(Long  id);
+
+    List<JSONObject> getAccountList();
+
+    void getItemTop(String cookie,Long statDate, Long id, String name, Integer offset);
 }
 }

+ 56 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/JiaoYangFenXiaoServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.kuaishou.modules.batch.entity.JyClipCooperation;
 import cn.com.ctop.kuaishou.modules.batch.entity.JyClipCooperation;
+import cn.com.ctop.kuaishou.modules.batch.entity.JyClipTopList;
 import cn.com.ctop.kuaishou.modules.batch.entity.JyOrderList;
 import cn.com.ctop.kuaishou.modules.batch.entity.JyOrderList;
 
 
 import cn.com.ctop.kuaishou.modules.batch.mapper.JiaoYangFenXiaoMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.JiaoYangFenXiaoMapper;
@@ -179,7 +180,7 @@ public class JiaoYangFenXiaoServiceImpl implements IJiaoYangFenXiaoService {
             clipCooperation.setAuthItemGmv30d(jsonObject.getString("authItemGmv30d"));
             clipCooperation.setAuthItemGmv30d(jsonObject.getString("authItemGmv30d"));
             clipCooperation.setStatDate(statDate);
             clipCooperation.setStatDate(statDate);
             JSONObject getData = this.getClipData(jsonObject.getLong("clipId"), cookie);
             JSONObject getData = this.getClipData(jsonObject.getLong("clipId"), cookie);
-            if(!Check.isNull(getData)){
+            if (!Check.isNull(getData)) {
                 clipCooperation.setVideoCount(getData.getString("videoCount"));
                 clipCooperation.setVideoCount(getData.getString("videoCount"));
                 clipCooperation.setVideoShow(getData.getString("videoShow"));
                 clipCooperation.setVideoShow(getData.getString("videoShow"));
             }
             }
@@ -194,6 +195,60 @@ public class JiaoYangFenXiaoServiceImpl implements IJiaoYangFenXiaoService {
         }
         }
     }
     }
 
 
+    @Override
+    public String getCookieById(Long id) {
+        return jiaoYangFenXiaoMapper.getCookieById(id);
+    }
+
+    @Override
+    public List<JSONObject> getAccountList() {
+        return jiaoYangFenXiaoMapper.getAccountList();
+    }
+
+    @Override
+    public void getItemTop(String cookie, Long statDate, Long id, String name, Integer offset) {
+        JSONObject returnJson = new JSONObject();
+        Map<String, Object> params = new HashMap<>();
+        params.put("activityUserId", id);
+        params.put("bizCode", 2);
+        params.put("limit", 10);
+        params.put("offset", offset);
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Cookie", cookie);
+        String postUrl = "https://cps.kwaixiaodian.com/gateway/distribute/platform/seller/activity/topItem/list";
+        String resultStr = null;
+        try {
+            resultStr = HttpUtils.KuaiShouttpGetRequest(postUrl, params, headers);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        JSONObject result = JSONObject.parseObject(resultStr);
+        Integer code = result.getInteger("result");
+        JSONArray topActivityItemInfo = new JSONArray();
+        if (code == 1) {
+            JSONObject data = result.getJSONObject("data");
+            if (!Check.isNull(data)) {
+                topActivityItemInfo = data.getJSONArray("topActivityItemInfo");
+                for (int i = 0; i < topActivityItemInfo.size(); i++) {
+                    JSONObject jsonObject = topActivityItemInfo.getJSONObject(i);
+                    jsonObject.put("statDate", statDate);
+                    jsonObject.put("clipId", id);
+                    jsonObject.put("clipName", name);
+                }
+
+                List<JyClipTopList> adds = topActivityItemInfo.toJavaList(JyClipTopList.class);
+                if (!Check.isNull(adds)) {
+                    jiaoYangFenXiaoMapper.replaceTopItem(adds);
+                }
+            }
+        }
+
+        if (topActivityItemInfo.size() > 0) {
+            getItemTop(cookie, statDate, id, name, offset + 10);
+        }
+
+    }
+
     private JSONObject getClipData(Long clipId, String cookie) {
     private JSONObject getClipData(Long clipId, String cookie) {
         JSONObject returnJson = new JSONObject();
         JSONObject returnJson = new JSONObject();
         Map<String, Object> params = new HashMap<>();
         Map<String, Object> params = new HashMap<>();