<?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.fzm.mall.server.admin.goods_center.mapper.ExternalTokenTradeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.goods_center.model.ExternalTokenTrade">
        <id column="id" property="id" />
        <result column="commodity_pass_id" property="commodityPassId" />
        <result column="trade_id" property="tradeId" />
        <result column="opposite_address" property="oppositeAddress" />
        <result column="trade_number" property="tradeNumber" />
        <result column="trade_type" property="tradeType" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <select id="page" resultType="com.fzm.mall.server.admin.goods_center.entity.dto.ExternalTokenTradeDTO">
        select *
        from external_token_trade
        <where>
            commodity_pass_id = #{commodityPassId}
            <if test="oppositeAddress != null and oppositeAddress != ''">
                and opposite_address like CONCAT('%', #{oppositeAddress},'%')
            </if>
            <if test="tradeType != null">
                and trade_type = #{tradeType}
            </if>
            <if test="startTime != null">
                and create_time &gt;= #{startTime}
            </if>
            <if test="endTime != null">
                and create_time &lt;= #{endTime}
            </if>

        </where>
        order by create_time desc
    </select>
</mapper>
