<?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,
        b.name,
        c.release_at, c.trading_txhash
        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
        <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="tradingTxhash!=''">
                and c.trading_txhash = #{tradingTxhash}
            </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>
