<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxl.job.executor.report.mapper.BytedanceReportMapper">


    <select id="selectDayReport" resultType="com.alibaba.fastjson.JSONObject">
        select
         sum(charge) cost,
         sum(photo_show) photoShow,
         sum(photo_click) photoClick,
         sum(aclick) aclick,
         max(stat_hour) maxHour
       from
        ctop_kuaishou_report_hourly_account
        where stat_date = #{date}
      </select>


    <select id="selectByDate" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick
     from
      ctop_kuaishou_report_daily_account
      where stat_date &lt;= #{startDate}
      and  stat_date &gt;= #{endDate}
    </select>

    <select id="selectAllAccount" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick
     from
      ctop_kuaishou_report_daily_account
    </select>


    <select id="selectReportDetail" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       stat_hour statHour,
       stat_date statDate
     from
      ctop_kuaishou_report_hourly_account
      where stat_date = #{date}
      group by stat_hour
      order by stat_hour asc
    </select>


    <select id="selectDayHourlyByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick
     from
      ctop_kuaishou_report_hourly_account
      where stat_date = #{date}
      and stat_hour = #{statHour}
    </select>

    <select id="selectSumDayHourlyByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick
     from
      ctop_kuaishou_report_hourly_account
      where stat_date = #{date}
      and stat_hour &lt;= #{statHour}
    </select>


    <select id="selectDayDetailByDate" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       stat_date statDate
     from
      ctop_kuaishou_report_daily_account
      where stat_date &lt;= #{startDate}
      and  stat_date &gt;= #{endDate}
      group by stat_date
      order by stat_date asc
    </select>


    <select id="selectDayDetailByMonth" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       DATE_FORMAT(stat_date,'%Y-%m') statDate
     from
      ctop_kuaishou_report_daily_account
      where stat_date &lt;= #{startDate}
      and  stat_date &gt;= #{endDate}
      group by DATE_FORMAT(stat_date,'%Y-%m')
      order by stat_date asc
    </select>

    <select id="selectAllDayDetailByMonth" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       DATE_FORMAT(stat_date,'%Y-%m') statDate
     from
      ctop_kuaishou_report_daily_account
      group by DATE_FORMAT(stat_date,'%Y-%m')
      order by stat_date asc
    </select>


    <select id="selectMonthReportByDate" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       DATE_FORMAT(stat_date,'%Y-%m') statDate
     from
      ctop_kuaishou_report_daily_account
      where DATE_FORMAT(stat_date,'%Y-%m') = #{date}
    </select>


    <select id="selectDayDetailsByMonth" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       stat_date statDate
     from
      ctop_kuaishou_report_daily_account
      where DATE_FORMAT(stat_date,'%Y-%m') = #{date}
      group by stat_date
      order by stat_date asc
    </select>


    <select id="selectDayDailyByDate" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       stat_date statDate
     from
      ctop_kuaishou_report_daily_account
      where stat_date = #{statDate}
      group by stat_date
    </select>


    <select id="selectDayReportByDate" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       stat_date statDate
     from
      ctop_kuaishou_report_daily_account
      where stat_date = #{date}
      group by stat_date
    </select>


    <select id="selectHourlyDetailsByDate" resultType="com.alibaba.fastjson.JSONObject">
      select
       sum(charge) cost,
       sum(photo_show) photoShow,
       sum(photo_click) photoClick,
       sum(aclick) aclick,
       stat_hour statHour,
       stat_date statDate
     from
      ctop_kuaishou_report_hourly_account
      where stat_date = #{date}
      group by stat_hour
      order by stat_hour asc
    </select>
</mapper>
