<?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.recommend.mapper.AcRepurSharRuleConfigMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="AcRepurSharRuleConfigExt" type="com.hzs.common.domain.activity.recommend.ext.AcRepurSharRuleConfigExt">
        <id column="PK_ID" property="pkId"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <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="PK_BASE_ID" property="pkBaseId"/>
        <result column="ORDER_AMOUNT" property="orderAmount"/>
        <result column="ORDER_ACHIEVE" property="orderAchieve"/>
        <result column="RATIO_VALUE" property="ratioValue"/>
        <collection property="repurSharOrderTypeList" ofType="com.hzs.common.domain.activity.recommend.AcRepurSharOrderType">
            <result column="ORDER_TYPE" property="orderType"/>
        </collection>
    </resultMap>

    <update id="deleteSharRuleConfigByActivityId">
        update ac_repur_shar_rule_config c
        set c.del_flag = 1, c.modified_time = sysdate, c.pk_modified = #{pkModifyId}
        where c.pk_order_type in (select t.pk_id
        from ac_repur_shar_order_type t
        where t.del_flag = 0
        and t.pk_base_id = #{activityId}
        and t.order_type in
        <foreach collection="orderTypeList" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        )
    </update>

</mapper>
