puzhibing
2023-08-16 d5b3e5a413bcfccba294793ee093722f31b2448a
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
<?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="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 desc
    </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>