package com.ruixuan.report.utils;

import com.alibaba.fastjson.JSON;

import java.util.Map;

/**
 * 整理报表字段
 */
public class AccountReportConstants {

    public static final String KUAISHOU_ACCOUNT_REPORT_JSON = "{\n" +
            "  \"costTotal\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.cost_total),0) as costTotal \",\n" +
            "    \"comment\": \"花费\"\n" +
            "  },\n" +
            "  \"adShow\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.ad_show),0) as adShow \",\n" +
            "    \"comment\": \"广告曝光数\"\n" +
            "  },\n" +
            "  \"adShow1kCost\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.ad_show) != 0 THEN ROUND(sum(t1.cost_total) / sum(t1.ad_show) * 1000, 2) ELSE 0 END AS adShow1kCost \",\n" +
            "    \"comment\": \"平均千次广告曝光花费\"\n" +
            "  },\n" +
            "  \"impression\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.impression),0) as impression \",\n" +
            "    \"comment\": \"封面曝光数\"\n" +
            "  },\n" +
            "  \"photoClick\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.photo_click),0) as photoClick \",\n" +
            "    \"comment\": \"封面点击数\"\n" +
            "  },\n" +
            "  \"photoClickRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.impression) != 0 THEN CONCAT(CAST(ROUND((sum(t1.photo_click) / sum(t1.impression)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS photoClickRatio \",\n" +
            "    \"comment\": \"封面点击率\"\n" +
            "  },\n" +
            "  \"click\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.click),0) as click \",\n" +
            "    \"comment\": \"素材曝光数\"\n" +
            "  },\n" +
            "  \"actionbarClick\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.actionbar_click),0) as actionbarClick \",\n" +
            "    \"comment\": \"行为数\"\n" +
            "  },\n" +
            "  \"actionbarClickCost\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.actionbar_click) != 0 THEN ROUND(sum(t1.cost_total) / sum(t1.actionbar_click), 2) ELSE 0 END AS actionbarClickCost \",\n" +
            "    \"comment\": \"行为成本\"\n" +
            "  },\n" +
            "  \"espClickRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.ad_show) != 0 THEN CONCAT(CAST(ROUND((sum(t1.actionbar_click) / sum(t1.ad_show)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS espClickRatio \",\n" +
            "    \"comment\": \"行为率\"\n" +
            "  },\n" +
            "  \"actionRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.click) != 0 THEN CONCAT(CAST(ROUND((sum(t1.actionbar_click) / sum(t1.click)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS actionRatio \",\n" +
            "    \"comment\": \"素材点击率\"\n" +
            "  },\n" +
            "  \"adItemClickCount\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.ad_item_click_count),0) as adItemClickCount \",\n" +
            "    \"comment\": \"组件点击数\"\n" +
            "  },\n" +
            "  \"espLivePlayedSeconds\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.esp_live_played_seconds),0) as espLivePlayedSeconds \",\n" +
            "    \"comment\": \"直播平均观看时长\"\n" +
            "  },\n" +
            "  \"playedThreeSeconds\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.played_three_seconds),0) as playedThreeSeconds \",\n" +
            "    \"comment\": \"作品3秒播放数\"\n" +
            "  },\n" +
            "  \"play3sRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.click) != 0 THEN CONCAT(CAST(ROUND((sum(t1.played_three_seconds) / sum(t1.click)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS play3sRatio \",\n" +
            "    \"comment\": \"作品3秒播放率\"\n" +
            "  },\n" +
            "  \"playedFiveSeconds\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.played_five_seconds),0) as playedFiveSeconds \",\n" +
            "    \"comment\": \"作品5秒播放数\"\n" +
            "  },\n" +
            "  \"play5sRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.click) != 0 THEN CONCAT(CAST(ROUND((sum(t1.played_five_seconds) / sum(t1.click)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS play5sRatio \",\n" +
            "    \"comment\": \"作品5秒播放率\"\n" +
            "  },\n" +
            "  \"playedEnd\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.played_end),0) as playedEnd \",\n" +
            "    \"comment\": \"作品完播数\"\n" +
            "  },\n" +
            "  \"playEndRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.click) != 0 THEN CONCAT(CAST(ROUND((sum(t1.played_end) / sum(t1.click)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS playEndRatio \",\n" +
            "    \"comment\": \"作品完播率\"\n" +
            "  },\n" +
            "  \"share\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.share),0) as share \",\n" +
            "    \"comment\": \"作品分享数\"\n" +
            "  },\n" +
            "  \"comment\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.comment),0) as comment \",\n" +
            "    \"comment\": \"作品评论数\"\n" +
            "  },\n" +
            "  \"likes\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.likes),0) as likes \",\n" +
            "    \"comment\": \"作品点赞数\"\n" +
            "  },\n" +
            "  \"report\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.report),0) as report \",\n" +
            "    \"comment\": \"作品举报数\"\n" +
            "  },\n" +
            "  \"block\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.block),0) as block \",\n" +
            "    \"comment\": \"作品拉黑数\"\n" +
            "  },\n" +
            "  \"itemNegative\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.item_negative),0) as itemNegative \",\n" +
            "    \"comment\": \"详情页减少此类作品数\"\n" +
            "  },\n" +
            "  \"liveShare\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.live_share),0) as liveShare \",\n" +
            "    \"comment\": \"直播间分享数\"\n" +
            "  },\n" +
            "  \"liveComment\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.live_comment),0) as liveComment \",\n" +
            "    \"comment\": \"直播间评论数\"\n" +
            "  },\n" +
            "  \"liveReward\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.live_reward),0) as liveReward \",\n" +
            "    \"comment\": \"直播间送礼数\"\n" +
            "  },\n" +
            "  \"effectivePlayCount\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.effective_play_count),0) as effectivePlayCount \",\n" +
            "    \"comment\": \"有效播放数\"\n" +
            "  },\n" +
            "  \"effectivePlayRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.ad_show) != 0 THEN CONCAT(CAST(ROUND((sum(t1.effective_play_count) / sum(t1.ad_show)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS effectivePlayRatio \",\n" +
            "    \"comment\": \"有效播放率\"\n" +
            "  },\n" +
            "  \"adLivePlayed1mNum\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.ad_live_played1m_num),0) as adLivePlayed1mNum \",\n" +
            "    \"comment\": \"直播间停留1分数\"\n" +
            "  },\n" +
            "  \"conversionNum\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.conversion_num),0) as conversionNum \",\n" +
            "    \"comment\": \"转化数\"\n" +
            "  },\n" +
            "  \"conversionCostEsp\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.conversion_num) != 0 THEN ROUND(sum(t1.cost_total) / sum(t1.conversion_num), 2) ELSE 0 END AS conversionCostEsp \",\n" +
            "    \"comment\": \"转化成本\"\n" +
            "  },\n" +
            "  \"gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.gmv),0) as gmv \",\n" +
            "    \"comment\": \"GMV\"\n" +
            "  },\n" +
            "  \"t0Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t0_gmv),0) as t0Gmv \",\n" +
            "    \"comment\": \"当日累计GMV\"\n" +
            "  },\n" +
            "  \"t1Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t1_gmv),0) as t1Gmv \",\n" +
            "    \"comment\": \"次日累计GMV\"\n" +
            "  },\n" +
            "  \"t7Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t7_gmv),0) as t7Gmv \",\n" +
            "    \"comment\": \"7日累计GMV\"\n" +
            "  },\n" +
            "  \"t15Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t15_gmv),0) as t15Gmv \",\n" +
            "    \"comment\": \"15日累计GMV\"\n" +
            "  },\n" +
            "  \"t30Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t30_gmv),0) as t30Gmv \",\n" +
            "    \"comment\": \"30日累计GMV\"\n" +
            "  },\n" +
            "  \"roi\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.cost_total) != 0 THEN ROUND((sum(t1.t0_gmv) / sum(t1.cost_total)),2) ELSE '0.00' END AS roi \",\n" +
            "    \"comment\": \"ROI\"\n" +
            "  },\n" +
            "  \"paiedOrder\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.paied_order),0) as paiedOrder \",\n" +
            "    \"comment\": \"直接订单数\"\n" +
            "  },\n" +
            "  \"orderRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.actionbar_click) != 0 THEN CONCAT(CAST(ROUND((sum(t1.paied_order) / sum(t1.actionbar_click)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS orderRatio \",\n" +
            "    \"comment\": \"直接下单率\"\n" +
            "  },\n" +
            "  \"t0OrderCnt\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t0_order_cnt),0) as t0OrderCnt \",\n" +
            "    \"comment\": \"当日累计订单数\"\n" +
            "  },\n" +
            "  \"t0OrderCntCost\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.t0_order_cnt) != 0 THEN ROUND(sum(t1.cost_total) / sum(t1.t0_order_cnt), 2) ELSE 0 END AS t0OrderCntCost \",\n" +
            "    \"comment\": \"当日累计订单成本\"\n" +
            "  },\n" +
            "  \"t0OrderCntRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.actionbar_click) != 0 THEN CONCAT(CAST(ROUND((sum(t1.t0_order_cnt) / sum(t1.actionbar_click)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS t0OrderCntRatio \",\n" +
            "    \"comment\": \"累计订单下单率\"\n" +
            "  },\n" +
            "  \"t1OrderCnt\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t1_order_cnt),0) as t1OrderCnt \",\n" +
            "    \"comment\": \"次日累计订单数\"\n" +
            "  },\n" +
            "  \"t7OrderCnt\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t7_order_cnt),0) as t7OrderCnt \",\n" +
            "    \"comment\": \"7日累计订单数\"\n" +
            "  },\n" +
            "  \"t15OrderCnt\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t15_order_cnt),0) as t15OrderCnt \",\n" +
            "    \"comment\": \"15日累计订单数\"\n" +
            "  },\n" +
            "  \"t30OrderCnt\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t30_order_cnt),0) as t30OrderCnt \",\n" +
            "    \"comment\": \"30日累计订单数\"\n" +
            "  },\n" +
            "  \"merchantRecoFans\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.merchant_reco_fans),0) as merchantRecoFans \",\n" +
            "    \"comment\": \"涨粉数\"\n" +
            "  },\n" +
            "  \"t1Retention\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t1_retention),0) as t1Retention \",\n" +
            "    \"comment\": \"次日涨粉留存数\"\n" +
            "  },\n" +
            "  \"t7Retention\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t7_retention),0) as t7Retention \",\n" +
            "    \"comment\": \"7日涨粉留存数\"\n" +
            "  },\n" +
            "  \"t15Retention\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t15_retention),0) as t15Retention \",\n" +
            "    \"comment\": \"15日涨粉留存数\"\n" +
            "  },\n" +
            "  \"t30Retention\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.t30_retention),0) as t30Retention \",\n" +
            "    \"comment\": \"30日涨粉留存数\"\n" +
            "  },\n" +
            "  \"reservationSuccess\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.reservation_success),0) as reservationSuccess \",\n" +
            "    \"comment\": \"预约成功数\"\n" +
            "  },\n" +
            "  \"reservationCost\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.reservation_success) != 0 THEN ROUND(sum(t1.cost_total) / sum(t1.reservation_success), 2) ELSE 0 END AS reservationCost \",\n" +
            "    \"comment\": \"预约成功成本\"\n" +
            "  },\n" +
            "  \"standardLivePlayedStarted\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.standard_live_played_started),0) as standardLivePlayedStarted \",\n" +
            "    \"comment\": \"直播观看数\"\n" +
            "  },\n" +
            "  \"liveAudienceCost\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.standard_live_played_started) != 0 THEN ROUND(sum(t1.cost_total) / sum(t1.standard_live_played_started), 2) ELSE 0 END AS liveAudienceCost \",\n" +
            "    \"comment\": \"直播观看成本\"\n" +
            "  },\n" +
            "  \"liveEventGoodsView\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.live_event_goods_view),0) as liveEventGoodsView \",\n" +
            "    \"comment\": \"直播间商品点击数\"\n" +
            "  },\n" +
            "  \"goodsClickRatio\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.standard_live_played_started) != 0 THEN CONCAT(CAST(ROUND((sum(t1.live_event_goods_view) / sum(t1.standard_live_played_started)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS goodsClickRatio \",\n" +
            "    \"comment\": \"直播间商品点击率\"\n" +
            "  },\n" +
            "  \"directAttrPlatNewBuyerCnt\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.direct_attr_plat_new_buyer_cnt),0) as directAttrPlatNewBuyerCnt \",\n" +
            "    \"comment\": \"直接平台新客\"\n" +
            "  },\n" +
            "  \"directAttrSellerNewBuyerCnt\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.direct_attr_seller_new_buyer_cnt),0) as directAttrSellerNewBuyerCnt \",\n" +
            "    \"comment\": \"直接店铺新客\"\n" +
            "  },\n" +
            "  \"fansT0Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.fans_t0_gmv),0) as fansT0Gmv \",\n" +
            "    \"comment\": \"涨粉当日GMV\"\n" +
            "  },\n" +
            "  \"fansT1Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.fans_t1_gmv),0) as fansT1Gmv \",\n" +
            "    \"comment\": \"涨粉次日GMV\"\n" +
            "  },\n" +
            "  \"fansT7Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.fans_t7_gmv),0) as fansT7Gmv \",\n" +
            "    \"comment\": \"涨粉7日GMV\"\n" +
            "  },\n" +
            "  \"fansT15Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.fans_t15_gmv),0) as fansT15Gmv \",\n" +
            "    \"comment\": \"涨粉15日GMV\"\n" +
            "  },\n" +
            "  \"fansT30Gmv\": {\n" +
            "    \"filed\": \"IFNULL(sum(t1.fans_t30_gmv),0) as fansT30Gmv \",\n" +
            "    \"comment\": \"涨粉30日GMV\"\n" +
            "  },\n" +
            "  \"fansT0Roi\": {\n" +
            "    \"filed\": \"CASE WHEN sum(t1.cost_total) != 0 THEN CONCAT(CAST(ROUND((sum(t1.fans_t0_gmv) / sum(t1.cost_total)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS fansT0Roi \",\n" +
            "    \"comment\": \"涨粉当日ROI\"\n" +
            "  }\n" +
            "}";

    public static Map<String, Map<String, Object>> getKuaishouAccountReport() {
        Object kuaiShouVideoDictJson = JSON.parseObject(KUAISHOU_ACCOUNT_REPORT_JSON);
        return JsonResourceUtil.jsonToMap(kuaiShouVideoDictJson);
    }
}
