<?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 c.trading_at, c.nft_id, a.* from (select
        user_id,order_code,order_id,order_type,pay_type,price_actual,
        status,pay_time,created_at,sku_title as name, mid, ex_code, box_sku_id
        from goblin_nft_order
        <where>
            <if test="name!=''">
                and sku_title like concat('%', #{name}, '%')
            </if>
            <if test="userId!=''">
                and user_id = #{userId}
            </if>
            <if test="userMobile!=''">
                and user_mobile = #{userMobile}
            </if>
            <if test="shortOrderCode!=''">
                and order_code like concat('%', #{shortOrderCode}, '%')
            </if>
            <if test="orderCode!=''">
                and order_code = #{orderCode}
            </if>
            <if test="orderType != null and orderType!=''">
                and order_type = #{orderType}
            </if>
            <if test="payType!=''">
                and pay_type = #{payType}
            </if>
            <if test="status != null and status!=''">
                and status = #{status}
            </if>
            <if test="payTimeStart != null  and payTimeStart != ''">
                <!-- and amo.payment_at &gt; #{paymentAtStart} -->
                and pay_time <![CDATA[>=]]> #{payTimeStart}
            </if>
            <if test="payTimeEnd != null  and payTimeEnd != ''">
                <!-- and amo.payment_at &lt; #{paymentAtEnd} -->
                and pay_time <![CDATA[<=]]> #{payTimeEnd}
            </if>
            <if test="exCode!=''">
                and ex_code = #{exCode}
            </if>
        </where>
        ) as a
        left join goblin_user_digital_artwork as c on c.order_id = a.order_id and c.del_flg = '0'
        <where>
            <if test="nftId!=''">
                and c.nft_id = #{nftId}
            </if>
        </where>
        -- group by a.order_id
        -- order by a.created_at desc
        order by a.mid desc
    </select>
</mapper>
