puzhibing
2023-05-25 380c0e958fbc3f2b42a3e38ae5dc9af3254b8f5c
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
<?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.agentdriving.user.modular.system.dao.OrderMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.agentdriving.user.modular.system.model.Order">
        <id column="id" property="id" />
        <result column="code" property="code" />
        <result column="userId" property="userId" />
        <result column="userPhone" property="userPhone" />
        <result column="userName" property="userName" />
        <result column="driverId" property="driverId" />
        <result column="source" property="source" />
        <result column="agentId" property="agentId" />
        <result column="branchOfficeId" property="branchOfficeId" />
        <result column="orderTakingTime" property="orderTakingTime"/>
        <result column="goToAppointmentPointTime" property="goToAppointmentPointTime"/>
        <result column="arrivalTimeAtTheAppointmentPoint" property="arrivalTimeAtTheAppointmentPoint"/>
        <result column="startTime" property="startTime" />
        <result column="startAddress" property="startAddress" />
        <result column="startLat" property="startLat" />
        <result column="startLng" property="startLng" />
        <result column="endAddress" property="endAddress" />
        <result column="endLat" property="endLat" />
        <result column="endLng" property="endLng" />
        <result column="boardingTime" property="boardingTime" />
        <result column="getoffTime" property="getoffTime" />
        <result column="startDistance" property="startDistance" />
        <result column="startPrice" property="startPrice" />
        <result column="overDriveDistance" property="overDriveDistance" />
        <result column="overDrivePrice" property="overDrivePrice" />
        <result column="longDistance" property="longDistance" />
        <result column="longDistancePrice" property="longDistancePrice" />
        <result column="overLongDistance" property="overLongDistance" />
        <result column="overLongDistancePrice" property="overLongDistancePrice" />
        <result column="waitTime" property="waitTime" />
        <result column="waitTimePrice" property="waitTimePrice" />
        <result column="outWaitTime" property="outWaitTime" />
        <result column="outWaitTimePrice" property="outWaitTimePrice" />
        <result column="badWeatherDistance" property="badWeatherDistance" />
        <result column="badWeatherPrice" property="badWeatherPrice" />
        <result column="overBadWeatherDistance" property="overBadWeatherDistance" />
        <result column="overBadWeatherPrice" property="overBadWeatherPrice" />
        <result column="weather" property="weather"/>
        <result column="estimatedPrice" property="estimatedPrice" />
        <result column="estimatedMileage" property="estimatedMileage"/>
        <result column="orderMoney" property="orderMoney" />
        <result column="actualMileage" property="actualMileage"/>
        <result column="payMoney" property="payMoney" />
        <result column="discountedPrice" property="discountedPrice" />
        <result column="couponId" property="couponId" />
        <result column="discountAmount" property="discountAmount"/>
        <result column="discount" property="discount"/>
        <result column="payType" property="payType" />
        <result column="payTime" property="payTime" />
        <result column="orderNo" property="orderNo"/>
        <result column="hallOrder" property="hallOrder"/>
        <result column="startWaitTime" property="startWaitTime"/>
        <result column="state" property="state" />
        <result column="oldState" property="oldState"/>
        <result column="isInvoice" property="isInvoice"/>
        <result column="status" property="status" />
        <result column="createTime" property="createTime" />
    </resultMap>
 
 
 
    <select id="queryOrderInfo" resultType="com.agentdriving.user.modular.system.warpper.OrderInfoWarpper">
        select
        a.id as orderId,
        a.`code`,
        a.startAddress,
        a.startLat,
        a.startLng,
        a.endAddress,
        a.endLat,
        a.endLng,
        b.id as driverId,
        b.avatar as driverAvatar,
        b.`name` as driverName,
        b.phone as driverPhone,
        b.`code` as driverCode,
        ifnull(DATE_FORMAT(now(), '%Y') - DATE_FORMAT(b.firstCertificateTime, '%Y'), 0) as driverAge,
        (select count(1) from t_order where driverId = b.id and `status` = 1 and state in (107, 108, 109)) + 200 as driverNumber,
        b.score as driverScore,
        a.state,
        UNIX_TIMESTAMP(a.createTime) * 1000 as createTime,
        c.score as evaluationScore,
        c.evaluate as evaluationContent
        from t_order a
        left join t_driver b on (a.driverId = b.id)
        left join t_evaluate c on (a.id = c.orderId)
        where a.id = #{orderId}
    </select>
 
 
    <select id="queryMyOrder" resultType="com.agentdriving.user.modular.system.warpper.OrderListWarpper">
        select
        id,
        '超省新代驾订单' as title,
        startAddress,
        endAddress,
        state,
        UNIX_TIMESTAMP(createTime) * 1000 as createTime
        from t_order
        where `status` = 1 and userId = #{uid} order by createTime desc limit #{pageNum}, #{pageSize}
    </select>
 
 
 
    <select id="queryNotInvoiceOrder" resultType="com.agentdriving.user.modular.system.warpper.OrderListWarpper">
        select
        id,
        '超省新代驾' as title,
        startAddress,
        endAddress,
        state,
        UNIX_TIMESTAMP(createTime) * 1000 as createTime,
        payMoney as amount
        from t_order
        where `status` = 1 and isInvoice != 1 and state in (108, 109) and userId = #{uid}
        <if test="null != notInvoiceOrder.startTime and '' != notInvoiceOrder.startTime and null != notInvoiceOrder.endTime and '' != notInvoiceOrder.endTime">
            and DATE_FORMAT(createTime, '%Y-%m-%d') between #{notInvoiceOrder.startTime} and #{notInvoiceOrder.endTime}
        </if>
        <if test="null != notInvoiceOrder.startAmount and null != notInvoiceOrder.endAmount">
            and payMoney between #{notInvoiceOrder.startAmount} and #{notInvoiceOrder.endAmount}
        </if>
        order by createTime desc limit #{notInvoiceOrder.pageNum}, #{notInvoiceOrder.pageSize}
    </select>
</mapper>