|
@@ -0,0 +1,366 @@
|
|
|
+# Author zhaohailiang
|
|
|
+# coding=utf-8
|
|
|
+# @Time : 2021/12/20 2:20 下午
|
|
|
+# @Site :
|
|
|
+# @File : AppKuaishouAccountAdAceneReport.py
|
|
|
+# @Software: PyCharm
|
|
|
+# @contact: zhaohailiang@c-top.com.cn
|
|
|
+# @Tel 18201631162
|
|
|
+import logging
|
|
|
+
|
|
|
+from Apietl.conn.TidbConn import TidbConn
|
|
|
+from Apietl.utlis.Utils import Utils
|
|
|
+
|
|
|
+
|
|
|
+class AppKuaishouAccountAdAceneReport:
|
|
|
+ def __init__(self):
|
|
|
+ self.conn = TidbConn.get_connection()
|
|
|
+ self.parm = Utils.get_task_args()
|
|
|
+ self.date_time = self.parm[0]
|
|
|
+
|
|
|
+ def taskHandler(self):
|
|
|
+ try:
|
|
|
+ sql = """
|
|
|
+ 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_account_ad_scene_report_d`
|
|
|
+ (
|
|
|
+ account_id,
|
|
|
+ stat_date,
|
|
|
+ project_id,
|
|
|
+ product_id,
|
|
|
+ advertiser_id,
|
|
|
+ company_id,
|
|
|
+ account_name,
|
|
|
+ project_name,
|
|
|
+ advertiser_name,
|
|
|
+ company_name,
|
|
|
+ sale_id,
|
|
|
+ sale_name,
|
|
|
+ user_id,
|
|
|
+ user_name,
|
|
|
+ leader_id,
|
|
|
+ leader_name,
|
|
|
+ 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
|
|
|
+ )
|
|
|
+ select
|
|
|
+ report.advertiser_id account_id,
|
|
|
+ report.stat_date,
|
|
|
+ bei.project_id,
|
|
|
+ bei.product_id,
|
|
|
+ bei.advertiser_id,
|
|
|
+ bei.company_id,
|
|
|
+ bei.account_name,
|
|
|
+ bei.project_name,
|
|
|
+ bei.advertiser_name,
|
|
|
+ bei.company_name,
|
|
|
+ bei.sale_id,
|
|
|
+ bei.sale_name,
|
|
|
+ bei.user_id,
|
|
|
+ bei.user_name,
|
|
|
+ bei.leader_id,
|
|
|
+ bei.leader_name,
|
|
|
+ bei.org_code,
|
|
|
+ report.charge,
|
|
|
+ report.`show`,
|
|
|
+ report.photo_click,
|
|
|
+ report.aclick,
|
|
|
+ report.bclick,
|
|
|
+ report.photo_click_ratio,
|
|
|
+ report.play_3s_ratio,
|
|
|
+ report.action_ratio,
|
|
|
+ report.impression_1k_cost,
|
|
|
+ report.photo_click_cost,
|
|
|
+ report.action_cost,
|
|
|
+ report.`share`,
|
|
|
+ report.`comment`,
|
|
|
+ report.`like`,
|
|
|
+ report.follow,
|
|
|
+ report.cancel_follow,
|
|
|
+ report.report,
|
|
|
+ report.block,
|
|
|
+ report.negative,
|
|
|
+ report.submit,
|
|
|
+ report.download_started,
|
|
|
+ report.download_completed,
|
|
|
+ report.activation,
|
|
|
+ report.event_pay_first_day,
|
|
|
+ report.event_pay_purchase_amount_first_day,
|
|
|
+ report.event_pay_first_day_roi,
|
|
|
+ report.event_pay,
|
|
|
+ report.event_pay_purchase_amount,
|
|
|
+ report.event_pay_roi,
|
|
|
+ report.event_register,
|
|
|
+ report.event_register_cost,
|
|
|
+ report.event_register_ratio,
|
|
|
+ report.event_jin_jian_app,
|
|
|
+ report.event_jin_jian_app_cost,
|
|
|
+ report.event_credit_grant_app,
|
|
|
+ report.event_credit_grant_app_cost,
|
|
|
+ report.event_credit_grant_app_ratio,
|
|
|
+ report.event_order_paid,
|
|
|
+ report.event_order_paid_purchase_amount,
|
|
|
+ report.event_order_paid_cost,
|
|
|
+ report.event_next_day_stay,
|
|
|
+ report.event_next_day_stay_cost,
|
|
|
+ report.event_next_day_stay_ratio,
|
|
|
+ report.form_count,
|
|
|
+ report.form_cost,
|
|
|
+ report.form_action_ratio,
|
|
|
+ report.event_jin_jian_landing_page,
|
|
|
+ report.event_jin_jian_landing_page_cost,
|
|
|
+ report.event_credit_grant_landing_page,
|
|
|
+ report.event_credit_grant_landing_page_cost,
|
|
|
+ report.event_credit_grant_landing_page_ratio,
|
|
|
+ report.event_valid_clues,
|
|
|
+ report.event_valid_clues_cost,
|
|
|
+ report.event_add_wechat,
|
|
|
+ report.event_add_wechat_cost,
|
|
|
+ report.event_add_wechat_ratio,
|
|
|
+ report.event_get_through,
|
|
|
+ report.event_get_through_cost,
|
|
|
+ report.event_get_through_ratio,
|
|
|
+ report.event_app_invoked,
|
|
|
+ report.event_app_invoked_cost,
|
|
|
+ report.event_app_invoked_ratio,
|
|
|
+ report.event_credit_grant_landing_ratio,
|
|
|
+ report.play_5s_ratio,
|
|
|
+ report.play_end_ratio,
|
|
|
+ report.event_new_user_pay,
|
|
|
+ report.event_new_user_pay_cost,
|
|
|
+ report.event_new_user_pay_ratio,
|
|
|
+ report.click_1k_cost,
|
|
|
+ report.ad_product_cnt,
|
|
|
+ report.event_goods_view,
|
|
|
+ report.merchant_reco_fans,
|
|
|
+ report.event_order_amount_roi,
|
|
|
+ report.event_goods_view_cost,
|
|
|
+ report.merchant_reco_fans_cost,
|
|
|
+ report.event_button_click,
|
|
|
+ report.event_button_click_cost,
|
|
|
+ report.event_button_click_ratio,
|
|
|
+ report.event_order_paid_roi,
|
|
|
+ report.event_new_user_jinjian_app,
|
|
|
+ report.event_new_user_jinjian_app_cost,
|
|
|
+ report.event_new_user_jinjian_app_roi,
|
|
|
+ report.event_new_user_credit_grant_app,
|
|
|
+ report.event_new_user_credit_grant_app_cost,
|
|
|
+ report.event_new_user_credit_grant_app_roi,
|
|
|
+ report.event_new_user_jinjian_page,
|
|
|
+ report.event_new_user_jinjian_page_cost,
|
|
|
+ report.event_new_user_jinjian_page_roi,
|
|
|
+ report.event_new_user_credit_grant_page,
|
|
|
+ report.event_new_user_credit_grant_page_cost,
|
|
|
+ report.event_new_user_credit_grant_page_roi,
|
|
|
+ report.event_appoint_form,
|
|
|
+ report.event_appoint_form_cost,
|
|
|
+ report.event_appoint_form_ratio,
|
|
|
+ report.event_appoint_jump_click,
|
|
|
+ report.event_appoint_jump_click_cost,
|
|
|
+ report.event_appoint_jump_click_ratio,
|
|
|
+ report.union_event_pay_purchase_amount_7d,
|
|
|
+ report.union_event_pay_purchase_amount_7d_roi,
|
|
|
+ report.placement_type,
|
|
|
+ report.ad_scene,
|
|
|
+ report.event_order_successed,
|
|
|
+ report.ad_photo_played_10s_ratio,
|
|
|
+ report.key_action_cost,
|
|
|
+ report.event_add_shopping_cart_cost,
|
|
|
+ report.event_ad_watch_times_ratio,
|
|
|
+ report.event_outbound_call_cost,
|
|
|
+ report.event_outbound_call,
|
|
|
+ report.action_new_ratio,
|
|
|
+ report.event_watch_app_ad,
|
|
|
+ report.event_multi_conversion_cost,
|
|
|
+ report.event_phone_card_activate,
|
|
|
+ report.ad_photo_played_75percent_ratio,
|
|
|
+ report.key_action_ratio,
|
|
|
+ report.event_ad_watch_times_cost,
|
|
|
+ report.event_add_shopping_cart,
|
|
|
+ report.key_action,
|
|
|
+ report.event_multi_conversion,
|
|
|
+ report.event_wechat_connected,
|
|
|
+ report.event_dsp_gift_form,
|
|
|
+ report.event_intention_confirmed,
|
|
|
+ report.event_phone_get_through,
|
|
|
+ report.event_multi_conversion_ratio,
|
|
|
+ report.event_measurement_house,
|
|
|
+ report.ad_photo_played_2s_ratio,
|
|
|
+ report.event_outbound_call_ratio,
|
|
|
+ report.event_ad_watch_times
|
|
|
+ from (select * from `media_api`.kuaishou_account_ad_scene_report_daily where stat_date={date_time}) 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,
|
|
|
+ sale.realname sale_name,
|
|
|
+ su.id user_id,
|
|
|
+ su.realname user_name,
|
|
|
+ su.leader_id,
|
|
|
+ lea.realname leader_name,
|
|
|
+ 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`.sys_user sale ON sale.id = cp.sale_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`.ctop_product product ON product.id = cp.product_id
|
|
|
+ WHERE
|
|
|
+ cua.account_id IS NOT NULL) bei
|
|
|
+ON report.advertiser_id = bei.account_id;
|
|
|
+ """.format(date_time=self.date_time)
|
|
|
+ TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
|
+ self.conn.commit()
|
|
|
+ TidbConn.conn_close(conn=self.conn)
|
|
|
+ return 0
|
|
|
+ except Exception as e:
|
|
|
+ logging.error(e)
|
|
|
+ return -1
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ status = AppKuaishouAccountAdAceneReport().taskHandler()
|
|
|
+ if status == 0:
|
|
|
+ print("作业执行成功")
|
|
|
+ exit(0)
|
|
|
+ else:
|
|
|
+ print("作业执行失败")
|
|
|
+ exit(-1)
|