Przeglądaj źródła

Merge branch 'master' of codeup.aliyun.com:60c06368dbbed34fe0f0c263/job/hr_job-bytedance into pingkang

huangpingkang 1 rok temu
rodzic
commit
3831be1979

+ 70 - 36
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/CPSReportMapper.xml

@@ -19,43 +19,77 @@
         pay_amount,
         xn_pay_amount,
         pay_users,
-        pay_counts,order_counts
+        pay_counts,
+        order_counts
         )
-        SELECT t1.consume_date,
-               t0.official_account_id,
-               t0.responsibility_person_id,
-               t2.app_id,
-               t0.id,
-               IFNULL(t3.new_users, 0) as 'new_users',
-                count(DISTINCT case when t1.consume_date = DATE_FORMAT(t1.activation_time, '%Y%m%d') then t1.uid end ) as 'new_pay_users',
-                SUM(if(t1.consume_date = DATE_FORMAT(t1.activation_time, '%Y%m%d') AND t1.status = 1, 1,0)) as 'new_pay_counts',
-                SUM(if(t1.consume_date = DATE_FORMAT(t1.activation_time, '%Y%m%d'), 1,0)) as 'new_order_counts',
-                IFNULL(ROUND(SUM(if(t1.consume_date = DATE_FORMAT(t1.activation_time, '%Y%m%d'), t1.total_fee,0)),2),0.00) as 'new_pay_amount',
-                IFNULL(ROUND(SUM(IF(t1.consume_date = DATE_FORMAT(t1.activation_time, '%Y%m%d') and (t1.pay_merchant = 15 or pay_type = 20),total_fee,0)),2),0.00) as 'new_xn_pay_amount',
-                IFNULL(ROUND(SUM(t1.total_fee),2),0.00) as 'pay_amount',
-                IFNULL(ROUND(SUM(IF(t1.pay_merchant = 15 or pay_type = 20, total_fee, 0)),2),0.00) as 'xn_pay_amount',
-                count(DISTINCT t1.uid) as 'pay_users',
-                SUM(IF(t1.status = 1, 1, 0)) as 'pay_counts',
-                count(t1.order_no) as 'order_counts'
-        FROM thirtpart.ly_link t0
-                 LEFT JOIN thirtpart.ly_pay_record t1 ON t0.id = t1.link_id
-                 LEFT JOIN thirtpart.ly_official_accounts t2 ON t0.official_account_id = t2.id
-                 LEFT JOIN (
-                 SELECT
-                     t0.id,
-                     t0.official_account_id,
-                     t0.responsibility_person_id,
-                     count(DISTINCT t.uid) AS 'new_users'
-                   FROM thirtpart.ly_user_activation_info t
-                   LEFT JOIN thirtpart.ly_link t0 ON t.link_id = t0.id
-                   WHERE DATE_FORMAT(t.activation_time, '%Y%m%d') = #{nowDate}
-                   GROUP BY t0.id, t0.official_account_id, t0.responsibility_person_id
-                   ) t3 ON t0.id = t3.id
-                          AND t0.official_account_id = t3.official_account_id
-                          AND t0.responsibility_person_id = t3.responsibility_person_id
-        WHERE consume_date = #{nowDate}
-          AND t0.id in (SELECT id FROM thirtpart.ly_link)
-        GROUP BY t0.id, t0.official_account_id, t0.responsibility_person_id
+        SELECT
+            t3.date,
+            t0.official_account_id,
+            t0.responsibility_person_id,
+            t2.app_id,
+            t0.id,
+            t3.new_users,
+            t1.new_pay_users,
+            t1.new_pay_counts,
+            t1.new_order_counts,
+            t1.new_pay_amount,
+            t1.new_xn_pay_amount,
+            t1.pay_amount,
+            t1.xn_pay_amount,
+            t1.pay_users,
+            t1.pay_counts,
+            t1.order_counts
+        FROM
+            (
+                SELECT
+                    DATE_FORMAT( activation_time, '%Y%m%d' ) as 'date',
+                        link_id,
+                    count( DISTINCT uid ) AS 'new_users'
+                FROM
+                    thirtpart.ly_user_activation_info
+                WHERE
+                    DATE_FORMAT( activation_time, '%Y%m%d' ) = #{nowDate}
+                GROUP BY
+                    link_id
+            ) t3
+                LEFT JOIN	thirtpart.ly_link t0 ON t0.id = t3.link_id
+                LEFT JOIN (
+                SELECT
+                    consume_date,
+
+                    link_id,
+
+                    count( DISTINCT CASE WHEN t1.consume_date = DATE_FORMAT( t1.activation_time, '%Y%m%d' ) THEN t1.uid END ) AS 'new_pay_users',
+
+                        SUM(IF( t1.consume_date = DATE_FORMAT( t1.activation_time, '%Y%m%d' ) AND t1.STATUS = 1, 1, 0 )) AS 'new_pay_counts',
+
+                        SUM(IF( t1.consume_date = DATE_FORMAT( t1.activation_time, '%Y%m%d' ), 1, 0 )) AS 'new_order_counts',
+
+                        IFNULL(	ROUND( SUM( IF ( t1.consume_date = DATE_FORMAT( t1.activation_time, '%Y%m%d' ), t1.total_fee, 0 )), 2 ),0.00 ) AS 'new_pay_amount',
+
+                        IFNULL(ROUND(SUM(IF(t1.consume_date = DATE_FORMAT( t1.activation_time, '%Y%m%d') AND ( t1.pay_merchant = 15 OR pay_type = 20 ),	total_fee,0 )),	2 ),0.00 ) AS 'new_xn_pay_amount',
+
+                        IFNULL( ROUND( SUM( t1.total_fee ), 2 ), 0.00 ) AS 'pay_amount',
+
+                        IFNULL( ROUND( SUM( IF ( t1.pay_merchant = 15 OR pay_type = 20, total_fee, 0 )), 2 ), 0.00 ) AS 'xn_pay_amount',
+
+                        count( DISTINCT t1.uid ) AS 'pay_users',
+
+                        SUM(IF( t1.STATUS = 1, 1, 0 )) AS 'pay_counts',
+
+                        count( t1.order_no ) AS 'order_counts'
+
+                FROM
+                    thirtpart.ly_pay_record t1
+                WHERE
+                    consume_date = #{nowDate}
+                GROUP BY
+                    link_id
+            ) t1 ON  t3.link_id = t1.link_id
+                LEFT JOIN thirtpart.ly_official_accounts t2 ON t0.official_account_id = t2.id
+        WHERE official_account_id is not null
+        GROUP BY
+            t3.link_id
     </insert>
 
     <insert id="cleanCPSIaaDailyReports">