<?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.github.wxiaoqi.security.admin.mapper.BaseUserMemberExportMapper">
    <resultMap type="com.github.wxiaoqi.security.admin.entity.BaseUserMemberExport" id="baseUserMemberExportMap">
        <id property="id" column="id"/>
        <result property="discount" column="discount"/>
        <result property="memberLevel" column="member_level"/>
        <result property="rentFreeDays" column="rent_free_days"/>
        <result property="totalNumber" column="total_number"/>
        <result property="username" column="username"/>
        <result property="isDel" column="is_del"/>
        <result property="status" column="status"/>
        <result property="crtId" column="crt_id"/>
        <result property="crtName" column="crt_name"/>
        <result property="crtTime" column="crt_time"/>
    </resultMap>

    <update id="updateUserMemberExportDataToLoseEfficacyByPhone">
        update `base_user_member_export` set `status`=1 where `username`=#{phone}
    </update>

    <select id="findExportDataPage" resultType="com.github.wxiaoqi.security.admin.dto.BaseUserMemberExportDTO">
        select `id`,`member_level` as `memberLevel`,`member_name` as `memberName`,`rent_free_days` as `rentFreeDays`,`total_number` as `totalNumber`,`username`,`status`,`crt_name` as `crtName`,`crt_time`as `crtTime` from `base_user_member_export`
        where `is_del`=0  and  source = 0
            <if test="username != null and username != ''">
               and  `username`=#{username}
            </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>

    <update id="updateUserMemberExportDataStatusById">
        update `base_user_member_export` set `is_del`=#{status}  where `id`=#{id}
    </update>
</mapper>