<?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.kmall.schedule.dao.QzStoreCampMinusMapper">
    <select id="queryCampMinusListByPasting" resultType="map">
        select
        `camp_minus_id` 'campMinusId', a.store_topic_id 'storeTopicId'
        from mk_store_camp_minus a
        where 1=1 AND a.camp_end_time <![CDATA[ < ]]> now() AND a.is_valid = 0 and a.is_past = 0
    </select>
    <select id="queryCampMinusListByPastNotStart" resultType="map">
        select
        `camp_minus_id` 'campMinusId', a.store_topic_id 'storeTopicId'
        from mk_store_camp_minus a
        where 1=1 AND a.camp_beg_time <![CDATA[ <= ]]> now() AND a.is_valid = 0 and a.is_past = 2
    </select>

    <update id="updateStoreCampMinus" parameterType="map">
        update mk_store_camp_minus set
        <if test="isValid != null and isValid != ''">
            is_valid = 1,
        </if>
         <if test="isPast != null and isPast != ''">
             is_past = #{isPast},
         </if>
         mod_time = now() where camp_minus_id = #{campMinusId}
    </update>

    <select id="selectAdIdByTopicId" resultType="map">
        select
        id 'adId'
        from mall_ad
        where store_topic_id = #{storeTopicId}
    </select>

    <update id="updateAd" parameterType="map">
        update mall_ad set enabled = #{enabled} where id = #{adId}
    </update>
    <update id="updateStoreTopic" parameterType="map">
        update mall_store_topic set is_valid = 1,mod_time = now() where id = #{storeTopicId}
    </update>
</mapper>