yumeng 1 gadu atpakaļ
vecāks
revīzija
182c0a2192

+ 33 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/JiaoYangFenXiaoJob.java

@@ -86,6 +86,39 @@ public class JiaoYangFenXiaoJob {
 
 
     /**
+     * 获取二创信息
+     *
+     * @throws Exception
+     */
+    @XxlJob("jyClipCooperationV2")
+    public void jyClipCooperationV2() throws Exception {
+
+        List<JSONObject> cookies = jiaoYangFenXiaoService.getCookie();
+        if (Check.isNull(cookies)) {
+            log.error("cookie数据为空");
+            return;
+        }
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String date = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        Long statDate = Long.valueOf(date.replace("-", ""));
+        List<Integer> statusList = new ArrayList();
+
+        statusList.add(1);
+
+        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.getClipCooperationV2(cookie, 0, statDate, status);
+            }
+
+        }
+
+
+    }
+
+    /**
      * 当前小时数据获取
      **/
     @XxlJob("jyNowHourOrderGet")

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

@@ -16,4 +16,6 @@ public interface IJiaoYangFenXiaoService {
     List<JSONObject> getAccountList();
 
     void getItemTop(String cookie,Long statDate, Long id, String name, Integer offset);
+
+    void getClipCooperationV2(String cookie, int i, Long statDate, Integer status) throws Exception;
 }

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

@@ -188,11 +188,11 @@ public class JiaoYangFenXiaoServiceImpl implements IJiaoYangFenXiaoService {
             clipCooperation.setAuthItemGmv30d(jsonObject.getString("authItemGmv30d"));
             clipCooperation.setStatDate(statDate);
             JSONObject getData = this.getClipData(jsonObject.getLong("clipId"), cookie);
-            if (!Check.isNull(getData)) {
+          /*  if (!Check.isNull(getData)) {
                 clipCooperation.setVideoCount(getData.getString("videoCount"));
                 clipCooperation.setVideoShow(getData.getString("videoShow"));
                 Thread.sleep(60 * 1000);
-            }
+            }*/
             adds.add(clipCooperation);
 
 
@@ -257,6 +257,73 @@ public class JiaoYangFenXiaoServiceImpl implements IJiaoYangFenXiaoService {
 
     }
 
+    @Override
+    public void getClipCooperationV2(String cookie, int offset, Long statDate, Integer status) throws Exception {
+        Map<String, Object> params = new HashMap<>();
+        params.put("status", status);
+        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/recreate/leader/clip/cooperation/list";
+        String resultStr = HttpUtils.httpPostRequest(postUrl, params, headers);
+        JSONObject result = JSONObject.parseObject(resultStr);
+        if (Check.isNull(result)) {
+            log.error("骄阳分销数据返回为空");
+            return;
+        }
+        Integer code = result.getInteger("result");
+        if (code != 1) {
+            log.info("骄阳分销尔创列表数据返回异常:", resultStr);
+            sendMessageService.sendMessage("113dee46c7df464da78c07a985e92cd1", "骄阳分销cookie失效,请及时更新。媒体返回信息:" + resultStr);
+            return;
+        }
+        JSONObject dataJson = result.getJSONObject("data");
+        if (Check.isNull(dataJson)) {
+            log.error("骄阳分销数据返回为data数据为空");
+            return;
+        }
+        JSONArray list = dataJson.getJSONArray("leaderCoopClip");
+        if (Check.isNull(list)) {
+            log.error("骄阳分销数据返回为list数据为空");
+            return;
+        }
+        log.info("骄阳分销当前数据条数:{}", list.size());
+        List<JyClipCooperation> adds = new ArrayList<>();
+        for (int i = 0; i < list.size(); i++) {
+            JSONObject jsonObject = list.getJSONObject(i);
+            JyClipCooperation clipCooperation = new JyClipCooperation();
+            clipCooperation.setClipId(jsonObject.getLong("clipId"));
+            clipCooperation.setClipName(jsonObject.getString("clipName"));
+            clipCooperation.setHeadImg(jsonObject.getString("headImg"));
+            clipCooperation.setCommissionRate(jsonObject.getLong("commissionRate"));
+            clipCooperation.setFansNum(jsonObject.getString("fansNum"));
+            clipCooperation.setGmv30d(jsonObject.getString("gmv30d"));
+            clipCooperation.setStartTime(jsonObject.getString("startTime"));
+            clipCooperation.setEndTime(jsonObject.getString("endTime"));
+            clipCooperation.setStatus(jsonObject.getInteger("status"));
+            clipCooperation.setTerminationReason(jsonObject.getString("terminationReason"));
+            clipCooperation.setCommissionRateView(jsonObject.getString("commissionRateView"));
+            clipCooperation.setShopScore(jsonObject.getString("shopScore"));
+            clipCooperation.setClipGmv30d(jsonObject.getString("clipGmv30d"));
+            clipCooperation.setAuthItemGmv30d(jsonObject.getString("authItemGmv30d"));
+            clipCooperation.setStatDate(statDate);
+            JSONObject getData = this.getClipData(jsonObject.getLong("clipId"), cookie);
+            if (!Check.isNull(getData)) {
+                clipCooperation.setVideoCount(getData.getString("videoCount"));
+                clipCooperation.setVideoShow(getData.getString("videoShow"));
+                Thread.sleep(30 * 1000);
+            }
+            adds.add(clipCooperation);
+
+
+        }
+        jiaoYangFenXiaoMapper.replaceClipCooperation(adds);
+        if (list.size() >= 10) {
+            getClipCooperation(cookie, offset + 10, statDate, status);
+        }
+    }
+
     private JSONObject getClipData(Long clipId, String cookie) {
         JSONObject returnJson = new JSONObject();
         Map<String, Object> params = new HashMap<>();