<?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.yiqi.order.mapper.OrderDeliveryMapper">

    <select id="selectOrderDeliveryList" resultType="com.yiqi.order.domain.vo.OrderDeliveryVO">
        SELECT s.`name` as 'storeName',u.nick_name AS 'userName', d.*
        FROM order_delivery d
        JOIN sys_store s ON s.id = d.store_id
        JOIN app_user u ON u.id = d.app_user_id
        WHERE 1 = 1
        <if test="requestDTO.storeId != null">
            AND d.store_id = #{requestDTO.storeId}
        </if>
        <if test="requestDTO.orderSn != null">
            AND d.order_sn = #{requestDTO.orderSn}
        </if>
        <if test="requestDTO.mobile != null">
            AND d.user_phone = #{requestDTO.mobile}
        </if>
        <if test="requestDTO.startDate != null and requestDTO.endDate != null">
            AND d.create_time BETWEEN #{requestDTO.startDate} AND #{requestDTO.endDate}
        </if>
        <if test="requestDTO.clothOrderType != null">
            AND d.cloth_order_type = #{requestDTO.clothOrderType}
        </if>
        <if test="requestDTO.deliveryStatus != null">
            AND d.delivery_status = #{requestDTO.deliveryStatus}
        </if>
        ORDER BY d.id DESC
    </select>
</mapper>