RoomMapper.xml
5.5 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
<?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.hotel.dao.HotelRoomDao">
<!-- 房型列表【默认取当天的】 -->
<select id="listRoomByHotelId" resultMap="listRoomResponse" parameterType="map">
SELECT
a.room_id,a.room_name,a.retail_price,a.martket_price,a.integral,a.number room_stock,
a.room_floor,a.bed_type,a.room_area,a.thumb_url,a.ispay_integral from (select min(rstock.price) retail_price,min(rstock.integral) integral,rstock.number,
rstock.ispay_integral,room.room_id,room.room_name,room.martket_price,room.room_floor,room.bed_type,room.room_area,room.thumb_url from room_type room left join room_stock rstock on room.room_id = rstock.room_id
WHERE
room.hotel_id = #{hotelId} and rstock.stock_date >= #{checkInDate} and rstock.stock_date < #{checkOutDate} and room.is_open = 1 and rstock.is_open = 1
GROUP BY room.room_id
ORDER BY
rstock.price asc) a
</select>
<resultMap type="com.sibu.orderHelper.hotel.response.HotelRoomListResponse" id="listRoomResponse">
<id column="room_id" property="roomId" />
<result column="room_name" property="roomName" />
<result column="retail_price" property="retailPrice" />
<result column="martket_price" property="martketPrice" />
<result column="integral" property="integral" />
<result column="room_stock" property="roomStock" />
<result column="room_floor" property="roomFloor" />
<result column="bed_type" property="bedType" />
<result column="room_area" property="roomArea" />
<result column="thumb_url" property="thumbUrl" />
<result column="ispay_integral" property="ispayIntegral" />
</resultMap>
<!-- 酒店房间详情 -->
<select id="getRoomDetailByRoomId" resultMap="roomDetailResponse" parameterType="map">
SELECT room_id,room_name,room_floor,bed_type,room_area,room_intro,image_url1,image_url2,image_url3
FROM room_type WHERE room_id = #{roomId} limit 1
</select>
<resultMap type="com.sibu.orderHelper.hotel.response.RoomDetailResponse" id="roomDetailResponse">
<id column="room_id" property="roomId" />
<result column="room_name" property="roomName" />
<result column="room_floor" property="roomFloor" />
<result column="bed_type" property="bedType" />
<result column="room_area" property="roomArea" />
<result column="room_intro" property="roomIntro" />
<result column="image_url1" property="imageUrl1" />
<result column="image_url2" property="imageUrl2" />
<result column="image_url3" property="imageUrl3" />
</resultMap>
<!-- 获取酒店房间逾期退款详情 -->
<select id="getRoomOverdueByRoomId" resultMap="roomOverdueResponse" parameterType="java.lang.String">
SELECT room_id,room_name,dedit_amount,overdue_days,overdue_amount,dedit_integral,overdue_integral
FROM room_type WHERE room_id = #{roomId} limit 1
</select>
<resultMap type="com.sibu.orderHelper.hotel.response.RoomOverdueResponse" id="roomOverdueResponse">
<id column="room_id" property="roomId" />
<result column="room_name" property="roomName" />
<result column="dedit_amount" property="deditAmount" />
<result column="overdue_days" property="overdueDays" />
<result column="overdue_amount" property="overdueAmount" />
<result column="dedit_integral" property="deditIntegral" />
<result column="overdue_integral" property="overdueIntegral" />
</resultMap>
<!-- 根据日期筛选可选择的房型 -->
<select id="selectRoomByDate" resultMap="listRoomResponse" parameterType="map">
select room.room_id,room.room_name,b.price retail_price,room.martket_price,b.integral,b.number room_stock,
room.room_floor,room.bed_type,room.room_area,room.thumb_url,b.ispay_integral
from room_type room LEFT JOIN (
select COUNT(*) cou, rstock.room_id, min(rstock.price) price, min(rstock.integral) integral, rstock.number, rstock.ispay_integral
from room_stock rstock
where (rstock.stock_date >= #{checkInDate} and rstock.stock_date < #{checkOutDate})
and rstock.number > 0 and rstock.is_open = 1 and rstock.hotel_id = #{hotelId} GROUP BY rstock.room_id)
b on room.room_id = b.room_id where b.cou = ${days}
</select>
<!-- 获取房间每晚的价格明细 -->
<select id="getOrderPriceDetail" resultMap="listOrderPriceDetails" parameterType="map">
select rstock.stock_id,rstock.price,rstock.integral,rstock.stock_date,rstock.number,rstock.is_open
from room_stock rstock
where rstock.room_id = #{roomId} and (rstock.stock_date >= #{checkInDate} and rstock.stock_date < #{checkOutDate})
order by rstock.stock_date asc
</select>
<resultMap type="com.sibu.orderHelper.hotel.response.OrderPriceDetailResponse" id="listOrderPriceDetails">
<id column="stock_id" property="stockId"/>
<result column="stock_date" property="stockDate" />
<result column="price" property="price"/>
<result column="integral" property="integral"/>
<result column="number" property="stockNumber"/>
<result column="is_open" property="isOpen"/>
</resultMap>
<!-- 更新酒店房型库存 -->
<update id="updateRoomStock" parameterType="map">
update room_stock set number = number-${roomNumber} where room_id = #{roomId} and (stock_date >= #{checkInDate} and stock_date < #{checkOutDate})
</update>
</mapper>