<?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.miaxis.vip.mapper.VipCodeMapper">

    <resultMap type="VipCode" id="VipCodeResult">
        <result property="id"    column="id"    />
        <result property="vipCode"    column="vip_code"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="status"    column="status"    />
        <result property="activationTime"    column="activation_time"    />
        <result property="activationUserId"    column="activation_user_id"    />
    </resultMap>

    <sql id="selectVipCodeVo">
        select * from vip_code
    </sql>

    <select id="selectVipCodeList" parameterType="QueryVipCodeListDTO" resultMap="VipCodeResult">
        <include refid="selectVipCodeVo"/>
        <where>
            1=1
            <if test="vipCode != null  and vipCode != ''"> and vip_code like concat('%', #{vipCode}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="startTime != null">
                and DATE_FORMAT(create_time,'%Y-%m-%d')<![CDATA[ >= ]]> #{startTime}
            </if>
            <if test="endTime != null">
                and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ < ]]> #{endTime}
            </if>
            order by create_time desc
        </where>
    </select>

</mapper>
