<?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.liquidnet.service.adam.mapper.AdamMemberOrderMapper">
    <resultMap id="orderListResult" type="com.liquidnet.service.adam.dto.MemberOrderDto" >
        <result column="uid" property="uid" />
        <result column="order_no" property="orderNo" />
        <result column="state" property="state" />
        <result column="pay_type" property="payType" />
        <result column="price" property="price" />
        <result column="price_paid" property="pricePaid" />
        <result column="payment_at" property="paymentAt" />
        <result column="created_at" property="createdAt" />
        <result column="mobile" property="mobile" />
        <result column="source" property="source" />
        <result column="mode" property="mode" />
    </resultMap>
    <select id="getMemberOrderList" resultMap="orderListResult">
        select amo.uid,
        amo.order_no,
        amo.state,
        amo.pay_type,
        amo.price,
        amo.price_paid,
        amo.payment_at,
        amo.created_at,
        au.mobile,
        amo.source,
        amo.mode
        from adam_member_order amo
        inner join adam_user_member aum
        on amo.uid = aum.uid
        inner join adam_user au on aum.uid = au.uid
        <where>
            <if test="orderNo != null  and orderNo != ''">
                and amo.order_no = #{orderNo}
            </if>
            <if test="mobile != null  and mobile != ''">
                and au.mobile = #{mobile}
            </if>
            <if test="payType != null  and payType != ''">
                and amo.pay_type = #{payType}
            </if>
            <if test="state != null  and state != ''">
                and amo.state = #{state}
            </if>
            <if test="mode != null  and mode != ''">
                and amo.mode = #{mode}
            </if>
            <if test="source != null  and source != ''">
                and amo.source = #{source}
            </if>
            <if test="paymentAtStart != null  and paymentAtStart != ''">
                <!-- and amo.payment_at &gt; #{paymentAtStart} -->
                and amo.payment_at <![CDATA[>=]]> #{paymentAtStart}
            </if>
            <if test="paymentAtEnd != null  and paymentAtEnd != ''">
                <!-- and amo.payment_at &lt; #{paymentAtEnd} -->
                and amo.payment_at <![CDATA[<=]]> #{paymentAtEnd}
            </if>
        </where>
        order by amo.created_at desc
    </select>
</mapper>
