<?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.trading_txhash as 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.trading_txhash = #{nftId}
            </if>
        </where>
        -- group by a.order_id
        -- order by a.created_at desc
        order by a.mid desc
    </select>
    <select id="selectOrderList" resultType="com.liquidnet.service.goblin.dto.PlatformGoblinNftOrderNotPayDto">
        select sku_id,
               list_id,
               sum(if(status = 1, num, 0)) as notPayNum
--             # select status, created_at,pay_time,updated_at,cancel_time,sku_id,list_id
        from goblin_nft_order
        where 1 > 0
--             # and sku_title = '正在现场盲盒  正在现场盲盒'
          and pay_type != 'EXCODE'
--             #     and status = 3
          and created_at > DATE_SUB(NOW(), INTERVAL 10 MINUTE)
--             #   and created_at > DATE_SUB('2022-06-07 12:10:24', INTERVAL 10 MINUTE)
        group by sku_id, list_id;
    </select>
</mapper>
