<?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="cn.iocoder.mall.order.biz.dao.order.OrderMapper">

    <sql id="selectWhere">
        <if test="status != null">
            AND `status` = #{status}
        </if>
        <if test="userId != null">
            AND `user_id` = #{userId}
        </if>
        <if test="id != null">
            AND `id` = #{id}
        </if>
        <if test="orderNo != null">
            AND `order_no` = #{orderNo}
        </if>
        <if test="hasReturnExchange != null">
            AND `has_return_exchange` = #{hasReturnExchange}
        </if>
        <if test="startCreateTime != null and endCreateTime != null">
            AND `create_time` &gt;= #{startCreateTime}
            AND `create_time` &lt;= #{endCreateTime}
        </if>
    </sql>

    <select id="selectPageCount" resultType="java.lang.Integer">
        SELECT
        COUNT(*)
        FROM `orders`
        <where>
            <include refid="selectWhere" />
        </where>
    </select>

    <select id="selectPage" resultType="cn.iocoder.mall.order.biz.dataobject.OrderDO">
        SELECT
        <include refid="FIELDS" />
        FROM `orders`
        <where>
            <include refid="selectWhere" />
        </where>
        LIMIT ${pageNo * pageSize}, ${pageSize}
    </select>


</mapper>
