<?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.xxfc.platform.vehicle.mapper.VehicleUserReserveMapper" >


    <select id="getList"   parameterType="com.xxfc.platform.vehicle.pojo.dto.VehicleUserReserveDTO" resultType="com.xxfc.platform.vehicle.pojo.vo.VehicleUserReserveVo">
        SELECT
        r.id,
        r.user_id AS userId,
        r.mode_id AS modeId,
        r.`name`,
        r.phone,
        r.start_time AS startTime,
        r.end_time AS endTime,
        r.addr_province AS addrProvince,
        r.province_name AS provinceName,
        r.addr_city AS addrCity,
        r.city_name AS cityName,
        r.company_id AS companyId,
        CONCAT(bct.province_name,bct.city_name,bct.town_name,bct.addr_detail) AS `companyAddress`,
        r.arrival_companyId AS arrivalCompanyId,
        CONCAT(bcr.province_name,bcr.city_name,bcr.town_name,bcr.addr_detail) AS `arrivalcompanyAddress`,
        bct.NAME AS `companyName`,
        bcr.NAME AS `arrivalCompanyName`,
        r.crt_time AS crtTime,
        r.upd_time AS updTime,
        r.`status`,
        m.`name` AS modelName,
        m.`cover_pic` AS `vehiclePic`
        FROM
        vehicle_user_reserve r
        LEFT JOIN vehicle_model m ON r.mode_id = m.id
        LEFT JOIN `branch_company` AS `bct` ON bct.id = r.company_Id
        LEFT JOIN `branch_company` AS `bcr` ON bcr.id = r.arrival_companyId
        <where>
            r.is_del=0 and  r.user_id=#{userId}
        </where>
        order by r.upd_time desc
    </select>

</mapper>