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
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
<?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.TCancelOrderMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TCancelOrder">
        <id column="id" property="id" />
        <result column="orderId" property="orderId" />
        <result column="userType" property="userType" />
        <result column="userId" property="userId" />
        <result column="cause" property="cause" />
        <result column="status" property="status" />
        <result column="createTime" property="createTime" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, orderId, userType, userId, cause, status, createTime
    </sql>
 
    <sql id="Base_Column_Order">
        co.id, co.orderId, co.userType, co.userId, co.cause, co.status, co.createTime,o.code, o.`source`, o.startAddress, o.endAddress,o.createTime AS placeTime,
            a.nickname AS userName,a.phone AS userPhone,a.cancelCount,a.status AS userStatus,d.name AS driverName,d.phone AS driverPhone
    </sql>
 
 
    <select id="orderExceptionList" resultType="com.stylefeng.guns.modular.system.controller.resp.TOrderResp">
        select
        o.id,
        o.createTime,
        o.code,
        o.source,
        o.startTime,
        o.userName,
        o.userPhone,
        o.startAddress,
        o.endAddress,
        d.name as driverName,
        d.phone as driverPhone,
        o.estimatedPrice,
        a.cancelCount,
        o.state,
        a.status AS userStatus
        from t_order o
        left join t_app_user a on o.userId = a.id
        left join t_driver d on o.driverId = d.id
        <where>
            a.cancelCount >= 3
            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                AND o.createTime between #{startTime} and #{endTime}
            </if>
            <if test="code != null and code != ''">
                AND o.code LIKE concat('%',#{code},'%')
            </if>
            <if test="source != null">
                AND o.source = #{source}
            </if>
            <if test="userName != null and userName != ''">
                AND a.nickname LIKE concat('%',#{userName},'%')
            </if>
            <if test="userPhone != null and userPhone != ''">
                AND a.phone LIKE concat('%',#{userPhone},'%')
            </if>
            <if test="state != null">
                AND o.state = #{state}
            </if>
            <if test="driverName != null and driverName != ''">
                AND d.name LIKE concat('%',#{driverName},'%')
            </if>
            <if test="roleType != null and roleType == 2">
                AND o.branchOfficeId = #{objectId}
            </if>
            <if test="roleType != null and roleType == 3">
                AND o.agentId = #{objectId}
            </if>
        </where>
        ORDER BY o.createTime
    </select>
 
 
 
    <select id="getCancelOrderList" resultType="com.stylefeng.guns.modular.system.controller.resp.TOrderResp">
        select <include refid="Base_Column_Order"></include>
        from t_cancel_order co
        left join t_order o on co.orderId = o.id
        left join t_app_user a on o.userId = a.id
        left join t_driver d on o.driverId = d.id
        <where>
            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                AND co.createTime between #{startTime} and #{endTime}
            </if>
            <if test="code != null and code != ''">
                AND o.code LIKE concat('%',#{code},'%')
            </if>
            <if test="source != null">
                AND o.source = #{source}
            </if>
            <if test="userName != null and userName != ''">
                AND a.nickname LIKE concat('%',#{userName},'%')
            </if>
            <if test="userPhone != null and userPhone != ''">
                AND a.phone LIKE concat('%',#{userPhone},'%')
            </if>
            <if test="state != null">
                AND o.state = #{state}
            </if>
            <if test="driverName != null and driverName != ''">
                AND d.name LIKE concat('%',#{driverName},'%')
            </if>
            <if test="roleType != null and roleType == 2">
                AND o.branchOfficeId = #{objectId}
            </if>
            <if test="roleType != null and roleType == 3">
                AND o.agentId = #{objectId}
            </if>
        </where>
        ORDER BY co.createTime
    </select>
    <select id="userCancelOrderList" resultType="com.stylefeng.guns.modular.system.controller.resp.TOrderResp">
        select co.createTime,o.code,o.startAddress,o.endAddress
        from t_cancel_order co
        left join t_order o  on co.orderId = o.id
        <where>
            <if test="userId != null">
                AND co.userId = #{userId}
            </if>
            <if test="orderId != null">
                AND co.orderId = #{orderId}
            </if>
            AND co.userType = 1
        </where>
        ORDER BY co.createTime DESC
    </select>
 
</mapper>