<?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.GoblinNftOrderRefundMapper">

    <select id="searchList" resultType="com.liquidnet.service.goblin.dto.admin.GoblinNftOrderRefundListDto">
        select
        d.refund_code,d.price,d.status,d.refund_at,d.error_reason,d.created_at,
        a.user_id,a.order_code,a.order_type,a.pay_type,a.pay_time,a.created_at as order_created_at,
        b.name,
        c.trading_at, c.nft_id
        from goblin_nft_order_refund as d
        left join goblin_nft_order as a on a.order_id = d.order_id
        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 d.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 d.created_at desc
        order by d.mid desc
    </select>
</mapper>
