فهرست منبع

Merge remote-tracking branch 'origin/master'

zhaoxian 1 سال پیش
والد
کامیت
441b856427

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

@@ -155,45 +155,22 @@ public class TestController {
     @Autowired
     private IKuaiShouActivityItemListService activityItemListService;
 
-    @GetMapping(value = "/getData")
-    public void getDate(String startDate, String endDate) throws Exception {
+    public static void main(String[] args) {
+        List<String> days = DateUtils.getDays("2023-08-01", "2023-09-25");
+        System.err.println(days);
+    }
 
 
-//        Map<Long, Long> itemMap = activityItemListService.getItemMap();
-//        System.err.println(itemMap);
 
-        List<JSONObject> cookies = ikuaishouSupplyChainService.getCookie();
-        if (Check.isNull(cookies)) {
-            log.error("cookie数据为空");
-            return;
-        }
-        List<String> days = DateUtils.getDays(startDate, endDate);
-        JSONArray hourList = KuaishouHourEnum.getHourList();
-        JSONArray minSecList = KuaishouMinSecEnum.getMinSecList();
-        Map<Long, Long> itemMap = activityItemListService.getItemMap();
-        for (int z = 0; z < days.size(); z++) {
-            String date = days.get(z);
-            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");
-                        ikuaishouSupplyChainService.getOrderList(cookie, 0, orderCreateTimeStart, orderCreateTimeEnd, itemMap);
-                    }
+    @GetMapping(value = "/getData")
+    public void getDate(String startDate, String endDate) throws Exception {
 
-                }
-            }
+        List<String> days = DateUtils.getDays("2023-08-01", "2023-09-25");
+        for (int i = 0; i < days.size(); i++) {
+            Long date = Long.valueOf(days.get(i).replace("-",""));
+            System.err.println("当前日期:"+ date);
+            ikuaishouSupplyChainService.deletePromoterBindChannelByDate(date);
+            ikuaishouSupplyChainService.cleanPromoterBindChannel(date);
         }
     }
 

+ 1 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceAdvertisingDataLoadJob.java

@@ -50,7 +50,7 @@ public class BytedanceAdvertisingDataLoadJob {
                 //2:获取当日广告计划数据
                 advertiserDataService.getAdvertiserPlan(token, "", dateString, null);
                 //3:获取当日创意数据
-                creativeService.getAdvertiserCreative(token, "", dateString);
+              //  creativeService.getAdvertiserCreative(token, "", dateString);
             } catch (Exception e) {
                 e.printStackTrace();
             }

+ 41 - 39
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouOrderLIstGetJob.java

@@ -17,6 +17,7 @@ import org.springframework.stereotype.Component;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -269,29 +270,53 @@ public class KuaishouOrderLIstGetJob {
         }
         String date = DateUtils.getNowDate("yyyy-MM-dd");
         Integer nowHour = DateUtils.getNowHour();
+        JSONArray hours = new JSONArray();
+        hours.add(nowHour);
+        if (nowHour >= 1) {
+            hours.add(nowHour - 1);
+        }
+
+
         JSONArray minSecList = KuaishouMinSecEnum.getMinSecList();
         Map<Long, Long> itemMap = activityItemListService.getItemMap();
-        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 + " " + nowHour + ":" + startTime;
-            String end = date + " " + nowHour + ":" + 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");
-                ikuaishouSupplyChainService.getOrderList(cookie, 0, orderCreateTimeStart, orderCreateTimeEnd, itemMap);
+        for (int i = 0; i < hours.size(); i++) {
+            Integer hour = hours.getInteger(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");
+                    ikuaishouSupplyChainService.getOrderList(cookie, 0, orderCreateTimeStart, orderCreateTimeEnd, itemMap);
+                }
             }
-
         }
     }
 
 
+    public static void main(String[] args) {
+        Integer nowHour = null;
+        try {
+            nowHour = DateUtils.getNowHour();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+       List<Integer> hours = new ArrayList<>();
+        hours.add(nowHour);
+        if (nowHour >= 1) {
+            hours.add(nowHour - 1);
+        }
+        System.err.println(hours);
+    }
+
     /**
      * 当天前前小时数据获取
      **/
@@ -335,27 +360,4 @@ public class KuaishouOrderLIstGetJob {
     }
 
 
-    public static void main(String[] args) throws ParseException {
-        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();
-                //     ikuaishouSupplyChainService.getOrderList(cookie, 0, orderCreateTimeStart, orderCreateTimeEnd);
-            }
-        }
-
-
-    }
 }

+ 27 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/settlementJob.java

@@ -33,10 +33,29 @@ public class settlementJob {
         String date = DateUtils.getLastDay(DateUtils.date2Str(), 1);
         Long statDate = Long.valueOf(date.replace("-", ""));
         List<JSONObject> list = ikuaishouSupplyChainService.getDataList(statDate);
-
         if (Check.isNull(list)) {
             return;
+        }
+        List<List<JSONObject>> partition = Lists.partition(list, 1000);
+        for (int i = 0; i < partition.size(); i++) {
+            List<JSONObject> jsonObjects = partition.get(i);
+            Map<String, Object> param = new HashMap<>();
+            param.put("statDate", statDate);
+            param.put("data", jsonObjects);
+            HttpUtils.httpPostRequest(url, param, null);
+        }
 
+    }
+
+
+    @XxlJob("cleanPromoterSettlementData")
+    public void cleanPromoterSettlementData() {
+        String url = "http://ruixuan.api.tjyourong.com.cn/settlement/promoterData";
+        String date = DateUtils.getLastDay(DateUtils.date2Str(), 1);
+        Long statDate = Long.valueOf(date.replace("-", ""));
+        List<JSONObject> list = ikuaishouSupplyChainService.getPromoterDataList(statDate);
+        if (Check.isNull(list)) {
+            return;
         }
         List<List<JSONObject>> partition = Lists.partition(list, 1000);
         for (int i = 0; i < partition.size(); i++) {
@@ -50,6 +69,13 @@ public class settlementJob {
     }
 
 
+    @XxlJob("cleanPromoterBindChannel")
+    public void cleanPromoterBindChannel() {
+        Long date = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+        ikuaishouSupplyChainService.deletePromoterBindChannelByDate(date);
+        ikuaishouSupplyChainService.cleanPromoterBindChannel(date);
+
+    }
 
 
 }

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

@@ -24,4 +24,10 @@ public interface KuaishouSupplyChainMapper extends BaseMapper<KuaishouSupplyChai
     void replaceSettlement(@Param(value = "adds") List<KuaishouSupplyChainSettlement> supplyChains);
 
     List<JSONObject> getDataList(@Param("statDate") Long statDate);
+
+    List<JSONObject> getPromoterDataList(@Param("statDate") Long statDate);
+
+    void deletePromoterBindChannelByDate(@Param("date") Long date);
+
+    void cleanPromoterBindChannel(@Param("date") Long date);
 }

+ 69 - 27
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouSupplyChainMapper.xml

@@ -81,40 +81,82 @@
             )
         </foreach>
     </insert>
+    <insert id="cleanPromoterBindChannel" parameterType="java.lang.Long">
+        insert into ruixuan.promoter_bind_channel_date (promoter_id, promoter_name,promoter_url, user_id, user_name, stat_date)
+        select t1.promoter_id, t1.promoter_nick_name, t1.promoter_url,t1.user_id, t1.user_name, #{date}
+        from ruixuan.kuaishou_promoter t1
+        left join ruixuan.sys_user_role t2
+        on t1.user_id = t2.user_id
+        left join ruixuan.sys_role t3
+        on t2.role_id = t3.role_id
+        where t1.media_id = 2
+        and t3.role_key in ('bdManager', 'bd')
+        and date_format(t1.create_time, '%Y%m%d')  &lt; #{date}
+        group by t1.promoter_id
+
+    </insert>
+    <delete id="deletePromoterBindChannelByDate" parameterType="java.lang.Long">
+        delete from ruixuan.promoter_bind_channel_date where stat_date = #{date}
+    </delete>
     <select id="getCookie" resultType="com.alibaba.fastjson.JSONObject">
 
         select  id ,cookie  from ruixuan.kuaishou_supply_chain_cookie
 
     </select>
     <select id="getDataList" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
-     select  *  from (
-      select t1.relate_id                      as 'relateId',
-       (case
-            when t2.rule_id is not null
-            then t2.rule_id
-            else 1
-            end
-        )                                as 'ruleId',
-       group_concat(t1.item_id)          as 'itemIds',
-       t1.promoter_id                    as 'promoterId',
-       t1.promoter_name                  as 'promoterName',
-       t1.item_create_id                 as 'itemCreateId',
-       t1.item_create_name               as 'itemCreateName',
-       t1.promoter_create_id             as 'promoterCreateId',
-       t1.promoter_create_name           as 'promoterCreateName',
-       ifnull(sum(t1.order_num),0)                 as 'orderNum',
-       ifnull(sum(t1.valid_order_num),0 )         as 'validOrderNum',
-       ifnull(sum(t1.yesterday_order_num),0 )      as 'yesterdayOrderNum',
-       ifnull(sum(t1.yesterday_valid_order_num),0) as 'yesterdayValidOrderNum',
-       t1.stat_date                      as 'statDate',
-       round(t2.item_price / 100, 2)               as      'itemPrice'
-       from ruixuan.kuaishou_rule_order_data t1
-         left join ruixuan.kuaishou_item_list t2 on t1.item_id = t2.item_id
-      where t1.stat_date = #{statDate}
-      and t1.relate_id is not null
-      group by t1.relate_id, t1.promoter_id ) t
+      select t.*, tt.rule_type
+      from (select *
+      from (select t1.relate_id                                 as 'relateId',
+                   (case
+                        when t2.rule_id is not null
+                            then t2.rule_id
+                        else 1
+                       end
+                       )                                        as 'ruleId',
+                   group_concat(t1.item_id)                     as 'itemIds',
+                   t1.promoter_id                               as 'promoterId',
+                   t1.promoter_name                             as 'promoterName',
+                   t1.item_create_id                            as 'itemCreateId',
+                   t1.item_create_name                          as 'itemCreateName',
+                   t1.promoter_create_id                        as 'promoterCreateId',
+                   t1.promoter_create_name                      as 'promoterCreateName',
+                   ifnull(sum(t1.order_num), 0)                 as 'orderNum',
+                   ifnull(sum(t1.valid_order_num), 0)           as 'validOrderNum',
+                   ifnull(sum(t1.yesterday_order_num), 0)       as 'yesterdayOrderNum',
+                   ifnull(sum(t1.yesterday_valid_order_num), 0) as 'yesterdayValidOrderNum',
+                   t1.stat_date                                 as 'statDate',
+                   round(t2.item_price / 100, 2)                as 'itemPrice'
+            from ruixuan.kuaishou_rule_order_data t1
+                     left join ruixuan.kuaishou_item_list t2 on t1.item_id = t2.item_id
+            where t1.stat_date = #{statDate}
+              and t1.relate_id is not null
+            group by t1.relate_id, t1.promoter_id) t
       where t.itemPrice >= 6
-      order by t.validOrderNum desc
+      order by t.validOrderNum desc) t
+         left join ruixuan.kuaishou_settlement_rules tt
+                   on t.ruleId = tt.id
+    </select>
+    <select id="getPromoterDataList" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
+select t1.rule_id                                   as 'ruleId',
+       t1.promoter_id                               as 'promoterId',
+       t2.promoter_name                             as 'promoterName',
+       ifnull(sum(t2.order_num), 0)                 as 'orderNum',
+       ifnull(sum(t2.valid_order_num), 0)           as 'validOrderNum',
+       ifnull(sum(t2.yesterday_order_num), 0)       as 'yesterdayOrderNum',
+       ifnull(sum(t2.yesterday_valid_order_num), 0) as 'yesterdayValidOrderNum',
+       t2.stat_date                                 as 'statDate',
+       3                                            as 'rule_type',
+       t3.item_price                                as 'itemPrice'
+
+from promoter_bind_rule t1
+         left join kuaishou_rule_order_data t2 on t1.promoter_id = t2.promoter_id
+         left join kuaishou_item_list t3 on t2.item_id = t3.item_id
+where 1 = 1
+  and t2.stat_date =  #{statDate}
+  and t3.item_price >= 600
+group by t1.promoter_id;
+
+
     </select>
 
 </mapper>

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

@@ -21,4 +21,10 @@ public interface IKuaishouSupplyChainService extends IService<KuaishouSupplyChai
     void getSettlementData(String cookie, Integer offset, Long orderCreateTimeStart, Long orderCreateTimeEnd) throws Exception;
 
     List<JSONObject> getDataList(Long statDate);
+
+    List<JSONObject> getPromoterDataList(Long statDate);
+
+    void deletePromoterBindChannelByDate(Long date);
+
+    void cleanPromoterBindChannel(Long date);
 }

+ 8 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActivityItemListServiceImpl.java

@@ -117,7 +117,10 @@ public class KuaiShouActivityItemListServiceImpl extends ServiceImpl<KuaiShouAct
                 Integer status = itemMap.get(itemId);
                 if (!Check.isNull(status)) {
                     if (status != 4) {
-                        activityItemListMapper.updateItemStatusByItem(itemId, 4); // 招商活动失效,修改商品状态为活动结束
+                        if (itemId != 21003732814123L) {
+                            activityItemListMapper.updateItemStatusByItem(itemId, 4); // 招商活动失效,修改商品状态为活动结束
+
+                        }
                     }
                 }
 
@@ -125,8 +128,10 @@ public class KuaiShouActivityItemListServiceImpl extends ServiceImpl<KuaiShouAct
                 Integer status = itemMap.get(itemId);
                 if (!Check.isNull(status)) { // 0 下架 1在售
                     if (itemStatus == 0 || itemAuditStatus == 5) {
-                        activityItemListMapper.updateItemStatusByItem(itemId, 5); // 商品失效
-                    } else  {
+                        if (itemId != 21003732814123L) {
+                            activityItemListMapper.updateItemStatusByItem(itemId, 5); // 商品失效
+                        }
+                    } else {
                         activityItemListMapper.updateItemStatusByItem(itemId, 2); // 商品在售
                     }
                 }

+ 3 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -327,7 +327,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     videoGet.setIsKaiPing(typeBySize.get("isKaiPing"));
                 }
                 videoGetList.add(videoGet);
-                getCut(token.getAccessToken(), token.getAccountId(), signature, photo_id);
+//                getCut(token.getAccessToken(), token.getAccountId(), signature, photo_id);
             }
             if (!Check.isNull(videoGetList)) {
                 videoGetService.replaceBatch(videoGetList);
@@ -1750,13 +1750,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             videoGet.setIsKaiPing(typeBySize.get("isKaiPing"));
                         }
                         videoGetList.add(videoGet);
-                        Thread thread = new Thread() {
+                       /* Thread thread = new Thread() {
                             @Override
                             public void run() {
                                 videoGetService.getKeyFrame(accessToken, accountId, signature, photo_id);
                             }
                         };
-                        thread.start();
+                        thread.start();*/
                     }
                     if (!Check.isNull(videoGetList)) {
                         videoGetService.replaceBatch(videoGetList);

+ 19 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouSupplyChainServiceImpl.java

@@ -40,6 +40,7 @@ public class KuaishouSupplyChainServiceImpl extends ServiceImpl<KuaishouSupplyCh
 
     @Override
     public void getOrderList(String cookie, Integer offset, Long orderCreateTimeStart, Long orderCreateTimeEnd, Map<Long, Long> itemMap) throws Exception {
+        Thread.sleep(500L);
         Map<String, Object> params = new HashMap<>();
         if (!Check.isNull(orderCreateTimeStart)) {
             params.put("orderCreateTimeStart", orderCreateTimeStart);
@@ -48,7 +49,7 @@ public class KuaishouSupplyChainServiceImpl extends ServiceImpl<KuaishouSupplyCh
             params.put("orderCreateTimeEnd", orderCreateTimeEnd);
         }
         params.put("fundType", 1);
-        params.put("limit", 5000);
+        params.put("limit", 200);
         params.put("offset", offset);
 
         Map<String, String> headers = new HashMap<>();
@@ -113,9 +114,8 @@ public class KuaishouSupplyChainServiceImpl extends ServiceImpl<KuaishouSupplyCh
             supplyChains.add(supplyChain);
         }
         supplyChainMapper.replace(supplyChains);
-        Thread.sleep(2000L);
-        if (list.size() >= 5000) {
-            getOrderList(cookie, offset + 5000, orderCreateTimeStart, orderCreateTimeEnd, itemMap);
+        if (list.size() >= 200) {
+            getOrderList(cookie, offset + 200, orderCreateTimeStart, orderCreateTimeEnd, itemMap);
         }
 
     }
@@ -189,6 +189,21 @@ public class KuaishouSupplyChainServiceImpl extends ServiceImpl<KuaishouSupplyCh
         return supplyChainMapper.getDataList(statDate);
     }
 
+    @Override
+    public List<JSONObject> getPromoterDataList(Long statDate) {
+        return supplyChainMapper.getPromoterDataList(statDate);
+    }
+
+    @Override
+    public void deletePromoterBindChannelByDate(Long date) {
+        supplyChainMapper.deletePromoterBindChannelByDate(date);
+    }
+
+    @Override
+    public void cleanPromoterBindChannel(Long date) {
+        supplyChainMapper.cleanPromoterBindChannel(date);
+    }
+
     public static String filterSupplement(String content) {
         StringBuilder sb = new StringBuilder();
         for (char ch : content.toCharArray()) {