<?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.ai.mapper.AiKuaishouUnitLevelOperationRecordMapper">
    <select id="selectAllByAccountId"
            resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord">
        select distinct account_id, campaign_id, unit_id
        from ctop_ai_kuaishou_unit_level_operation_record
        where unit_id is not null
          and create_time &gt;= #{startDate}
          and create_time &lt;= #{endDate}
          and account_id in (select account_id from ctop_user_allocation where project_id = 458)
        group by account_id, campaign_id, unit_id
    </select>
    <select id="selectAllByAccountIdAndDate"
            resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord">
        select distinct account_id, campaign_id, unit_id
        from ctop_ai_kuaishou_unit_level_operation_record
        where unit_id is not null
          and unit_type = 4
          and create_time &gt;= #{startDate}
          and create_time &lt;= #{endDate}
          and account_id = #{accountId}
        group by unit_id
    </select>

    <select id="selectAllAccountIds" resultType="long">
        select distinct account_id
        from ctop_ai_kuaishou_unit_level_operation_record
        where unit_id is not null
          and create_time &gt;= #{startDate}
          and create_time &lt;= #{endDate}
          and account_id in (select account_id from ctop_user_allocation where project_id = 458)
        group by account_id
    </select>
</mapper>
