<?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.ruoyi.member.mapper.MemberOrderMapper">

    <resultMap type="MemberOrder" id="MemberOrderResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="userType"    column="user_type"    />
        <result property="nickname"    column="nickname"    />
        <result property="orderNo"    column="order_no"    />
        <result property="orderType"    column="order_type"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="goodsNum"    column="goods_num"    />
        <result property="goodsPrice"    column="goods_price"    />
        <result property="payTime"    column="pay_time"    />
        <result property="content"    column="content"    />
        <result property="payWay"    column="pay_way"    />
        <result property="isPay"    column="is_pay"    />
        <result property="isRefund"    column="is_refund"    />
        <result property="refundUserId"    column="refund_user_id"    />
        <result property="refundWay"    column="refund_way"    />
        <result property="refundNo"    column="refund_no"    />
        <result property="refundApplyTime"    column="refund_apply_time"    />
        <result property="refundReceiveTime"    column="refund_receive_time"    />
        <result property="refundReason"    column="refund_reason"    />
        <result property="remark"    column="remark"    />
        <result property="creator"    column="creator"    />
        <result property="createTime"    column="create_time"    />
        <result property="updater"    column="updater"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMemberOrderVo">
        select id, user_id, user_type, nickname, order_no, order_type, goods_id, goods_num, goods_price, pay_time,
               content, pay_way, is_pay, is_refund, refund_user_id, refund_way, refund_no, refund_apply_time, refund_receive_time,
               refund_reason, remark, creator, create_time, updater, update_time, del_flag from dl_member_order
    </sql>

    <select id="queryListPage" parameterType="MemberOrder" resultMap="MemberOrderResult">
        select main.id, main.user_id, main.user_type, su.nick_name as nickname, main.order_no, main.order_type, main.goods_id, main.goods_num, main.goods_price, main.pay_time,
        main.content, main.pay_way, main.is_pay, main.is_refund, main.refund_user_id, main.refund_way, main.refund_no, main.refund_apply_time, main.refund_receive_time,
        main.refund_reason, main.remark, main.creator, main.create_time, main.updater, main.update_time, main.del_flag
        from dl_member_order main
        left join sys_user su on su.user_id = main.user_id
        <where>
            <if test="entity.nickname != null  and entity.nickname != ''"> and su.nick_name like concat('%', #{entity.nickname}, '%')</if>
            <if test="entity.orderNo != null  and entity.orderNo != ''"> and main.order_no like concat('%', #{entity.orderNo}, '%')</if>
            <if test="entity.userType != null  and entity.userType != ''"> and user_type = #{entity.userType}</if>
            <if test="entity.orderType != null  and entity.orderType != ''"> and order_type = #{entity.orderType}</if>
            <if test="entity.payWay != null  and entity.payWay != ''"> and pay_way = #{entity.payWay}</if>
            <if test="entity.refundWay != null  and entity.refundWay != ''"> and refund_way = #{entity.refundWay}</if>
            <if test="entity.isPay != null "> and is_pay = #{entity.isPay}</if>
            <if test="entity.isRefund != null "> and is_refund = #{entity.isRefund}</if>
            <if test="entity.userId != null "> and su.invite_id = #{entity.userId}</if>
        </where>
        order by create_time desc
    </select>
</mapper>
