|
@@ -34,13 +34,13 @@ from
|
|
|
left outer join
|
|
|
(select date as dt3,channel as channel3,count(1) as first_order_count, ---新用户首日充值
|
|
|
count(distinct user_id) as first_order_user,sum(amount) as first_order_amount
|
|
|
- from order where toDate(reg_time)=date group by date,channel) c
|
|
|
+ from order where status=2 and toDate(reg_time)=date group by date,channel) c
|
|
|
on dt=dt3 and channel=channel3
|
|
|
|
|
|
left outer join
|
|
|
(select date as dt4,channel as channel4,count(1) as order_count, ---账面充值
|
|
|
count(distinct user_id) as order_user,sum(amount) as order_amount
|
|
|
- from order group by date,channel) d
|
|
|
+ from order where status=2 group by date,channel) d
|
|
|
on dt=dt4 and channel=channel4
|
|
|
|
|
|
left outer join (
|
|
@@ -50,7 +50,7 @@ left outer join (
|
|
|
sum(if(user_order_count>=5,1,0)) reg_order_user_again5,
|
|
|
sum(if(user_order_count>=6,1,0)) reg_order_user_again6
|
|
|
from (select formatDateTime(reg_time,'%Y-%m-%d') reg_date,channel,count(1) user_order_count
|
|
|
- from order group by formatDateTime(reg_time,'%Y-%m-%d') ,user_id,channel) x group by reg_date,channel
|
|
|
+ from order where status=2 group by formatDateTime(reg_time,'%Y-%m-%d') ,user_id,channel) x group by reg_date,channel
|
|
|
) f on dt=dt6 and channel=channel6
|
|
|
|
|
|
left outer join
|
|
@@ -60,7 +60,7 @@ left outer join
|
|
|
sum(amount) as reg_order_amount,
|
|
|
count(distinct user_id) as reg_order_user,
|
|
|
count(1) as reg_order_count
|
|
|
- from order where reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel) b
|
|
|
+ from order where status=2 and reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel) b
|
|
|
on dt=dt2 and channel=channel2
|
|
|
having order_amount+cost+reg_order_amount>0"""
|
|
|
|
|
@@ -104,7 +104,7 @@ select toDate(formatDateTime(reg_time,'%Y-%m-%d')) as dt,
|
|
|
count(distinct if(subtractDays(date, 28)>=toDate(reg_time),null,user_id)) dc28,
|
|
|
count(distinct if(subtractDays(date, 29)>=toDate(reg_time),null,user_id)) dc29,
|
|
|
count(distinct if(subtractDays(date, 30)>=toDate(reg_time),null,user_id)) dc30
|
|
|
-from order where reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel"""
|
|
|
+from order where status=2 and reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel"""
|
|
|
|
|
|
data =ck.execute(sql)
|
|
|
isql="insert into dw_channel_user_daily values " \
|
|
@@ -182,7 +182,7 @@ def dw_channel_amount_daily():
|
|
|
if(dt<subtractDays(today(), 88),sum(if(subtractDays(date, 90)>=toDate(reg_time),0,amount)),null) as dm3,
|
|
|
if(dt<subtractDays(today(), 118),sum(if(subtractDays(date, 120)>=toDate(reg_time),0,amount)),null) as dm4,
|
|
|
if(dt<subtractDays(today(), 148),sum(if(subtractDays(date, 150)>=toDate(reg_time),0,amount)),null) as dm5
|
|
|
- from order where reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel """
|
|
|
+ from order where status=2 and reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel """
|
|
|
data=ck.execute(sql)
|
|
|
isql="insert into dw_channel_amount_daily values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s," \
|
|
|
"%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
|
|
@@ -201,7 +201,7 @@ def dw_channel_amount_daily_reverse():
|
|
|
sum(if(addDays(date,4)=today(),amount,0)) ba5,
|
|
|
sum(if(addDays(date,6)=today(),amount,0)) ba6,
|
|
|
sum(if(addDays(date,7)=today(),amount,0)) ba7
|
|
|
- from order where reg_time>'2019-03-18 00:00:00' and date>=subtractDays(today(),7) group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel"""
|
|
|
+ from order where status=2 and reg_time>'2019-03-18 00:00:00' and date>=subtractDays(today(),7) group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel"""
|
|
|
data = ck.execute(sql)
|
|
|
isql = "replace into dw_channel_amount_daily_reverse values (%s,%s,%s,%s,%s,%s,%s,%s,%s)"
|
|
|
db.dm.execute("truncate table dw_channel_amount_daily_reverse")
|