|
@@ -0,0 +1,328 @@
|
|
|
+# Author renyupeng
|
|
|
+# coding=utf-8
|
|
|
+# @Time : 2021/9/15 5:10 下午
|
|
|
+# @Site :
|
|
|
+# @File : NewMaterialimageDailyReport.py
|
|
|
+# @Software: PyCharm
|
|
|
+# @contact: renyupeng@c-top.com.cn
|
|
|
+
|
|
|
+import logging
|
|
|
+from Apietl.utlis.Utils import Utils
|
|
|
+from Apietl.conn.TidbConn import TidbConn
|
|
|
+
|
|
|
+
|
|
|
+class NewMaterialimageDailyReport:
|
|
|
+ def __init__(self):
|
|
|
+ self.conn = TidbConn.get_connection()
|
|
|
+ self.parm = Utils.get_live_args()
|
|
|
+ self.start_time = self.parm
|
|
|
+
|
|
|
+ def daily_report(self):
|
|
|
+ try:
|
|
|
+ sql = """
|
|
|
+replace into application.bytedance_material_image_report_daily_dw(account_id, material_id, image_mode, inventory,
|
|
|
+ stat_datetime, project_id, product_id, advertiser_id,
|
|
|
+ company_id, account_name, project_name,
|
|
|
+ advertiser_name, company_name, sale_id, user_id,
|
|
|
+ image_name,
|
|
|
+ cost, `show`, avg_show_cost, click,
|
|
|
+ avg_click_cost, ctr, `convert`, convert_cost,
|
|
|
+ convert_rate, deep_convert, deep_convert_cost,
|
|
|
+ deep_convert_rate, attribution_convert,
|
|
|
+ attribution_convert_cost, attribution_deep_convert,
|
|
|
+ attribution_deep_convert_cost, download_start,
|
|
|
+ download_start_cost, download_start_rate,
|
|
|
+ download_finish, download_finish_cost,
|
|
|
+ download_finish_rate, click_install, install_finish,
|
|
|
+ install_finish_cost, install_finish_rate, active,
|
|
|
+ active_cost, active_rate, register,
|
|
|
+ active_register_cost, active_register_rate,
|
|
|
+ active_pay_amount, next_day_open, next_day_open_cost,
|
|
|
+ next_day_open_rate, attribution_next_day_open_cnt,
|
|
|
+ attribution_next_day_open_cost,
|
|
|
+ attribution_next_day_open_rate, game_addiction,
|
|
|
+ game_addiction_cost, game_addiction_rate, pay_count,
|
|
|
+ active_pay_cost, active_pay_rate, loan_completion,
|
|
|
+ loan_completion_cost, loan_completion_rate,
|
|
|
+ pre_loan_credit, pre_loan_credit_cost, loan_credit,
|
|
|
+ loan_credit_cost, loan_credit_rate, in_app_uv,
|
|
|
+ in_app_detail_uv, in_app_cart, in_app_pay,
|
|
|
+ in_app_order, attribution_game_pay_7d_count,
|
|
|
+ attribution_game_pay_7d_cost,
|
|
|
+ attribution_active_pay_7d_per_count, game_pay_cost,
|
|
|
+ game_pay_count, phone, form, map_search, button, view,
|
|
|
+ download, qq, lottery, vote, message, redirect,
|
|
|
+ shopping, consult, wechat, phone_confirm,
|
|
|
+ phone_connect, consult_effective, coupon,
|
|
|
+ coupon_single_page, redirect_to_shop, poi_collect,
|
|
|
+ poi_address_click, luban_order_cnt,
|
|
|
+ luban_order_stat_amount, luban_order_roi,
|
|
|
+ luban_live_enter_cnt, live_watch_one_minute_count,
|
|
|
+ luban_live_follow_cnt, live_fans_club_join_cnt,
|
|
|
+ luban_live_comment_cnt, luban_live_share_cnt,
|
|
|
+ luban_live_gift_cnt, luban_live_gift_amount,
|
|
|
+ luban_live_slidecart_click_cnt,
|
|
|
+ luban_live_click_product_cnt,
|
|
|
+ luban_live_pay_order_count,
|
|
|
+ luban_live_pay_order_stat_cost, wechat_login_count,
|
|
|
+ attribution_wechat_login_30d_count, wechat_login_cost,
|
|
|
+ attribution_wechat_login_30d_cost,
|
|
|
+ wechat_first_pay_count,
|
|
|
+ attribution_wechat_first_pay_30d_count,
|
|
|
+ wechat_first_pay_cost,
|
|
|
+ attribution_wechat_first_pay_30d_cost,
|
|
|
+ wechat_first_pay_rate,
|
|
|
+ attribution_wechat_first_pay_30d_rate,
|
|
|
+ wechat_pay_amount, attribution_wechat_pay_30d_amount,
|
|
|
+ attribution_wechat_pay_30d_roi, phone_effective,
|
|
|
+ total_play, valid_play, valid_play_cost,
|
|
|
+ valid_play_rate, play_25_feed_break,
|
|
|
+ play_50_feed_break, play_75_feed_break,
|
|
|
+ play_100_feed_break, average_play_time_per_play,
|
|
|
+ play_over_rate, wifi_play_rate, wifi_play,
|
|
|
+ play_duration_sum, advanced_creative_phone_click,
|
|
|
+ advanced_creative_counsel_click,
|
|
|
+ advanced_creative_form_click,
|
|
|
+ advanced_creative_coupon_addition,
|
|
|
+ advanced_creative_form_submit, card_show, share,
|
|
|
+ comment, `like`, follow, home_visited,
|
|
|
+ ies_challenge_click, ies_music_click, location_click,
|
|
|
+ message_action, click_landing_page, click_shopwindow,
|
|
|
+ click_website, click_download, click_call_dy, cpc,
|
|
|
+ cpm, cpa, interact_per_cost, convert_show_rate,
|
|
|
+ play_duration_10s_rate, play_50_feed_break_rate,
|
|
|
+ play_25_feed_break_rate, play_duration_5s_rate,
|
|
|
+ play_duration_2s_rate, average_play_progress,
|
|
|
+ play_100_feed_break_rate, play_duration_3s_rate,
|
|
|
+ play_75_feed_break_rate, play_duration,
|
|
|
+ play_duration_3s, play_duration_2s, play_duration_10s,
|
|
|
+ average_video_play, avg_rank,
|
|
|
+ submit_certification_count, approval_count,
|
|
|
+ first_order_count, first_rental_order_count,
|
|
|
+ commute_first_pay_count, image_url, signature)
|
|
|
+select report.advertiser_id account_id, #'账户ID'
|
|
|
+ report.material_id, #头条素材id
|
|
|
+ '' as image_mode, #素材类型
|
|
|
+ '' as inventory, #广告位
|
|
|
+ report.stat_datetime, #数据起始时间
|
|
|
+ cua.project_id, #项目id
|
|
|
+ product.id product_id, #项目中产品id
|
|
|
+ cua.advertiser_id, #广告主id
|
|
|
+ uc.company_id, #运营人的公司id
|
|
|
+ cua.auth_name account_name, #账户名称
|
|
|
+ cp.project_name, #项目名称
|
|
|
+ ca.name advertiser_name, #广告主名称
|
|
|
+ uc.company_name, #运营人的公司名称
|
|
|
+ cp.sale_id, #项目里的销售id
|
|
|
+ cua.user_id, #运营id
|
|
|
+ image.filename,
|
|
|
+ report.stat_cost,
|
|
|
+ report.show_cnt,
|
|
|
+ '' as show_cost,
|
|
|
+ report.`convert_cnt`,
|
|
|
+ report.`cpc_platform`,
|
|
|
+ report.`ctr`,
|
|
|
+ report.`convert_cnt`,
|
|
|
+ report.`conversion_cost`,
|
|
|
+ report.`conversion_rate`,
|
|
|
+ report.`deep_convert_cnt`,
|
|
|
+ report.`deep_convert_cost`,
|
|
|
+ report.`deep_convert_rate`,
|
|
|
+ '' as `attribution_convert`,
|
|
|
+ '' as `attribution_convert_cost`,
|
|
|
+ '' as `attribution_deep_convert`,
|
|
|
+ '' as `attribution_deep_convert_cost`,
|
|
|
+ report.`click_start_cnt`,
|
|
|
+ report.`click_start_cost`,
|
|
|
+ report.`click_start_rate`,
|
|
|
+ report.`download_finish_cnt`,
|
|
|
+ report.`download_finish_cost`,
|
|
|
+ report.`download_finish_rate`,
|
|
|
+ '' as `click_install`,
|
|
|
+ report.`install_finish_cnt`,
|
|
|
+ report.`install_finish_cost`,
|
|
|
+ report.`install_finish_rate`,
|
|
|
+ report.`active`,
|
|
|
+ report.`active_cost`,
|
|
|
+ report.`active_rate`,
|
|
|
+ report.`active_register`,
|
|
|
+ report.`active_register_cost`,
|
|
|
+ report.`active_register_rate`,
|
|
|
+ '' as `active_pay_amount`,
|
|
|
+ report.`next_day_open`,
|
|
|
+ '' as `next_day_open_cost`,
|
|
|
+ '' as `next_day_open_rate`,
|
|
|
+ report.`attribution_next_day_open_cnt`,
|
|
|
+ report.`attribution_next_day_open_cost`,
|
|
|
+ report.`attribution_next_day_open_rate`,
|
|
|
+ report.`game_addiction`,
|
|
|
+ report.`game_addiction_cost`,
|
|
|
+ report.`game_addiction_rate`,
|
|
|
+ '' as `cnt`,
|
|
|
+ report.`active_pay_cost`,
|
|
|
+ report.`active_pay_rate`,
|
|
|
+ '' as `loan_completion`,
|
|
|
+ '' as `loan_completion_cost`,
|
|
|
+ '' as `loan_completion_rate`,
|
|
|
+ '' as `pre_loan_credit`,
|
|
|
+ '' as `pre_loan_credit_cost`,
|
|
|
+ '' as `loan_credit`,
|
|
|
+ '' as `loan_credit_cost`,
|
|
|
+ '' as `loan_credit_rate`,
|
|
|
+ report.`in_app_uv`,
|
|
|
+ report.`in_app_detail_uv`,
|
|
|
+ report.`in_app_cart`,
|
|
|
+ report.`in_app_pay`,
|
|
|
+ report.`in_app_order`,
|
|
|
+ report.`attribution_game_pay_7d_count`,
|
|
|
+ report.`attribution_game_pay_7d_cost`,
|
|
|
+ '' as `attribution_active_pay_7d_per_count`,
|
|
|
+ report.`game_pay_cost`,
|
|
|
+ report.`game_pay_count`,
|
|
|
+ '' as `phone`,
|
|
|
+ '' as `form`,
|
|
|
+ '' as `map_search`,
|
|
|
+ '' as `button`,
|
|
|
+ '' as `view`,
|
|
|
+ '' as `download`,
|
|
|
+ '' as `qq`,
|
|
|
+ '' as `lottery`,
|
|
|
+ '' as `vote`,
|
|
|
+ '' as `message`,
|
|
|
+ '' as `redirect`,
|
|
|
+ '' as `shopping`,
|
|
|
+ '' as `consult`,
|
|
|
+ '' as `wechat`,
|
|
|
+ '' as `phone_confirm`,
|
|
|
+ '' as `phone_connect`,
|
|
|
+ '' as `consult_effective`,
|
|
|
+ '' as `coupon`,
|
|
|
+ '' as `coupon_single_page`,
|
|
|
+ '' as `redirect_to_shop`,
|
|
|
+ '' as `poi_collect`,
|
|
|
+ '' as `poi_address_click`,
|
|
|
+ '' as `luban_order_cnt`,
|
|
|
+ '' as `luban_order_stat_amount`,
|
|
|
+ '' as `luban_order_roi`,
|
|
|
+ '' as `luban_live_enter_cnt`,
|
|
|
+ '' as `live_watch_one_minute_count`,
|
|
|
+ '' as `luban_live_follow_cnt`,
|
|
|
+ '' as `live_fans_club_join_cnt`,
|
|
|
+ '' as `luban_live_comment_cnt`,
|
|
|
+ '' as `luban_live_share_cnt`,
|
|
|
+ '' as `luban_live_gift_cnt`,
|
|
|
+ '' as `luban_live_gift_amount`,
|
|
|
+ '' as `luban_live_slidecart_click_cnt`,
|
|
|
+ '' as `luban_live_click_product_cnt`,
|
|
|
+ '' as `luban_live_pay_order_count`,
|
|
|
+ '' as `luban_live_pay_order_stat_cost`,
|
|
|
+ '' as `wechat_login_count`,
|
|
|
+ '' as `attribution_wechat_login_30d_count`,
|
|
|
+ '' as `wechat_login_cost`,
|
|
|
+ '' as `attribution_wechat_login_30d_cost`,
|
|
|
+ '' as `wechat_first_pay_count`,
|
|
|
+ '' as `attribution_wechat_first_pay_30d_count`,
|
|
|
+ '' as `wechat_first_pay_cost`,
|
|
|
+ '' as `attribution_wechat_first_pay_30d_cost`,
|
|
|
+ '' as `wechat_first_pay_rate`,
|
|
|
+ '' as `attribution_wechat_first_pay_30d_rate`,
|
|
|
+ '' as `wechat_pay_amount`,
|
|
|
+ '' as `attribution_wechat_pay_30d_amount`,
|
|
|
+ '' as `attribution_wechat_pay_30d_roi`,
|
|
|
+ '' as `phone_effective`,
|
|
|
+ '' as `total_play`,
|
|
|
+ '' as `valid_play`,
|
|
|
+ '' as `valid_play_cost`,
|
|
|
+ '' as `valid_play_rate`,
|
|
|
+ '' as `play_25_feed_break`,
|
|
|
+ '' as `play_50_feed_break`,
|
|
|
+ '' as `play_75_feed_break`,
|
|
|
+ '' as `play_100_feed_break`,
|
|
|
+ '' as `average_play_time_per_play`,
|
|
|
+ '' as `play_over_rate`,
|
|
|
+ '' as `wifi_play_rate`,
|
|
|
+ '' as `wifi_play`,
|
|
|
+ '' as `play_duration_sum`,
|
|
|
+ '' as `advanced_creative_phone_click`,
|
|
|
+ '' as `advanced_creative_counsel_click`,
|
|
|
+ '' as `advanced_creative_form_click`,
|
|
|
+ '' as `advanced_creative_coupon_addition`,
|
|
|
+ '' as `advanced_creative_form_submit`,
|
|
|
+ '' as `card_show`,
|
|
|
+ '' as `share`,
|
|
|
+ '' as `comment`,
|
|
|
+ '' as `like`,
|
|
|
+ '' as `follow`,
|
|
|
+ '' as `home_visited`,
|
|
|
+ '' as `ies_challenge_click`,
|
|
|
+ '' as `ies_music_click`,
|
|
|
+ '' as `location_click`,
|
|
|
+ '' as `message_action`,
|
|
|
+ '' as `click_landing_page`,
|
|
|
+ '' as `click_shopwindow`,
|
|
|
+ '' as `click_website`,
|
|
|
+ '' as `click_download`,
|
|
|
+ '' as `click_call_dy`,
|
|
|
+ '' as `cpc`,
|
|
|
+ '' as `cpm`,
|
|
|
+ '' as `cpa`,
|
|
|
+ '' as `interact_per_cost`,
|
|
|
+ '' as `convert_show_rate`,
|
|
|
+ '' as `play_duration_10s_rate`,
|
|
|
+ '' as `play_50_feed_break_rate`,
|
|
|
+ '' as `play_25_feed_break_rate`,
|
|
|
+ '' as `play_duration_5s_rate`,
|
|
|
+ '' as `play_duration_2s_rate`,
|
|
|
+ '' as `average_play_progress`,
|
|
|
+ '' as `play_100_feed_break_rate`,
|
|
|
+ '' as `play_duration_3s_rate`,
|
|
|
+ '' as `play_75_feed_break_rate`,
|
|
|
+ '' as `play_duration`,
|
|
|
+ '' as `play_duration_3s`,
|
|
|
+ '' as `play_duration_2s`,
|
|
|
+ '' as `play_duration_10s`,
|
|
|
+ '' as `average_video_play`,
|
|
|
+ '' as `avg_rank`,
|
|
|
+ '' as `submit_certification_count`,
|
|
|
+ '' as `approval_count`,
|
|
|
+ '' as `first_order_count`,
|
|
|
+ '' as `first_rental_order_count`,
|
|
|
+ '' as `commute_first_pay_count`,
|
|
|
+ image.image_url,
|
|
|
+ image.signature
|
|
|
+from media_api.bytedance_material_image_daily report
|
|
|
+ left join
|
|
|
+ `media_api`.bytedance_file_image_get image
|
|
|
+ on report.material_id = image.material_id
|
|
|
+ and report.advertiser_id = image.advertiser_id
|
|
|
+ left join `jeecg-boot`.ctop_user_allocation cua
|
|
|
+ on report.advertiser_id = cua.account_id
|
|
|
+ left join `jeecg-boot`.ctop_advertiser ca
|
|
|
+ on cua.advertiser_id = ca.id
|
|
|
+ left join `jeecg-boot`.ctop_project cp
|
|
|
+ on cua.project_id = cp.id
|
|
|
+ left join `jeecg-boot`.user_company uc
|
|
|
+ on cua.user_id = uc.user_id
|
|
|
+ left join `jeecg-boot`.ctop_product product
|
|
|
+ on cp.product_id = product.id
|
|
|
+ left join `jeecg-boot`.sys_user su
|
|
|
+ on cua.user_id = su.id
|
|
|
+where report.stat_datetime = {start_time}
|
|
|
+ """.format(start_time=self.start_time)
|
|
|
+ print(sql)
|
|
|
+ TidbConn.upsert(conn=self.conn, sql_buff=sql)
|
|
|
+ self.conn.commit()
|
|
|
+ TidbConn.conn_close(conn=self.conn)
|
|
|
+ except Exception as e:
|
|
|
+ logging.error(e)
|
|
|
+ return -1
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ status = NewMaterialimageDailyReport().daily_report()
|
|
|
+ if status == 0:
|
|
|
+ print("作业执行成功")
|
|
|
+ exit(0)
|
|
|
+ else:
|
|
|
+ print("作业执行失败")
|
|
|
+ exit(-1)
|