| 
					
				 | 
			
			
				@@ -31,14 +31,13 @@ from 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         require_roi,require_mult from dw_daily_channel_cost) a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-left outer join 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+full  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 where status=2    group by date,channel) d 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         on dt=dt4 and channel=channel4 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-left outer join ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+left join ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     select sum(if(user_order_count>=2,1,0)) reg_order_user_again,channel channel6,toDate(reg_date) dt6,  ---复冲人数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sum(if(user_order_count>=3,1,0)) reg_order_user_again3, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sum(if(user_order_count>=4,1,0)) reg_order_user_again4, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -48,7 +47,7 @@ left outer join ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+left join 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        select toDate(formatDateTime(reg_time,'%Y-%m-%d')) as dt2,    ---新用户累计充值数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    channel as channel2, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -57,13 +56,13 @@ left outer join 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    count(1) as reg_order_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    left outer join 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+left 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 status=2 and toDate(reg_time)=date  group by date,channel) c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     on dt=dt3 and channel=channel3     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    having order_amount+cost+reg_order_amount>0""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    having order_amount+cost+reg_order_amount>0 '""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     data=ck.execute(sql) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     isql="insert into dw_channel 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)" 
			 |