|
@@ -72,17 +72,17 @@ def channel_info_daily(ymd):
|
|
|
|
|
|
pitcher_change=db.quchen_text.getData(
|
|
|
"select b.channel as channel,pitcher from "
|
|
|
- "(select min(end_time) as end_time,channel from pitcher_change "
|
|
|
- " where end_time>'{}' GROUP BY channel) a"
|
|
|
- " left join pitcher_change b on a.end_time=b.end_time and a.channel=b.channel".format(ymd))
|
|
|
+ "(select max(start_time) as start_time,channel from pitcher_change "
|
|
|
+ " where start_time<='{}' GROUP BY channel) a"
|
|
|
+ " left join pitcher_change b on a.start_time=b.start_time and a.channel=b.channel".format(ymd))
|
|
|
|
|
|
- platform_change=db.quchen_text.getData("select b.name as channel,primary_platform as platform from (select min(change_date) as change_date,name from platform_change "
|
|
|
- "where change_date>'{}' GROUP BY name) a "
|
|
|
+ platform_change=db.quchen_text.getData("select b.name as channel,current_platform as platform from (select max(change_date) as change_date,name from platform_change "
|
|
|
+ "where change_date<='{}' GROUP BY name) a "
|
|
|
"left join platform_change b on a.change_date=b.change_date and a.name=b.name".format(ymd))
|
|
|
|
|
|
- book_change=db.quchen_text.getData("select b.name as channel,book from (select min(end_time) as end_time,name from book_change "
|
|
|
- "where end_time>'{}' GROUP BY name) a "
|
|
|
- "left join book_change b on a.end_time=b.end_time and a.name=b.name".format(ymd))
|
|
|
+ book_change=db.quchen_text.getData("select b.name as channel,book from (select max(start_time) as start_time,name from book_change "
|
|
|
+ "where start_time<='{}' GROUP BY name) a "
|
|
|
+ "left join book_change b on a.start_time=b.start_time and a.name=b.name".format(ymd))
|
|
|
|
|
|
for i in data:
|
|
|
for j in pitcher_change:
|
|
@@ -131,13 +131,43 @@ def order_account_text():
|
|
|
db.quchen_text.execute("insert into order_account_text(platform,text) values ('文鼎','{}')".format(i))
|
|
|
|
|
|
|
|
|
+def update_dw_daily_channel_all(ymd):
|
|
|
+ """把某天的数据都捞出来 按照注册时间 更新前面日期的数据"""
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ """"""
|
|
|
+ sql="select count(1) as reg_user_order_count," \
|
|
|
+ " count(DISTINCT user_id) reg_user," \
|
|
|
+ " sum(amount) as reg_user_order_amount," \
|
|
|
+ " sum(if(DATE_SUB(date ,INTERVAL 30 day)>STR_TO_DATE('{0}','%Y-%m-%d '),0,amount)) as reg_user_order_amount30" \
|
|
|
+ " from ods_order where DATE_FORMAT(reg_time,'%Y-%m-%d')='{0}'".format(ymd)
|
|
|
+ data=db.quchen_text.getData(sql)
|
|
|
+ print(data)
|
|
|
+ exit(0)
|
|
|
+
|
|
|
+ update_sql="update dw_daily_channel set reg_user_order_count={},reg_user={},reg_user_order_amount={},reg_user_order_amount30={} " \
|
|
|
+ " where dt='{}'".format()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
-
|
|
|
- for i in dt.getDateLists('2019-05-20','2020-12-16'):
|
|
|
- print(i)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- clean_order(i)
|
|
|
+
|
|
|
+ for i in dt.getDateLists('2019-03-18','2020-12-16'):
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ channel_info_daily(i)
|
|
|
+
|
|
|
+
|