<?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.cool.store.mapper.visit.StoreVisitReservationMapper">

    <select id="adminPage" resultType="com.cool.store.vo.visit.StoreVisitReservationVO">
        SELECT
            id,
            intent_city_id AS intentCityId,
            contact_name AS contactName,
            mobile,
            visit_time AS visitTime,
            status,
            remark,
            cancel_reason AS cancelReason,
            current_follow_user AS currentFollowUser,
            service_user_id AS serviceUserId,
            create_time AS createTime
        FROM zxjp_store_visit_reservation
        <where>
            deleted = 0
            <if test="request.status != null">
                AND status = #{request.status}
            </if>
            <if test="request.contactName != null and request.contactName != ''">
                AND contact_name LIKE CONCAT('%', #{request.contactName}, '%')
            </if>
            <if test="request.mobile != null and request.mobile != ''">
                AND mobile LIKE CONCAT('%', #{request.mobile}, '%')
            </if>
            <if test="request.serviceUserId != null and request.serviceUserId != ''">
                AND service_user_id = #{request.serviceUserId}
            </if>
            <if test="request.visitStartTime != null">
                AND visit_time <![CDATA[ >= ]]> #{request.visitStartTime}
            </if>
            <if test="request.visitEndTime != null">
                AND visit_time <![CDATA[ <= ]]> #{request.visitEndTime}
            </if>
        </where>
        ORDER BY create_time DESC
    </select>
</mapper>
