|
@@ -299,24 +299,29 @@ def dw_channel_daily_total(ymd):
|
|
|
ck.execute(sql)
|
|
|
|
|
|
def dw_daily_pitcher(ymd):
|
|
|
- sql=f"""insert into dw_daily_pitcher
|
|
|
-select '{ymd}' dt, a.pitcher,
|
|
|
- start_cost_date,end_cost_date,
|
|
|
- sum(if(dt>=start_cost_date,reg_order_amount,0)) total_amount,
|
|
|
- sum(if(dt>=start_cost_date,cost,0)) total_cost
|
|
|
-from (select reg_order_amount,cost,dt,pitcher from dw_daily_channel where dt<='{ymd}')
|
|
|
- a left outer join
|
|
|
-(select min(dt) start_cost_date,max(dt) end_cost_date,pitcher
|
|
|
-from dw_daily_channel_cost where cost>0 group by pitcher) b on a.pitcher=b.pitcher
|
|
|
- group by pitcher,start_cost_date,end_cost_date
|
|
|
+ sql=f"""select '{ymd}' dt, a.pitcher,
|
|
|
+ start_cost_date,end_cost_date,total_amount,total_cost
|
|
|
+from
|
|
|
+ (select sum(cost) total_cost,pitcher from dw_daily_channel_cost where dt<='{ymd}' group by pitcher) a
|
|
|
+left outer join
|
|
|
+ (select min(dt) start_cost_date,max(dt) end_cost_date,pitcher
|
|
|
+ from dw_daily_channel_cost where cost>0 group by pitcher) b on a.pitcher=b.pitcher
|
|
|
+left outer join
|
|
|
+ (select pitcher,sum(if(toDate(formatDateTime(reg_time,'%Y-%m-%d'))>=start_cost_date,amount,0)) total_amount
|
|
|
+ from order a
|
|
|
+ left outer join dw_daily_channel_cost b on a.channel = b.channel and date=dt
|
|
|
+ left outer join (select min(dt) start_cost_date,pitcher from dw_daily_channel_cost where cost>0 group by pitcher) c on b.pitcher=c.pitcher
|
|
|
+ where date<='{ymd}' group by pitcher) c on a.pitcher=c.pitcher;
|
|
|
"""
|
|
|
- # print(sql)
|
|
|
+
|
|
|
ck.execute(f"alter table dw_daily_pitcher drop partition '{ymd}'")
|
|
|
ck.execute(sql)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
+ # dw_daily_pitcher('2021-01-14')
|
|
|
+
|
|
|
# dw_channel_daily_total('2020-07-20')
|
|
|
# channel_by_account_daily('2020-12-17')
|
|
|
# dw_daily_channel_cost('2020-12-17')
|
|
@@ -325,10 +330,11 @@ if __name__ == '__main__':
|
|
|
# ods_order('2020-12-20')
|
|
|
# dw_daily_channel_plus()
|
|
|
# exit()
|
|
|
- dw_daily_channel()
|
|
|
- exit(0)
|
|
|
+ # dw_daily_channel()
|
|
|
+ # exit(0)
|
|
|
# dm_pitcher_daily_page_total()
|
|
|
# dm_pitcher_daily_page_total()
|
|
|
+ # exit(0)
|
|
|
# dw_channel_daily_total('2021-01-11')
|
|
|
# dw_daily_channel_cost('2021-01-12')
|
|
|
# dw_channel_daily_total('2021-01-13')
|
|
@@ -336,10 +342,10 @@ if __name__ == '__main__':
|
|
|
|
|
|
# dw_daily_channel()
|
|
|
# # exit(0)
|
|
|
- for i in dt.getDateLists('2019-03-18','2021-01-13'):
|
|
|
+ for i in dt.getDateLists('2019-09-18','2021-01-13'):
|
|
|
print(i)
|
|
|
- dw_channel_daily_total(i)
|
|
|
- # dw_daily_pitcher(i)
|
|
|
+ # dw_channel_daily_total(i)
|
|
|
+ dw_daily_pitcher(i)
|
|
|
# channel_by_account_daily(i)
|
|
|
# dw_daily_channel_cost(i)
|
|
|
# dw_order_channel_cost_sync_ck(i)
|