xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?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.SellingCarMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.SellingCar">
        <id column="id" property="id"/>
        <result column="userType" property="userType"/>
        <result column="userId" property="userId"/>
        <result column="title" property="title"/>
        <result column="brandId" property="brandId"/>
        <result column="brandName" property="brandName"/>
        <result column="category" property="category"/>
        <result column="carIdentificationCode" property="carIdentificationCode"/>
        <result column="carLicensePlate" property="carLicensePlate"/>
        <result column="carColor" property="carColor"/>
        <result column="licensingTime" property="licensingTime"/>
        <result column="mileage" property="mileage"/>
        <result column="describe" property="describe"/>
        <result column="describeImgUrl" property="describeImgUrl"/>
        <result column="contactsPhone" property="contactsPhone"/>
        <result column="contactsName" property="contactsName"/>
        <result column="provinceCode" property="provinceCode"/>
        <result column="cityCode" property="cityCode"/>
        <result column="provinceName" property="provinceName"/>
        <result column="cityName" property="cityName"/>
        <result column="createTime" property="createTime"/>
        <result column="status" property="status"/>
        <result column="addres" property="addres"/>
        <result column="authRemark" property="authRemark"/>
        <result column="imgUrl" property="imgUrl"/>
        <result column="videoUrl" property="videoUrl"/>
        <result column="locationOfLicensePlate" property="locationOfLicensePlate"/>
        <result column="transferTimes" property="transferTimes"/>
        <result column="displacement" property="displacement"/>
        <result column="transmissionCase" property="transmissionCase"/>
        <result column="level" property="level"/>
        <result column="transferPrice" property="transferPrice"/>
        <result column="includingTransferFee" property="includingTransferFee"/>
        <result column="newCarPrice" property="newCarPrice"/>
        <result column="dueTimeOfCompulsoryInsurance" property="dueTimeOfCompulsoryInsurance"/>
        <result column="expirationTimeOfAnnualInspection" property="expirationTimeOfAnnualInspection"/>
        <result column="maturityTimeOfCommercialInsurance" property="maturityTimeOfCommercialInsurance"/>
        <result column="mortgage" property="mortgage"/>
        <result column="installationConfiguration" property="installationConfiguration"/>
        <result column="remainingOperationTime" property="remainingOperationTime"/>
        <result column="operationUpdateTime" property="operationUpdateTime"/>
        <result column="firstPageShow" property="firstPageShow"/>
    </resultMap>
 
 
    <select id="list" resultType="map">
        select
        a.id,
        DATE_FORMAT(a.createTime, '%Y/%m/%d %H:%i') as createTime,
        a.userType,
        if(a.userType = 1, b.`name`, if(a.userType = 2, c.`name`, d.`name`)) as pushUser,
        a.title,
        a.carLicensePlate,
        if(a.userType = 1, b.`phone`, if(a.userType = 2, c.`phone`, d.`principalPhone`)) as pushUserPhone,
        a.brandName,
        a.carColor,
        a.contactsName,
        a.contactsPhone,
        CONCAT(a.provinceName, a.cityName, a.addres) as address,
        a.firstPageShow,
        a.`status`
        from tb_selling_car a
        left join t_user b on (a.userType = 1 and a.userId = b.id)
        left join t_driver c on (a.userType = 2 and a.userId = c.id)
        left join t_company d on (a.userType = 3 and a.userId = d.id)
        where a.`status` != 6
        <if test="null != companyId">
            and a.userType = 3 and a.userId = #{companyId}
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.createTime, '%Y-%m-%d') BETWEEN #{start} and #{end}
        </if>
        <if test="null != carLicensePlate and '' != carLicensePlate">
            and a.carLicensePlate like CONCAT('%', #{carLicensePlate}, '%')
        </if>
        <if test="null != brandId">
            and a.brandId = #{brandId}
        </if>
        <if test="null != insertUser and '' != insertUser">
            and (b.`name` like CONCAT('%', #{insertUser}, '%') or c.`name` like CONCAT('%', #{insertUser}, '%') or d.`name` like CONCAT('%', #{insertUser}, '%'))
        </if>
        <if test="null != status">
            and a.status in
            <foreach collection="status" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != userType and 3 == userType">
            and d.type = 2
        </if>
        <if test="null != userType and 3 != userType">
            and a.userType = #{userType}
        </if>
        order by a.createTime desc
        <if test="null != offset and null != limit">
            limit #{offset}, #{limit}
        </if>
    </select>
 
 
 
    <select id="listCount" resultType="int">
        select
        count(1)
        from tb_selling_car a
        left join t_user b on (a.userType = 1 and a.userId = b.id)
        left join t_driver c on (a.userType = 2 and a.userId = c.id)
        left join t_company d on (a.userType = 3 and a.userId = d.id)
        where a.`status` != 6
        <if test="null != companyId">
            and a.userType = 3 and a.userId = #{companyId}
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.createTime, '%Y-%m-%d') BETWEEN #{start} and #{end}
        </if>
        <if test="null != carLicensePlate and '' != carLicensePlate">
            and a.carLicensePlate like CONCAT('%', #{carLicensePlate}, '%')
        </if>
        <if test="null != brandId">
            and a.brandId = #{brandId}
        </if>
        <if test="null != insertUser and '' != insertUser">
            and (b.`name` like CONCAT('%', #{insertUser}, '%') or c.`name` like CONCAT('%', #{insertUser}, '%') or d.`name` like CONCAT('%', #{insertUser}, '%'))
        </if>
        <if test="null != status">
            and a.status in
            <foreach collection="status" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != userType and 3 == userType">
            and d.type = 2
        </if>
        <if test="null != userType and 3 != userType">
            and a.userType = #{userType}
        </if>
    </select>
</mapper>