<?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.sqx.modules.address.dao.InsideAddressDao">

    <select id="selectPages" resultType="com.sqx.modules.address.vo.InsideAddressVO">
        SELECT
            a.id,
            a.create_time AS createTime,
            a.update_time AS updateTime,
            a.station_id AS stationId,
            rs.station_name AS stationName,
            a.delivery_fee AS deliveryFee,
            a.province,
            a.city,
            a.district,
            a.address_detail AS addressDetail,
            a.lng,
            a.lat,
            a.status,
            a.sort
        FROM
            inside_address a
        LEFT JOIN
            rider_station rs ON a.station_id = rs.id
        WHERE
            a.del_flag = '0'
        <if test="query.addressDetail != null and query.addressDetail != ''">
            AND a.address_detail LIKE CONCAT('%', #{query.addressDetail}, '%')
        </if>
        <if test="query.status != null and query.status != ''">
            AND a.status = #{query.status}
        </if>
        <if test="query.stationId != null">
            AND a.station_id = #{query.stationId}
        </if>
        <if test="query.startTime != null">
            AND a.create_time &gt;= #{query.startTime}
        </if>
        <if test="query.endTime != null">
            AND a.create_time &lt;= #{query.endTime}
        </if>
        ORDER BY
            a.sort
    </select>

    <select id="exportShippingAddress" resultType="com.sqx.modules.address.vo.InsideAddressVO">
        SELECT
        a.id,
        a.create_time AS createTime,
        a.update_time AS updateTime,
        a.station_id AS stationId,
        rs.station_name AS stationName,
        a.delivery_fee AS deliveryFee,
        a.province,
        a.city,
        a.district,
        a.address_detail AS addressDetail,
        a.lng,
        a.lat,
        a.status,
        a.sort
        FROM
        inside_address a
        LEFT JOIN
        rider_station rs ON a.station_id = rs.id
        WHERE
        a.del_flag = '0'
        <if test="query.addressDetail != null and query.addressDetail != ''">
            AND a.address_detail LIKE CONCAT('%', #{query.addressDetail}, '%')
        </if>
        <if test="query.status != null and query.status != ''">
            AND a.status = #{query.status}
        </if>
        <if test="query.stationId != null">
            AND a.station_id = #{query.stationId}
        </if>
        <if test="query.startTime != null">
            AND a.create_time &gt;= #{query.startTime}
        </if>
        <if test="query.endTime != null">
            AND a.create_time &lt;= #{query.endTime}
        </if>
        ORDER BY
        a.sort
    </select>
</mapper>