HotelOrderMapper.xml
17.0 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<?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.sibu.orderHelper.integral.web.dao.IMWebRoomOrderDao">
<!-- roomOrder List -->
<resultMap type="com.sibu.orderHelper.integral.reponse.HotelOrderResponse" id="roomOrderResponse">
<id column="order_id" property="orderId"/>
<result column="order_code" property="orderCode"/>
<result column="order_status" property="orderStatus"/>
<result column="order_money" property="orderMoney"/>
<result column="pay_integral" property="payIntegral"/>
<result column="checkin_days" property="checkinDays"/>
<result column="room_name" property="roomName"/>
<result column="hotel_name" property="hotelName"/>
<result column="num" property="roomNumber"/>
<result column="order_type" property="orderType"/>
<result column="check_in_date" property="checkInDate"/>
<result column="check_out_date" property="checkOutDate"/>
<result column="member_name" property="memberName"/>
<result column="member_telphone" property="memberTelphone"/>
<result column="pay_name" property="payName"></result>
<result column="pay_date" property="payDate"></result>
<result column="create_date" property="createDate"></result>
<result column="transaction_id" property="transactionId"></result>
<result column="renter_info" property="renterInfo"></result>
<result column="renter_idcard" property="renterIdcard"></result>
<result column="renter_phone" property="renterPhone"></result>
<collection property="detailBeans" ofType="com.sibu.orderHelper.integral.reponse.RoomOrderDetailBean" >
<id column="sub_order_id" property="subOrderId"/>
<result property="roomNumber" column="room_number"/>
<result property="retailPrice" column="retail_price"/>
<result property="integral" column="integral"/>
<result property="checkinDate" column="checkin_date"/>
<result property="hotelStatus" column="hotel_status"/>
<result property="subOrderCode" column="sub_order_code"/>
<result property="status" column="status"/>
</collection>
</resultMap>
<!-- 退单返回类 -->
<resultMap type="com.sibu.orderHelper.hotel.response.HotelOrderRefundResponse" id="orderRefundResponse">
<id column="refund_id" property="refundId"/>
<result column="refund_code" property="refundCode"/>
<result column="refund_price" property="refundPrice"/>
<result column="refund_integral" property="refundIntegral"/>
<result column="refund_reason" property="refundReason"/>
<result column="create_date" property="createDate"/>
<result column="sub_order_code" property="subOrderCode"/>
<result column="status" property="status"/>
<result column="hotel_status" property="hotelStatus"/>
<result column="member_name" property="memberName"/>
<result column="member_phone" property="memberPhone"/>
<result column="room_name" property="roomName"/>
<result column="hotel_name" property="hotelName"/>
<result column="renter_Idcard" property="renterIdcard"/>
<result column="order_date" property="orderDate"/>
<result column="pay_date" property="payDate"/>
<result column="retail_price" property="retailPrice"/>
<result column="integral" property="integral"/>
<result column="order_type" property="orderType"/>
<result column="checkin_date" property="checkinDate"/>
<result column="sub_order_id" property="subOrderId"/>
</resultMap>
<!-- 返回订单明细 -->
<resultMap type="com.sibu.orderHelper.hotel.response.HotelOrderDetailResponse" id="orderDetailResponse">
<result column="order_code" property="orderCode"></result>
<result column="status" property="status"/>
<result column="hotel_status" property="hotelStatus"/>
<result column="member_telphone" property="memberTelphone"/>
<result column="check_in_date" property="checkInDate"/>
<result column="check_out_date" property="checkOutDate"/>
</resultMap>
<!-- 导出 订单列表-->
<resultMap type="com.sibu.orderHelper.integral.vo.HotelOrderExportBean" id="exportHotelOrder">
<result property="orderCode" column="order_code"/>
<result property="subOrderCode" column="sub_order_code"/>
<result property="memberName" column="member_name"/>
<result property="memberPhone" column="member_telphone"/>
<result property="createDate" column="create_date"/>
<result property="payDate" column="pay_date"/>
<result property="orderType" column="order_type"/>
<result property="payName" column="pay_name"/>
<result property="transactionId" column="transaction_id"/>
<result property="renterInfo" column="renter_info"/>
<result property="renterIdcard" column="renter_idcard"/>
<result property="hotelName" column="hotel_name"/>
<result property="roomName" column="room_name"/>
<result property="retailPrice" column="retail_price"/>
<result property="integral" column="integral"/>
<result property="checkinDate" column="checkin_date"/>
<result property="status" column="status"/>
<result property="hotelStatus" column="hotel_status"/>
<result property="renterPhone" column="renter_phone"/>
</resultMap>
<!-- 查询客栈订单列表 -->
<select id="queryRoomOrderList" parameterType="com.sibu.orderHelper.integral.request.HotelOrderQueryParam" resultMap="roomOrderResponse">
SELECT o.order_id,o.member_name,o.member_telphone,o.order_code,o.order_status,o.pay_money,
o.order_money,o.pay_type,o.pay_integral,o.create_date,o.pay_date,
o.update_date,o.pay_name,o.transaction_id,o.is_delete,o.checkin_days,
o.renter_info,o.renter_idcard,o.renter_phone,o.check_in_date,
o.check_out_date,o.room_id,o.room_name,o.hotel_id,o.hotel_name,o.room_number as num,o.order_type
FROM room_order o
where o.is_delete=0
<if test="hotelId!=null and hotelId!=''">
and o.hotel_id =#{hotelId}
</if>
<if test="orderCode!=null and orderCode!=''">
and order_code =#{orderCode}
</if>
<if test="roomId!=null and roomId!=''">
and o.room_id=#{roomId}
</if>
<if test="memberTelphone!=null and memberTelphone!=''">
and o.member_telphone like concat(#{memberTelphone},'%')
</if>
<if test="memberName!=null and memberName!=''">
and o.member_name like concat(#{memberName},'%')
</if>
<if test="idCard !=null and idCard !=''">
and o.renter_idcard =#{idCard}
</if>
<if test="startDt!=null and startDt!=''">
and o.create_date >= #{startDt}
</if>
<if test="endDt!=null and endDt!=''">
<![CDATA[
and o.create_date <= #{endDt}
]]>
</if>
<if test="orderStatus!=null">
and o.order_status =#{orderStatus}
</if>
<if test="checkInDate!=null and checkInDate!=''">
and check_in_date >= #{checkInDate}
</if>
<if test="checkOutDate!=null and checkOutDate!=''">
and check_out_date <= #{checkOutDate}
</if>
<if test="payType!=null">
and pay_type=#{payType}
</if>
<if test="orderType!=null">
and order_type=#{orderType}
</if>
order by o.create_date desc
limit ${(pageNow-1)*pageSize}, ${pageSize}
</select>
<!-- 统计订单数量 -->
<select id="countRoomOrder" parameterType="com.sibu.orderHelper.integral.request.HotelOrderQueryParam" resultType="java.lang.Integer">
SELECT count(1)
FROM room_order o
where o.is_delete=0
<if test="hotelId!=null and hotelId!=''">
and o.hotel_id =#{hotelId}
</if>
<if test="orderCode!=null and orderCode!=''">
and order_code =#{orderCode}
</if>
<if test="roomId!=null and roomId!=''">
and o.room_id=#{roomId}
</if>
<if test="memberTelphone!=null and memberTelphone!=''">
and o.member_telphone like concat(#{memberTelphone},'%')
</if>
<if test="memberName!=null and memberName!=''">
and o.member_name like concat(#{memberName},'%')
</if>
<if test="idCard !=null and idCard !=''">
and o.renter_idcard =#{idCard}
</if>
<if test="startDt!=null and startDt!=''">
and o.create_date>=#{startDt}
</if>
<if test="endDt!=null and endDt!=''">
<![CDATA[
and o.create_date<= #{endDt}
]]>
</if>
<if test="orderStatus!=null">
and o.order_status =#{orderStatus}
</if>
<if test="checkInDate!=null and checkInDate!=''">
and check_in_date >= #{checkInDate}
</if>
<if test="checkOutDate!=null and checkOutDate!=''">
and check_in_date <= #{checkOutDate}
</if>
<if test="payType!=null">
and pay_type=#{payType}
</if>
<if test="orderType!=null">
and order_type=#{orderType}
</if>
</select>
<!-- roomOrder 明细查询 -->
<select id="queryRoomOrderDetail" parameterType="java.util.Map" resultMap="roomOrderResponse">
SELECT o.order_id,o.member_name,o.member_telphone,o.order_code,o.order_status,o.pay_money,
o.order_money,o.pay_type,o.pay_integral,o.create_date,o.pay_date,
o.update_date,o.pay_name,o.transaction_id,o.is_delete,o.checkin_days,
o.renter_info,o.renter_idcard,o.renter_phone,o.check_in_date,
o.check_out_date,o.room_id,o.room_name,o.hotel_id,o.hotel_name,o.room_number as num,o.order_type ,
detail.room_number,detail.retail_price,detail.integral,detail.checkin_date,
detail.hotel_status,detail.status,detail.sub_order_id,detail.sub_order_code
FROM room_order o inner join room_order_detail detail on o.order_id =detail.order_id
where o.is_delete=0
<if test="subOrderId!=null and subOrderId!=''">
and detail.sub_order_id =#{subOrderId}
</if>
<if test="orderId !=null and orderId !=''">
and o.order_id =#{orderId}
</if>
<if test="status !=null">
and detail.status =#{status}
</if>
<if test="hotelStatus!=null">
and detail.hotel_status=#{hotelStatus}
</if>
</select>
<!-- 更新订单状态 -->
<update id="updateVerifyStatus" parameterType="map">
update room_order set order_status=#{orderStatus} where order_code in
<foreach collection="ids" open="(" close=")" separator=" , " item="orderCode">
#{orderCode}
</foreach>
</update>
<!-- 查询订单的电话号码 -->
<select id="selectOrderPhoneByOrderId" parameterType="java.lang.String" resultType="java.lang.String">
select member_phone from room_order where order_id =#{orderId}
</select>
<!-- 更改子订单表状态 -->
<update id="updateVerifySubOrderStatus" parameterType="map">
UPDATE room_order_detail detail INNER JOIN room_order o
ON detail.order_id =o.order_id
SET detail.status =#{orderStatus} where detail.status=2 and o.order_code in
<foreach collection="ids" open="(" close=")" separator=" , " item="orderCode">
#{orderCode}
</foreach>
</update>
<!-- 更新 -->
<update id="updateSubOrderHotelStatus" parameterType="map">
update room_order_detail set hotel_status =#{hotelStatus}
where sub_order_id =#{subOrderId} and hotel_status=1 and status =3
</update>
<!-- 批量更新房间为已入住或者未入住 -->
<update id="updateSubOrderBookingStatus" parameterType="map">
update room_order_detail set hotel_status =#{hotelStatus}
where order_id =#{orderId} and hotel_status=0 and status=3
</update>
<update id="updateSubOrderStatus" parameterType="map">
update room_order_detail set status =#{status}
where sub_order_id =#{subOrderId}
</update>
<!-- 退单查询 -->
<select id="selectRoomOrderRefund" parameterType="com.sibu.orderHelper.hotel.request.HotelOrderRefundPagerRequest" resultMap="orderRefundResponse">
SELECT
refund.refund_code,refund.refund_price,refund.refund_integral,
refund.refund_reason,refund.create_date,
sub.sub_order_code,sub.status,sub.hotel_status,
o.member_name,o.member_telphone as member_phone,o.room_name,o.hotel_name,o.renter_idcard,o.create_date AS order_date,
o.pay_date,sub.integral,sub.retail_price,o.order_type,sub.checkin_date,sub.sub_order_id
FROM room_order_refund refund
INNER JOIN room_order_detail sub ON refund.sub_order_id =sub.sub_order_id
INNER JOIN room_order o ON o.order_id =refund.order_id
where 1=1 and o.is_delete=0
<if test="status !=null">
and sub.status =#{status}
</if>
<if test="renterIdcard !=null and renterIdcard!=''">
and o.renter_idcard=#{renterIdcard}
</if>
<if test="subOrderCode !=null and subOrderCode!=''">
and sub.sub_order_code=#{subOrderCode}
</if>
<if test="startRefundDate !=null">
and refund.create_date >= #{startRefundDate}
</if>
<if test="endRefundDate !=null">
and refund.create_date <#{endRefundDate}
</if>
<if test="startOrderDate !=null">
and o.create_date >= #{startOrderDate}
</if>
<if test="endOrderDate !=null">
and o.create_date <#{endOrderDate}
</if>
<if test="hotelId !=null and hotelId!=''">
and o.hotel_id =#{hotelId}
</if>
<if test="roomId !=null and roomId!=''">
and o.room_id =#{roomId}
</if>
<if test="memberName!=null and memberName !=''">
and o.member_name like concat('%',#{memberName},'%')
</if>
limit ${(pageNow-1)*pageSize}, ${pageSize}
</select>
<select id="countRoomOrderRefund" parameterType="com.sibu.orderHelper.hotel.request.HotelOrderRefundPagerRequest" resultType="java.lang.Integer">
SELECT count(1)
FROM room_order_refund refund
INNER JOIN room_order_detail sub ON refund.sub_order_id =sub.sub_order_id
INNER JOIN room_order o ON o.order_id =refund.order_id
where 1=1
<if test="status !=null">
and sub.status =#{status}
</if>
<if test="renterIdcard !=null and renterIdcard!=''">
and o.renter_idcard=#{renterIdcard}
</if>
<if test="subOrderCode !=null and subOrderCode!=''">
and sub.sub_order_code=#{subOrderCode}
</if>
<if test="startRefundDate !=null">
and refund.create_date >= #{startRefundDate}
</if>
<if test="endRefundDate !=null">
and refund.create_date <#{endRefundDate}
</if>
<if test="startOrderDate !=null">
and o.create_date >= #{startOrderDate}
</if>
<if test="endOrderDate !=null">
and o.create_date <#{endOrderDate}
</if>
<if test="hotelId !=null and hotelId!=''">
and o.hotel_id =#{hotelId}
</if>
<if test="roomId !=null and roomId!=''">
and o.room_id =#{roomId}
</if>
<if test="memberName!=null and memberName !=''">
and o.member_name like concat('%',#{memberName},'%')
</if>
</select>
<!-- 单条退单查询 -->
<select id="selectRoomOrderRefundDetail" parameterType="java.lang.String" resultMap="orderRefundResponse">
SELECT
refund.refund_code,refund.refund_price,refund.refund_integral,
refund.refund_reason,refund.create_date,
sub.sub_order_code,sub.status,sub.hotel_status,
o.member_name,o.member_telphone as member_phone,o.room_name,o.hotel_name,o.renter_idcard,o.create_date AS order_date,
o.pay_date,sub.integral,sub.retail_price,o.order_type,sub.checkin_date,sub.sub_order_id
FROM room_order_refund refund
INNER JOIN room_order_detail sub ON refund.sub_order_id =sub.sub_order_id
INNER JOIN room_order o ON o.order_id =refund.order_id
where sub.sub_order_id =#{subOrderId}
</select>
<!-- 查出已支付待入住的订单(逾期或者三天前发短信通知) -->
<select id="selectPayedAndNotCheckinOrder" parameterType="map" resultMap="orderDetailResponse">
SELECT o.member_telphone,o.check_in_date ,o.check_out_date ,detail.status ,detail.hotel_status,o.order_code
FROM (SELECT * FROM room_order_detail WHERE status =#{status} AND hotel_status =#{hotelStatus} ) detail
INNER JOIN room_order o
ON detail.order_id =o.order_id
GROUP BY detail.order_id ,detail.checkin_date HAVING
detail.checkin_date = (SELECT MIN(checkin_date) FROM room_order_detail WHERE order_id = detail.order_id)
</select>
<!-- 查询酒店订单并导出-->
<select id="selectHotelOrderForExport" parameterType="com.sibu.orderHelper.hotel.request.HotelOrderRefundPagerRequest" resultMap="exportHotelOrder">
SELECT o.order_code,d.sub_order_code,o.member_name,o.member_telphone,o.create_date ,
o.pay_date ,o.order_type,o.pay_name,o.transaction_id,o.renter_info,o.renter_idcard,o.renter_phone,
o.hotel_name,o.room_name,d.retail_price,d.integral,d.checkin_date,d.hotel_status,d.status
FROM room_order o INNER JOIN room_order_detail d
ON o.order_id =d.order_id and 1=1
<if test="hotelId!=null and hotelId!=''">
and o.hotel_id =#{hotelId}
</if>
<if test="orderCode!=null and orderCode!=''">
and order_code =#{orderCode}
</if>
<if test="roomId!=null and roomId!=''">
and o.room_id=#{roomId}
</if>
<if test="memberTelphone!=null and memberTelphone!=''">
and o.member_telphone like concat(#{memberTelphone},'%')
</if>
<if test="memberName!=null and memberName!=''">
and o.member_name like concat(#{memberName},'%')
</if>
<if test="idCard !=null and idCard !=''">
and o.renter_idcard =#{idCard}
</if>
<if test="startDt!=null and startDt!=''">
and o.create_date>=#{startDt}
</if>
<if test="endDt!=null and endDt!=''">
<![CDATA[
and o.create_date<= #{endDt}
]]>
</if>
<if test="orderStatus!=null">
and o.order_status =#{orderStatus}
</if>
<if test="checkInDate!=null and checkInDate!=''">
and check_in_date >= #{checkInDate}
</if>
<if test="checkOutDate!=null and checkOutDate!=''">
and check_in_date <= #{checkOutDate}
</if>
<if test="payType!=null">
and pay_type=#{payType}
</if>
<if test="orderType!=null">
and order_type=#{orderType}
</if>
</select>
</mapper>