<?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="org.springblade.modules.guosen.userPointsGoods.mapper.UserPointsGoodsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="userPointsGoodsResultMap"
               type="org.springblade.modules.guosen.userPointsGoods.entity.UserPointsGoods">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="user_id" property="userId"/>
        <result column="points_goods_id" property="pointsGoodsId"/>
        <result column="activity_id" property="activityId"/>
        <result column="points_goods_status" property="pointsGoodsStatus"/>
        <result column="points_value" property="pointsValue"/>
        <result column="hot_value" property="hotValue"/>
        <result column="cash_value" property="cashValue"/>
        <result column="address_id" property="addressId"/>
        <result column="tracking_number" property="trackingNumber"/>
        <result column="tracking_name" property="trackingName"/>


    </resultMap>

    <!-- 通用查询映射结果 -->
    <resultMap id="userPointsGoodsResultMapVO"
               type="org.springblade.modules.guosen.userPointsGoods.vo.UserPointsGoodsVO"
               extends="userPointsGoodsResultMap">
        <result column="user_nick_name" property="userNickName"/>
        <result column="user_phone" property="userPhone"/>
        <result column="recivier_name" property="recivierName"/>
        <result column="recivier_phone" property="recivierPhone"/>
        <result column="area" property="area"/>
        <result column="address" property="address"/>

    </resultMap>


    <select id="selectUserPointsGoodsPage" resultMap="userPointsGoodsResultMapVO">
        select
            cupg.*,
            clu.nick_name as user_nick_name,
            clu.phone as user_phone,
            cua.consignee as recivier_name,
            cua.phone as recivier_phone,
            cua.area as area,
            cua.detail as address
        from
            cyzh_user_points_goods cupg,cyzh_login_user clu,cyzh_user_address cua
        where cupg.is_deleted = 0 and cupg.user_id = clu.id and cupg.address_id = cua.id
        <if test="userPointsGoods != null">
            <if test="userPointsGoods.userNickName != null">
                and clu.nick_name like "%${userPointsGoods.userNickName}%"
            </if>
            <if test="userPointsGoods.userNickName != null">
                and clu.phone like "%${userPointsGoods.userPhone}%"
            </if>
            <if test="userPointsGoods.recivierName != null">
                and cua.consignee like "%${userPointsGoods.recivierName}%"
            </if>

            <if test="userPointsGoods.recivierName != null">
                and cua.phone like "%${userPointsGoods.recivierPhone}%"
            </if>
            <if test="userPointsGoods.area != null">
                and cua.area like "%${userPointsGoods.area}%"
            </if>
            <if test="userPointsGoods.address != null">
                and cua.detail like "%${userPointsGoods.address}%"
            </if>
            <if test="userPointsGoods.pointsGoodsStatus != null">
                and cupg.points_goods_status like "%${userPointsGoods.pointsGoodsStatus}%"
            </if>

        </if>



    </select>

</mapper>
