<?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.goblin.mapper.GoblinNftOrderMapper">

    <select id="searchList" resultType="com.liquidnet.service.goblin.dto.admin.GoblinNftOrderListDto">
        select
        a.user_id,a.order_code,a.order_type,a.pay_type,a.price_actual,a.status,a.pay_time,a.created_at,
        b.name,
        c.trading_at, c.nft_id
        from goblin_nft_order as a
        left join goblin_goods_sku as b on b.sku_id = a.sku_id
        left join goblin_user_digital_artwork as c on c.order_id = a.order_id and c.del_flg = '0'
        <where>
            <if test="name!=''">
                and b.name like concat('%', #{name}, '%')
            </if>
            <if test="userId!=''">
                and a.user_id = #{userId}
            </if>
            <if test="shortOrderCode!=''">
                and a.order_code like concat('%', #{shortOrderCode}, '%')
            </if>
            <if test="orderCode!=''">
                and a.order_code = #{orderCode}
            </if>
            <if test="nftId!=''">
                and c.nft_id = #{nftId}
            </if>
            <if test="orderType != null and orderType!=''">
                and a.order_type = #{orderType}
            </if>
            <if test="payType!=''">
                and a.pay_type = #{payType}
            </if>
            <if test="status != null and status!=''">
                and a.status = #{status}
            </if>
            <if test="payTimeStart != null  and payTimeStart != ''">
                <!-- and amo.payment_at &gt; #{paymentAtStart} -->
                and a.pay_time <![CDATA[>=]]> #{payTimeStart}
            </if>
            <if test="payTimeEnd != null  and payTimeEnd != ''">
                <!-- and amo.payment_at &lt; #{paymentAtEnd} -->
                and a.pay_time <![CDATA[<=]]> #{payTimeEnd}
            </if>
        </where>
        group by a.order_id
        order by a.created_at desc
    </select>
</mapper>
