puzhibing
2023-06-30 f58cca364b731eac2d60a440ffaa804be3cd43fd
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
<?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.TComplaintMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TComplaint">
        <id column="id" property="id" />
        <result column="userId" property="userId" />
        <result column="driverId" property="driverId" />
        <result column="reason" property="reason" />
        <result column="notes" property="notes" />
        <result column="state" property="state" />
        <result column="status" property="status" />
        <result column="createTime" property="createTime" />
        <result column="auditId" property="auditId" />
        <result column="auditPersonName" property="auditPersonName" />
        <result column="auditTime" property="auditTime" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userId, driverId, reason, notes, state, status, createTime,auditId,auditPersonName,auditTime
    </sql>
    <select id="getPageList" resultType="com.stylefeng.guns.modular.system.controller.resp.TComplaintResp">
        select c.id, c.userId, c.driverId, c.reason, c.notes, c.state, c.status, c.createTime,c.auditId,c.auditPersonName,c.auditTime,
               au.nickname AS userName,au.phone AS userPhone,d.phone AS driverPhone
        from t_complaint c
        left join t_app_user au on c.userId = au.id
        left join t_driver d on c.driverId = d.id
        <where>
            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                AND c.createTime between #{startTime} and #{endTime}
            </if>
            <if test="userName != null and userName != ''">
                AND au.nickname LIKE concat('%',#{userName},'%')
            </if>
            <if test="userPhone != null and userPhone != ''">
                AND au.phone LIKE concat('%',#{userPhone},'%')
            </if>
            <if test="driverPhone != null and driverPhone != ''">
                AND d.phone LIKE concat('%',#{driverPhone},'%')
            </if>
            <if test="state != null">
                AND c.state = #{state}
            </if>
            <if test="roleType != null and roleType == 2">
                AND d.branchOfficeId = #{objectId}
            </if>
            <if test="roleType != null and roleType == 3">
                AND d.agentId = #{objectId}
            </if>
        </where>
        ORDER BY c.state,c.createTime DESC
    </select>
 
</mapper>