123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 |
- # Author renyupeng
- # coding=utf-8
- # @Time : 2021/9/15 5:10 下午
- # @Site :
- # @File : AccountReport.py
- # @Software: PyCharm
- # @contact: renyupeng@c-top.com.cn
- import logging
- from Apietl.conn.TidbConn import TidbConn
- from Apietl.kwai_etl.report.ReplaceAccountInfo import ReplaceAccountInfo
- from Apietl.utlis.Utils import Utils
- class AccountReport:
- def __init__(self):
- self.conn = TidbConn.get_connection()
- def daily_report(self, account_id, start_date, end_date):
- try:
- sql = """
- replace into application.kuaishou_account_report_daily_dw
- (account_id, stat_date, project_id, product_id, advertiser_id, company_id, account_name, project_name, advertiser_name,
- company_name, sale_id, user_id, org_code, charge, `show`, photo_click, aclick, bclick, photo_click_ratio,
- play_3s_ratio, action_ratio, impression_1k_cost, photo_click_cost, action_cost, share, comment, `like`, follow,
- cancel_follow, report, block, negative, submit, download_started, download_completed, activation, event_pay_first_day,
- event_pay_purchase_amount_first_day, event_pay_first_day_roi, event_pay, event_pay_purchase_amount, event_pay_roi,
- event_register, event_register_cost, event_register_ratio, event_jin_jian_app, event_jin_jian_app_cost,
- event_credit_grant_app, event_credit_grant_app_cost, event_credit_grant_app_ratio, event_order_paid,
- event_order_paid_purchase_amount, event_order_paid_cost, event_next_day_stay, event_next_day_stay_cost,
- event_next_day_stay_ratio, form_count, form_cost, form_action_ratio, event_jin_jian_landing_page,
- event_jin_jian_landing_page_cost, event_credit_grant_landing_page, event_credit_grant_landing_page_cost,
- event_credit_grant_landing_page_ratio, event_valid_clues, event_valid_clues_cost, event_add_wechat,
- event_add_wechat_cost, event_add_wechat_ratio, event_get_through, event_get_through_cost, event_get_through_ratio,
- event_app_invoked, event_app_invoked_cost, event_app_invoked_ratio, event_credit_grant_landing_ratio, play_5s_ratio,
- play_end_ratio, event_new_user_pay, event_new_user_pay_cost, event_new_user_pay_ratio, click_1k_cost, ad_product_cnt,
- event_goods_view, merchant_reco_fans, event_order_amount_roi, event_goods_view_cost, merchant_reco_fans_cost,
- event_button_click, event_button_click_cost, event_button_click_ratio, event_order_paid_roi,
- event_new_user_jinjian_app, event_new_user_jinjian_app_cost, event_new_user_jinjian_app_roi,
- event_new_user_credit_grant_app, event_new_user_credit_grant_app_cost, event_new_user_credit_grant_app_roi,
- event_new_user_jinjian_page, event_new_user_jinjian_page_cost, event_new_user_jinjian_page_roi,
- event_new_user_credit_grant_page, event_new_user_credit_grant_page_cost, event_new_user_credit_grant_page_roi,
- event_appoint_form, event_appoint_form_cost, event_appoint_form_ratio, event_appoint_jump_click,
- event_appoint_jump_click_cost, event_appoint_jump_click_ratio, union_event_pay_purchase_amount_7d,
- union_event_pay_purchase_amount_7d_roi, placement_type, ad_scene, event_order_successed, ad_photo_played_10s_ratio,
- key_action_cost, event_add_shopping_cart_cost, event_ad_watch_times_ratio, event_outbound_call_cost,
- event_outbound_call, action_new_ratio, event_watch_app_ad, event_multi_conversion_cost, event_phone_card_activate,
- ad_photo_played_75percent_ratio, key_action_ratio, event_ad_watch_times_cost, event_add_shopping_cart, key_action,
- event_multi_conversion, event_wechat_connected, event_dsp_gift_form, event_intention_confirmed,
- event_phone_get_through, event_multi_conversion_ratio, event_measurement_house, ad_photo_played_2s_ratio,
- event_outbound_call_ratio, event_ad_watch_times,event_pay_purchase_amount_one_day_by_conversion,
- ad_photo_played_10s
- ,ad_photo_played_2s
- ,ad_photo_played_75percent
- ,approx_pay_cost
- ,approx_pay_count
- ,approx_pay_ratio
- ,cancel_like
- ,click_conversion_ratio
- ,conversion_cost
- ,conversion_cost_by_impression_7d
- ,conversion_num
- ,conversion_num_by_impression_7d
- ,conversion_num_cost
- ,conversion_ratio
- ,conversion_ratio_by_impression_7d
- ,deep_conversion_cost
- ,deep_conversion_cost_by_impression_7d
- ,deep_conversion_num
- ,deep_conversion_num_by_impression_7d
- ,deep_conversion_ratio
- ,deep_conversion_ratio_by_impression_7d
- ,download_completed_cost
- ,download_completed_ratio
- ,download_conversion_ratio
- ,download_installed
- ,download_started_cost
- ,download_started_ratio
- ,event_24h_stay
- ,event_24h_stay_by_conversion
- ,event_24h_stay_by_conversion_cost
- ,event_24h_stay_by_conversion_ratio
- ,event_24h_stay_cost
- ,event_24h_stay_ratio
- ,event_ad_watch_10_times
- ,event_ad_watch_10_times_cost
- ,event_ad_watch_10_times_ratio
- ,event_ad_watch_20_times
- ,event_ad_watch_20_times_cost
- ,event_ad_watch_20_times_ratio
- ,event_ad_watch_5_times
- ,event_ad_watch_5_times_cost
- ,event_ad_watch_5_times_ratio
- ,event_audition
- ,event_consultation_valid_retained
- ,event_consultation_valid_retained_cost
- ,event_consultation_valid_retained_ratio
- ,event_conversion_click_cost
- ,event_conversion_click_ratio
- ,event_credit_grant_first_day_app
- ,event_credit_grant_first_day_app_cost
- ,event_credit_grant_first_day_app_ratio
- ,event_credit_grant_first_day_landing_page
- ,event_credit_grant_first_day_landing_page_cost
- ,event_credit_grant_first_day_landing_page_ratio
- ,event_making_calls
- ,event_making_calls_cost
- ,event_making_calls_ratio
- ,event_order_submit
- ,event_pay_purchase_amount_one_day
- ,event_pay_purchase_amount_one_day_by_conversion_roi
- ,event_pay_purchase_amount_one_day_roi
- ,event_pay_purchase_amount_three_day_by_conversion
- ,event_pay_purchase_amount_three_day_by_conversion_roi
- ,event_pay_purchase_amount_week_by_conversion
- ,event_pay_purchase_amount_week_by_conversion_roi
- ,event_pay_week_by_conversion
- ,event_pay_week_by_conversion_cost
- ,event_pay_weighted_purchase_amount
- ,event_pay_weighted_purchase_amount_first_day
- ,event_pre_component_consultation_valid_retained
- ,event_three_day_stay_by_conversion
- ,event_three_day_stay_by_conversion_cost
- ,event_three_day_stay_by_conversion_ratio
- ,event_wechat_qr_code_link_click
- ,event_week_stay_by_conversion
- ,event_week_stay_by_conversion_cost
- ,event_week_stay_by_conversion_ratio
- ,live_event_goods_view
- ,live_played_3s
- ,played_end
- ,played_five_seconds
- ,played_three_seconds
- ,event_next_day_stay_new
- ,event_next_day_stay_new_cost
- ,event_next_day_stay_new_ratio
- ,ad_show
- ,event_credit_card_recheck
- ,event_credit_card_recheck_first_day
- ,event_no_intention
- ,event_multi_pay_seven_day_by_conversion
- ,event_multi_pay_seven_day_by_conversion_cost
- ,mcb_left_time_perf_cpa_bid
- ,mcb_left_time_perf_roi_ratio
- ,mcb_all_day_perf_cpa_bid
- ,mcb_all_day_perf_roi_ratio
- ,live_room_avg_played_seconds
- ,ad_live_share
- ,ad_live_comment
- ,live_played_started
- ,live_played_started_cost
- ,ad_live_follow
- ,ad_live_follow_cost
- ,simple_live_played_started
- ,standard_live_played_started
- ,conversion_component_impression
- ,conversion_component_click
- ,conversion_component_rate
- ,ad_landing_page_impression
- ,ad_app_download_half_impression
- ,event_draw_credit_line
- ,minigame_iaa_purchase_roi
- ,minigame_iaa_purchase_amount
- )
- select report.advertiser_id as account_id,
- stat_date,
- project_id,
- product_id,
- sys.advertiser_id,
- company_id,
- account_name,
- project_name,
- advertiser_name,
- company_name,
- sale_id,
- user_id,
- org_code,
- charge,
- `show`,
- photo_click,
- aclick,
- bclick,
- photo_click_ratio,
- play_3s_ratio,
- action_ratio,
- impression_1k_cost,
- photo_click_cost,
- action_cost,
- share,
- comment,
- `like`,
- follow,
- cancel_follow,
- report,
- block,
- negative,
- submit,
- download_started,
- download_completed,
- activation,
- event_pay_first_day,
- event_pay_purchase_amount_first_day,
- event_pay_first_day_roi,
- event_pay,
- event_pay_purchase_amount,
- event_pay_roi,
- event_register,
- event_register_cost,
- event_register_ratio,
- event_jin_jian_app,
- event_jin_jian_app_cost,
- event_credit_grant_app,
- event_credit_grant_app_cost,
- event_credit_grant_app_ratio,
- event_order_paid,
- event_order_paid_purchase_amount,
- event_order_paid_cost,
- event_next_day_stay,
- event_next_day_stay_cost,
- event_next_day_stay_ratio,
- form_count,
- form_cost,
- form_action_ratio,
- event_jin_jian_landing_page,
- event_jin_jian_landing_page_cost,
- event_credit_grant_landing_page,
- event_credit_grant_landing_page_cost,
- event_credit_grant_landing_page_ratio,
- event_valid_clues,
- event_valid_clues_cost,
- event_add_wechat,
- event_add_wechat_cost,
- event_add_wechat_ratio,
- event_get_through,
- event_get_through_cost,
- event_get_through_ratio,
- event_app_invoked,
- event_app_invoked_cost,
- event_app_invoked_ratio,
- event_credit_grant_landing_ratio,
- play_5s_ratio,
- play_end_ratio,
- event_new_user_pay,
- event_new_user_pay_cost,
- event_new_user_pay_ratio,
- click_1k_cost,
- ad_product_cnt,
- event_goods_view,
- merchant_reco_fans,
- event_order_amount_roi,
- event_goods_view_cost,
- merchant_reco_fans_cost,
- event_button_click,
- event_button_click_cost,
- event_button_click_ratio,
- event_order_paid_roi,
- event_new_user_jinjian_app,
- event_new_user_jinjian_app_cost,
- event_new_user_jinjian_app_roi,
- event_new_user_credit_grant_app,
- event_new_user_credit_grant_app_cost,
- event_new_user_credit_grant_app_roi,
- event_new_user_jinjian_page,
- event_new_user_jinjian_page_cost,
- event_new_user_jinjian_page_roi,
- event_new_user_credit_grant_page,
- event_new_user_credit_grant_page_cost,
- event_new_user_credit_grant_page_roi,
- event_appoint_form,
- event_appoint_form_cost,
- event_appoint_form_ratio,
- event_appoint_jump_click,
- event_appoint_jump_click_cost,
- event_appoint_jump_click_ratio,
- union_event_pay_purchase_amount_7d,
- union_event_pay_purchase_amount_7d_roi,
- placement_type,
- ad_scene,
- event_order_successed,
- ad_photo_played_10s_ratio,
- key_action_cost,
- event_add_shopping_cart_cost,
- event_ad_watch_times_ratio,
- event_outbound_call_cost,
- event_outbound_call,
- action_new_ratio,
- event_watch_app_ad,
- event_multi_conversion_cost,
- event_phone_card_activate,
- ad_photo_played_75percent_ratio,
- key_action_ratio,
- event_ad_watch_times_cost,
- event_add_shopping_cart,
- key_action,
- event_multi_conversion,
- event_wechat_connected,
- event_dsp_gift_form,
- event_intention_confirmed,
- event_phone_get_through,
- event_multi_conversion_ratio,
- event_measurement_house,
- ad_photo_played_2s_ratio,
- event_outbound_call_ratio,
- event_ad_watch_times,
- event_pay_purchase_amount_one_day_by_conversion,
- ad_photo_played_10s
- ,ad_photo_played_2s
- ,ad_photo_played_75percent
- ,approx_pay_cost
- ,approx_pay_count
- ,approx_pay_ratio
- ,cancel_like
- ,click_conversion_ratio
- ,conversion_cost
- ,conversion_cost_by_impression_7d
- ,conversion_num
- ,conversion_num_by_impression_7d
- ,conversion_num_cost
- ,conversion_ratio
- ,conversion_ratio_by_impression_7d
- ,deep_conversion_cost
- ,deep_conversion_cost_by_impression_7d
- ,deep_conversion_num
- ,deep_conversion_num_by_impression_7d
- ,deep_conversion_ratio
- ,deep_conversion_ratio_by_impression_7d
- ,download_completed_cost
- ,download_completed_ratio
- ,download_conversion_ratio
- ,download_installed
- ,download_started_cost
- ,download_started_ratio
- ,event_24h_stay
- ,event_24h_stay_by_conversion
- ,event_24h_stay_by_conversion_cost
- ,event_24h_stay_by_conversion_ratio
- ,event_24h_stay_cost
- ,event_24h_stay_ratio
- ,event_ad_watch_10_times
- ,event_ad_watch_10_times_cost
- ,event_ad_watch_10_times_ratio
- ,event_ad_watch_20_times
- ,event_ad_watch_20_times_cost
- ,event_ad_watch_20_times_ratio
- ,event_ad_watch_5_times
- ,event_ad_watch_5_times_cost
- ,event_ad_watch_5_times_ratio
- ,event_audition
- ,event_consultation_valid_retained
- ,event_consultation_valid_retained_cost
- ,event_consultation_valid_retained_ratio
- ,event_conversion_click_cost
- ,event_conversion_click_ratio
- ,event_credit_grant_first_day_app
- ,event_credit_grant_first_day_app_cost
- ,event_credit_grant_first_day_app_ratio
- ,event_credit_grant_first_day_landing_page
- ,event_credit_grant_first_day_landing_page_cost
- ,event_credit_grant_first_day_landing_page_ratio
- ,event_making_calls
- ,event_making_calls_cost
- ,event_making_calls_ratio
- ,event_order_submit
- ,event_pay_purchase_amount_one_day
- ,event_pay_purchase_amount_one_day_by_conversion_roi
- ,event_pay_purchase_amount_one_day_roi
- ,event_pay_purchase_amount_three_day_by_conversion
- ,event_pay_purchase_amount_three_day_by_conversion_roi
- ,event_pay_purchase_amount_week_by_conversion
- ,event_pay_purchase_amount_week_by_conversion_roi
- ,event_pay_week_by_conversion
- ,event_pay_week_by_conversion_cost
- ,event_pay_weighted_purchase_amount
- ,event_pay_weighted_purchase_amount_first_day
- ,event_pre_component_consultation_valid_retained
- ,event_three_day_stay_by_conversion
- ,event_three_day_stay_by_conversion_cost
- ,event_three_day_stay_by_conversion_ratio
- ,event_wechat_qr_code_link_click
- ,event_week_stay_by_conversion
- ,event_week_stay_by_conversion_cost
- ,event_week_stay_by_conversion_ratio
- ,live_event_goods_view
- ,live_played_3s
- ,played_end
- ,played_five_seconds
- ,played_three_seconds
- ,event_next_day_stay_new
- ,event_next_day_stay_new_cost
- ,event_next_day_stay_new_ratio
- ,ad_show
- ,event_credit_card_recheck
- ,event_credit_card_recheck_first_day
- ,event_no_intention
- ,event_multi_pay_seven_day_by_conversion
- ,event_multi_pay_seven_day_by_conversion_cost
- ,mcb_left_time_perf_cpa_bid
- ,mcb_left_time_perf_roi_ratio
- ,mcb_all_day_perf_cpa_bid
- ,mcb_all_day_perf_roi_ratio
- ,live_room_avg_played_seconds
- ,ad_live_share
- ,ad_live_comment
- ,live_played_started
- ,live_played_started_cost
- ,ad_live_follow
- ,ad_live_follow_cost
- ,simple_live_played_started
- ,standard_live_played_started
- ,conversion_component_impression
- ,conversion_component_click
- ,conversion_component_rate
- ,ad_landing_page_impression
- ,ad_app_download_half_impression
- ,event_draw_credit_line
- ,minigame_iaa_purchase_roi
- ,minigame_iaa_purchase_amount
- from media_api.kuaishou_account_report_daily report
- left join
- (SELECT
- cua.account_id id,
- cua.account_id account_id,
- cp.id project_id,
- product.id product_id,
- ca.id advertiser_id,
- uc.company_id company_id,
- cua.auth_name account_name,
- cp.project_name project_name,
- ca.`name` advertiser_name,
- uc.company_name company_name,
- cp.sale_id sale_id,
- su.id user_id,
- su.leader_id,
- su.org_code org_code
- FROM
- `jeecg-boot`.ctop_user_allocation cua
- 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`.sys_user su ON su.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
- WHERE
- cua.account_id IS NOT NULL
- ) sys
- on report.advertiser_id = sys.account_id
- where report.stat_date between {start_date} and {end_date}
- and report.advertiser_id={account_id}
- """.format(start_date=start_date, end_date=end_date, account_id=account_id)
- TidbConn.upsert(conn=self.conn, sql_buff=sql)
- self.conn.commit()
- TidbConn.conn_close(conn=self.conn)
- print(account_id, '快手账户日报执行完成')
- except Exception as e:
- logging.error(account_id, '执行失败')
- def hourly_report(self, account_id, start_date, end_date):
- try:
- sql = """
- replace into application.kuaishou_account_report_hourly_dw
- (account_id, stat_date,`hour`, project_id, product_id, advertiser_id, company_id, account_name, project_name, advertiser_name,
- company_name, sale_id, user_id, org_code, charge, `show`, photo_click, aclick, bclick, photo_click_ratio,
- play_3s_ratio, action_ratio, impression_1k_cost, photo_click_cost, action_cost, share, comment, `like`, follow,
- cancel_follow, report, block, negative, submit, download_started, download_completed, activation, event_pay_first_day,
- event_pay_purchase_amount_first_day, event_pay_first_day_roi, event_pay, event_pay_purchase_amount, event_pay_roi,
- event_register, event_register_cost, event_register_ratio, event_jin_jian_app, event_jin_jian_app_cost,
- event_credit_grant_app, event_credit_grant_app_cost, event_credit_grant_app_ratio, event_order_paid,
- event_order_paid_purchase_amount, event_order_paid_cost, event_next_day_stay, event_next_day_stay_cost,
- event_next_day_stay_ratio, form_count, form_cost, form_action_ratio, event_jin_jian_landing_page,
- event_jin_jian_landing_page_cost, event_credit_grant_landing_page, event_credit_grant_landing_page_cost,
- event_credit_grant_landing_page_ratio, event_valid_clues, event_valid_clues_cost, event_add_wechat,
- event_add_wechat_cost, event_add_wechat_ratio, event_get_through, event_get_through_cost, event_get_through_ratio,
- event_app_invoked, event_app_invoked_cost, event_app_invoked_ratio, event_credit_grant_landing_ratio, play_5s_ratio,
- play_end_ratio, event_new_user_pay, event_new_user_pay_cost, event_new_user_pay_ratio, click_1k_cost, ad_product_cnt,
- event_goods_view, merchant_reco_fans, event_order_amount_roi, event_goods_view_cost, merchant_reco_fans_cost,
- event_button_click, event_button_click_cost, event_button_click_ratio, event_order_paid_roi,
- event_new_user_jinjian_app, event_new_user_jinjian_app_cost, event_new_user_jinjian_app_roi,
- event_new_user_credit_grant_app, event_new_user_credit_grant_app_cost, event_new_user_credit_grant_app_roi,
- event_new_user_jinjian_page, event_new_user_jinjian_page_cost, event_new_user_jinjian_page_roi,
- event_new_user_credit_grant_page, event_new_user_credit_grant_page_cost, event_new_user_credit_grant_page_roi,
- event_appoint_form, event_appoint_form_cost, event_appoint_form_ratio, event_appoint_jump_click,
- event_appoint_jump_click_cost, event_appoint_jump_click_ratio, union_event_pay_purchase_amount_7d,
- union_event_pay_purchase_amount_7d_roi, placement_type, ad_scene, event_order_successed, ad_photo_played_10s_ratio,
- key_action_cost, event_add_shopping_cart_cost, event_ad_watch_times_ratio, event_outbound_call_cost,
- event_outbound_call, action_new_ratio, event_watch_app_ad, event_multi_conversion_cost, event_phone_card_activate,
- ad_photo_played_75percent_ratio, key_action_ratio, event_ad_watch_times_cost, event_add_shopping_cart, key_action,
- event_multi_conversion, event_wechat_connected, event_dsp_gift_form, event_intention_confirmed,
- event_phone_get_through, event_multi_conversion_ratio, event_measurement_house, ad_photo_played_2s_ratio,
- event_outbound_call_ratio, event_ad_watch_times,event_pay_purchase_amount_one_day_by_conversion, ad_photo_played_10s
- ,ad_photo_played_2s
- ,ad_photo_played_75percent
- ,approx_pay_cost
- ,approx_pay_count
- ,approx_pay_ratio
- ,cancel_like
- ,click_conversion_ratio
- ,conversion_cost
- ,conversion_cost_by_impression_7d
- ,conversion_num
- ,conversion_num_by_impression_7d
- ,conversion_num_cost
- ,conversion_ratio
- ,conversion_ratio_by_impression_7d
- ,deep_conversion_cost
- ,deep_conversion_cost_by_impression_7d
- ,deep_conversion_num
- ,deep_conversion_num_by_impression_7d
- ,deep_conversion_ratio
- ,deep_conversion_ratio_by_impression_7d
- ,download_completed_cost
- ,download_completed_ratio
- ,download_conversion_ratio
- ,download_installed
- ,download_started_cost
- ,download_started_ratio
- ,event_24h_stay
- ,event_24h_stay_by_conversion
- ,event_24h_stay_by_conversion_cost
- ,event_24h_stay_by_conversion_ratio
- ,event_24h_stay_cost
- ,event_24h_stay_ratio
- ,event_ad_watch_10_times
- ,event_ad_watch_10_times_cost
- ,event_ad_watch_10_times_ratio
- ,event_ad_watch_20_times
- ,event_ad_watch_20_times_cost
- ,event_ad_watch_20_times_ratio
- ,event_ad_watch_5_times
- ,event_ad_watch_5_times_cost
- ,event_ad_watch_5_times_ratio
- ,event_audition
- ,event_consultation_valid_retained
- ,event_consultation_valid_retained_cost
- ,event_consultation_valid_retained_ratio
- ,event_conversion_click_cost
- ,event_conversion_click_ratio
- ,event_credit_grant_first_day_app
- ,event_credit_grant_first_day_app_cost
- ,event_credit_grant_first_day_app_ratio
- ,event_credit_grant_first_day_landing_page
- ,event_credit_grant_first_day_landing_page_cost
- ,event_credit_grant_first_day_landing_page_ratio
- ,event_making_calls
- ,event_making_calls_cost
- ,event_making_calls_ratio
- ,event_order_submit
- ,event_pay_purchase_amount_one_day
- ,event_pay_purchase_amount_one_day_by_conversion_roi
- ,event_pay_purchase_amount_one_day_roi
- ,event_pay_purchase_amount_three_day_by_conversion
- ,event_pay_purchase_amount_three_day_by_conversion_roi
- ,event_pay_purchase_amount_week_by_conversion
- ,event_pay_purchase_amount_week_by_conversion_roi
- ,event_pay_week_by_conversion
- ,event_pay_week_by_conversion_cost
- ,event_pay_weighted_purchase_amount
- ,event_pay_weighted_purchase_amount_first_day
- ,event_pre_component_consultation_valid_retained
- ,event_three_day_stay_by_conversion
- ,event_three_day_stay_by_conversion_cost
- ,event_three_day_stay_by_conversion_ratio
- ,event_wechat_qr_code_link_click
- ,event_week_stay_by_conversion
- ,event_week_stay_by_conversion_cost
- ,event_week_stay_by_conversion_ratio
- ,live_event_goods_view
- ,live_played_3s
- ,played_end
- ,played_five_seconds
- ,played_three_seconds
- ,event_next_day_stay_new
- ,event_next_day_stay_new_cost
- ,event_next_day_stay_new_ratio
- ,ad_show
- ,event_credit_card_recheck
- ,event_credit_card_recheck_first_day
- ,event_no_intention
- ,event_multi_pay_seven_day_by_conversion
- ,event_multi_pay_seven_day_by_conversion_cost
- ,mcb_left_time_perf_cpa_bid
- ,mcb_left_time_perf_roi_ratio
- ,mcb_all_day_perf_cpa_bid
- ,mcb_all_day_perf_roi_ratio
- ,live_room_avg_played_seconds
- ,ad_live_share
- ,ad_live_comment
- ,live_played_started
- ,live_played_started_cost
- ,ad_live_follow
- ,ad_live_follow_cost
- ,simple_live_played_started
- ,standard_live_played_started
- ,conversion_component_impression
- ,conversion_component_click
- ,conversion_component_rate
- ,ad_landing_page_impression
- ,ad_app_download_half_impression
- ,event_draw_credit_line
- ,minigame_iaa_purchase_amount
- ,minigame_iaa_purchase_roi
- )
- select report.advertiser_id as account_id,
- stat_date,
- `hour`,
- project_id,
- product_id,
- sys.advertiser_id,
- company_id,
- account_name,
- project_name,
- advertiser_name,
- company_name,
- sale_id,
- user_id,
- org_code,
- charge,
- `show`,
- photo_click,
- aclick,
- bclick,
- photo_click_ratio,
- play_3s_ratio,
- action_ratio,
- impression_1k_cost,
- photo_click_cost,
- action_cost,
- share,
- comment,
- `like`,
- follow,
- cancel_follow,
- report,
- block,
- negative,
- submit,
- download_started,
- download_completed,
- activation,
- event_pay_first_day,
- event_pay_purchase_amount_first_day,
- event_pay_first_day_roi,
- event_pay,
- event_pay_purchase_amount,
- event_pay_roi,
- event_register,
- event_register_cost,
- event_register_ratio,
- event_jin_jian_app,
- event_jin_jian_app_cost,
- event_credit_grant_app,
- event_credit_grant_app_cost,
- event_credit_grant_app_ratio,
- event_order_paid,
- event_order_paid_purchase_amount,
- event_order_paid_cost,
- event_next_day_stay,
- event_next_day_stay_cost,
- event_next_day_stay_ratio,
- form_count,
- form_cost,
- form_action_ratio,
- event_jin_jian_landing_page,
- event_jin_jian_landing_page_cost,
- event_credit_grant_landing_page,
- event_credit_grant_landing_page_cost,
- event_credit_grant_landing_page_ratio,
- event_valid_clues,
- event_valid_clues_cost,
- event_add_wechat,
- event_add_wechat_cost,
- event_add_wechat_ratio,
- event_get_through,
- event_get_through_cost,
- event_get_through_ratio,
- event_app_invoked,
- event_app_invoked_cost,
- event_app_invoked_ratio,
- event_credit_grant_landing_ratio,
- play_5s_ratio,
- play_end_ratio,
- event_new_user_pay,
- event_new_user_pay_cost,
- event_new_user_pay_ratio,
- click_1k_cost,
- ad_product_cnt,
- event_goods_view,
- merchant_reco_fans,
- event_order_amount_roi,
- event_goods_view_cost,
- merchant_reco_fans_cost,
- event_button_click,
- event_button_click_cost,
- event_button_click_ratio,
- event_order_paid_roi,
- event_new_user_jinjian_app,
- event_new_user_jinjian_app_cost,
- event_new_user_jinjian_app_roi,
- event_new_user_credit_grant_app,
- event_new_user_credit_grant_app_cost,
- event_new_user_credit_grant_app_roi,
- event_new_user_jinjian_page,
- event_new_user_jinjian_page_cost,
- event_new_user_jinjian_page_roi,
- event_new_user_credit_grant_page,
- event_new_user_credit_grant_page_cost,
- event_new_user_credit_grant_page_roi,
- event_appoint_form,
- event_appoint_form_cost,
- event_appoint_form_ratio,
- event_appoint_jump_click,
- event_appoint_jump_click_cost,
- event_appoint_jump_click_ratio,
- union_event_pay_purchase_amount_7d,
- union_event_pay_purchase_amount_7d_roi,
- placement_type,
- ad_scene,
- event_order_successed,
- ad_photo_played_10s_ratio,
- key_action_cost,
- event_add_shopping_cart_cost,
- event_ad_watch_times_ratio,
- event_outbound_call_cost,
- event_outbound_call,
- action_new_ratio,
- event_watch_app_ad,
- event_multi_conversion_cost,
- event_phone_card_activate,
- ad_photo_played_75percent_ratio,
- key_action_ratio,
- event_ad_watch_times_cost,
- event_add_shopping_cart,
- key_action,
- event_multi_conversion,
- event_wechat_connected,
- event_dsp_gift_form,
- event_intention_confirmed,
- event_phone_get_through,
- event_multi_conversion_ratio,
- event_measurement_house,
- ad_photo_played_2s_ratio,
- event_outbound_call_ratio,
- event_ad_watch_times,
- event_pay_purchase_amount_one_day_by_conversion,
- ad_photo_played_10s
- ,ad_photo_played_2s
- ,ad_photo_played_75percent
- ,approx_pay_cost
- ,approx_pay_count
- ,approx_pay_ratio
- ,cancel_like
- ,click_conversion_ratio
- ,conversion_cost
- ,conversion_cost_by_impression_7d
- ,conversion_num
- ,conversion_num_by_impression_7d
- ,conversion_num_cost
- ,conversion_ratio
- ,conversion_ratio_by_impression_7d
- ,deep_conversion_cost
- ,deep_conversion_cost_by_impression_7d
- ,deep_conversion_num
- ,deep_conversion_num_by_impression_7d
- ,deep_conversion_ratio
- ,deep_conversion_ratio_by_impression_7d
- ,download_completed_cost
- ,download_completed_ratio
- ,download_conversion_ratio
- ,download_installed
- ,download_started_cost
- ,download_started_ratio
- ,event_24h_stay
- ,event_24h_stay_by_conversion
- ,event_24h_stay_by_conversion_cost
- ,event_24h_stay_by_conversion_ratio
- ,event_24h_stay_cost
- ,event_24h_stay_ratio
- ,event_ad_watch_10_times
- ,event_ad_watch_10_times_cost
- ,event_ad_watch_10_times_ratio
- ,event_ad_watch_20_times
- ,event_ad_watch_20_times_cost
- ,event_ad_watch_20_times_ratio
- ,event_ad_watch_5_times
- ,event_ad_watch_5_times_cost
- ,event_ad_watch_5_times_ratio
- ,event_audition
- ,event_consultation_valid_retained
- ,event_consultation_valid_retained_cost
- ,event_consultation_valid_retained_ratio
- ,event_conversion_click_cost
- ,event_conversion_click_ratio
- ,event_credit_grant_first_day_app
- ,event_credit_grant_first_day_app_cost
- ,event_credit_grant_first_day_app_ratio
- ,event_credit_grant_first_day_landing_page
- ,event_credit_grant_first_day_landing_page_cost
- ,event_credit_grant_first_day_landing_page_ratio
- ,event_making_calls
- ,event_making_calls_cost
- ,event_making_calls_ratio
- ,event_order_submit
- ,event_pay_purchase_amount_one_day
- ,event_pay_purchase_amount_one_day_by_conversion_roi
- ,event_pay_purchase_amount_one_day_roi
- ,event_pay_purchase_amount_three_day_by_conversion
- ,event_pay_purchase_amount_three_day_by_conversion_roi
- ,event_pay_purchase_amount_week_by_conversion
- ,event_pay_purchase_amount_week_by_conversion_roi
- ,event_pay_week_by_conversion
- ,event_pay_week_by_conversion_cost
- ,event_pay_weighted_purchase_amount
- ,event_pay_weighted_purchase_amount_first_day
- ,event_pre_component_consultation_valid_retained
- ,event_three_day_stay_by_conversion
- ,event_three_day_stay_by_conversion_cost
- ,event_three_day_stay_by_conversion_ratio
- ,event_wechat_qr_code_link_click
- ,event_week_stay_by_conversion
- ,event_week_stay_by_conversion_cost
- ,event_week_stay_by_conversion_ratio
- ,live_event_goods_view
- ,live_played_3s
- ,played_end
- ,played_five_seconds
- ,played_three_seconds
- ,event_next_day_stay_new
- ,event_next_day_stay_new_cost
- ,event_next_day_stay_new_ratio
- ,ad_show
- ,event_credit_card_recheck
- ,event_credit_card_recheck_first_day
- ,event_no_intention
- ,event_multi_pay_seven_day_by_conversion
- ,event_multi_pay_seven_day_by_conversion_cost
- ,mcb_left_time_perf_cpa_bid
- ,mcb_left_time_perf_roi_ratio
- ,mcb_all_day_perf_cpa_bid
- ,mcb_all_day_perf_roi_ratio
- ,live_room_avg_played_seconds
- ,ad_live_share
- ,ad_live_comment
- ,live_played_started
- ,live_played_started_cost
- ,ad_live_follow
- ,ad_live_follow_cost
- ,simple_live_played_started
- ,standard_live_played_started
- ,conversion_component_impression
- ,conversion_component_click
- ,conversion_component_rate
- ,ad_landing_page_impression
- ,ad_app_download_half_impression
- ,event_draw_credit_line
- ,minigame_iaa_purchase_amount
- ,minigame_iaa_purchase_roi
- from media_api.kuaishou_account_report_hourly report
- left join
- (SELECT
- cua.account_id id,
- cua.account_id account_id,
- cp.id project_id,
- product.id product_id,
- ca.id advertiser_id,
- uc.company_id company_id,
- cua.auth_name account_name,
- cp.project_name project_name,
- ca.`name` advertiser_name,
- uc.company_name company_name,
- cp.sale_id sale_id,
- su.id user_id,
- su.leader_id,
- su.org_code org_code
- FROM
- `jeecg-boot`.ctop_user_allocation cua
- 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`.sys_user su ON su.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
- WHERE
- cua.account_id IS NOT NULL
- ) sys
- on report.advertiser_id = sys.account_id
- where report.stat_date between {start_date} and {end_date}
- and report.advertiser_id={account_id}
- """.format(start_date=start_date, end_date=end_date, account_id=account_id)
- TidbConn.upsert(conn=self.conn, sql_buff=sql)
- self.conn.commit()
- TidbConn.conn_close(conn=self.conn)
- print(account_id, '快手账户时报执行完成')
- except Exception as e:
- logging.error(account_id, '执行失败')
- def handler(self, date_type, account_id, start_date, end_date):
- if date_type == "daily":
- self.daily_report(account_id, start_date, end_date)
- else:
- self.hourly_report(account_id, start_date, end_date)
|