<?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.hzs.activity.other.mapper.AcOtherPriceConfigMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.activity.other.AcOtherPriceConfig">
        <id column="PK_ID" property="pkId"/>
        <result column="CREATION_TIME" property="creationTime"/>
        <result column="PK_CREATOR" property="pkCreator"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="PK_MODIFIED" property="pkModified"/>
        <result column="PK_COUNTRY" property="pkCountry"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <result column="TYPE" property="type"/>
        <result column="PLACE_DEPT_NUMBER" property="placeDeptNumber"/>
        <result column="PLACE_DEPT_PV" property="placeDeptPv"/>
        <result column="PK_BASE_ID" property="pkBaseId"/>
        <result column="PARENT_PV" property="parentPv"/>
    </resultMap>

    <!-- 查询其它活动明细 -->
    <select id="queryList" resultType="com.hzs.common.domain.activity.other.ext.AcOtherPriceConfigExt">
        select aopc.*, abc.act_start_date, abc.act_end_date
        from ac_base_config abc
        left join ac_other_price_config aopc
        on aopc.pk_base_id = abc.pk_id
        and aopc.del_flag = 0
        where abc.del_flag = 0
        <if test="null != pkCountry">
            and abc.pk_country = #{pkCountry}
        </if>
        and abc.act_type in
        <foreach collection="actTypeList" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and #{nowDate} >= to_char(abc.act_start_date, 'yyyy-mm-dd')
        and to_char(abc.act_end_date, 'yyyy-mm-dd') >= #{nowDate}
        order by abc.pk_country, abc.act_type, abc.act_start_date
    </select>

    <delete id="deleteByPkCountryAll">
        delete from AC_OTHER_PRICE_CONFIG where PK_COUNTRY = #{pkCountry} and PK_BASE_ID = #{pkBaseId}
        <if test="notIdlList != null and notIdlList.size > 0">
            and PK_ID not in
            <foreach collection="notIdlList" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
    </delete>
</mapper>
