|
@@ -470,7 +470,11 @@ def get_channel_order_trend(user_id, channel, pitcher, start, end, page, page_si
|
|
op = f" and channel in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
op = f" and channel in {str(UserAuthUtils.get_auth_channel(user_id))}"
|
|
|
|
|
|
op1 = f" and pitcher ='{pitcher}' " if pitcher else ''
|
|
op1 = f" and pitcher ='{pitcher}' " if pitcher else ''
|
|
- if channel and len(channel) > 1:
|
|
|
|
|
|
+ if not channel:
|
|
|
|
+ op2 = ''
|
|
|
|
+ elif type(channel) is str:
|
|
|
|
+ op2 = f" and channel='{channel}'" if channel else ''
|
|
|
|
+ elif len(channel) > 1:
|
|
op2 = f" and channel in {str(tuple(channel))}"
|
|
op2 = f" and channel in {str(tuple(channel))}"
|
|
else:
|
|
else:
|
|
op2 = f" and channel='{channel[0]}'" if channel else ''
|
|
op2 = f" and channel='{channel[0]}'" if channel else ''
|
|
@@ -478,101 +482,13 @@ def get_channel_order_trend(user_id, channel, pitcher, start, end, page, page_si
|
|
op4 = f" and dt<='{end}' " if end else ''
|
|
op4 = f" and dt<='{end}' " if end else ''
|
|
op5 = f" order by {order_by} {order}" if order_by and order else ''
|
|
op5 = f" order by {order_by} {order}" if order_by and order else ''
|
|
|
|
|
|
- base_sql_multi_channel = f'''
|
|
|
|
- ( select a.dt,group_concat(a.channel) channel ,group_concat(a.pitcher ) pitcher ,
|
|
|
|
- group_concat(a.stage ) stage ,group_concat(a.platform) platform ,
|
|
|
|
- group_concat(a.book) book, group_concat(a.type) type,sum(a.order_count ) order_count ,
|
|
|
|
- sum(a.order_user ) order_user ,sum(a.order_amount ) order_amount ,
|
|
|
|
- sum(a.reg_order_amount) reg_order_amount,
|
|
|
|
- sum(a.first_order_amount ) first_order_amount ,sum(a.view_count) view_count,
|
|
|
|
- sum(a.click_count) click_count ,sum(a.follow_user) follow_user ,
|
|
|
|
- sum(a.cost) cost,sum(a.reg_order_count) reg_order_count,
|
|
|
|
- sum(a.reg_order_user) reg_order_user ,sum(a.web_view_count) web_view_count ,
|
|
|
|
- sum(a.platform_view_count) platform_view_count ,sum(a.web_order_count ) web_order_count ,
|
|
|
|
- sum(a.reg_order_user_again) reg_order_user_again ,sum(a.reg_order_user_again3 ) reg_order_user_again3 ,
|
|
|
|
- sum(a.reg_order_user_again4) reg_order_user_again4,sum(a.reg_order_user_again5) reg_order_user_again5,
|
|
|
|
- sum(a.reg_order_user_again6) reg_order_user_again6,sum(b.da1) as da1,
|
|
|
|
- sum(b.da2) as da2,
|
|
|
|
- sum(b.da3) as da3,
|
|
|
|
- sum(b.da4) as da4,
|
|
|
|
- sum(b.da5) as da5,
|
|
|
|
- sum(b.da6) as da6,
|
|
|
|
- sum(b.da7) as da7,
|
|
|
|
- sum(b.da8) as da8,
|
|
|
|
- sum(b.da9) as da9,
|
|
|
|
- sum(b.da10) as da10,
|
|
|
|
- sum(b.da11) as da11,
|
|
|
|
- sum(b.da12) as da12,
|
|
|
|
- sum(b.da13) as da13,
|
|
|
|
- sum(b.da14) as da14,
|
|
|
|
- sum(b.da15) as da15,
|
|
|
|
- sum(b.da16) as da16,
|
|
|
|
- sum(b.da17) as da17,
|
|
|
|
- sum(b.da18) as da18,
|
|
|
|
- sum(b.da19) as da19,
|
|
|
|
- sum(b.da20) as da20,
|
|
|
|
- sum(b.da21) as da21,
|
|
|
|
- sum(b.da22) as da22,
|
|
|
|
- sum(b.da23) as da23,
|
|
|
|
- sum(b.da24) as da24,
|
|
|
|
- sum(b.da25) as da25,
|
|
|
|
- sum(b.da26) as da26,
|
|
|
|
- sum(b.da27) as da27,
|
|
|
|
- sum(b.da28) as da28,
|
|
|
|
- sum(b.da29) as da29,
|
|
|
|
- sum(b.da30) as da30,
|
|
|
|
- sum(b.da31) as da31,
|
|
|
|
- sum(b.da32) as da32,
|
|
|
|
- sum(b.da33) as da33,
|
|
|
|
- sum(b.da34) as da34,
|
|
|
|
- sum(b.da35) as da35,
|
|
|
|
- sum(b.da36) as da36,
|
|
|
|
- sum(b.da37) as da37,
|
|
|
|
- sum(b.da38) as da38,
|
|
|
|
- sum(b.da39) as da39,
|
|
|
|
- sum(b.da40) as da40,
|
|
|
|
- sum(b.da41) as da41,
|
|
|
|
- sum(b.da42) as da42,
|
|
|
|
- sum(b.da43) as da43,
|
|
|
|
- sum(b.da44) as da44,
|
|
|
|
- sum(b.da45) as da45,
|
|
|
|
- sum(b.da46) as da46,
|
|
|
|
- sum(b.da47) as da47,
|
|
|
|
- sum(b.da48) as da48,
|
|
|
|
- sum(b.da49) as da49,
|
|
|
|
- sum(b.da50) as da50,
|
|
|
|
- sum(b.da51) as da51,
|
|
|
|
- sum(b.da52) as da52,
|
|
|
|
- sum(b.da53) as da53,
|
|
|
|
- sum(b.da54) as da54,
|
|
|
|
- sum(b.da55) as da55,
|
|
|
|
- sum(b.da56) as da56,
|
|
|
|
- sum(b.da57) as da57,
|
|
|
|
- sum(b.da58) as da58,
|
|
|
|
- sum(b.da59) as da59,
|
|
|
|
- sum(b.da60) as da60,
|
|
|
|
- sum(b.dm3) as dm3,
|
|
|
|
- sum(b.dm4) as dm4,
|
|
|
|
- sum(b.dm5) as dm5,
|
|
|
|
- sum(c.node) as node,
|
|
|
|
- group_concat(annual_mult) as annual_mult
|
|
|
|
- from
|
|
|
|
- ( select * from dw_channel where cost+reg_order_amount>0
|
|
|
|
- {op} {op1} {op2} {op3} {op4} ) a
|
|
|
|
- left join dw_channel_amount_daily b on a.channel=b.channel
|
|
|
|
- and a.dt=b.dt
|
|
|
|
- left join src_book_info c on a.dt=c.dt and a.book=c.book
|
|
|
|
- and a.type=c.type and a.platform=c.platform
|
|
|
|
- group by a.dt ) a
|
|
|
|
- '''
|
|
|
|
|
|
|
|
- base_sql_singel_channel = f'''
|
|
|
|
|
|
+ base_sql = f'''
|
|
( select * from dw_channel where cost+reg_order_amount>0 {op} {op1} {op2} {op3} {op4} ) a
|
|
( select * from dw_channel where cost+reg_order_amount>0 {op} {op1} {op2} {op3} {op4} ) a
|
|
left join dw_channel_amount_daily b on a.channel=b.channel and a.dt=b.dt
|
|
left join dw_channel_amount_daily b on a.channel=b.channel and a.dt=b.dt
|
|
left join src_book_info c on a.dt=c.dt and a.book=c.book and a.type=c.type and a.platform=c.platform
|
|
left join src_book_info c on a.dt=c.dt and a.book=c.book and a.type=c.type and a.platform=c.platform
|
|
'''
|
|
'''
|
|
|
|
|
|
- base_sql = base_sql_multi_channel if channel and len(channel) > 1 else base_sql_singel_channel
|
|
|
|
|
|
|
|
sql = f"""select row_number() over() as id,
|
|
sql = f"""select row_number() over() as id,
|
|
stage,pitcher,a.channel,a.dt date,a.book,cost,
|
|
stage,pitcher,a.channel,a.dt date,a.book,cost,
|