<?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.xxfc.platform.activity.mapper.ActivityLuckyDrawMapper">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.xxfc.platform.activity.entity.ActivityLuckyDraw" id="activityLuckyDrawMap">
        <result property="id" column="id"/>
        <result property="userName" column="user_name"/>
        <result property="phone" column="phone"/>
        <result property="activityId" column="activity_id"/>
        <result property="activityName" column="activity_name"/>
        <result property="ticketNum" column="ticket_num"/>
        <result property="crtTime" column="crt_time"/>
        <result property="userId" column="user_id"/>
    </resultMap>

    <select id="listLuckDrawWithPage" resultMap="activityLuckyDrawMap">
        select * from `activity_lucky_draw` where 1=1
        <if test="activityId!=null">
           and `activity_id`=#{activityId}
        </if>
        <if test="phone!=null and phone!=''">
            and `phone`=#{phone}
        </if>
        <if test="startTime!=null and endTime!=null">
            and `crt_time` between #{startTime} and #{endTime}
        </if>
        <if test="startTime!=null and endTime==null">
            and <![CDATA[
            `crt_time`>=#{startTime}
            ]]>
        </if>
        <if test="startTime==null and endTime!=null">
            and <![CDATA[
            `crt_time`<=#{endTime}
            ]]>
        </if>
        order by `crt_time` desc
    </select>

    <select id="getAllByPage" resultType="com.xxfc.platform.activity.vo.ActivityLuckyDrawListVo" parameterType="Map">
        select * from `activity_lucky_draw_list` where 1=1
        <if test="activityId != null">
            and `activity_id`=#{activityId}
        </if>
        <if test= "phone != null and phone != ''">
            and `phone`=#{phone}
        </if>
        <if test="parentPhone!=null and parentPhone!=''">
            and `parentPhone`=#{parentPhone}
        </if>
        <if test="startTime != null and endTime != null">
            and `crt_time` between #{startTime} and #{endTime}
        </if>
        <if test="startTime != null and endTime == null">
            and <![CDATA[
            `crt_time` >= #{startTime}
            ]]>
        </if>
        <if test="startTime==null and endTime!=null">
            and <![CDATA[
            `crt_time`<=#{endTime}
            ]]>
        </if>
        order by `crt_time` desc
    </select>


</mapper>