|
@@ -55,7 +55,7 @@ trust_campaign_num,
|
|
trust_unit_num
|
|
trust_unit_num
|
|
)
|
|
)
|
|
select * from (
|
|
select * from (
|
|
-select
|
|
|
|
|
|
+select
|
|
{date_time} stat_date,
|
|
{date_time} stat_date,
|
|
t1.account_id,
|
|
t1.account_id,
|
|
bei.account_name,
|
|
bei.account_name,
|
|
@@ -83,34 +83,41 @@ ifnull(t4.new_eff_material,0) as new_effect_num,
|
|
ifnull(t5.new_hot_material,0) as new_hot_num,
|
|
ifnull(t5.new_hot_material,0) as new_hot_num,
|
|
t1.put_campaign_num,
|
|
t1.put_campaign_num,
|
|
t1.put_unit_num,
|
|
t1.put_unit_num,
|
|
-t1.trust_campaign_num,
|
|
|
|
-t1.trust_unit_num
|
|
|
|
|
|
+trush_cam_num,
|
|
|
|
+trust_unit_num
|
|
from (select * from `application`.`app_kuaishou_account_base_info_d` where stat_date= date_sub({date_time}, INTERVAL 1 DAY)) t1
|
|
from (select * from `application`.`app_kuaishou_account_base_info_d` where stat_date= date_sub({date_time}, INTERVAL 1 DAY)) t1
|
|
-left join
|
|
|
|
|
|
+left join
|
|
(select advertiser_id account_id,count(distinct campaign_id) cam_num ,count(unit_id) unit_num from `media_api`.kuaishou_ad_unit_list where date_format(create_time,'%Y%m%d')={date_time}
|
|
(select advertiser_id account_id,count(distinct campaign_id) cam_num ,count(unit_id) unit_num from `media_api`.kuaishou_ad_unit_list where date_format(create_time,'%Y%m%d')={date_time}
|
|
group by advertiser_id) t2
|
|
group by advertiser_id) t2
|
|
on t1.account_id=t2.account_id
|
|
on t1.account_id=t2.account_id
|
|
-left join
|
|
|
|
-(select account_id,count(distinct signature) day_num from `media_api`.kuaishou_video_list
|
|
|
|
|
|
+left join
|
|
|
|
+(select account_id,count(distinct signature) day_num from `media_api`.kuaishou_video_list
|
|
where date_format(stat_date,'%Y%m%d')={date_time} group by account_id) t3
|
|
where date_format(stat_date,'%Y%m%d')={date_time} group by account_id) t3
|
|
on t1.account_id=t3.account_id
|
|
on t1.account_id=t3.account_id
|
|
-left join
|
|
|
|
-(select t2.account_id,count(distinct t1.material_id) new_eff_material from
|
|
|
|
|
|
+left join
|
|
|
|
+(select t2.account_id,count(distinct t1.material_id) new_eff_material from
|
|
(select material_id from application.app_kuaishou_material_info where effect_date={date_time}) t1
|
|
(select material_id from application.app_kuaishou_material_info where effect_date={date_time}) t1
|
|
-inner join
|
|
|
|
|
|
+inner join
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')>=
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')>=
|
|
date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
on t1.material_id=t2.signature group by t2.account_id) t4
|
|
on t1.material_id=t2.signature group by t2.account_id) t4
|
|
on t1.account_id=t4.account_id
|
|
on t1.account_id=t4.account_id
|
|
-left join
|
|
|
|
-(select t2.account_id,count(distinct t1.material_id) new_hot_material from
|
|
|
|
|
|
+left join
|
|
|
|
+(select t2.account_id,count(distinct t1.material_id) new_hot_material from
|
|
(select material_id from application.app_kuaishou_material_info where faddish_date={date_time}) t1
|
|
(select material_id from application.app_kuaishou_material_info where faddish_date={date_time}) t1
|
|
-inner join
|
|
|
|
|
|
+inner join
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')>=
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')>=
|
|
date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
on t1.material_id=t2.signature group by t2.account_id) t5
|
|
on t1.material_id=t2.signature group by t2.account_id) t5
|
|
on t1.account_id=t5.account_id
|
|
on t1.account_id=t5.account_id
|
|
-left join
|
|
|
|
|
|
+ left join
|
|
|
|
+(
|
|
|
|
+ select advertiser_id account_id,count(unit_id) trush_unit_num, count(distinct campaign_id) trush_cam_num from `media_api`.kuaishou_ad_unit_list where date_format(create_time,'%Y%m%d')={date_time}
|
|
|
|
+ and unit_source=1
|
|
|
|
+group by advertiser_id
|
|
|
|
+ )trush
|
|
|
|
+ on t1.account_id=trush.account_id
|
|
|
|
+left join
|
|
(
|
|
(
|
|
SELECT
|
|
SELECT
|
|
cua.account_id id,
|
|
cua.account_id id,
|
|
@@ -137,7 +144,7 @@ FROM
|
|
LEFT JOIN `jeecg-boot`.ctop_project cp ON cua.project_id = cp.id
|
|
LEFT JOIN `jeecg-boot`.ctop_project cp ON cua.project_id = cp.id
|
|
LEFT JOIN `jeecg-boot`.ctop_advertiser ca ON ca.id = cua.advertiser_id
|
|
LEFT JOIN `jeecg-boot`.ctop_advertiser ca ON ca.id = cua.advertiser_id
|
|
LEFT JOIN `jeecg-boot`.sys_user su ON su.id = cua.user_id
|
|
LEFT JOIN `jeecg-boot`.sys_user su ON su.id = cua.user_id
|
|
-LEFT JOIN `jeecg-boot`.sys_user lea ON lea.id = su.leader_id
|
|
|
|
|
|
+LEFT JOIN `jeecg-boot`.sys_user lea ON lea.id = su.leader_id
|
|
LEFT JOIN `jeecg-boot`.user_company uc ON uc.user_id = cua.user_id
|
|
LEFT JOIN `jeecg-boot`.user_company uc ON uc.user_id = cua.user_id
|
|
LEFT JOIN `jeecg-boot`.ctop_product product ON product.id = cp.product_id
|
|
LEFT JOIN `jeecg-boot`.ctop_product product ON product.id = cp.product_id
|
|
LEFT JOIN `jeecg-boot`.sys_user_depart dep ON cua.user_id=dep.user_id
|
|
LEFT JOIN `jeecg-boot`.sys_user_depart dep ON cua.user_id=dep.user_id
|
|
@@ -147,7 +154,7 @@ cua.account_id IS NOT NULL and cua.account_status=0 and cua.media_id=2
|
|
) bei
|
|
) bei
|
|
ON t1.account_id = bei.account_id where bei.account_id is not null
|
|
ON t1.account_id = bei.account_id where bei.account_id is not null
|
|
union all
|
|
union all
|
|
-select
|
|
|
|
|
|
+select
|
|
{date_time} stat_date,
|
|
{date_time} stat_date,
|
|
t1.account_id,
|
|
t1.account_id,
|
|
bei.account_name,
|
|
bei.account_name,
|
|
@@ -175,38 +182,45 @@ ifnull(t5.new_hot_material,0) as hot_num,
|
|
ifnull(t5.new_hot_material,0) as new_hot_num,
|
|
ifnull(t5.new_hot_material,0) as new_hot_num,
|
|
0 put_campaign_num,
|
|
0 put_campaign_num,
|
|
0 put_unit_num,
|
|
0 put_unit_num,
|
|
-0 trust_campaign_num,
|
|
|
|
-0 trust_unit_num
|
|
|
|
-from
|
|
|
|
|
|
+ trush_cam_num,
|
|
|
|
+ trush_unit_num
|
|
|
|
+from
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')={date_time}) t1
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')={date_time}) t1
|
|
-left join
|
|
|
|
|
|
+left join
|
|
(select * from `application`.`app_kuaishou_account_base_info_d` where stat_date= date_sub({date_time}, INTERVAL 1 DAY)) tt
|
|
(select * from `application`.`app_kuaishou_account_base_info_d` where stat_date= date_sub({date_time}, INTERVAL 1 DAY)) tt
|
|
on t1.account_id=tt.account_id
|
|
on t1.account_id=tt.account_id
|
|
-left join
|
|
|
|
|
|
+left join
|
|
(select advertiser_id account_id,count(distinct campaign_id) cam_num ,count(unit_id) unit_num from `media_api`.kuaishou_ad_unit_list where date_format(create_time,'%Y%m%d')={date_time}
|
|
(select advertiser_id account_id,count(distinct campaign_id) cam_num ,count(unit_id) unit_num from `media_api`.kuaishou_ad_unit_list where date_format(create_time,'%Y%m%d')={date_time}
|
|
group by advertiser_id) t2
|
|
group by advertiser_id) t2
|
|
on t1.account_id=t2.account_id
|
|
on t1.account_id=t2.account_id
|
|
-left join
|
|
|
|
-(select account_id,count(distinct signature) day_num from `media_api`.kuaishou_video_list
|
|
|
|
|
|
+left join
|
|
|
|
+(select account_id,count(distinct signature) day_num from `media_api`.kuaishou_video_list
|
|
where date_format(stat_date,'%Y%m%d')={date_time} group by account_id) t3
|
|
where date_format(stat_date,'%Y%m%d')={date_time} group by account_id) t3
|
|
on t1.account_id=t3.account_id
|
|
on t1.account_id=t3.account_id
|
|
-left join
|
|
|
|
-(select t2.account_id,count(distinct t1.material_id) new_eff_material from
|
|
|
|
|
|
+left join
|
|
|
|
+(select t2.account_id,count(distinct t1.material_id) new_eff_material from
|
|
(select material_id from application.app_kuaishou_material_info where effect_date={date_time}) t1
|
|
(select material_id from application.app_kuaishou_material_info where effect_date={date_time}) t1
|
|
-inner join
|
|
|
|
|
|
+inner join
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')>=
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')>=
|
|
date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
on t1.material_id=t2.signature group by t2.account_id) t4
|
|
on t1.material_id=t2.signature group by t2.account_id) t4
|
|
on t1.account_id=t4.account_id
|
|
on t1.account_id=t4.account_id
|
|
-left join
|
|
|
|
-(select t2.account_id,count(distinct t1.material_id) new_hot_material from
|
|
|
|
|
|
+left join
|
|
|
|
+(select t2.account_id,count(distinct t1.material_id) new_hot_material from
|
|
(select material_id from application.app_kuaishou_material_info where faddish_date={date_time}) t1
|
|
(select material_id from application.app_kuaishou_material_info where faddish_date={date_time}) t1
|
|
-inner join
|
|
|
|
|
|
+inner join
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')>=
|
|
(select distinct account_id,signature from `media_api`.kuaishou_video_list where date_format(stat_date,'%Y%m%d')>=
|
|
date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
date_sub({date_time},INTERVAL 29 DAY)) t2
|
|
on t1.material_id=t2.signature group by t2.account_id) t5
|
|
on t1.material_id=t2.signature group by t2.account_id) t5
|
|
on t1.account_id=t5.account_id
|
|
on t1.account_id=t5.account_id
|
|
-left join
|
|
|
|
|
|
+left join
|
|
|
|
+(
|
|
|
|
+ select advertiser_id account_id,count(unit_id) trush_unit_num, count(distinct campaign_id) trush_cam_num from `media_api`.kuaishou_ad_unit_list where date_format(create_time,'%Y%m%d')={date_time}
|
|
|
|
+ and unit_source=1
|
|
|
|
+group by advertiser_id
|
|
|
|
+ )trush
|
|
|
|
+ on t1.account_id=trush.account_id
|
|
|
|
+left join
|
|
(
|
|
(
|
|
SELECT
|
|
SELECT
|
|
cua.account_id id,
|
|
cua.account_id id,
|
|
@@ -233,7 +247,7 @@ FROM
|
|
LEFT JOIN `jeecg-boot`.ctop_project cp ON cua.project_id = cp.id
|
|
LEFT JOIN `jeecg-boot`.ctop_project cp ON cua.project_id = cp.id
|
|
LEFT JOIN `jeecg-boot`.ctop_advertiser ca ON ca.id = cua.advertiser_id
|
|
LEFT JOIN `jeecg-boot`.ctop_advertiser ca ON ca.id = cua.advertiser_id
|
|
LEFT JOIN `jeecg-boot`.sys_user su ON su.id = cua.user_id
|
|
LEFT JOIN `jeecg-boot`.sys_user su ON su.id = cua.user_id
|
|
-LEFT JOIN `jeecg-boot`.sys_user lea ON lea.id = su.leader_id
|
|
|
|
|
|
+LEFT JOIN `jeecg-boot`.sys_user lea ON lea.id = su.leader_id
|
|
LEFT JOIN `jeecg-boot`.user_company uc ON uc.user_id = cua.user_id
|
|
LEFT JOIN `jeecg-boot`.user_company uc ON uc.user_id = cua.user_id
|
|
LEFT JOIN `jeecg-boot`.ctop_product product ON product.id = cp.product_id
|
|
LEFT JOIN `jeecg-boot`.ctop_product product ON product.id = cp.product_id
|
|
LEFT JOIN `jeecg-boot`.sys_user_depart dep ON cua.user_id=dep.user_id
|
|
LEFT JOIN `jeecg-boot`.sys_user_depart dep ON cua.user_id=dep.user_id
|
|
@@ -242,6 +256,7 @@ WHERE
|
|
cua.account_id IS NOT NULL and cua.account_status=0 and cua.media_id=2
|
|
cua.account_id IS NOT NULL and cua.account_status=0 and cua.media_id=2
|
|
) bei
|
|
) bei
|
|
ON t1.account_id = bei.account_id where tt.account_id is null and bei.account_id is not null) m;
|
|
ON t1.account_id = bei.account_id where tt.account_id is null and bei.account_id is not null) m;
|
|
|
|
+
|
|
""".format(date_time=self.date_time)
|
|
""".format(date_time=self.date_time)
|
|
TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
self.conn.commit()
|
|
self.conn.commit()
|