Browse Source

渠道业绩归属人数据清洗

yumeng 1 year ago
parent
commit
5161288743

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

@@ -155,45 +155,22 @@ public class TestController {
     @Autowired
     @Autowired
     private IKuaiShouActivityItemListService activityItemListService;
     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);
         }
         }
     }
     }
 
 

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

@@ -48,7 +48,6 @@ public class settlementJob {
     }
     }
 
 
 
 
-
     @XxlJob("cleanPromoterSettlementData")
     @XxlJob("cleanPromoterSettlementData")
     public void cleanPromoterSettlementData() {
     public void cleanPromoterSettlementData() {
         String url = "http://ruixuan.api.tjyourong.com.cn/settlement/promoterData";
         String url = "http://ruixuan.api.tjyourong.com.cn/settlement/promoterData";
@@ -70,4 +69,13 @@ public class settlementJob {
     }
     }
 
 
 
 
+    @XxlJob("cleanPromoterBindChannel")
+    public void cleanPromoterBindChannel() {
+        Long date = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+        ikuaishouSupplyChainService.deletePromoterBindChannelByDate(date);
+        ikuaishouSupplyChainService.cleanPromoterBindChannel(date);
+
+    }
+
+
 }
 }

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

@@ -26,4 +26,8 @@ public interface KuaishouSupplyChainMapper extends BaseMapper<KuaishouSupplyChai
     List<JSONObject> getDataList(@Param("statDate") Long statDate);
     List<JSONObject> getDataList(@Param("statDate") Long statDate);
 
 
     List<JSONObject> getPromoterDataList(@Param("statDate") Long statDate);
     List<JSONObject> getPromoterDataList(@Param("statDate") Long statDate);
+
+    void deletePromoterBindChannelByDate(@Param("date") Long date);
+
+    void cleanPromoterBindChannel(@Param("date") Long date);
 }
 }

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

@@ -81,6 +81,23 @@
             )
             )
         </foreach>
         </foreach>
     </insert>
     </insert>
+    <insert id="cleanPromoterBindChannel" parameterType="java.lang.Long">
+        insert into ruixuan.promoter_bind_channel_date (promoter_id, promoter_name, user_id, user_name, stat_date)
+        select t1.promoter_id, t1.promoter_nick_name, 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="getCookie" resultType="com.alibaba.fastjson.JSONObject">
 
 
         select  id ,cookie  from ruixuan.kuaishou_supply_chain_cookie
         select  id ,cookie  from ruixuan.kuaishou_supply_chain_cookie

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

@@ -23,4 +23,8 @@ public interface IKuaishouSupplyChainService extends IService<KuaishouSupplyChai
     List<JSONObject> getDataList(Long statDate);
     List<JSONObject> getDataList(Long statDate);
 
 
     List<JSONObject> getPromoterDataList(Long statDate);
     List<JSONObject> getPromoterDataList(Long statDate);
+
+    void deletePromoterBindChannelByDate(Long date);
+
+    void cleanPromoterBindChannel(Long date);
 }
 }

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

@@ -194,6 +194,16 @@ public class KuaishouSupplyChainServiceImpl extends ServiceImpl<KuaishouSupplyCh
         return supplyChainMapper.getPromoterDataList(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) {
     public static String filterSupplement(String content) {
         StringBuilder sb = new StringBuilder();
         StringBuilder sb = new StringBuilder();
         for (char ch : content.toCharArray()) {
         for (char ch : content.toCharArray()) {