<?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.kuaishou.modules.batch.mapper.BatchMapper">

    <select id="getDailyCost" resultType="java.math.BigDecimal">
      select
      (case
        when sum(charge) != ''
        then sum(charge)
        else 0
        end
        )
      from ctop_kuaishou_report_daily_account
      where account_id = #{accountId}
    </select>


    <select id="getHourCost" resultType="java.math.BigDecimal">
      select
      (case
        when sum(charge) != ''
        then sum(charge)
        else 0
        end
        )

      from ctop_kuaishou_report_hourly_account
      where account_id = #{accountId}
      and stat_date = #{statDate}
    </select>

    <select id="getBudget" resultType="java.math.BigDecimal">
      select
      (case
        when sum(day_budget) != ''
        then sum(day_budget)
        else 0
        end
        )

      from ctop_kuaishou_campaign
      where account_id = #{accountId}
    </select>


    <select id="getProjectMaxBidByProject" resultType="java.math.BigDecimal">
      select
      max_bid
      from
      ctop_project
      where id = #{projectId}
    </select>


</mapper>