|
@@ -24,28 +24,168 @@ class AppKuaishouCompanyDesignReportBusi:
|
|
SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
|
|
SET sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
|
|
REPLACE INTO application.app_kuaishou_company_design_report_busi_{day_count}d
|
|
REPLACE INTO application.app_kuaishou_company_design_report_busi_{day_count}d
|
|
select
|
|
select
|
|
-concat(date_format(date_sub({date_time}, INTERVAL ({day_count} -1 ) DAY),'%Y%m%d'),'-',{date_time}) start_end_time,
|
|
|
|
-ifnull(company_id,'-') company_id,
|
|
|
|
-company_name,
|
|
|
|
-org_code,
|
|
|
|
-org_type,
|
|
|
|
-id,
|
|
|
|
-depart_name,
|
|
|
|
-ifnull(leader_id,'-') leader_id,
|
|
|
|
-leader_name,
|
|
|
|
-count(DISTINCT signature) num,
|
|
|
|
-count(distinct innovate_code) innovate_num,
|
|
|
|
-sum(charge) charge,
|
|
|
|
|
|
+new.start_end_time,
|
|
|
|
+ifnull(new.company_id,'-') company_id,
|
|
|
|
+new.company_name,
|
|
|
|
+new.org_code,
|
|
|
|
+new.org_type,
|
|
|
|
+new.dep_id,
|
|
|
|
+new.dep_name,
|
|
|
|
+ifnull(new.leader_id,'-') leader_id,
|
|
|
|
+new.leader_name,
|
|
|
|
+new.material_count,
|
|
|
|
+new.innovate_num,
|
|
|
|
+new.charge,
|
|
|
|
+ifnull(ratio.charge,0) last_charge,
|
|
|
|
+ifnull(round((new.charge-ratio.charge)/ratio.charge*100,3),0) charge_ratio,
|
|
|
|
+new.show ,
|
|
|
|
+new.photo_click,
|
|
|
|
+new.aclick,
|
|
|
|
+new.bclick,
|
|
|
|
+new.photo_click_ratio,
|
|
|
|
+new.play_3s_ratio ,
|
|
|
|
+new.action_ratio,
|
|
|
|
+new.impression_1k_cost,
|
|
|
|
+new.photo_click_cost ,
|
|
|
|
+new.action_cost,
|
|
|
|
+new.share,
|
|
|
|
+new.comment ,
|
|
|
|
+new.like ,
|
|
|
|
+new.follow,
|
|
|
|
+new.cancel_follow ,
|
|
|
|
+new.report,
|
|
|
|
+new.block,
|
|
|
|
+new.negative,
|
|
|
|
+new.submit,
|
|
|
|
+new.download_started ,
|
|
|
|
+new.download_completed,
|
|
|
|
+new.activation ,
|
|
|
|
+new.event_pay_first_day ,
|
|
|
|
+new.event_pay_purchase_amount_first_day,
|
|
|
|
+new.event_pay_first_day_roi,
|
|
|
|
+new.event_pay,
|
|
|
|
+new.event_pay_purchase_amount ,
|
|
|
|
+new.event_pay_roi ,
|
|
|
|
+new.event_register,
|
|
|
|
+new.event_register_cost ,
|
|
|
|
+new.event_register_ratio,
|
|
|
|
+new.event_jin_jian_app,
|
|
|
|
+new.event_jin_jian_app_cost,
|
|
|
|
+new.event_credit_grant_app ,
|
|
|
|
+new.event_credit_grant_app_cost,
|
|
|
|
+new.event_credit_grant_app_ratio ,
|
|
|
|
+new.event_order_paid ,
|
|
|
|
+new.event_order_paid_purchase_amount,
|
|
|
|
+new.event_order_paid_cost,
|
|
|
|
+new.event_next_day_stay ,
|
|
|
|
+new.event_next_day_stay_cost,
|
|
|
|
+new.event_next_day_stay_ratio ,
|
|
|
|
+new.form_count ,
|
|
|
|
+new.form_cost,
|
|
|
|
+new.form_action_ratio,
|
|
|
|
+new.event_jin_jian_landing_page,
|
|
|
|
+new.event_jin_jian_landing_page_cost,
|
|
|
|
+new.event_credit_grant_landing_page ,
|
|
|
|
+new.event_credit_grant_landing_page_cost,
|
|
|
|
+new.event_credit_grant_landing_page_ratio ,
|
|
|
|
+new.event_valid_clues,
|
|
|
|
+new.event_valid_clues_cost ,
|
|
|
|
+new.event_add_wechat ,
|
|
|
|
+new.event_add_wechat_cost,
|
|
|
|
+new.event_add_wechat_ratio ,
|
|
|
|
+new.event_get_through,
|
|
|
|
+new.event_get_through_cost ,
|
|
|
|
+new.event_get_through_ratio,
|
|
|
|
+new.event_app_invoked,
|
|
|
|
+new.event_app_invoked_cost ,
|
|
|
|
+new.event_app_invoked_ratio,
|
|
|
|
+new.event_credit_grant_landing_ratio,
|
|
|
|
+new.play_5s_ratio ,
|
|
|
|
+new.play_end_ratio,
|
|
|
|
+new.event_new_user_pay,
|
|
|
|
+new.event_new_user_pay_cost,
|
|
|
|
+new.event_new_user_pay_ratio,
|
|
|
|
+new.click_1k_cost ,
|
|
|
|
+new.ad_product_cnt,
|
|
|
|
+new.event_goods_view ,
|
|
|
|
+new.merchant_reco_fans,
|
|
|
|
+new.event_order_amount_roi ,
|
|
|
|
+new.event_goods_view_cost,
|
|
|
|
+new.merchant_reco_fans_cost,
|
|
|
|
+new.event_button_click,
|
|
|
|
+new.event_button_click_cost,
|
|
|
|
+new.event_button_click_ratio,
|
|
|
|
+new.event_order_paid_roi,
|
|
|
|
+new.event_new_user_jinjian_app,
|
|
|
|
+new.event_new_user_jinjian_app_cost ,
|
|
|
|
+new.event_new_user_jinjian_app_roi,
|
|
|
|
+new.event_new_user_credit_grant_app ,
|
|
|
|
+new.event_new_user_credit_grant_app_cost,
|
|
|
|
+new.event_new_user_credit_grant_app_roi,
|
|
|
|
+new.event_new_user_jinjian_page,
|
|
|
|
+new.event_new_user_jinjian_page_cost,
|
|
|
|
+new.event_new_user_jinjian_page_roi ,
|
|
|
|
+new.event_new_user_credit_grant_page,
|
|
|
|
+new.event_new_user_credit_grant_page_cost ,
|
|
|
|
+new.event_new_user_credit_grant_page_roi,
|
|
|
|
+new.event_appoint_form,
|
|
|
|
+new.event_appoint_form_cost,
|
|
|
|
+new.event_appoint_form_ratio,
|
|
|
|
+new.event_appoint_jump_click,
|
|
|
|
+new.event_appoint_jump_click_cost,
|
|
|
|
+new.event_appoint_jump_click_ratio,
|
|
|
|
+new.union_event_pay_purchase_amount_7d ,
|
|
|
|
+new.union_event_pay_purchase_amount_7d_roi,
|
|
|
|
+new.event_order_successed,
|
|
|
|
+new.ad_photo_played_10s_ratio ,
|
|
|
|
+new.key_action_cost,
|
|
|
|
+new.event_add_shopping_cart_cost ,
|
|
|
|
+new.event_ad_watch_times_ratio,
|
|
|
|
+new.event_outbound_call_cost,
|
|
|
|
+new.event_outbound_call ,
|
|
|
|
+new.action_new_ratio ,
|
|
|
|
+new.event_watch_app_ad,
|
|
|
|
+new.event_multi_conversion_cost,
|
|
|
|
+new.event_phone_card_activate ,
|
|
|
|
+new.ad_photo_played_75percent_ratio ,
|
|
|
|
+new.key_action_ratio ,
|
|
|
|
+new.event_ad_watch_times_cost ,
|
|
|
|
+new.event_add_shopping_cart,
|
|
|
|
+new.key_action ,
|
|
|
|
+new.event_multi_conversion ,
|
|
|
|
+new.event_wechat_connected ,
|
|
|
|
+new.event_dsp_gift_form ,
|
|
|
|
+new.event_intention_confirmed ,
|
|
|
|
+new.event_phone_get_through,
|
|
|
|
+new.event_multi_conversion_ratio ,
|
|
|
|
+new.event_measurement_house,
|
|
|
|
+new.ad_photo_played_2s_ratio,
|
|
|
|
+new.event_outbound_call_ratio ,
|
|
|
|
+new.event_ad_watch_times
|
|
|
|
+from
|
|
|
|
+(select
|
|
|
|
+ concat(date_format(date_sub({date_time}, INTERVAL {day_count}-1 DAY),'%Y%m%d'),'-',{date_time}) start_end_time,
|
|
|
|
+ company_id,
|
|
|
|
+ company_name,
|
|
|
|
+ org_code,
|
|
|
|
+ org_type,
|
|
|
|
+ id dep_id,
|
|
|
|
+ depart_name dep_name,
|
|
|
|
+ leader_id,
|
|
|
|
+ leader_name,
|
|
|
|
+ count(DISTINCT signature) material_count,
|
|
|
|
+ count(distinct innovate_code) innovate_num,
|
|
|
|
+ sum(charge) charge,
|
|
sum(`show`) `show`,
|
|
sum(`show`) `show`,
|
|
sum(photo_click)photo_click,
|
|
sum(photo_click)photo_click,
|
|
sum(aclick) aclick,
|
|
sum(aclick) aclick,
|
|
sum(bclick) bclick,
|
|
sum(bclick) bclick,
|
|
-ifnull(round(sum(photo_click)/sum(`show`),3),0) photo_click_ratio,
|
|
|
|
-ifnull(round(sum(play_3s_ratio)/{day_count}*100,3),0) play_3s_ratio,
|
|
|
|
-ifnull(round(sum(bclick)/sum(aclick)*100,3),0) action_ratio,
|
|
|
|
-ifnull(round(sum(impression_1k_cost)/{day_count},3),0) impression_1k_cost,
|
|
|
|
-ifnull(round(sum(charge)/sum(photo_click),3),0) photo_click_cost,
|
|
|
|
-ifnull(round(sum(charge)/sum(bclick),3),0) action_cost,
|
|
|
|
|
|
+round(sum(photo_click)/sum(`show`),3) photo_click_ratio,
|
|
|
|
+round(sum(play_3s_ratio)/{day_count}*100,3) play_3s_ratio,
|
|
|
|
+round(sum(bclick)/sum(aclick)*100,3) action_ratio,
|
|
|
|
+round(sum(impression_1k_cost)/{day_count},3) impression_1k_cost,
|
|
|
|
+round(sum(charge)/sum(photo_click),3) photo_click_cost,
|
|
|
|
+round(sum(charge)/sum(bclick),3) action_cost,
|
|
sum(`share`) `share`,
|
|
sum(`share`) `share`,
|
|
sum(`comment`) `comment`,
|
|
sum(`comment`) `comment`,
|
|
sum(`like`) `like`,
|
|
sum(`like`) `like`,
|
|
@@ -60,94 +200,94 @@ sum(download_completed) download_completed,
|
|
sum(activation) activation,
|
|
sum(activation) activation,
|
|
sum(event_pay_first_day) event_pay_first_day,
|
|
sum(event_pay_first_day) event_pay_first_day,
|
|
sum(event_pay_purchase_amount_first_day) event_pay_purchase_amount_first_day,
|
|
sum(event_pay_purchase_amount_first_day) event_pay_purchase_amount_first_day,
|
|
-ifnull(round(sum(event_pay_purchase_amount_first_day)/sum(charge)*100,3),0) event_pay_first_day_roi ,
|
|
|
|
|
|
+round(sum(event_pay_purchase_amount_first_day)/sum(charge)*100,3) event_pay_first_day_roi ,
|
|
sum(event_pay) event_pay,
|
|
sum(event_pay) event_pay,
|
|
sum(event_pay_purchase_amount) event_pay_purchase_amount,
|
|
sum(event_pay_purchase_amount) event_pay_purchase_amount,
|
|
-ifnull(round(sum(event_pay_purchase_amount)/sum(charge)*100,3),0) event_pay_roi,
|
|
|
|
|
|
+round(sum(event_pay_purchase_amount)/sum(charge)*100,3) event_pay_roi,
|
|
sum(event_register) event_register,
|
|
sum(event_register) event_register,
|
|
-ifnull(round(sum(charge)/sum(event_register),3),0) event_register_cost,
|
|
|
|
-ifnull(round(sum(event_register)/sum(activation)*100,3),0) event_register_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_register),3) event_register_cost,
|
|
|
|
+round(sum(event_register)/sum(activation)*100,3) event_register_ratio,
|
|
sum(event_jin_jian_app) event_jin_jian_app,
|
|
sum(event_jin_jian_app) event_jin_jian_app,
|
|
-ifnull(round(sum(charge)/sum(event_jin_jian_app),3),0) event_jin_jian_app_cost,
|
|
|
|
|
|
+round(sum(charge)/sum(event_jin_jian_app),3) event_jin_jian_app_cost,
|
|
sum(event_credit_grant_app) event_credit_grant_app,
|
|
sum(event_credit_grant_app) event_credit_grant_app,
|
|
-ifnull(round(sum(charge)/sum(event_credit_grant_app),3),0) event_credit_grant_app_cost ,
|
|
|
|
-ifnull(round(sum(event_credit_grant_app_ratio)/{day_count}*100,3),0) event_credit_grant_app_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_credit_grant_app),3) event_credit_grant_app_cost ,
|
|
|
|
+round(sum(event_credit_grant_app_ratio)/{day_count}*100,3) event_credit_grant_app_ratio,
|
|
sum(event_order_paid) event_order_paid,
|
|
sum(event_order_paid) event_order_paid,
|
|
sum(event_order_paid_purchase_amount) event_order_paid_purchase_amount,
|
|
sum(event_order_paid_purchase_amount) event_order_paid_purchase_amount,
|
|
-ifnull(round(sum(event_order_paid_purchase_amount)/sum(event_order_paid) ,3),0) event_order_paid_cost,
|
|
|
|
|
|
+round(sum(event_order_paid_purchase_amount)/sum(event_order_paid) ,3) event_order_paid_cost,
|
|
sum(event_next_day_stay) event_next_day_stay,
|
|
sum(event_next_day_stay) event_next_day_stay,
|
|
-ifnull(round(sum(charge)/sum(event_next_day_stay),3),0) event_next_day_stay_cost,
|
|
|
|
-ifnull(round(sum(event_next_day_stay)/sum(activation)*100,3),0) event_next_day_stay_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_next_day_stay),3) event_next_day_stay_cost,
|
|
|
|
+round(sum(event_next_day_stay)/sum(activation)*100,3) event_next_day_stay_ratio,
|
|
sum(form_count) form_count,
|
|
sum(form_count) form_count,
|
|
-ifnull(round(sum(charge)/sum(form_count),3),0) form_cost,
|
|
|
|
-ifnull(round(sum(form_count)/sum(`bclick`)*100,3),0) form_action_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(form_count),3) form_cost,
|
|
|
|
+round(sum(form_count)/sum(`bclick`)*100,3) form_action_ratio,
|
|
sum(event_jin_jian_landing_page) event_jin_jian_landing_page,
|
|
sum(event_jin_jian_landing_page) event_jin_jian_landing_page,
|
|
-ifnull(round(sum(charge)/sum(event_jin_jian_landing_page),3),0) event_jin_jian_landing_page_cost,
|
|
|
|
|
|
+round(sum(charge)/sum(event_jin_jian_landing_page),3) event_jin_jian_landing_page_cost,
|
|
sum(event_credit_grant_landing_page) event_credit_grant_landing_page,
|
|
sum(event_credit_grant_landing_page) event_credit_grant_landing_page,
|
|
-ifnull(round(sum(charge)/sum(event_credit_grant_landing_page),3),0) event_credit_grant_landing_page_cost,
|
|
|
|
-ifnull(round(sum(event_credit_grant_landing_page)/{day_count}*100,3),0) event_credit_grant_landing_page_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_credit_grant_landing_page),3) event_credit_grant_landing_page_cost,
|
|
|
|
+round(sum(event_credit_grant_landing_page)/{day_count}*100,3) event_credit_grant_landing_page_ratio,
|
|
sum(event_valid_clues) event_valid_clues,
|
|
sum(event_valid_clues) event_valid_clues,
|
|
-ifnull(round(sum(charge)/sum(event_valid_clues),3),0) event_valid_clues_cost,
|
|
|
|
|
|
+round(sum(charge)/sum(event_valid_clues),3) event_valid_clues_cost,
|
|
sum(event_add_wechat) event_add_wechat,
|
|
sum(event_add_wechat) event_add_wechat,
|
|
-ifnull(round(sum(charge)/sum(event_add_wechat),3),0) event_add_wechat_cost,
|
|
|
|
-ifnull(round(sum(event_add_wechat)/sum(bclick)*100,3),0) event_add_wechat_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_add_wechat),3) event_add_wechat_cost,
|
|
|
|
+round(sum(event_add_wechat)/sum(bclick)*100,3) event_add_wechat_ratio,
|
|
sum(event_get_through) event_get_through,
|
|
sum(event_get_through) event_get_through,
|
|
-ifnull(round(sum(charge)/sum(event_get_through),3),0) event_get_through_cost,
|
|
|
|
-ifnull(round(sum(event_get_through)/sum(bclick)*100,3),0) event_get_through_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_get_through),3) event_get_through_cost,
|
|
|
|
+round(sum(event_get_through)/sum(bclick)*100,3) event_get_through_ratio,
|
|
sum(event_app_invoked) event_app_invoked,
|
|
sum(event_app_invoked) event_app_invoked,
|
|
-ifnull(round(sum(charge)/sum(event_app_invoked),3),0) event_app_invoked_cost ,
|
|
|
|
-ifnull(round(sum(event_app_invoked)/sum(bclick)*100,3),0) event_app_invoked_ratio,
|
|
|
|
-ifnull(round(sum(event_credit_grant_landing_ratio)/{day_count}*100,3),0) event_credit_grant_landing_ratio,
|
|
|
|
-ifnull(round(sum(play_5s_ratio)/{day_count}*100,3),0) play_5s_ratio,
|
|
|
|
-ifnull(round(sum(play_end_ratio)/{day_count}*100,3),0) play_end_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_app_invoked),3) event_app_invoked_cost ,
|
|
|
|
+round(sum(event_app_invoked)/sum(bclick)*100,3) event_app_invoked_ratio,
|
|
|
|
+round(sum(event_credit_grant_landing_ratio)/{day_count}*100,3) event_credit_grant_landing_ratio,
|
|
|
|
+round(sum(play_5s_ratio)/{day_count}*100,3) play_5s_ratio,
|
|
|
|
+round(sum(play_end_ratio)/{day_count}*100,3) play_end_ratio,
|
|
sum(event_new_user_pay) event_new_user_pay,
|
|
sum(event_new_user_pay) event_new_user_pay,
|
|
-ifnull(round(sum(charge)/sum(event_new_user_pay),3),0) event_new_user_pay_cost,
|
|
|
|
-ifnull(round(sum(event_new_user_pay)/sum(activation)*100,3),0) event_new_user_pay_ratio,
|
|
|
|
-ifnull(round(sum(click_1k_cost)/{day_count}*100,3),0) click_1k_cost,
|
|
|
|
|
|
+round(sum(charge)/sum(event_new_user_pay),3) event_new_user_pay_cost,
|
|
|
|
+round(sum(event_new_user_pay)/sum(activation)*100,3) event_new_user_pay_ratio,
|
|
|
|
+round(sum(click_1k_cost)/{day_count}*100) click_1k_cost,
|
|
sum(ad_product_cnt) ad_product_cnt,
|
|
sum(ad_product_cnt) ad_product_cnt,
|
|
sum(event_goods_view) event_goods_view,
|
|
sum(event_goods_view) event_goods_view,
|
|
sum(merchant_reco_fans) merchant_reco_fans,
|
|
sum(merchant_reco_fans) merchant_reco_fans,
|
|
-ifnull(round(sum(event_order_amount_roi)/{day_count}*100,3),0) event_order_amount_roi,
|
|
|
|
-ifnull(round(sum(charge)/sum(event_goods_view) ,3),0) event_goods_view_cost,
|
|
|
|
-ifnull(round(sum(charge)/sum(merchant_reco_fans),3),0) merchant_reco_fans_cost,
|
|
|
|
|
|
+round(sum(event_order_amount_roi)/{day_count}*100,3) event_order_amount_roi,
|
|
|
|
+round(sum(charge)/sum(event_goods_view) ,3) event_goods_view_cost,
|
|
|
|
+round(sum(charge)/sum(merchant_reco_fans),3) merchant_reco_fans_cost,
|
|
sum(event_button_click) event_button_click,
|
|
sum(event_button_click) event_button_click,
|
|
-ifnull(round(sum(charge)/sum(event_button_click),3),0) event_button_click_cost,
|
|
|
|
-ifnull(round(sum(event_button_click)/sum(bclick)*100,3),0) event_button_click_ratio ,
|
|
|
|
-ifnull(round(sum(event_order_paid_roi)/{day_count}*100,3),0) event_order_paid_roi,
|
|
|
|
|
|
+round(sum(charge)/sum(event_button_click),3) event_button_click_cost,
|
|
|
|
+round(sum(event_button_click)/sum(bclick)*100,3) event_button_click_ratio ,
|
|
|
|
+round(sum(event_order_paid_roi)/{day_count}*100,3) event_order_paid_roi,
|
|
sum(event_new_user_jinjian_app) event_new_user_jinjian_app,
|
|
sum(event_new_user_jinjian_app) event_new_user_jinjian_app,
|
|
-ifnull(round(sum(charge)/sum(event_new_user_jinjian_app),3),0) event_new_user_jinjian_app_cost,
|
|
|
|
-ifnull(round(sum(event_new_user_jinjian_app)/sum(form_count)*100,3),0) event_new_user_jinjian_app_roi ,
|
|
|
|
|
|
+round(sum(charge)/sum(event_new_user_jinjian_app),3) event_new_user_jinjian_app_cost,
|
|
|
|
+round(sum(event_new_user_jinjian_app)/sum(form_count)*100,3) event_new_user_jinjian_app_roi ,
|
|
sum(event_new_user_credit_grant_app) event_new_user_credit_grant_app,
|
|
sum(event_new_user_credit_grant_app) event_new_user_credit_grant_app,
|
|
-ifnull(round(sum(charge)/sum(event_new_user_credit_grant_app),3),0) event_new_user_credit_grant_app_cost,
|
|
|
|
-ifnull(round(sum(event_new_user_credit_grant_app)/sum(form_count)*100,3),0) event_new_user_credit_grant_app_roi,
|
|
|
|
|
|
+round(sum(charge)/sum(event_new_user_credit_grant_app),3) event_new_user_credit_grant_app_cost,
|
|
|
|
+round(sum(event_new_user_credit_grant_app)/sum(form_count)*100,3) event_new_user_credit_grant_app_roi,
|
|
sum(event_new_user_jinjian_page) event_new_user_jinjian_page,
|
|
sum(event_new_user_jinjian_page) event_new_user_jinjian_page,
|
|
-ifnull(round(sum(charge)/sum(event_new_user_jinjian_page),3),0) event_new_user_jinjian_page_cost,
|
|
|
|
-ifnull(round(sum(event_new_user_jinjian_page)/sum(form_count)*100,3),0) event_new_user_jinjian_page_roi ,
|
|
|
|
|
|
+round(sum(charge)/sum(event_new_user_jinjian_page),3) event_new_user_jinjian_page_cost,
|
|
|
|
+round(sum(event_new_user_jinjian_page)/sum(form_count)*100,3) event_new_user_jinjian_page_roi ,
|
|
sum(event_new_user_credit_grant_page) event_new_user_credit_grant_page,
|
|
sum(event_new_user_credit_grant_page) event_new_user_credit_grant_page,
|
|
-ifnull(round(sum(charge)/sum(event_new_user_credit_grant_page) ,3),0) event_new_user_credit_grant_page_cost,
|
|
|
|
-ifnull(round(sum(event_new_user_credit_grant_page)/sum(form_count)*100,3),0) event_new_user_credit_grant_page_roi,
|
|
|
|
|
|
+round(sum(charge)/sum(event_new_user_credit_grant_page) ,3) event_new_user_credit_grant_page_cost,
|
|
|
|
+round(sum(event_new_user_credit_grant_page)/sum(form_count)*100,3) event_new_user_credit_grant_page_roi,
|
|
sum(event_appoint_form) event_appoint_form,
|
|
sum(event_appoint_form) event_appoint_form,
|
|
-ifnull(round(sum(charge)/sum(event_appoint_form),3),0) event_appoint_form_cost,
|
|
|
|
-ifnull(round(sum(event_appoint_form)/sum(form_count)*100,3),0) event_appoint_form_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_appoint_form),3) event_appoint_form_cost,
|
|
|
|
+round(sum(event_appoint_form)/sum(form_count)*100,3) event_appoint_form_ratio,
|
|
sum(event_appoint_jump_click) event_appoint_jump_click,
|
|
sum(event_appoint_jump_click) event_appoint_jump_click,
|
|
-ifnull(round(sum(charge)/sum(event_appoint_jump_click),3),0) event_appoint_jump_click_cost,
|
|
|
|
-ifnull(round(sum(event_appoint_jump_click_cost)/sum(form_count)*100,3),0) event_appoint_jump_click_ratio,
|
|
|
|
|
|
+round(sum(charge)/sum(event_appoint_jump_click),3) event_appoint_jump_click_cost,
|
|
|
|
+round(sum(event_appoint_jump_click_cost)/sum(form_count)*100,3) event_appoint_jump_click_ratio,
|
|
sum(union_event_pay_purchase_amount_7d) union_event_pay_purchase_amount_7d,
|
|
sum(union_event_pay_purchase_amount_7d) union_event_pay_purchase_amount_7d,
|
|
-ifnull(round(sum(union_event_pay_purchase_amount_7d_roi)/{day_count}*100,3),0) union_event_pay_purchase_amount_7d_roi,
|
|
|
|
|
|
+round(sum(union_event_pay_purchase_amount_7d_roi)/{day_count}*100,3) union_event_pay_purchase_amount_7d_roi,
|
|
sum(event_order_successed) event_order_successed,
|
|
sum(event_order_successed) event_order_successed,
|
|
-ifnull(round(sum(ad_photo_played_10s_ratio)/{day_count}*100,3),0) ad_photo_played_10s_ratio,
|
|
|
|
-ifnull(round(sum(charge)/sum(key_action),3),0) key_action_cost,
|
|
|
|
-ifnull(round(sum(charge)/sum(event_add_shopping_cart) ,3),0) event_add_shopping_cart_cost ,
|
|
|
|
-ifnull(round(sum(event_ad_watch_times)/sum(bclick)*100,3),0) event_ad_watch_times_ratio,
|
|
|
|
-ifnull(round(sum(charge)/sum(event_outbound_call),3),0) event_outbound_call_cost,
|
|
|
|
|
|
+round(sum(ad_photo_played_10s_ratio)/{day_count}*100,3) ad_photo_played_10s_ratio,
|
|
|
|
+round(sum(charge)/sum(key_action),3) key_action_cost,
|
|
|
|
+round(sum(charge)/sum(event_add_shopping_cart) ,3) event_add_shopping_cart_cost ,
|
|
|
|
+round(sum(event_ad_watch_times)/sum(bclick)*100,3) event_ad_watch_times_ratio,
|
|
|
|
+round(sum(charge)/sum(event_outbound_call),3) event_outbound_call_cost,
|
|
sum(event_outbound_call) event_outbound_call,
|
|
sum(event_outbound_call) event_outbound_call,
|
|
-ifnull(round(sum(action_new_ratio)/{day_count}*100,3),0) action_new_ratio,
|
|
|
|
|
|
+round(sum(action_new_ratio)/{day_count}*100,3) action_new_ratio,
|
|
sum(event_watch_app_ad) event_watch_app_ad,
|
|
sum(event_watch_app_ad) event_watch_app_ad,
|
|
-ifnull(round(sum(charge)/sum(event_multi_conversion) ,3),0) event_multi_conversion_cost,
|
|
|
|
|
|
+round(sum(charge)/sum(event_multi_conversion) ,3) event_multi_conversion_cost,
|
|
sum(event_phone_card_activate) event_phone_card_activate,
|
|
sum(event_phone_card_activate) event_phone_card_activate,
|
|
-ifnull(round(sum(ad_photo_played_75percent_ratio)/{day_count}*100,3),0) ad_photo_played_75percent_ratio,
|
|
|
|
-ifnull(round(sum(key_action)/sum(activation)*100,3),0) key_action_ratio ,
|
|
|
|
-ifnull(round(sum(charge)/sum(event_ad_watch_times),3),0) event_ad_watch_times_cost,
|
|
|
|
|
|
+round(sum(ad_photo_played_75percent_ratio)/{day_count}*100,3) ad_photo_played_75percent_ratio,
|
|
|
|
+round(sum(key_action)/sum(activation)*100,3) key_action_ratio ,
|
|
|
|
+round(sum(charge)/sum(event_ad_watch_times),3) event_ad_watch_times_cost,
|
|
sum(event_add_shopping_cart) event_add_shopping_cart,
|
|
sum(event_add_shopping_cart) event_add_shopping_cart,
|
|
sum(key_action) key_action,
|
|
sum(key_action) key_action,
|
|
sum(event_multi_conversion) event_multi_conversion,
|
|
sum(event_multi_conversion) event_multi_conversion,
|
|
@@ -155,34 +295,30 @@ sum(event_wechat_connected) event_wechat_connected,
|
|
sum(event_dsp_gift_form) event_dsp_gift_form,
|
|
sum(event_dsp_gift_form) event_dsp_gift_form,
|
|
sum(event_intention_confirmed) event_intention_confirmed,
|
|
sum(event_intention_confirmed) event_intention_confirmed,
|
|
sum(event_phone_get_through) event_phone_get_through,
|
|
sum(event_phone_get_through) event_phone_get_through,
|
|
-ifnull(round(sum(event_multi_conversion)/sum(activation)*100,3),0) event_multi_conversion_ratio,
|
|
|
|
|
|
+round(sum(event_multi_conversion)/sum(activation)*100,3) event_multi_conversion_ratio,
|
|
sum(event_measurement_house) event_measurement_house,
|
|
sum(event_measurement_house) event_measurement_house,
|
|
-ifnull(round(sum(ad_photo_played_2s_ratio)/{day_count}*100,3),0) ad_photo_played_2s_ratio,
|
|
|
|
-ifnull(round(sum(event_outbound_call_ratio)/sum(activation)*100,3),0) event_outbound_call_ratio,
|
|
|
|
|
|
+round(sum(ad_photo_played_2s_ratio)/{day_count}*100,3) ad_photo_played_2s_ratio,
|
|
|
|
+round(sum(event_outbound_call_ratio)/sum(activation)*100,3) event_outbound_call_ratio,
|
|
sum(event_ad_watch_times) event_ad_watch_times
|
|
sum(event_ad_watch_times) event_ad_watch_times
|
|
from
|
|
from
|
|
(SELECT
|
|
(SELECT
|
|
video.signature,
|
|
video.signature,
|
|
uc.company_id,
|
|
uc.company_id,
|
|
-CASE
|
|
|
|
-WHEN uc.company_id = 'd57fecdcf7a94d009736d9c850731582' THEN
|
|
|
|
-'北京汇创思拓数字科技有限公司'
|
|
|
|
-WHEN uc.company_id = '6608ed13c0dd42de93c790dbdf124234' THEN
|
|
|
|
-'广州汇创思拓数字科技有限公司'
|
|
|
|
-WHEN uc.company_id = '4b10089775c040119e139087517aed88' THEN
|
|
|
|
-'上海汇创思拓数字科技有限公司'
|
|
|
|
|
|
+CASE WHEN uc.company_id = 'd57fecdcf7a94d009736d9c850731582' THEN '北京汇创思拓数字科技有限公司'
|
|
|
|
+ WHEN uc.company_id = '6608ed13c0dd42de93c790dbdf124234' THEN '广州汇创思拓数字科技有限公司'
|
|
|
|
+ WHEN uc.company_id = '4b10089775c040119e139087517aed88' THEN '上海汇创思拓数字科技有限公司'
|
|
ELSE
|
|
ELSE
|
|
uc.company_name
|
|
uc.company_name
|
|
END company_name,
|
|
END company_name,
|
|
cma.leader_id,
|
|
cma.leader_id,
|
|
- us.realname leader_name,
|
|
|
|
|
|
+us.realname leader_name,
|
|
ur.org_type,
|
|
ur.org_type,
|
|
ur.org_code,
|
|
ur.org_code,
|
|
ur.id,
|
|
ur.id,
|
|
ur.depart_name,
|
|
ur.depart_name,
|
|
case when cmi.material_innovate=2 then video.signature else '' end innovate_code,
|
|
case when cmi.material_innovate=2 then video.signature else '' end innovate_code,
|
|
report.charge ,
|
|
report.charge ,
|
|
- report.`show`,
|
|
|
|
|
|
+report.`show`,
|
|
report.photo_click,
|
|
report.photo_click,
|
|
report.aclick ,
|
|
report.aclick ,
|
|
report.bclick ,
|
|
report.bclick ,
|
|
@@ -308,13 +444,11 @@ report.charge ,
|
|
report.ad_photo_played_2s_ratio ,
|
|
report.ad_photo_played_2s_ratio ,
|
|
report.event_outbound_call_ratio,
|
|
report.event_outbound_call_ratio,
|
|
report.event_ad_watch_times
|
|
report.event_ad_watch_times
|
|
-FROM
|
|
|
|
-(select * from media_api.kuaishou_material_video_report_daily
|
|
|
|
-where stat_date >= date_format(date_sub({date_time}, INTERVAL {day_count} -1 DAY),'%Y%m%d')
|
|
|
|
-) report
|
|
|
|
-LEFT JOIN
|
|
|
|
-(select account_id,signature,photo_id from media_api.kuaishou_video_list group by account_id,signature,photo_id) video
|
|
|
|
- ON report.advertiser_id = video.account_id AND report.photo_id = video.photo_id
|
|
|
|
|
|
+ FROM
|
|
|
|
+ (select * from media_api.kuaishou_material_video_report_daily where stat_date >= date_format(date_sub({date_time}, INTERVAL {day_count}-1 DAY),'%Y%m%d')) report
|
|
|
|
+ LEFT JOIN
|
|
|
|
+(select account_id,signature,photo_id from media_api.kuaishou_video_list group by account_id,signature,photo_id) video
|
|
|
|
+ON report.advertiser_id = video.account_id AND report.photo_id = video.photo_id
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
SELECT
|
|
SELECT
|
|
CODE,
|
|
CODE,
|
|
@@ -336,25 +470,33 @@ FROM
|
|
SELECT
|
|
SELECT
|
|
material_id,
|
|
material_id,
|
|
leader_id,
|
|
leader_id,
|
|
-row_number () over (
|
|
|
|
-PARTITION BY material_id
|
|
|
|
-ORDER BY
|
|
|
|
-create_time
|
|
|
|
-) rn
|
|
|
|
-FROM
|
|
|
|
-`jeecg-boot`.ctop_material_ascription
|
|
|
|
-) m
|
|
|
|
-WHERE
|
|
|
|
-rn = 1
|
|
|
|
-) cma ON video.signature = cma.material_id
|
|
|
|
- left join `jeecg-boot`.sys_user us on us.id=cma.leader_id
|
|
|
|
|
|
+row_number () over (PARTITION BY material_id ORDER BY create_time) rn FROM `jeecg-boot`.ctop_material_ascription) m
|
|
|
|
+WHERE rn = 1) cma ON video.signature = cma.material_id
|
|
|
|
+left join `jeecg-boot`.sys_user us on us.id=cma.leader_id
|
|
LEFT JOIN `jeecg-boot`.user_company uc ON cma.leader_id = uc.user_id
|
|
LEFT JOIN `jeecg-boot`.user_company uc ON cma.leader_id = uc.user_id
|
|
LEFT JOIN `jeecg-boot`.sys_user_depart de ON cma.leader_id = de.user_id
|
|
LEFT JOIN `jeecg-boot`.sys_user_depart de ON cma.leader_id = de.user_id
|
|
LEFT JOIN `jeecg-boot`.sys_depart ur ON de.dep_id = ur.id) def
|
|
LEFT JOIN `jeecg-boot`.sys_depart ur ON de.dep_id = ur.id) def
|
|
group by
|
|
group by
|
|
- company_id,
|
|
|
|
- leader_id
|
|
|
|
-;
|
|
|
|
|
|
+company_id,
|
|
|
|
+company_name,
|
|
|
|
+org_code,
|
|
|
|
+org_type,
|
|
|
|
+id,
|
|
|
|
+depart_name,
|
|
|
|
+leader_id,
|
|
|
|
+leader_name) new
|
|
|
|
+left join
|
|
|
|
+(select ifnull(cma.leader_id,'-') leader_id,sum(report.charge) charge from
|
|
|
|
+(select advertiser_id account_id,photo_id,sum(charge) charge from media_api.kuaishou_material_video_report_daily
|
|
|
|
+where stat_date between date_format(date_sub(date_format(date_sub({date_time}, INTERVAL {day_count} DAY),'%Y%m%d'), INTERVAL {day_count} -1 DAY),'%Y%m%d')
|
|
|
|
+and date_format(date_sub({date_time}, INTERVAL {day_count} DAY),'%Y%m%d') group by advertiser_id,photo_id) report
|
|
|
|
+LEFT JOIN
|
|
|
|
+(select account_id,signature,photo_id from media_api.kuaishou_video_list group by account_id,signature,photo_id) video
|
|
|
|
+ON report.account_id = video.account_id AND report.photo_id=video.photo_id
|
|
|
|
+LEFT JOIN (SELECT material_id,leader_id FROM (SELECT material_id,leader_id,row_number () over (PARTITION BY material_id ORDER BY create_time ) rn
|
|
|
|
+FROM `jeecg-boot`.ctop_material_ascription) m WHERE rn = 1 ) cma ON video.signature = cma.material_id
|
|
|
|
+group by cma.leader_id) ratio
|
|
|
|
+on new.leader_id=ratio.leader_id;
|
|
""".format(date_time=self.date_time, day_count=self.day_count)
|
|
""".format(date_time=self.date_time, day_count=self.day_count)
|
|
print(sql)
|
|
print(sql)
|
|
TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
TidbConn.upsert(conn=self.conn, sql_buff=sql)
|