Pu Zhibing
2024-12-13 73b750200f25df08aa64124da49e7461f9de6653
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?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.stylefeng.guns.modular.system.dao.CarMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Car">
        <id column="id" property="id"/>
        <result column="isPlatCar" property="isPlatCar"/>
        <result column="companyId" property="companyId"/>
        <result column="franchiseeId" property="franchiseeId"/>
        <result column="carColor" property="carColor"/>
        <result column="carModelId" property="carModelId"/>
        <result column="carBrandId" property="carBrandId"/>
        <result column="carLicensePlate" property="carLicensePlate"/>
        <result column="carPhoto" property="carPhoto"/>
        <result column="drivingLicenseNumber" property="drivingLicenseNumber"/>
        <result column="drivingLicensePhoto" property="drivingLicensePhoto"/>
        <result column="annualInspectionTime" property="annualInspectionTime"/>
        <result column="insurancePhoto" property="insurancePhoto" />
        <result column="commercialInsuranceTime" property="commercialInsuranceTime"/>
        <result column="insertTime" property="insertTime"/>
        <result column="state" property="state"/>
        <result column="addType" property="addType"/>
        <result column="addObjectId" property="addObjectId"/>
    </resultMap>
 
 
 
 
    <select id="queryCarList" resultType="map">
        select
        a.id as id,
        a.carLicensePlate as name,
        if((
        (select count(id) from t_order_private_car where isDelete = 1 and state in (6,7,8,9,10,12) and carId = a.id) +
        (select count(id) from t_order_taxi where isDelete = 1 and state in (6,7,8,9,10,12) and carId = a.id) +
        (select count(id) from t_order_cross_city where isDelete = 1 and state in (6,8,9,10,12) and carId = a.id)
        ) = 0, 1, 2) as state
        from t_car a where a.state = 1 and if(a.franchiseeId is null or a.franchiseeId = 0, a.companyId = #{companyId}, a.franchiseeId = #{companyId})
    </select>
 
 
    <select id="queryCarInfo" resultType="map">
        select
        a.id as id,
        c.`name` as brand,
        d.`name` as carModel,
        a.carColor as color,
        if((
        (select count(id) from t_order_private_car where isDelete = 1 and state in (6,7,8,9,10,12) and carId = a.id) +
        (select count(id) from t_order_taxi where isDelete = 1 and state in (6,7,8,9,10,12) and carId = a.id) +
        (select count(id) from t_order_cross_city where isDelete = 1 and state in (6,8,9,10,12) and carId = a.id)
        ) = 0, 1, 2) as state
        from t_car a
        left join t_car_brand c on (a.carBrandId = c.id)
        left join t_car_model d on (a.carModelId = d.id)
        where a.id = #{id}
    </select>
</mapper>