|
@@ -19,7 +19,8 @@
|
|
|
pay_amount,
|
|
pay_amount,
|
|
|
xn_pay_amount,
|
|
xn_pay_amount,
|
|
|
pay_users,
|
|
pay_users,
|
|
|
- pay_counts,order_counts
|
|
|
|
|
|
|
+ pay_counts,
|
|
|
|
|
+ order_counts
|
|
|
)
|
|
)
|
|
|
SELECT t1.consume_date,
|
|
SELECT t1.consume_date,
|
|
|
t0.official_account_id,
|
|
t0.official_account_id,
|
|
@@ -27,18 +28,35 @@
|
|
|
t2.app_id,
|
|
t2.app_id,
|
|
|
t0.id,
|
|
t0.id,
|
|
|
IFNULL(t3.new_users, 0) as 'new_users',
|
|
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'
|
|
|
|
|
|
|
+ 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 thirtpart.ly_link t0
|
|
FROM thirtpart.ly_link t0
|
|
|
- LEFT JOIN thirtpart.ly_pay_record t1 ON t0.id = t1.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 t0.id = t1.link_id
|
|
|
LEFT JOIN thirtpart.ly_official_accounts t2 ON t0.official_account_id = t2.id
|
|
LEFT JOIN thirtpart.ly_official_accounts t2 ON t0.official_account_id = t2.id
|
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
SELECT
|
|
@@ -49,13 +67,10 @@
|
|
|
FROM thirtpart.ly_user_activation_info t
|
|
FROM thirtpart.ly_user_activation_info t
|
|
|
LEFT JOIN thirtpart.ly_link t0 ON t.link_id = t0.id
|
|
LEFT JOIN thirtpart.ly_link t0 ON t.link_id = t0.id
|
|
|
WHERE DATE_FORMAT(t.activation_time, '%Y%m%d') = #{nowDate}
|
|
WHERE DATE_FORMAT(t.activation_time, '%Y%m%d') = #{nowDate}
|
|
|
- GROUP BY t0.id, t0.official_account_id, t0.responsibility_person_id
|
|
|
|
|
|
|
+ GROUP BY t0.id
|
|
|
) t3 ON t0.id = t3.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
|
|
|
|
|
|
|
+ WHERE t1.consume_date is not null
|
|
|
|
|
+ GROUP BY t0.id
|
|
|
</insert>
|
|
</insert>
|
|
|
|
|
|
|
|
<insert id="cleanCPSIaaDailyReports">
|
|
<insert id="cleanCPSIaaDailyReports">
|