Browse Source

分时数据

yumeng 1 year ago
parent
commit
3161c55b4f
1 changed files with 36 additions and 51 deletions
  1. 36 51
      ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

+ 36 - 51
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -2789,101 +2789,86 @@
     </select>
     <select id="getKsChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
         select stat_hour as 'time',
-        round(sum(t2.pay_amount) / 100, 2) as 'charge'
-        from (select promoter_id, user_id
-        from kuaishou_promoter where
-        1 = 1
+        round(sum(pay_amount) / 100, 2) as 'charge' from kuaishou_supply_chain
+        where stat_date = #{date}
         <if test='userList != null and userList.size() > 0'>
+            and promoter_id in (
+            select promoter_id
+            from kuaishou_promoter where
+            1 = 1
             and user_id in
             <foreach collection="userList" item="item" separator=","
                      open="(" close=")">
                 #{item}
             </foreach>
-
+            group by promoter_id
+            )
         </if>
-          group by promoter_id ) t1
-        inner join (select id, promoter_id, stat_hour, pay_amount
-        from kuaishou_supply_chain
-        where stat_date = #{date}
-        and order_status != 80) t2
-        on t1.promoter_id = t2.promoter_id
         group by stat_hour
-        order by stat_hour asc
+        order by stat_hour asc;
     </select>
 
 
     <select id="getKsCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
-        select stat_hour as 'time',
-        round(sum(t2.pay_amount) / 100, 2) as 'charge'
-        from (
-        select item_id, user_id
-        from kuaishou_item_list where
-        1 = 1
+        select stat_hour  as 'time',
+        round(sum(pay_amount) / 100, 2) as 'charge'
+        from kuaishou_supply_chain
+        where stat_date = #{date}
         <if test='userList != null and userList.size() > 0'>
+            and item_id in (
+            select item_id
+            from kuaishou_item_list where
+            1 = 1
             and user_id in
             <foreach collection="userList" item="item" separator=","
                      open="(" close=")">
                 #{item}
             </foreach>
-
+            group by item_id
+            )
         </if>
-        group by item_id) t1
-        inner join (select id, item_id, stat_hour, pay_amount
-        from kuaishou_supply_chain
-        where stat_date = #{date}
-        and order_status != 80) t2
-        on t1.item_id = t2.item_id
         group by stat_hour
-        order by stat_hour asc
-
+        order by stat_hour asc;
 
     </select>
     <select id="getBytedanceChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
         select pay_success_time_hour as 'time',
-        round(sum(t2.total_pay_amount) / 100, 2) as 'charge'
-        from (select promoter_id, user_id
-        from kuaishou_promoter where
-        1 = 1
+        round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
         <if test='userList != null and userList.size() > 0'>
+            and author_short_id in(
+            select promoter_id
+            from kuaishou_promoter where
+            1 = 1
             and user_id in
             <foreach collection="userList" item="item" separator=","
                      open="(" close=")">
                 #{item}
             </foreach>
-
+            group by promoter_id
+            )
         </if>
-        group by promoter_id ) t1
-        inner join (select order_id, author_short_id, pay_success_time_hour, total_pay_amount
-        from bytedance_order_list
-        where pay_success_time = #{date}
-        and flow_point != 'REFUND') t2
-        on t1.promoter_id = t2.author_short_id
         group by pay_success_time_hour
-        order by pay_success_time_hour asc
+        order by pay_success_time_hour asc;
 
     </select>
     <select id="getBytedanceCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
         select pay_success_time_hour as 'time',
-        round(sum(t2.total_pay_amount) / 100, 2) as 'charge'
-        from (select item_id, user_id
-        from kuaishou_item_list where
-        1 = 1
+        round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
         <if test='userList != null and userList.size() > 0'>
+            and product_id in(
+            select item_id
+            from kuaishou_item_list where
+            1 = 1
             and user_id in
             <foreach collection="userList" item="item" separator=","
                      open="(" close=")">
                 #{item}
             </foreach>
-
+            group by item_id
+            )
         </if>
-        group by item_id ) t1
-        inner join (select order_id, product_id, pay_success_time_hour, total_pay_amount
-        from bytedance_order_list
-        where pay_success_time = #{date}
-        and flow_point != 'REFUND') t2
-        on t1.item_id = t2.product_id
         group by pay_success_time_hour
-        order by pay_success_time_hour asc
+        order by pay_success_time_hour asc;
     </select>
 
     <insert id="replaceKuaiShouActivityOpenItemList">