<?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.iamberry.wechat.service.mapper.SpikeMapper">
    <resultMap  id="BaseResultMap" type="Spike" >
        <result    column="spike_id"    property="spikeId" />
        <result    column="promotions_id"    property="promotionsId" />
        <result    column="spike_color_id"    property="spikeColorId" />
        <result    column="spike_price"    property="spikePrice" />
        <result    column="spike_discount"    property="spikeDiscount" />
        <result    column="spike_status"    property="spikeStatus" />
        <result    column="spike_create_time"    property="spikeCreateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.spike_id,
        t.promotions_id,
        t.spike_color_id,
        t.spike_price,
        t.spike_discount,
        t.spike_status,
        t.spike_create_time
    </sql>
    <select id="getSpikeList" resultMap="BaseResultMap" parameterType="Spike" >
        select
        <include refid="Base_List" />
        from tb_iamberry_eo_spike t
        <where>
            <if test="spikeId != null ">
                AND t.spike_id = #{spikeId}
            </if >
            <if test="promotionsId != null ">
                AND t.promotions_id = #{promotionsId}
            </if >
            <if test="spikeColorId != null ">
                AND t.spike_color_id = #{spikeColorId}
            </if >
            <if test="spikeDiscount != null and spikeDiscount != ''">
                AND t.spike_discount  like  CONCAT ('%',#{spikeDiscount},'%')
            </if >
            <if test="spikeStatus != null">
                AND t.spike_status  = #{spikeStatus}
            </if >
        </where>
    </select>
    <select id="getSpikeListAll" resultMap="BaseResultMap" parameterType="java.util.List" >
        select
        <include refid="Base_List" />
        from tb_iamberry_eo_spike t
        <where>
            t.spike_status  = 1
            AND t.promotions_id IN (
                <foreach collection="array" item="item" separator=",">
                    #{item}
                </foreach>
            )
        </where>
    </select>
    <select id="getSpikeById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_eo_spike t
        where t.spike_id= #{spikeId}
    </select>
</mapper>