ck 4 년 전
부모
커밋
a6c04c580c
1개의 변경된 파일5개의 추가작업 그리고 7개의 파일을 삭제
  1. 5 7
      data_manage/pitcher_panel.py

+ 5 - 7
data_manage/pitcher_panel.py

@@ -468,9 +468,7 @@ def get_channel_order_trend(channel,pitcher,start,end,page,page_size,order_by,or
 
     channel_op =f" and channel='{channel}' " if channel!='' else ''
 
-
-    
-    sql=f"""select pitcher,'{channel}' channel,toString(dt) date,book,toDecimal32(cost,2),toDecimal32(reg_order_amount,2),roi,new_follow_user,new_follow_per_cost,order_user,order_count,
+    sql=f"""select pitcher,channel,toString(dt) date,book,toDecimal32(cost,2),toDecimal32(reg_order_amount,2),roi,new_follow_user,new_follow_per_cost,order_user,order_count,
        toDecimal32(order_user_per_cost,2),
        concat(toString(r1),',',toString(r1/cost),',', toString(a1/cost),',',toString(b1)),
        concat(toString(a2),',',toString(r2/cost),',', toString(a2/cost),',',toString(b2)),
@@ -537,7 +535,7 @@ concat(toString(a120),',',toString(r120/cost),',', toString(a120/cost),',',toStr
 concat(toString(a150),',',toString(r150/cost),',', toString(a150/cost),',',toString(b150))
 from
               (
-select pitcher,dt,book,cost,reg_order_amount,
+select pitcher,channel,dt,book,cost,reg_order_amount,
        if(cost=0,0,reg_order_amount/cost) roi,
        follow_user new_follow_user,
        if(follow_user=0,0,cost/follow_user) new_follow_per_cost,
@@ -546,7 +544,7 @@ select pitcher,dt,book,cost,reg_order_amount,
        from dw_daily_channel where dt>='{start}' and dt<='{end}' {channel_op} and pitcher='{pitcher}'  and cost>0) a
 
 left outer join (
-select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,
+select toDate(formatDateTime(reg_time,'%Y-%m-%d')) dt,channel,
        sum(if(toDate(formatDateTime(reg_time,'%Y-%m-%d'))=date,amount,0)) as r1,
        sum(if(addDays(toDate(formatDateTime(reg_time,'%Y-%m-%d')),1)>=date,amount,0)) as r2,
        sum(if(addDays(toDate(formatDateTime(reg_time,'%Y-%m-%d')),2)>=date,amount,0)) as r3,
@@ -673,8 +671,8 @@ r60-r59 a60,if(r1=0,0,r60/r1) b60,
 r90-r60 a90,if(r1=0,0,r90/r1) b90,
 r120-r90 a120,if(r1=0,0,r120/r1) b120,
 r150-r120 a150,if(r1=0,0,r150/r1) b150
-from order where  dt>='{start}' {channel_op}  group by formatDateTime(reg_time,'%Y-%m-%d')
-    ) b on a.dt=b.dt
+from order where  dt>='{start}' {channel_op}  group by formatDateTime(reg_time,'%Y-%m-%d'),channel
+    ) b on a.dt=b.dt and a.channel=b.channel
 """
     print(sql)
     if start==end: