OrderAppointmentSMapper.xml
8.46 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?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.zteits.order.mapper.smapper.OrderAppointmentSMapper">
<resultMap id="BaseResultMap" type="com.zteits.order.domain.OrderAppointment">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="appointment_config_id" jdbcType="BIGINT" property="appointmentConfigId"/>
<result column="appointment_type" jdbcType="INTEGER" property="appointmentType"/>
<result column="order_id" jdbcType="VARCHAR" property="orderId"/>
<result column="order_type" jdbcType="INTEGER" property="orderType"/>
<result column="order_state" jdbcType="INTEGER" property="orderState"/>
<result column="terminal_source" jdbcType="INTEGER" property="terminalSource"/>
<result column="order_dicount_fee" jdbcType="BIGINT" property="orderDicountFee"/>
<result column="order_act_fee" jdbcType="BIGINT" property="orderActFee"/>
<result column="order_total_fee" jdbcType="BIGINT" property="orderTotalFee"/>
<result column="cust_type" jdbcType="INTEGER" property="custType"/>
<result column="cust_id" jdbcType="VARCHAR" property="custId"/>
<result column="user_phone" jdbcType="VARCHAR" property="userPhone"/>
<result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
<result column="car_number_color" jdbcType="VARCHAR" property="carNumberColor"/>
<result column="pl_no" jdbcType="VARCHAR" property="plNo"/>
<result column="pl_name" jdbcType="VARCHAR" property="plName"/>
<result column="berth_no" jdbcType="VARCHAR" property="berthNo"/>
<result column="appointment_opt_time" jdbcType="TIMESTAMP" property="appointmentOptTime"/>
<result column="appointment_begin_time" jdbcType="TIMESTAMP" property="appointmentBeginTime"/>
<result column="appointment_end_time" jdbcType="TIMESTAMP" property="appointmentEndTime"/>
<result column="push_state" jdbcType="INTEGER" property="pushState"/>
<result column="org_id" jdbcType="BIGINT" property="orgId"/>
<result column="rlt_order_id" jdbcType="VARCHAR" property="rltOrderId"/>
<result column="appointment_state" jdbcType="INTEGER" property="appointmentState"/>
<result column="data_state" jdbcType="INTEGER" property="dataState"/>
<result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId"/>
<result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="modfiy_emp_id" jdbcType="VARCHAR" property="modfiyEmpId"/>
<result column="modfiy_emp_name" jdbcType="VARCHAR" property="modfiyEmpName"/>
<result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
</resultMap>
<sql id="Base_Column_List">
id, appointment_config_id, appointment_type, order_id, order_type, order_state, terminal_source,
order_dicount_fee, order_act_fee, order_total_fee, cust_type, cust_id, user_phone,
car_number, car_number_color, pl_no, pl_name, berth_no, appointment_opt_time, appointment_begin_time,
appointment_end_time, push_state, org_id, rlt_order_id, appointment_state, data_state,
create_emp_id, create_emp_name, create_date, modfiy_emp_id, modfiy_emp_name, modfiy_date,
remark
</sql>
<!-- 根据车场编号查询已预约订单数 -->
<select id="countOccupyBerthByPlNos" resultType="com.zteits.clouds.api.dto.order.appointment.dto.CountAppointDTO">
select pl_no plNo,
count(1) occupyBerthNum
from order_appointment
where data_state = 1
and appointment_state in (10, 20)
<if test="plNoList != null and plNoList.size >0">
and pl_no in
<foreach collection="plNoList" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
<if test="orgId !=null">
AND org_id = #{orgId,jdbcType=BIGINT},
</if>
group by pl_no;
</select>
<!-- 根据日期查询车场剩余预约泊位数 -->
<select id="queryFreeBerthListByDate" resultType="com.zteits.clouds.api.dto.order.appointment.dto.FreeBerthDTO">
select #{berthTotal}-count(*) freeBerthNum,
date(appointment_begin_time) day
from order_appointment
where data_state = 1
and pl_no = #{plNo}
and appointment_state = 10
<if test="orgId !=null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
<if test="dateList != null and dateList.size >0">
and date(appointment_begin_time) in
<foreach collection="dateList" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
group by date(appointment_begin_time);
</select>
<select id="queryNoPustAppointmentCarList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from order_appointment
where data_state = 1 and push_state = 0
and #{nowDate} > appointment_begin_time
and appointment_end_time > #{nowDate}
and appointment_state = 10
</select>
<select id="queryOrderAppointment" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from order_appointment
where data_state = 1
and appointment_state in
<foreach collection="appointmentState" open="(" close=")" item="state" separator=",">
#{state}
</foreach>
and cust_id = #{custId}
and org_id = #{orgId}
order by id desc
</select>
<select id="checkRepeatAppointment" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from order_appointment
where data_state = 1
and appointment_state in (10,20)
and pl_no = #{plNo}
<if test="orgId !=null">
and org_id = #{orgId}
</if>
and car_number = #{carNumber}
and (<![CDATA[(appointment_begin_time <= #{appointmentBeginTime} and appointment_end_time >= #{appointmentBeginTime})
or (appointment_begin_time <= #{appointmentEndTime} and appointment_end_time >= #{appointmentEndTime})]]>)
order by id desc
</select>
<!-- -->
<select id="queryOrderAppointmentForBcpPage" resultMap="BaseResultMap" parameterType="com.zteits.clouds.api.dto.order.appointment.param.OrderAppointmentPageRequest">
select
<include refid="Base_Column_List" />
from order_appointment
where data_state = 1
<if test="orgId !=null">
and org_id = #{orgId}
</if>
<if test="carNumber != null and carNumber != ''">
and car_number = #{carNumber,jdbcType=VARCHAR}
</if>
<if test="plNoList != null and plNoList.size >0">
and pl_no in
<foreach collection="plNoList" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
<if test="appointmentStates != null and appointmentStates.size >0">
and appointment_state in
<foreach collection="appointmentStates" open="(" close=")" item="appointmentState" separator=",">
#{appointmentState}
</foreach>
</if>
<if test="berthNo != null and berthNo != ''">
and berth_no = #{berthNo,jdbcType=VARCHAR}
</if>
<if test="optBeginTime != null">
and appointment_opt_time > #{optBeginTime,jdbcType=TIMESTAMP}
</if>
<if test="optEndTime != null">
and #{optEndTime,jdbcType=TIMESTAMP} > appointment_opt_time
</if>
order by appointment_opt_time desc
</select>
<select id="queryUnDoneAppointment" parameterType="com.zteits.clouds.api.dto.order.param.UnDoneOrderAppointmentRequest"
resultType="com.zteits.clouds.api.dto.order.dto.UnDoneOrderAppointmentDTO">
SELECT
t.pl_no AS plNo,
GROUP_CONCAT(t.order_id separator ',') AS orderIds,
count(t.order_id) AS num,
GROUP_CONCAT(t.car_number separator ',') AS carNumbers
FROM
order_appointment t
where t.appointment_state = #{appointmentState} and t.push_state = #{pushState}
GROUP BY t.pl_no
</select>
</mapper>