<?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.VehicleCommonPriceInfoMapper">

    <select id="selectList" resultType="com.xxfc.platform.vehicle.pojo.vo.VehicleCommonPriceVo">
        SELECT
        vci.*, v.`code`,
        v.number_plate,
        FLOOR(
        YEAR (NOW()) - YEAR (v.vehicle_register_date)
        ) as vehicleAge,
        v.vehicle_status,
        v.mileage_last_update AS mileage
        FROM
        vehicle_common_price_info vci
        LEFT JOIN vehicle v ON v.id = vci.vehicle_id
        <where>
            <if test="companyId != null and companyId > 0">
                and vci.company_id = #{companyId}
            </if>
            <if test="modelId != null and modelId > 0">
                and vci.model_id = #{modelId}
            </if>
            and v.is_del = 0 and v.status &lt; 3
        </where>
        order by vci.upd_time DESC
    </select>

</mapper>