| 
					
				 | 
			
			
				@@ -9,64 +9,6 @@ ck = CkUtils() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 dt = DateUtils() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def dw_daily_bytedance_cost(ymd): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    logging.info(f'dw_daily_bytedance_cost 数据填充开始') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    sql = ''' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    select x.dt,x.channel,pitcher,stage,x.platform,x.book, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               ifnull(view_count,0),ifnull(click_count,0), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               ifnull(follow_user,0),ifnull(cost,0)/100 as cost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               ifnull(web_view_count,0) web_view_count, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               ifnull(platform_view_count,0) platform_view_count, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               ifnull(web_order_count,0) web_order_count, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               'BYTEDANCE' type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ,0 require_roi,0 require_mult 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                 from 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ( select dt, channel,stage,pitcher,platform,book  from channel_info_daily cid  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            where dt='{0}' and channel !='' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            and channel in  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            (select distinct(channel) from channel_by_account_daily cbad  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            where dt='{0}' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            and type ='BYTEDANCE'  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ) x  -- 只允许渠道MP、GDT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        (select channel,sum(cost) as cost,sum(view_count) as view_count,sum(valid_click_count) as click_count,sum(from_follow_uv)  as follow_user, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         sum(web_view_count) as web_view_count,sum(platform_view_count) as platform_view_count,sum(web_order_count) as web_order_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         from 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            (select account_id,cost,view_count,valid_click_count,round(valid_click_count*official_account_follow_rate,0) as from_follow_uv, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            0 as  web_view_count, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            0 as platform_view_count, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            0 as web_order_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-             from daily_tt where date='{0} 00:00:00' ) a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        (select account_id,channel from channel_by_account_daily where dt='{0}') b  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         on a.account_id=b.account_id  group by channel)  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        z on x.channel=z.channel   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        '''.format(ymd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data = db.quchen_text.get_data_list(sql) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data1 = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    col = "dt,channel,pitcher,stage,platform,book,view_count,click_count,follow_user,cost,web_view_count,platform_view_count,web_order_count,type,require_roi,require_mult" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for i in data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[0] = str(i[0]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[9] = str(i[9]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[6] = float(i[6]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[7] = float(i[7]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[8] = float(i[8]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[9] = float(i[9]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[10] = float(i[10]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[11] = float(i[11]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        i[12] = float(i[12]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        data1.append(tuple(i)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ck.execute(f"alter table dw_daily_bytedance_cost drop  partition '{ymd}' ") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    logging.info(len(data1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ck.insertMany("dw_daily_bytedance_cost", col, tuple(data1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    logging.info(f'dw_daily_bytedance_cost 数据填充结束') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def platform_data_sum(ymd): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     logging.info('dw_daily_platform_cost开始数据更新') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ck.execute("alter table game_data.dw_daily_platform_cost drop  partition '{}' ".format(ymd)) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -155,7 +97,7 @@ def dw_daily_channel_cost(ymd): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join db_mp.mp_mp_conf e on d.advertiser_conf_id =e.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join quchen_text.advertiser_vx f on e.mp_id = f.wechat_account_id  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         where f.name is not null  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        and a.create_time > {timestamp_ymd} and a.create_time < {timestamp_tom} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        and c.create_time > {timestamp_ymd} and c.create_time < {timestamp_tom} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         group by f.name,wx_date 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         order by wx_date desc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ) w on x.channel= w.channel 
			 |