<?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="cn.com.ctop.common.module.mapper.CustomDataByAccountMapper">

    <select id="queryKsCampaignData" 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_campaign
        where stat_date = #{date}
          and account_id = #{accountId}
    </select>

    <select id="queryKsGroupData" 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_group
        where stat_date = #{date}
          and account_id = #{accountId}
    </select>

    <select id="queryKsAccountData" 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 = #{date}
          and account_id = #{accountId}
    </select>

    <select id="queryByCampaignData" resultType="com.alibaba.fastjson.JSONObject">
        SELECT
            sum(cost) cost,
            sum(show_num) showNum,
            sum(click) click
        from ctop_bytedance_report_campaign_daily
        where stat_datetime = #{date}
          and advertiser_id = #{accountId}
    </select>

    <select id="queryByPlanData" resultType="com.alibaba.fastjson.JSONObject">
        SELECT sum(cost)     cost,
               sum(show_num) showNum,
               sum(click)    click
        from ctop_bytedance_report_plan_daily
        where stat_datetime = '${date} 00:00:00'
          and advertiser_id = #{accountId}
    </select>

    <select id="queryByAccountData" resultType="com.alibaba.fastjson.JSONObject">
        SELECT sum(cost)     cost,
               sum(show_num) showNum,
               sum(click)    click
        FROM ctop_bytedance_report_advertiser_daily
        where stat_datetime = '${date} 00:00:00'
          and advertiser_id = #{accountId}
    </select>

</mapper>
