# -*- coding:UTF-8 -*-
# @Time  : 2020/9/15 16:17
# @File  : user_behavior_path.py
# @email : litao@igengmei.com
# @author : litao


# -*- coding:UTF-8 -*-
# @Time  : 2020/9/8 13:39
# @File  : spark_test.py
# @email : litao@igengmei.com
# @author : litao

# -*- coding:UTF-8 -*-
# @Time  : 2020/9/4 17:07
# @File  : search_meigou_ctr.py
# @email : litao@igengmei.com
# @author : litao

import hashlib
import json

import pymysql
import xlwt, datetime
import redis
# from pyhive import hive
from maintenance.func_send_email_with_file import send_file_email
from typing import Dict, List
from elasticsearch_7 import Elasticsearch
from elasticsearch_7.helpers import scan
import sys
import time
from pyspark import SparkConf
from pyspark.sql import SparkSession, DataFrame


# from pyspark.sql.functions import lit
# import pytispark.pytispark as pti


def con_sql(sql):
    # 从数据库的表里获取数据

    db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy',
                         db='jerry_prod')
    cursor = db.cursor()
    cursor.execute(sql)
    result = cursor.fetchall()
    db.close()
    return result


startTime = time.time()
sparkConf = SparkConf()
sparkConf.set("spark.sql.crossJoin.enabled", True)
sparkConf.set("spark.debug.maxToStringFields", "100")
sparkConf.set("spark.tispark.plan.allow_index_double_read", False)
sparkConf.set("spark.tispark.plan.allow_index_read", True)
sparkConf.set("spark.hive.mapred.supports.subdirectories", True)
sparkConf.set("spark.hadoop.mapreduce.input.fileinputformat.input.dir.recursive", True)
sparkConf.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
sparkConf.set("mapreduce.output.fileoutputformat.compress", False)
sparkConf.set("mapreduce.map.output.compress", False)
sparkConf.set("prod.gold.jdbcuri",
              "jdbc:mysql://172.16.30.136/doris_prod?user=doris&password=o5gbA27hXHHm&rewriteBatchedStatements=true")
sparkConf.set("prod.mimas.jdbcuri",
              "jdbc:mysql://172.16.30.138/mimas_prod?user=mimas&password=GJL3UJe1Ck9ggL6aKnZCq4cRvM&rewriteBatchedStatements=true")
sparkConf.set("prod.gaia.jdbcuri",
              "jdbc:mysql://172.16.30.143/zhengxing?user=work&password=BJQaT9VzDcuPBqkd&rewriteBatchedStatements=true")
sparkConf.set("prod.tidb.jdbcuri",
              "jdbc:mysql://172.16.40.158:4000/eagle?user=st_user&password=aqpuBLYzEV7tML5RPsN1pntUzFy&rewriteBatchedStatements=true")
sparkConf.set("prod.jerry.jdbcuri",
              "jdbc:mysql://172.16.40.158:4000/jerry_prod?user=st_user&password=aqpuBLYzEV7tML5RPsN1pntUzFy&rewriteBatchedStatements=true")
sparkConf.set("prod.tispark.pd.addresses", "172.16.40.158:2379")
sparkConf.set("prod.tispark.pd.addresses", "172.16.40.170:4000")
sparkConf.set("prod.tidb.database", "jerry_prod")
sparkConf.setAppName("user_behavior_path")

spark = (SparkSession.builder.config(conf=sparkConf).config("spark.sql.extensions", "org.apache.spark.sql.TiExtensions")
         .config("spark.tispark.pd.addresses", "172.16.40.170:2379").enableHiveSupport().getOrCreate())

spark.sql("ADD JAR hdfs:///user/hive/share/lib/udf/brickhouse-0.7.1-SNAPSHOT.jar")
spark.sql("ADD JAR hdfs:///user/hive/share/lib/udf/hive-udf-1.0-SNAPSHOT.jar")
spark.sql("CREATE TEMPORARY FUNCTION json_map AS 'brickhouse.udf.json.JsonMapUDF'")
spark.sql("CREATE TEMPORARY FUNCTION is_json AS 'com.gmei.hive.common.udf.UDFJsonFormatCheck'")
spark.sql("CREATE TEMPORARY FUNCTION arrayMerge AS 'com.gmei.hive.common.udf.UDFArryMerge'")

task_list = []
task_days = 8

name_dict = {
    "/api/my_order/recommend/service/list": "我的订单页推荐美购列表",
    "/api/private_conversation": "私信事件",
    "activity_list_click_tab": "免费活动列表页点击TAB",
    "activity_promotion_index_benefits_tab": "大促活动聚合页点击美购分区TAB",
    "activity_promotion_index_imgmix": "大促活动聚合页点击内容混排",
    "activity_promotion_seckill_collect": "大促活动秒杀页点击美购收藏按钮",
    "activity_promotion_seckill_notice": "大促活动秒杀页点击提醒我按钮",
    "activity_promotion_seckill_remindme": "大促活动秒杀页点击提醒我按钮",
    "activity_promotion_seckill_service": "大促活动秒杀页点击美购卡片",
    "activity_show_click_invite_code_btn": "某综艺投票活动页点击榜单头像",
    "activity_show_click_vote": "某综艺投票活动页投票弹窗投票按钮点击",
    "activity_show_vote_click_votebtn": "某综艺投票活动页点击投票按钮",
    "activity_zone_detail_click_hide_more": "当用户点击收起按钮时",
    "activity_zone_detail_click_show_more": "当用户点击展开全部按钮时",
    "all_case_service_comment_click_tab": "美购评论列表页点击TAB按钮",
    "all_cases_click_item": "美购详情页点击日记本卡片",
    "all_result_click_item": "当用户点击搜索结果卡片中的单项时",
    "all_result_click_more": "当用户点击搜索结果卡片中的查看更多按钮时",
    "all_sort_click_sort": "选择项目页点击分类标签按钮",
    "all_sort_click_tab": "全部分类页点击TAB",
    "all_wiki_click_banner": "当用户点击广告位时",
    "all_wiki_click_wikis_item": "全部百科页点击百科卡片",
    "answer_detail_click_add_comment": "回答详情页点击添加一级评论按钮",
    "answer_detail_click_all_answer": "回答详情页点击所有回答按钮",
    "answer_detail_click_all_comment": "回答详情页点击查看全部评论按钮",
    "answer_detail_click_avatar": "回答详情页点击作者头像按钮",
    "answer_detail_click_recommend_block": "回答详情页点击推荐卡片",
    "answer_detail_click_service_button": "回答详情页点击美购卡片",
    "answer_detail_click_service_related": "回答详情页点击关联美购和吸顶美购卡片",
    "answer_detail_click_switch_page": "回答详情页点击上一篇或下一篇按钮",
    "answer_detail_click_vote": "回答详情页点击赞",
    "answer_meigou_wow_click_service": "回答详情页点击底部美购卡片",
    "article_detail_click_recommend_block": "专栏详情页点击推荐卡片",
    "attention_click": "点击关注",
    "authority_page_click": "授权浮层页点击授权按钮",
    "batch_topic_create_diary": "创建日记贴页点击发布按钮",
    "big_wheel_click_raffle_immediately": "新专题页大转盘区域点击抽奖",
    "bind_order_wow_click_sure": "绑定订单弹窗点击确定",
    "broadcast_live_leave": "直播页离开",
    "category_click_tab": "品类聚合页点击TAB",
    "category_hot_brand_click_all": "点击热门品牌模块_全部",
    "change_diary_info_click_complete_btn": "获取日记本信息页点击完成按钮",
    "choiceness_click_banner": "当用户点击点击每个大banner时",
    "click_adposition_expert_item": "当用户点击带有广告位的专家列表项时",
    "click_adposition_welfare_item": "点击广告位美购",
    "click_group_card": "点击小组区",
    "click_home_notification": "首页点击推送弹窗",
    "click_horizontal_templates_item": "当用户点击单排横滑模板项时",
    "click_hot_brand": "点击热门品牌",
    "click_message_hf": "点击私信横幅",
    "click_static_templates_sub_item": "点击运营位豆腐块",
    "click_wiki_detail_button": "点击百科聚合",
    "click_wiki_item_button": "点击项目百科",
    "comment_item_click_avatar": "帖子详情页-用户评论-去往用户个人主页",
    "comment_item_click_more": "日记本详情页点击某条评论的更多按钮",
    "comment_item_click_reply": "日记本详情页-点击某条评论的评论按钮或者评论区域",
    "comment_item_click_reply_comment": "评论弹出框点击回复评论",
    "comment_item_click_reply_post": "点击弹出框中回复框（回复帖子）",
    "comment_item_click_vote": "帖子评论弹出框点赞",
    "comment_list_click_comment": "当用户点击TAB时",
    "comment_list_click_source": "当用户点击日记本/帖子链接时",
    "community_home_click_channel": "当用户点击顶部固定按钮区单项（频道入口）时",
    "community_home_click_feed_card": "发现页点击FEED流卡片",
    "community_home_click_focus_card": "点击已关注小组卡片",
    "community_home_click_hot_zone_item": "当用户点击热门圈子项",
    "community_home_click_hotin24hs": "当用户点击横滑第一项即24小时最热时",
    "community_home_click_more_zone": "当用户点击热门圈子的查看全部按钮时",
    "community_home_click_operation_card": "社区首页点击运营位卡片",
    "community_home_click_qa_item_comment": "当用户点击好评列表项中的评论内容时",
    "community_home_click_qa_item_portrait": "当用户点击好评列表项中的评论头像时",
    "community_home_click_qa_item_topic": "当用户点击好评列表项中的帖子内容时",
    "community_home_click_recomment_card": "当用户点击_推荐小组卡片",
    "community_home_click_recomment_focus_button": "当用户点击_推荐小组关注按钮",
    "community_home_click_selected_banner": "当用户点击每个精选活动时",
    "community_home_click_selected_banner_more": "当用户点击精选活动查看更多时",
    "community_home_click_tab": "当用户点击置顶项时",
    "community_home_click_topic_item": "当用户点击各TAB下的帖子列表项时",
    "community_home_click_topup": "当用户点击置顶项时",
    "consult_home_click_diagnosis": "当用户点击自助问诊（快速咨询）按钮时",
    "consult_home_click_doctor_item": "当用户点击找专家专家项时",
    "consult_home_click_doctor_more": "当用户点击找专家查看全部按钮时",
    "consult_home_click_free_customization": "当用户点击免费定制时",
    "consult_home_click_itemwiki": "当用户点击科普知识时",
    "consult_home_click_selected_theme": "当用户点击精选主题时",
    "consult_home_click_wiki_hot": "当用户点击查百科热门百科项时",
    "contentaggre_click_middle_tab": "首页点击视频TAB",
    "contentaggre_click_top": "内容聚合页点击置顶条按钮",
    "conversation_detail_click_diary_card": "私信详情页点击日记本卡片",
    "conversation_detail_click_gift": "私信详情页点击红包按钮",
    "conversation_detail_click_report": "私信详情页点击举报有奖按钮",
    "coupon_center_click_alltab": "美券中心点击所有美券TAB",
    "coupon_center_click_listpage_button": "美券中心奠基列表按钮",
    "coupon_modal_click_share_channel": "分享美券浮层点击分享渠道",
    "coupon_welfare_list_click_get": "美券相关的美购列表页点击领券按钮",
    "coupon_welfare_list_click_tab": "美券相关的美购列表页点击TAB",
    "create_diary_click_next": "创建日记本标题页点击下一步按钮",
    "create_topic_click_video": "日记贴详情页点击添加视频按钮",
    "create_topic_upload_video": "七牛图片编辑页点击上传按钮",
    "create_topic_upload_video_success": "七牛图片编辑页视频上传成功",
    "dbtc_click_create_new_diary_btn": "创建日记本标题页点击新增一篇日记按钮",
    "diagnosis_click_option": "当用户点击咨询选项时",
    "diagnosis_click_restart": "当用户点击导航栏中的重新咨询按钮时",
    "diagnosis_click_wiki_detail": "当用户点击标签卡片上的查看百科介绍按钮时",
    "diagnosis_click_wiki_related_service": "当用户点击标签卡片上的查看相关美购按钮时",
    "diary_book_change_cover_click": "获取日记本信息页点击修改选项",
    "diary_book_create_click": "我的日记页点击创建日记本按钮",
    "diary_book_image_click": "我的日记本页点击图片",
    "diary_book_list_item_click": "日记本列表页点击日记本卡片",
    "diary_book_topic_create_click_changetime_btn": "创建日记贴页点击修改时间按钮",
    "diary_buy_immediately_wow_click_service": "日记详情页点击底部美购卡片",
    "diary_card_click_banner": "点击大图横滑BANNER",
    "diary_card_click_iffold": "评价页面日记卡片点击展开或者收起",
    "diary_card_click_vote": "日记本卡片点赞或取消赞",
    "diary_detail_bottom_click_same_service": "日记贴详情页点击同类美购按钮",
    "diary_detail_bottom_click_samediary_icon": "日记本详情页_底栏_点击_同类日记按钮",
    "diary_item_click_avatar": "日记本卡片-点击作者头像",
    "diary_item_click_banner": "首页精选tab-点击feed流banner",
    "diary_item_click_comment": "日记本卡片-点击评论按钮",
    "diary_item_click_image": "日记本卡片-点击图片",
    "diary_item_click_vote": "日记本卡片-点赞",
    "diary_list_click_item": "跳转到日记本详情页",
    "diary_order_wow_click": "订单评价弹窗_点击",
    "diary_topic_image_click": "日记贴创建页-点击已添加的图片",
    "diarybook_detail_bottom_click_collect": "日记详情页点击收藏按钮",
    "diarybook_detail_click_add_diary": "日记详情页点击更新日记按钮",
    "diarybook_detail_click_adjust": "日记详情页点击手术时间不准按钮",
    "diarybook_detail_click_after_album": "日记详情页点击术后相册按钮",
    "diarybook_detail_click_before_album": "日记详情页点击术前相册",
    "diarybook_detail_click_buy_immediately": "日记详情页点击立即咨询按钮",
    "diarybook_detail_click_cashback_area": "日记详情页点击返现区",
    "diarybook_detail_click_comment": "日记详情页点击评论按钮",
    "diarybook_detail_click_comment_button": "日记详情页点击美购n评价按钮",
    "diarybook_detail_click_diary_item": "日记详情页点击日记卡片",
    "diarybook_detail_click_float_comment": "日记详情页点击浮动条评论按钮",
    "diarybook_detail_click_fold_topic": "日记详情页点击收起全文按钮",
    "diarybook_detail_click_group_area": "日记详情页点击小组区",
    "diarybook_detail_click_header": "日记详情页点击作者头像按钮",
    "diarybook_detail_click_hot_comments": "点击热门/最新评论区",
    "diarybook_detail_click_input": "日记详情页点击评论框",
    "diarybook_detail_click_lookallpicture_button": "日记详情页点击查看全部图片按钮",
    "diarybook_detail_click_more_topic": "日记详情页点击查看更多日记按钮",
    "diarybook_detail_click_organization_button": "日记详情页点击机构按钮",
    "diarybook_detail_click_previous_photo": "日记详情页点击术前照片",
    "diarybook_detail_click_recommend_block": "日记详情页点击推荐卡片",
    "diarybook_detail_click_recommend_service": "日记详情页点击美购卡片",
    "diarybook_detail_click_recommend_service_more": "日记详情页点击推荐美购区域的更多按钮",
    "diarybook_detail_click_same_diary": "日记详情页点击同类日记按钮",
    "diarybook_detail_click_same_service_button": "日记详情页点击同类商品区卡片",
    "diarybook_detail_click_service_block": "日记详情页点击顶部美购卡片",
    "diarybook_detail_click_service_related": "日记详情页点击美购卡片",
    "diarybook_detail_click_sort": "日记详情页点击排序项按钮",
    "diarybook_detail_click_tag_block": "点击顶部TAG区域",
    "diarybook_detail_click_topafter_picture": "日记详情页点击顶部afte图",
    "diarybook_detail_click_unfold_topic": "日记详情页点击展开全文按钮",
    "diarybook_detail_click_view_all_comments": "日记详情页点击查看全部评论按钮",
    "diarybook_detail_click_vote": "日记详情页点击赞(感谢)按钮",
    "diarybook_detail_click_wiki_button": "日记详情页点击百科卡片",
    "diarytopic_detail_click_comment_button": "日记贴详情页点击美购N评价按钮",
    "diarytopic_detail_click_lowbar_comment": "日记贴详情页点击底部BAR按钮",
    "diarytopic_detail_click_organization_button": "日记贴详情页点击机构按钮",
    "diarytopic_detail_click_same_service_button": "日记贴详情页点击同类商品区卡片",
    "dig_privacy_click_item": "更美扒扒扒页点击列表卡片",
    "director_column_click_item": "专栏详情页点击列表项卡片",
    "do_search": "点击执行搜索按钮",
    "doing_spell_order_detail_click_applyrefund": "拼中_订单详情页点击申请退款按钮",
    "doing_spell_order_detail_click_invitespell": "拼中_订单详情页点击邀请好友参团",
    "edit_insurance_click_cancel_buy": "保险信息填写页弹窗点击确认或不买了按钮",
    "edit_insurance_click_confirm_submit": "保险信息填写页点击确认购买弹窗的知道了按钮",
    "edit_insurance_click_insurance_rule": "保险信息填写页点击保险条款按钮",
    "edit_insurance_click_user_rule": "保险信息填写页点击用户须知按钮",
    "expert_detail_click_case": "点击头部的案例按钮",
    "expert_detail_click_diary": "医生主页真人案例栏点击日记本卡片",
    "expert_detail_click_diary_all": "医生主页点击案例栏查看全部按钮",
    "expert_detail_click_follow": "医生主页点击关注按钮",
    "expert_detail_click_maidan": "医生主页点击优惠买单按钮",
    "expert_detail_click_message": "医生主页点击在线咨询按钮",
    "expert_detail_click_phone": "医生主页点击电话咨询按钮",
    "expert_detail_click_qa": "点击头部的答疑按钮",
    "expert_detail_click_read_address": "医生主页点击查看地址信息按钮",
    "expert_detail_click_read_all": "医生主页点击头部阅读全部按钮",
    "expert_detail_click_topic": "医生主页点击发布帖子按钮",
    "expert_detail_click_topic_all": "医生主页真人案例栏点击查看更多按钮",
    "expert_detail_click_welfare_all": "医生主页热卖美购栏点击查看更多按钮",
    "face_analyze_share": "人脸分析上传分析页点击分享按钮",
    "face_click_skip": "各页面点击“跳过”按钮",
    "face_result_click_banner": "人脸分析面部分析结果页点击BANNER",
    "face_result_click_option": "人脸分析颜值报告报告页点击点击查看相关项目按钮",
    "face_result_click_related_services": "人脸分析颜值报告报告页点击查看相关项目按钮",
    "face_result_click_result": "人脸分析面部分析结果页点击五官结论按钮",
    "famous_doctor_vote": "青年医生大赛点击分享按钮",
    "find_expert_click_tab": "找专家页点击TAB",
    "free_activity_click_item": "免费活动列表页点击免费活动卡片",
    "free_activity_detail_click_remind": "免费活动详情页点击我要报名按钮",
    "full_stack_click_video_card_full_screen_play": "视频卡片点击全屏播放",
    "goto_activity": "点击前往活动页",
    "goto_set_notification": "消息首页点击立即前往",
    "goto_welfare_detail": "前往美购详情页点击事件集合",
    "goto_welfare_special": "跳转美购专题页点击",
    "goto_zone": "跳转圈子页点击",
    "home_choice_click_live_card": "点击直播卡片",
    "home_click_awards_popup": "首页点击红包弹窗",
    "home_click_button": "首页点击顶部ICON",
    "home_click_function_entrance_btn": "首页点击功能区",
    "home_click_icon_area_someone": "首页点击ICON",
    "home_click_item": "首页点击信息流卡片",
    "home_click_little_banner": "首页点击小BANNER",
    "home_click_navbar_area": "首页点击导航栏地域选择按钮",
    "home_click_section": "首页点击ICON",
    "home_click_sign_wow": "首页点击签到浮窗按钮",
    "home_click_tab": "首页点击TAB切换按钮",
    "home_click_tab_new": "首页点击TAB切换按钮",
    "home_topic_item_click_image": "点击关注Tab下帖子的图片",
    "hot_wiki_click_item_content": "点击列表项中的内容部分",
    "hot_wiki_click_item_tag": "点击列表项标签部分中的某一标签时",
    "installment_renmai_contaction_next": "联系人信息页点击下一步按钮",
    "installment_renmai_get_contacts": "联系人信息页点击通讯录按钮",
    "installment_renmai_get_verifycode": "分期额度详情页点击个人信息中的获取验证码按钮",
    "installment_renmai_plan_next": "分期额度详情页点击选择分期中的下一步按钮",
    "installment_renmai_workinfo_next": "分期额度详情页点击工作信息中的下一步按钮",
    "installment_yrd_click_bill": "绑定银行卡流程点击提交",
    "invite_for_gift_click_share": "邀请好友页点击分享按钮",
    "invite_friends_click": "点击分享我的邀请码给好友按钮",
    "items_select_click_sure_btn": "选择项目页点击确定按钮",
    "kefu_consult_click_common_problem": "客服详情页点击常见问题按钮",
    "kefu_consult_click_more": "客服详情页点击更多(...)按钮",
    "kefu_consult_click_phone": "客服详情页点击拨打电话按钮",
    "level2_wiki_click_tag": "点击某一个三级百科项时",
    "live_audience_click_msg": "直播页点击私信按钮",
    "live_share_click": "直播页点击分享按钮",
    "login_click_find_password": "注册页点击忘记密码按钮",
    "login_click_login": "注册页点击第三方登录按钮",
    "login_click_register": "注册页点击注册按钮",
    "login_click_use_password": "注册页点击切换到密码登陆按钮",
    "maidan_desc_click": "点击买单说明",
    "maidan_detail_hospital_click": "买单详情页点击医院头像按钮",
    "maidan_detail_map_click": "买单详情页点击地图按钮",
    "maidan_detail_message_click": "买单详情页点击私信咨询ICON",
    "maidan_detail_tel_click": "买单详情页点击电话咨询ICON",
    "maidan_money_click": "结算单详情页点击输入金额按钮",
    "maidan_nopay_detail_cancel_click": "我的订单页点击取消订单按钮",
    "maidan_nopay_detail_paymentbutton_click": "我的订单页待付款TAB点击支付按钮",
    "maidan_payment_click": "支付订单页点击支付按钮",
    "maidan_tagselected_finish": "搜索标签页点击完成按钮",
    "mail_address_click_cancel": "邮件地址页点击取消按钮",
    "mail_address_click_submit": "邮件地址页点击提交按钮",
    "main_click_tab": "首页点击底部TAB",
    "message_home_click_tab": "消息首页点击TAB",
    "message_home_click_votecollect": "消息首页点击赞与收藏或回复按钮",
    "message_home_favor_click_item": "收到点赞页点击赞与收藏条",
    "message_home_favor_click_tab": "赞和评论页点击tab",
    "message_home_notification_click_item": "消息首页通知子页点击推送消息列表卡片",
    "my_coupon_click_tab": "我的美券页点击TAB",
    "my_diary_bind_order_confirm_click": "我的日记本页_绑定订单确认弹窗_点击_去绑定/下次再说",
    "my_diary_book_click_edit": "我的日记页点击编辑日记本按钮",
    "my_diary_book_detail_click_edit": "我的日记页点击编辑日记本按钮",
    "my_diary_click_change_info_btn": "我的日记页点击修改信息按钮",
    "my_diary_click_tipsitem": "我的日记页点击提示条按钮",
    "my_message_list_click_item": "消息首页点击通知消息条目",
    "my_order_click_common_problem": "我的订单页点击常见问题按钮",
    "my_order_click_order_book": "我的订单页点击预约按钮",
    "my_order_click_order_invitespell": "我的订单页点击邀请好友按钮",
    "my_order_click_order_other_pay": "点击订单卡片（申请分期后状态）的其他方式支付按钮时",
    "my_order_click_order_rate": "我的订单页点击订单卡片去评价按钮",
    "my_order_click_settlement_item": "我的订单页点击订单卡片",
    "my_order_click_settlement_pay": "我的订单页待付款TAB点击去付款按钮",
    "my_order_click_tab": "我的订单页点击TAB按钮",
    "my_topic_click_create_question": "我的问题页问题TAB点击我要提问按钮",
    "my_topic_click_tab": "我的问题页点击TAB按钮",
    "my_unused_coupon_click_to_use": "美券相关的美购列表页点击去使用按钮",
    "mymaidan_customerservice_click": "个人主页点击客服中心ICON",
    "mymaidan_nopay_click": "我的订单页点击未付款TAB",
    "mymaidan_nopay_item_click": "我的订单页待付款TAB点击待付款订单卡片",
    "mymaidan_nopay_paymentbutton_click": "我的订单页待付款TAB点击去付款按钮",
    "mymaidan_pay_click": "我的订单页点击已付款TAB",
    "mymaidan_pay_item_click": "我的订单页点击订单卡片",
    "mytopic_click_tab": "我的帖子页点击TAB按钮",
    "navigation_click": "医院主页点击导航按钮",
    "new_sign_click_activity_rules": "新签到页点击规则按钮",
    "new_sign_click_calendar": "新签到页点击美分按钮",
    "new_sign_click_convert": "新签到页点击兑换按钮",
    "new_sign_click_exchange": "新签到页点击兑换按钮",
    "new_sign_click_exchange_record": "新签到页点击兑换纪录按钮",
    "new_sign_click_immediately_retroactive": "新签到页点击立即补签按钮",
    "new_sign_click_remind_switch": "新签到页点击开启OR关闭提醒按钮",
    "new_sign_click_sign": "新签到页点击签到或重新签到按钮",
    "new_sign_click_signin_remind": "新签到页点击签到提醒按钮",
    "new_sign_click_wow_sure": "新签到页点击兑换弹窗确认按钮",
    "newt_welfare_special_click_choose_area": "新美购专题页点击地址选择按钮",
    "newt_welfare_special_click_play_video": "新美购专题页点击视频播放按钮",
    "newt_welfare_special_click_storey_picture": "新美购专题页点击图片卡片",
    "newt_welfare_special_video_click_pic_item": "新美购专题页点击视频播放或图片条",
    "newt_welfare_special_video_click_tab": "新美购专题页点击TAB",
    "notification_authorize_warm_prompt_click": "首页点击push弹窗开启或关闭按钮",
    "on_click_answer_card": "点击回答卡片",
    "on_click_apply": "报名页面点击立即报名",
    "on_click_article_card": "点击专栏卡片",
    "on_click_banner": "BANNER点击",
    "on_click_big_recommend_card": "点击大图横滑BANNER",
    "on_click_button": "按钮点击事件",
    "on_click_buutton": "按钮点击事件",
    "on_click_card": "卡片点击事件",
    "on_click_category": "品类聚合页点击ICON",
    "on_click_city_filter": "选择城市页国际/港澳台TAB点击城市",
    "on_click_city_filter_real": "选择城市页中国TAB点击城市",
    "on_click_comment": "评论事件点击",
    "on_click_common_webview_share": "直播预告分享",
    "on_click_create_topic": "创建日记帖点击",
    "on_click_diary_card": "跳转到日记本详情页",
    "on_click_exposure_service": "首页点击日记本卡片外漏美购",
    "on_click_face_analyze": "个人主页点击人脸识别BANNER",
    "on_click_favor": "点击收藏按钮",
    "on_click_filter_item": "筛选器选项点击",
    "on_click_fold_recommend_region": "他人个人主页点击推荐用户模块",
    "on_click_function": "功能区按钮点击",
    "on_click_jumping_hot_word": "搜索首页点击热门搜索词",
    "on_click_multitopic": "首页点击大杂烩置顶条目",
    "on_click_navbar_cart": "搜索导航栏点击购物车按钮",
    "on_click_operation_card_a": "点击首页精选-运营位A",
    "on_click_operation_card_b": "点击首页精选-运营位B",
    "on_click_organization_album_picture": "医院主页点击医院相册图片",
    "on_click_organization_album_video": "医院主页点击视频播放按钮",
    "on_click_pgc_item_click": "搜索结果页点击pgc",
    "on_click_pgc_item_more": "搜索结果页点击查看更多",
    "on_click_play": "百科详情页视频播放按钮点击",
    "on_click_post_comment": "帖子评论按钮点击",
    "on_click_post_comment_input": "帖子评论输入框点击",
    "on_click_post_favor": "帖子收藏按钮点击",
    "on_click_post_out_comment": "帖子露出评论点击",
    "on_click_post_tag": "点击帖子标签",
    "on_click_post_unfold": "帖子展开点击",
    "on_click_post_vote": "帖子点赞",
    "on_click_private_message_button": "他人页面-点击私信按钮",
    "on_click_question_card": "点击问题卡片",
    "on_click_rank_card": "点击榜单卡片",
    "on_click_reply_block": "点击回复",
    "on_click_search": "标签点击",
    "on_click_seckill_module": "美购首页点击限时秒杀BANNER",
    "on_click_simulator_alert_share": "人脸分析颜值报告报告页点击用户调研按钮",
    "on_click_static_button": "点击大图横滑BANNNER",
    "on_click_story_banner": "首页点击体验故事banner",
    "on_click_tab": "tab切换点击",
    "on_click_top_card": "跳转到问题详情页或者回答详情页",
    "on_click_ugc_diary": "搜索结果页（综合tab）-点击日记本卡片",
    "on_click_ugc_diary_comment": "日记本卡片-点击评论icon",
    "on_click_ugc_diary_follow": "点击日记本关注按钮",
    "on_click_ugc_diary_like": "日记本卡片点赞",
    "on_click_ugc_diary_more": "点击查看更多按钮",
    "on_click_ugc_diary_unfollow": "日记本取消关注",
    "on_click_ugc_diary_unlike": "日记本卡片取消赞",
    "on_click_ugc_service": "搜索结果页点击美购卡片",
    "on_click_ugc_service_more": "搜索结果页点击更多美购按钮",
    "on_click_ugc_topic": "点击帖子卡片",
    "on_click_ugc_topic_comment": "点击帖子评论按钮",
    "on_click_ugc_wanshitong": "点击更美万事通(ugc)项",
    "on_click_ugc_wanshitong_more": "搜索结果页点击更美万事通内容更多按钮",
    "on_click_ugc_wiki": "点击相关百科项",
    "on_click_vote": "点击赞按钮",
    "on_click_welfare_album_picture": "美购详情页点击官方图片或网友美图",
    "on_click_welfare_banner": "首页点击专题BANNER",
    "on_click_welfare_card": "内容聚合页点击美购卡片",
    "open_app_ad_click": "更美app开屏投放广告点击",
    "open_notification_click_item": "多场景追加授权提示用户点击弹窗提醒",
    "order_create_click_commit": "结算单预览页点击提交按钮",
    "order_create_click_coupon": "结算单预览页点击选择美券按钮",
    "order_create_click_insurance": "结算单预览页点击美丽保按钮",
    "order_create_click_point": "结算单预览页点击美分抵扣开关按钮",
    "order_create_click_total_price_arrow": "结算单预览页点击合计金额收起按钮",
    "order_detail_click_address": "订单详情页点击查看地图按钮",
    "order_detail_click_avatar": "订单详情页点击医生头像按钮",
    "order_detail_click_cancel_refund": "订单详情页点击取消退款按钮",
    "order_detail_click_coupon": "订单详情页点击发红包ICON",
    "order_detail_click_installment_choose_periods": "选择分期期数后，点击下一步",
    "order_detail_click_installment_request_refund": "取消退款按钮",
    "order_detail_click_message": "订单详情页点击私信咨询按钮",
    "order_detail_click_phone": "订单详情页点击电话咨询按钮",
    "order_detail_click_refund_detail": "订单详情页点击退款详情按钮",
    "order_detail_click_welfare": "订单详情页点击商品介绍按钮",
    "order_evaluate_click_complete_btn": "美购评价页点击完成按钮",
    "order_payment_check_channel": "支付订单页点击选择支付渠道按钮",
    "order_payment_click_pay": "支付订单页点击支付按钮",
    "order_payment_pay_success": "支付订单页支付成功状态返回",
    "order_share_click_to_evaluate": "分享返现页点击去评价按钮",
    "order_share_click_to_post": "分享返现页点击去发布按钮",
    "order_share_float_click_edit": "分享返现页点击修改帖子按钮",
    "order_share_float_click_help": "分享返现页点击查看帮助ICON",
    "order_share_float_click_to_post": "分享返现页点击去发布按钮",
    "organization_detail_album_click_button": "医院主页点击头图中视频或图片",
    "organization_detail_click_album_video": "医院主页点击视频播放按钮",
    "organization_detail_click_answer_questions_more": "医院主页点击机构答疑栏查看更多按钮",
    "organization_detail_click_case_num": "医院主页点击查看更多案例按钮",
    "organization_detail_click_doctor_num": "医院主页点击查看所有医生按钮",
    "organization_detail_click_message": "医院主页点击在线咨询按钮",
    "organization_detail_click_phone": "医院主页点击电话咨询按钮",
    "organization_detail_click_release_card": "医院主页点击功能区免费招募功能区卡片",
    "organization_detail_click_release_more": "医院主页机构发布栏点击查看更多按钮",
    "organization_detail_click_safe_buy": "点击放心购",
    "organization_detail_click_service_num": "点击共xx个美购标签",
    "organization_detail_click_service_tag": "点击美购标签",
    "organization_detail_click_tab": "点击tab",
    "organization_detail_good_project_click_more": "医院主页点击擅长项目栏更多按钮",
    "other_homepage_click_tab": "他人个人主页点击TAB",
    "page_click_return": "返回按钮点击",
    "page_click_share": "分享按钮点击",
    "page_click_share_channel": "分享渠道按钮点击",
    "page_precise_exposure": "精准曝光",
    "pay_success_click_share_channel": "支付成功浮层点击分享渠道按钮",
    "personal_balance_click_invitation": "个人余额页点击邀请好友赚现金按钮",
    "personal_customerservice_click": "客服详情页点击ICON",
    "personal_home_click_activity": "当用户点击美购活动时",
    "personal_home_click_cart": "点击购物车按钮",
    "personal_home_click_comment": "用户点击评论",
    "personal_home_click_coupon": "点击美券",
    "personal_home_click_coupon_gift": "个人主页点击分享有礼按钮",
    "personal_home_click_favor": "用户点击收藏按钮",
    "personal_home_click_item": "个人主页点击工具栏ICON",
    "personal_home_click_more": "个人主页点击设置按钮",
    "personal_home_click_my_post": "个人主页点击我的发布",
    "personal_home_click_my_report": "个人主页点击我的颜值报告按钮",
    "personal_home_click_my_reservation": "点击我的预约",
    "personal_home_click_portrait": "个人主页点击头像按钮",
    "personal_home_click_qr_code": "点击扫一扫",
    "personal_home_click_service_center": "点击客服中心",
    "personal_home_click_sign_icon": "个人主页点击工具栏签到ICON",
    "personal_more_click_item": "个人主页点击工具栏ICON",
    "personal_store_click_tab": "我的收藏美购页点击TAB",
    "picture_select_beautify_type": "七牛图片编辑页点击滤镜、裁剪、贴纸按钮",
    "private_message_user_click_enter": "私信详情页点击回车发送按钮",
    "question_detail_click_add_answer": "问题详情页点击我要回答按钮",
    "question_detail_click_recommend_block": "问题详情页点击推荐卡片",
    "question_detail_click_recommend_service_more": "问题详情页点击更多美购按钮",
    "question_detail_click_rservice_button": "问题详情页底部点击相关美购按钮",
    "question_detail_click_service_related": "问题详情页点击中间关联美购和吸顶美购",
    "question_rservice_wow_click_service": "问题详情页底部点击相关美购卡片",
    "recommend_zone_click_finish": "推荐圈子页点击完成按钮",
    "recovery_remind_click_diary_item": "恢复提醒页点击日记卡片",
    "recovery_remind_click_diary_more": "点击日记-查看更多",
    "recovery_remind_click_welfare_item": "恢复提醒页点击美购卡片",
    "register_click_register": "注册页点击第三方登录按钮",
    "renmai_intallment_click_final_installment": "我的订单页点击尾款分期按钮",
    "renmai_intallment_click_intallment_detail": "我的订单页点击分期详情按钮",
    "renmai_intallment_click_repay_detail": "我的订单页点击还款详情按钮",
    "report_ad_active_status": "广告链接点击进入更美客户端后上报",
    "reset_password_click_submit": "重置密码页点击确定按钮",
    "screenshot_click_share_channel": "APP截屏分享",
    "search_result_click_recommend_item": "搜索结果页点击推荐美购卡片",
    "search_result_click_search": "搜索结果页点击搜索按钮",
    "search_result_click_tab": "搜索结果页点击TAB按钮",
    "search_result_hospital_click_doctor": "搜索结果医院页点击医生卡片",
    "search_result_more_click_face": "搜索结果综合页点击魔镜",
    "search_result_more_click_freeface": "搜索结果综合页点击免费整卡片",
    "search_result_more_click_more": "搜索结果页点击查看更多",
    "search_result_more_diary_click_item": "点击案例",
    "search_result_welfare_click_jumping_hot_word": "搜索结果美购页搜索无结果或结果较少时点击热门搜索词按钮",
    "search_result_welfare_click_suggestion_key": "点击美购tab下的纠错提示",
    "search_result_welfare_click_tags": "搜索结果美购页点击标签按钮",
    "search_result_wiki_click_item": "搜索结果百科页点击百科卡片",
    "search_result_wiki_click_jumping_hot_word": "搜索结果页百科TAB点击热门搜索词按钮",
    "search_result_wiki_click_recommend_wiki": "搜索结果百科页搜索无结果点击推荐百科卡片",
    "serve_gather_click_tab": "美购服务说明页点击TAB",
    "service_center_click_my_feedback": "点击我的反馈栏",
    "settlement_detail_click_pay": "结算单详情页点击支付按钮",
    "settlement_detail_click_welfare_item": "结算单详情页点击美购卡片",
    "settlement_detail_order_cancel": "我的订单页点击取消订单按钮",
    "settlement_preview_imprest_click": "结算单预览页点击去领取最大优惠券按钮",
    "settlement_preview_retainage_click": "结算单预览页点击去领取最大优惠券按钮",
    "shopcart_paybutton_click": "我的购物车页点击去结算按钮",
    "sign_calendar_click_exchange_record": "签到日历页点击兑换记录按钮",
    "sign_calendar_click_retroactive": "签到日历页点击立即补签按钮",
    "spell_special_list_click_card": "拼团专场列表页点击拼团卡片",
    "spell_welfare_detail_click_gospell": "拼团美购详情页点击去拼团按钮",
    "spell_welfare_detail_click_oddbuy": "拼团美购详情页点击单独购买按钮",
    "staggered_diary_click": "瀑布流用户首页点击日记本",
    "staggered_operation_click": "当用户点击首页瀑布流中运营位时",
    "staggered_topic_click": "当用户点击首页瀑布流中日记帖时",
    "star_users_click_item": "达人列表页当用户点击列表项时",
    "suggest_welfare_click_doctor_homepage": "当用户点击去专家主页按钮时",
    "suggest_welfare_click_online_notification": "当用户点击上架通知我按钮时",
    "suggest_welfare_click_welfare_item": "当用户点击美购列表项时",
    "topic_create_consult": "创建日记贴页点击发布按钮",
    "topic_create_diary": "创建日记贴页点击发布按钮",
    "topic_create_select_type": "点击写日记晒美照或问专家求讨论按钮",
    "topic_detail_click_belong_diarybook": "点击所属日记本区域",
    "topic_detail_click_float_comment": "日记贴详情页点击悬浮条评论按钮",
    "topic_detail_click_header": "日记贴详情页点击用户头像按钮",
    "topic_detail_click_input": "日记贴详情页点击回复框或评论框",
    "topic_detail_click_photo": "点击帖子内图片",
    "topic_detail_click_service_block": "日记贴详情页点击美购卡片",
    "topic_detail_click_vote": "日记贴详情页点击赞按钮",
    "topic_detail_click_voter": "点击点赞的用户头像",
    "topic_item_click_avatar": "点击帖子列表项中的作者头像",
    "topic_item_click_comment": "点击帖子列表项中的评论按钮",
    "topic_item_click_image": "点击帖子列表项中的图片",
    "topic_item_click_vote": "点击帖子列表项中的赞按钮",
    "topic_reply": "日记贴详情页点击评论或回复按钮",
    "upcoming_click_remind": "免费活动列表页即将开始TAB点击开启提醒报名按钮",
    "votecollect_click_tab": "收到点赞页点击TAB",
    "w_repair_sign_a_click_wantjoin": "站外补签分享页A点击我要参加按钮",
    "w_repair_sign_b_click": "站外补签分享页B点击",
    "weixin_click_share_channel": "个人余额页点击分享渠道按钮",
    "welfare_attribute_click_serviceitem": "美购详情页点击选择项目分类按钮",
    "welfare_detail_album_click_button": "美购详情页点击头图上视频或图片按钮",
    "welfare_detail_click_add": "PUSH美购列表页点击加入购物车按钮",
    "welfare_detail_click_address": "美购详情页点击地址横条按钮",
    "welfare_detail_click_album": "美购详情页点击美购相册卡片",
    "welfare_detail_click_album_video": "美购详情页点击头图视频播放按钮",
    "welfare_detail_click_all_diary": "美购详情页点击查看*篇日记按钮",
    "welfare_detail_click_all_user_case": "美购详情页点击推荐日记查看更多按钮",
    "welfare_detail_click_bottom_seller": "美购详情页点击底部商家icon",
    "welfare_detail_click_buy": "美购详情页点击立即购买按钮",
    "welfare_detail_click_close_float_coupon": "美购详情页点击头图部分美券横条浮窗",
    "welfare_detail_click_comment": "美购详情页点击评价或查看更多评价按钮",
    "welfare_detail_click_consult": "美购详情页点击私信咨询按钮",
    "welfare_detail_click_coupon": "美购详情页点击美券领取按钮",
    "welfare_detail_click_coupon": "美购详情页点击美券领取按钮",
    "welfare_detail_click_curearea": "美购详情页点击医生或医院卡片",
    "welfare_detail_click_curearea_contact": "美购详情页点击电话咨询或在线咨询按钮",
    "welfare_detail_click_float_coupon": "美购详情页点击美券按钮",
    "welfare_detail_click_git": "点击_美购详情页新人红包按钮",
    "welfare_detail_click_go_to_hospital": "美购详情页点击进商家逛逛按钮",
    "welfare_detail_click_help": "点击底部的帮助按钮",
    "welfare_detail_click_intallment": "美购详情页点击分期按钮",
    "welfare_detail_click_message": "美购详情页点击私信按钮",
    "welfare_detail_click_newtab": "美购详情页点击顶部TAB",
    "welfare_detail_click_phone": "美购详情页点击电话咨询按钮",
    "welfare_detail_click_preorder": "美购详情页点击底部开团提醒按钮",
    "welfare_detail_click_score": "美购详情页点击美购评分条",
    "welfare_detail_click_seller_service_item": "美购详情页点击横滑美购卡片",
    "welfare_detail_click_service_features": "美购详情页点击基础服务横条按钮",
    "welfare_detail_click_special_promotion": "美购详情页点击专场按钮",
    "welfare_detail_click_tab": "美购详情页点击TAB",
    "welfare_detail_click_user_case_item": "美购详情页点击用户案例区案例卡片",
    "welfare_detail_dairylist_next_click_unfold": "美购详情页点击全部日记本栏展开按钮",
    "welfare_detail_tab_detail_click_welfare_item": "美购详情页点击详情或推荐里面的美购卡片",
    "welfare_detail_tab_diary_click_diary_item": "美购详情页点击日记本卡片",
    "welfare_home_click_activity": "点击查专题活动项",
    "welfare_home_click_icon": "美购首页点击ICON",
    "welfare_home_click_navbar_area": "美购首页点击城市地区选择按钮",
    "welfare_home_click_navbar_cart": "点击导航栏购物车按钮",
    "welfare_home_click_section": "美购首页点击ICON",
    "welfare_home_click_special_banner": "美购首页点击头部BANNER",
    "welfare_home_click_special_more": "美购首页点击外显美购查看更多按钮",
    "welfare_home_click_special_service": "美购首页点击专题美购BANNER",
    "welfare_list_click_expert": "医生美购列表项中的医生头像",
    "welfare_list_click_expert_welfare": "点击医生美购列表项中的医生美购",
    "welfare_list_click_filter_label": "点击筛选标签",
    "welfare_list_click_item": "美购列表页点击美购卡片",
    "welfare_multiattribute_click_add": "点击加入购物车按钮",
    "welfare_multiattribute_click_buy": "美购多属性页点击立即支付按钮",
    "welfare_special_click_benefits_zone": "美购专题页点击分区美购卡片",
    "welfare_special_click_coupon": "美购专题页点击美券按钮",
    "welfare_special_click_diary": "美购专题页点击精选案例栏的日记本卡片",
    "welfare_special_click_doctor_rank_item": "美购专题页点击医生排行榜",
    "welfare_special_click_expert": "点击医生列表中的医生",
    "welfare_special_click_more": "点击外显美购专题的banner或“查看更多”按钮",
    "welfare_special_click_related_service": "点击外显美购专题的美购",
    "welfare_special_click_service": "美购专题页点击美购卡片",
    "welfare_special_click_service_rank_item": "美购专题页点击排行榜中的美购卡片",
    "welfare_special_click_storey_tab": "美购专题页点击TAB按钮",
    "welfare_special_click_storey_template": "美购专题页点击图片",
    "welfare_special_click_tab": "美购专题页点击推荐内容栏中的卡片",
    "welfare_special_click_tag": "点击美购分组tag按钮",
    "welfare_special_click_template": "美购专题页点击固定模版",
    "wiki_detail_click_adv": "点击广告位",
    "wiki_detail_click_benefits_item": "百科详情页点击推荐美购卡片",
    "wiki_detail_click_diaries_item": "百科详情页点击日记本卡片",
    "wiki_detail_click_goto_zone": "用户点击进入圈子",
    "wiki_detail_click_more_diary": "百科详情页点击相关日记中的查看全部按钮",
    "wiki_detail_click_more_welfare": "百科详情页点击推荐美购中的查看全部按钮",
    "wiki_detail_click_more_zone": "点击相关圈子中的查看全部",
    "wiki_detail_click_wikis_item": "百科详情页点击百科卡片",
    "wiki_detail_click_zones_item": "点击相关圈子的圈子项",
    "zhibo_relpay": "直播回放页页面访问",
    "zone_detail_click_create": "圈子详情页点击发帖按钮",
    "zone_detail_click_detail": "圈子详情页点击图片或文字卡片",
    "zone_detail_click_diary": "跳转到日记本详情页",
    "zone_detail_click_follow": "圈子详情页点击关注按钮",
    "zone_detail_click_item": "点击列表项",
    "zone_detail_click_item_wiki": "点击项目百科",
    "zone_detail_click_related_diary": "点击相关日记",
    "zone_detail_click_related_welfare": "点击相关美购",
    "zone_detail_click_related_zone": "点击每一个相关圈子",
    "zone_detail_click_sorting_item": "圈子详情页点击排序下拉菜单下的排序项",
    "zone_detail_click_tab": "圈子详情页点击TAB按钮",
    "zone_detail_click_topic": "点击每一个列表项",
    "zone_detail_click_topic_item": "点击每一个列表项",
    "zone_detail_click_topup": "点击每一个置顶帖",
    "zone_detail_click_welfare": "圈子详情页美购TAB点击美购列表卡片",
    "zone_detail_click_wiki": "圈子详情页点击百科按钮",
    "zone_v3_click_diary_topic": "内容聚合页点击日记贴卡片",
    "/api/diary": "首页功能区-看日记日记本列表",
    "/api/experts/": "首页功能区-找医生和机构医生和机构列表",
    "/api/video/list": "首页功能区-看视频视频列表",
    "/api/doctor/services": "医生主页美购列表",
    "/api/hospital/services": "医院主页美购列表",
    "organization_detail_service_exposure": "医院主页综合和美购TAB列表",
    "/api/index/feed_content": "首页去掉运营推荐TAB列表",
    "/api/index/homepage_icon": "首页BANNER列表",
    "/api/index/new/v4": "首页瀑布流综合列表",
    "/api/index/v4": "首页瀑布流综合列表",
    "/api/index/v5/homepage": "首页瀑布流综合列表",
    "/api/index/v6": "首页瀑布流综合列表",
    "/api/index/v7": "首页瀑布流综合列表",
    "/api/order/recommend/service/list": "支付成功页猜你喜欢美购列表",
    "/api/personal/recommends": "用户个性化推荐综合列表",
    "/api/polymerization/content": "内容聚合页召回各TAB列表",
    "/api/polymerization/recommend": "内容聚合页推荐各TAB列表",
    "/api/zone/detail/v2": "内容聚合页美购列表",
    "/api/zone/detail/v3": "内容聚合页各TAB列表",
    "/api/purchase/recommend/service/list": "美分商城页美购列表",
    "/api/search/keywords/": "搜索首页各TAB下搜索发现词列表",
    "/api/search/keywords/comprehensive/": "搜索首页综合TAB下大家都在看词列表",
    "/api/search/v2/content": "搜索结果综合页综合列表",
    "/api/search/v2/diary": "搜索结果日记页日记本列表",
    "/api/search/v2/doctor": "搜索结果医生页医生列表",
    "/api/search/v2/hospital": "搜索结果医院页医院列表",
    "/api/search/v2/service": "搜索结果美购页美购列表",
    "/api/search/v3/content": "搜索结果综合页综合列表",
    "/api/search/v4/content": "搜索结果综合页综合列表",
    "/api/search/v5/content": "搜索结果综合页综合列表",
    "/api/services/willbuy": "搜索结果美购页-你可能感兴趣的美购列表",
    "/api/service/home/v2": "美购首页美购列表",
    "/api/service/home/v3": "美购首页美购列表",
    "/api/service/home/v3/list": "美购首页美购列表",
    "/api/services/": "美购列表页美购列表",
    "/api/services/v1": "美购列表页美购列表",
    "/hybrid/activity/varietyvote/feed": "综艺活动页瀑布流问题列表",
    "/hybrid/promotion/_data": "美购专题页美购列表",
    "/hybrid/question/answer_list/_data": "问题详情页推荐阅读问题列表",
    "/api/feeds/tag_service": "品类聚合页美购TAB美购列表",
    "/search/v2/diary": "品类聚合页日记TAB日记本列表",
    "/gm_ai/face_app/test_skin_v2": "人脸分析测肤报告结果页专题入口列表",
    "/gm_ai/heidong/recommend": "人脸分析测肤报告结果页推荐卡片综合列表",
    "/hybrid/article": "专栏详情页美购列表",
    "/hybrid/base_wiki/item": "百科详情页美购列表",
    "/hybrid/base_wiki/product": "药品/仪器/材料百科详情页美购列表",
    "/api/shopcart/recommend/service/list": "我的美券页推荐美购列表",
    "answer_card_click_comment": "回答详情页点击评论按钮",
    "answer_card_click_vote": "回答详情页点赞",
    "article_detail_click_related_item": "专栏详情页点击日记本卡片",
    "article_list_click_tab": "专栏列表页点击TAB按钮",
    "authorization_click_confirm": "授权浮层页点击确认或取消授权按钮",
    "broadcast_live_click_download": "直播页点击下载APP按钮",
    "buy_again_popup_click_add_to_shopcart": "我的订单页再次购买弹窗内点击加入购物车按钮",
    "buy_again_popup_click_think_again": "我的订单页再次购买弹窗内点击我再想想按钮",
    "click_deeplink_download": "下载APP按钮点击",
    "click_deeplink_open": "美购详情页点击打开更美APP按钮",
    "consult_click_areaofwx": "陌陌咨询页点击加微信按钮",
    "consult_click_consult_immediately": "陌陌咨询页点击立即咨询颜值分析按钮",
    "consult_wx_wow_click_addme_immediately": "陌陌咨询页点击立即加我按钮",
    "coupon_click_to_beauty": "注册领美券页点击去变美啦按钮",
    "diary_book_topic_create_deletebtn_click_confirm_wow": "创建日记贴页点击删除按钮后确认弹窗按钮",
    "diary_detail_click_photo": "日记贴详情页点击日记相册卡片",
    "diary_detail_click_photo": "日记贴详情页点击日记相册卡片",
    "diary_detail_click_recommend_diary": "日记贴详情页点击推荐日记卡片",
    "diary_detail_click_recommend_welfare_card": "日记贴详情页点击推荐美购卡片",
    "diary_detail_click_writecomment": "日记贴详情页点击评论条按钮",
    "diary_home_click_collect": "日记首页点击收藏按钮",
    "diary_home_click_filtrate": "日记本首页点击筛选按钮",
    "diarybook_detail_click_bottom_comment": "日记详情页点击底栏评论按钮",
    "diarybook_detail_click_diary_image": "日记详情页点击日记卡片上的图片",
    "diarybook_detail_click_more_service_comment": "日记详情页美购评价区点击展开评论按钮",
    "diarybook_detail_click_view_more_comments": "日记详情页点击查看更多评论按钮",
    "expert_detail_click_address": "医生主页点击地址按钮",
    "expert_detail_click_answer": "医生主页医生答疑项点击答疑卡片",
    "expert_detail_click_answer_all": "医生主页点击医生答疑查看更多按钮",
    "expert_detail_click_credential": "医生主页点击医生证件按钮",
    "expert_detail_click_hospital": "医生主页点击医院信息按钮",
    "expert_detail_click_release": "医生主页点击医生发布直播、免费招募、专栏卡片",
    "expert_detail_click_release_all": "医生主页医生发布栏点击查看更多按钮",
    "face_report_click_down": "人脸分析颜值报告报告页点击进入首页或回个人主页等按钮",
    "face_report_click_related_items": "人脸分析颜值报告报告页点击查看相关项目按钮",
    "face_report_click_tag": "人脸分析颜值报告报告页点击标签按钮",
    "face_report_click_test_again": "人脸分析颜值报告报告页点击重测按钮",
    "face_simulator_click_option": "人脸分析虚拟整形页点击弹窗选项",
    "face_start_click_begin": "人脸分析启动页点击开始测试按钮",
    "face_start_click_go_home": "人脸分析启动页点击进入首页按钮",
    "fen_xiang_gou_apply_click": "首页点击报名加入纷享购按钮",
    "finalpage_click_result": "颜值分享结果页点击查看结果按钮",
    "fun_catch_click_catch": "抓娃娃活动页点击抓取按钮",
    "fun_catch_click_share": "抓娃娃活动页点击分享按钮",
    "gm_seckill_click_operation_resource": "大促活动秒杀页点击美购卡片",
    "home_click_banner": "小程序和M站首页点击BANNER",
    "home_click_banner": "小程序和M站首页点击BANNER",
    "home_click_diary": "首页点击日记卡片",
    "home_click_search": "首页点击搜索框按钮",
    "home_click_search": "首页点击搜索框按钮",
    "homepage_click_join_pic": "小程序首页点击PIKCK投票图片",
    "installment_add_bank": "支付订单页点击添加新卡支付按钮",
    "installment_apply_cancel": "分期支付详情页点击取消按钮",
    "installment_ascension_email": "分期提额页点击信用卡邮箱按钮",
    "installment_ascension_operator": "分期提额页点击手机运营商按钮",
    "installment_ascension_report": "分期提额页点击征信报告按钮",
    "installment_ascension_taobao": "分期提额页点击淘宝账号按钮",
    "installment_click_bill": "分期额度详情页点击按钮",
    "installment_credit_click": "分期额度介绍页点击开通更美白条按钮或未通过请补充按钮",
    "installment_credit_detail": "用户进入分期额度介绍页",
    "installment_credit_promote": "分期额度介绍页点击提额包按钮",
    "installment_look_period": "额度详情页点击查看分期美购按钮",
    "installment_pay_repay": "分期中间页点击确认支付或余额不足按钮",
    "installment_select_bank": "支付订单页点击选择银行卡按钮",
    "maidan_tagname_click": "买单详情页点击请选择项目名称按钮",
    "message_home_click_delete": "消息首页点击一键清除按钮",
    "message_home_private_msg_click_item": "消息首页点击私信列表条按钮",
    "my_focus_content_click_tab": "我的关注内容页点击TAB按钮",
    "my_order_click_buy_again": "我的订单页待付款订单TAB点击再次购买按钮",
    "my_order_click_order_item": "我的订单页各TAB下点击列表卡片",
    "mz_meigouspecial_click_atoncebuy_btn": "美购详情页点击立即购买按钮",
    "mz_meigouspecial_click_consult_btn": "美购详情页点击咨询按钮",
    "mz_meigouspecial_click_openapp_btn": "美购详情页点击打开APP按钮",
    "newuser_register_click_getcode": "注册页点击获取验证码按钮",
    "newuser_register_click_getmoney": "新人注册领取页面点击领红包",
    "notification_authorize_warm_prompt_click_again": "首页点击PUSH弹窗开启或关闭按钮",
    "on_click_qa_recommend_card": "首页各TAB下点击问答卡片",
    "on_map_cover_click": "覆盖地图页点击分类项目或底部BANNER",
    "order_pay_click_back": "支付订单页点击后退按钮",
    "order_validate": "验证订单页点击弹窗选择按钮",
    "organization_detail_click_address": "医院主页点击医院地址按钮",
    "organization_detail_click_album": "医院主页点击头图卡片",
    "organization_detail_click_all_diary": "医院主页点击查看**篇日记按钮",
    "organization_detail_click_claim_coupon": "医院主页点击医院红包按钮",
    "organization_detail_click_credential": "医院主页点击医院证件按钮",
    "organization_detail_click_score": "医院主页点击评分条按钮",
    "organization_diary_click_tag": "医生主页点击TAG标签按钮",
    "organization_infomation_detail_click_release": "医院主页点击医生发布的直播或答疑或专栏或招募卡片",
    "pay_detail_click_payn": "支付订单页点击支付按钮",
    "permit_push_notification": "新设备首页通知弹窗点击不允许或好按钮",
    "picture_paster_select_type": "七牛图片编辑页点击贴纸类型",
    "private_message_doctor_click_enter": "WEB站医生点击回车",
    "push_meigou_list_click_welfare_item": "PUSH美购列表页点击美购卡片",
    "push_reminder_click_close": "消息首页点击push开启浮层内关闭按钮",
    "push_reminder_click_setting": "消息首页点击push开启浮层内立即设置按钮",
    "question_answer_card_click_top_card": "跳转到问题详情页或者回答详情页",
    "question_detail_answerlist_click_comment_send_btn": "点击评论列表回复发送",
    "question_home_click_question_card": "问答首页点击问答卡片",
    "receive_page_click_submit": "地址填写成功点击提交",
    "recovery_remind_click_create_diary": "恢复提醒页点击我要发帖按钮",
    "register_click_get_verifycode": "注册页点击获取验证码按钮",
    "result_prize_click_use": "抓娃娃活动页点击立即使用按钮",
    "seckill_list_click_banner": "秒杀聚合页点击BANNER",
    "seckill_list_click_service": "聚合页点击美购卡片",
    "seckill_special_click_coupon": "美购专题页点击礼包按钮",
    "settings_click_reset_password": "个人设置页点击修改密码按钮",
    "settings_order_click_submit_order": "提交订单页点击提交订单按钮",
    "settlement_detail_click_buy_again": "结算单详情页点击再次购买按钮",
    "settlement_preview_click_top_pay": "结算单预览页点击未支付头部按钮",
    "spell_welfare_detail_click_openspell": "拼团美购详情页点击我要开团按钮",
    "task_center_click_items": "任务中心页点击去完成或已完成按钮",
    "topic_card_click_comment": "帖子卡片点击评论按钮",
    "topic_detail_click_bottom_comment": "专栏详情页点击底部评论按钮",
    "topic_detail_click_roll_page": "日记贴详情页点击翻页按钮",
    "topic_detail_roll_picture": "日记贴详情页点击头图卡片",
    "w_repair_sign_b_click": "站外补签分享页B点击打开",
    "welfare_attribute_click_purchase": "美购详情页弹窗购买次数点击",
    "welfare_detail_click_avatar": "美购详情页点击医生头像卡片",
    "welfare_detail_click_comment_arrow": "美购详情页点击评论聚合TAG展开箭头按钮",
    "welfare_detail_click_coupon": "美购详情页点击美券领取按钮",
    "welfare_detail_click_gift": "美购详情页点击新人红包按钮",
    "welfare_detail_click_label": "美购详情页点击基础服务弹窗",
    "welfare_detail_click_message_new": "美购详情页点击私信咨询按钮",
    "welfare_detail_click_pay_immediately": "美购详情页点击立即购买按钮",
    "welfare_detail_click_phone_new": "美购详情页点击电话咨询按钮",
    "welfare_detail_click_recommend_welfare": "美购详情页点击推荐美购卡片",
    "welfare_home_click_search": "搜索首页点击搜索按钮",
    "welfare_home_click_welfare_card": "美购首页点击美购卡片",
    "welfare_special_click_welfare": "美购专题页点击美购卡片",
    "wiki_detail_click_fold": "百科详情页点击展开或折叠按钮",
    "wiki_detail_click_picture": "百科详情页点击效果图片卡片",
    "home_choiceness_card_exposure": "精准曝光"
}

for t in range(1, task_days):
    day_num = 0 - t
    now = (datetime.datetime.now() + datetime.timedelta(days=day_num))
    last_30_day_str = (now + datetime.timedelta(days=-30)).strftime("%Y%m%d")
    today_str = now.strftime("%Y%m%d")
    today_str_format = now.strftime("%Y-%m-%d")
    yesterday_str = (now + datetime.timedelta(days=-1)).strftime("%Y%m%d")
    yesterday_str_format = (now + datetime.timedelta(days=-1)).strftime("%Y-%m-%d")
    one_week_age_str = (now + datetime.timedelta(days=-7)).strftime("%Y%m%d")
    new_urser_device_id_sql = r"""
    select t2.device_id as device_id from 
    (select device_id from online.ml_device_day_active_status where partition_date = '{today_str}' and active_type in (1,2)) t2
    LEFT JOIN
    (
        select distinct device_id
        from ml.ml_d_ct_dv_devicespam_d  --去除机构刷单设备，即作弊设备（浏览和曝光事件去除）
        WHERE partition_day='{today_str}'

        union all

        select distinct device_id
        from dim.dim_device_user_staff   --去除内网用户
    )spam_pv
    on spam_pv.device_id=t2.device_id
        LEFT JOIN
    (
        SELECT partition_date,device_id
        FROM
            (--找出user_id当天活跃的第一个设备id
          SELECT user_id,partition_date,
                  if(size(device_list) > 0, device_list [ 0 ], '') AS device_id
            FROM online.ml_user_updates
            WHERE partition_date='{today_str}'
        )t1
                JOIN
            (  --医生账号
          SELECT distinct user_id
          FROM online.tl_hdfs_doctor_view
          WHERE partition_date = '{today_str}'

          --马甲账号/模特用户
          UNION ALL
          SELECT user_id
          FROM ml.ml_c_ct_ui_user_dimen_d
          WHERE partition_day = '{today_str}'
          AND (is_puppet = 'true' or is_classifyuser = 'true')

          UNION ALL
          --公司内网覆盖用户
          select distinct user_id
          from dim.dim_device_user_staff

          UNION ALL
          --登陆过医生设备
          SELECT distinct t1.user_id
            FROM
            (
                SELECT user_id, v.device_id as device_id
                FROM online.ml_user_history_detail
                    LATERAL VIEW EXPLODE(device_history_list) v AS device_id
                WHERE partition_date = '{today_str}'
            ) t1
            JOIN
            (
                SELECT device_id
                FROM online.ml_device_history_detail
                WHERE partition_date = '{today_str}'
                AND is_login_doctor = '1'
            ) t2
                ON t1.device_id = t2.device_id
        )t2
            on t1.user_id=t2.user_id
        group by partition_date,device_id
    )dev
    on t2.device_id=dev.device_id
WHERE spam_pv.device_id IS NULL
  and dev.device_id is null
    """.format(today_str=today_str, yesterday_str_format=yesterday_str_format, today_str_format=today_str_format)

    print(new_urser_device_id_sql)
    new_urser_device_id_df = spark.sql(new_urser_device_id_sql)
    new_urser_device_id_df.createOrReplaceTempView("device_id_view")
    new_urser_device_id_df.show(1)
    sql_res = new_urser_device_id_df.collect()

    print("-------------------------------")
    for count, res in enumerate(sql_res):
        print(count, res)

    res_dict = {}
    maidian_sql = """select t1.device_id,t2.track as track from 
    (select device_id from device_id_view)t1 
    left join 
    (select cl_id, concat_ws(',', collect_list(action)) as track from
(select * from online.bl_hdfs_maidian_updates where partition_date = {partition_date} and cl_id is not null ) group by cl_id) t2 
on t1.device_id = t2.cl_id""".format(partition_date=today_str)
    print(maidian_sql)
    track_df = spark.sql(maidian_sql)
    # track_df.createOrReplaceTempView("device_id_view")
    track_df.show(1)
    sql_res = track_df.collect()

    print("-------------------------------")
    for count, res in enumerate(sql_res):
        # print(count, res)
        track = res.track
        if not track:
            continue
        track_list = track.split(",")
        for one_key_word in track_list:
            if one_key_word in res_dict:
                res_dict[one_key_word] += 1
            else:
                res_dict[one_key_word] = 1
    print(res_dict)

    exception_list = ("report_status","is_open_push")
    for action in res_dict:
        partition_date = yesterday_str
        pid = hashlib.md5((partition_date + action).encode("utf8")).hexdigest()
        action_count = res_dict[action]
        action_ch = name_dict.get(action)
        if not action_ch:
            action_ch = action
        if action_ch in exception_list:
            continue
        instert_sql = """replace into new_user_click_count(
                    partition_day,pid,action_count,action_ch,action) VALUES('{partition_day}','{pid}',{action_count},'{action_ch}','{action}');""".format(
            partition_date=partition_date, partition_day=yesterday_str, pid=pid, action_count=action_count,
            action_ch=action_ch, action=action
        )
        print(instert_sql)
        # cursor.execute("set names 'UTF8'")
        db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy',
                             db='jerry_prod')
        cursor = db.cursor()
        res = cursor.execute(instert_sql)
        db.commit()
        print(res)
    # cursor.executemany()
    db.close()
