<?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.hzs.member.address.mapper.CuMemberGiftMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.address.CuMemberGift">
        <id column="PK_ID" property="pkId"/>
        <result column="PK_MEMBER" property="pkMember"/>
        <result column="GIFT_ADDRESS" property="giftAddress"/>
        <result column="GIFT_NAME" property="giftName"/>
        <result column="GIFT_PHONE" property="giftPhone"/>
        <result column="GIFT_PROVINCE" property="giftProvince"/>
        <result column="GIFT_CITY" property="giftCity"/>
        <result column="GIFT_COUNTY" property="giftCounty"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <result column="PK_CREATOR" property="pkCreator"/>
        <result column="CREATION_TIME" property="creationTime"/>
        <result column="PK_MODIFIED" property="pkModified"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="PK_COUNTRY" property="pkCountry"/>
    </resultMap>


    <!--  查询会员礼包收货地址列表-->
    <select id="selectCuMemberGiftList" parameterType="com.hzs.member.param.CuMemberGiftParam"
            resultType="com.hzs.member.param.CuMemberGiftParam">
        select a.PK_ID,
        a.PK_MEMBER,
        a.GIFT_ADDRESS,
        a.GIFT_NAME,
        a.GIFT_PHONE,
        a.GIFT_PROVINCE,
        a.GIFT_CITY,
        a.GIFT_COUNTY,
        a.DEL_FLAG,
        a.CREATION_TIME,
        a.MODIFIED_TIME,
        a.PK_COUNTRY,
        a.PK_CREATOR,
        a.PK_MODIFIED,b.MEMBER_CODE as memberCode ,b.MEMBER_NAME as memberName
        from CU_MEMBER_GIFT a INNER JOIN CU_MEMBER b on a.PK_MEMBER=b.PK_ID
        where a.DEL_FLAG = 0 and b.DEL_FLAG = 0
        <if test="memberCode != null and memberCode != ''">
            AND b.MEMBER_CODE like '%' || #{memberCode} || '%'
        </if>
        <if test="memberName != null and memberName != ''">
            AND b.USER_NAME like '%' || #{memberName} || '%'
        </if>
        <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
            and a.CREATION_TIME &gt;= to_date(#{params.beginTime}, 'yyyy-mm-dd')
        </if>
        <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
            and a.CREATION_TIME &lt;= to_date(#{params.endTime} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
        </if>
        order by a.CREATION_TIME desc
    </select>

</mapper>
