<?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="org.jeecg.modules.bytedance.advertise.mapper.ByteDanceAdvertisePlanMapper">

    <select id="selectWarningGroup" resultType="java.lang.String">
   SELECT
   name
   FROM ctop_bytedance_advertise_plan
   WHERE account_id = #{accountId}
   and (cpa_bid &gt; #{maxBid} or bid &gt; #{maxBid})
   and toutiao_status = 'AD_STATUS_DELIVERY_OK'
    </select>


    <select id="selectWarningCpaBid" resultType="java.lang.String">
   SELECT
   name
   FROM ctop_bytedance_advertise_plan
   WHERE account_id = #{accountId}
   and deep_cpabid &gt; #{maxCpaBid}
   and toutiao_status = 'AD_STATUS_DELIVERY_OK'
    </select>
    <select id="queryTodayBuiltCount" resultType="java.lang.Integer">
        SELECT count(1) FROM ctop_bytedance_advertise_plan
        WHERE account_id = #{accountId}
          AND LOCATE(#{date}, ad_create_time)
    </select>



    <!--更新广告计划 操作状态 或 定向包id 或 出价-->
    <update id="updateAdvertisePlan">

        update ctop_bytedance_advertise_plan
        <set>
            <if test="optStatus != null">
                opt_status = #{optStatus},
            </if>
            <if test="audiencePackageId != null">
                audience_package_id = #{audiencePackageId},
            </if>
            <if test="bid != null">
                bid = #{bid},
            </if>
            <if test="cpaBid != null and cpaBid!=''">
                cpa_bid = #{cpaBid},
            </if>
            <if test="scheduleTime != null and scheduleTime!=''">
                schedule_time = #{scheduleTime},
            </if>
            <if test="budgetMode != null and budgetMode!=''">
                budget_mode = #{budgetMode},
            </if>
            <if test="budget != null and budget!=''">
                budget = #{budget},
            </if>
        </set>
        where id = #{id}
    </update>



</mapper>
