退房登记完成

This commit is contained in:
FreeeBird 2018-12-10 10:51:31 +08:00
parent c1591ad821
commit 3aba922a10
3 changed files with 20 additions and 7 deletions

View File

@ -15,10 +15,12 @@ public interface CheckInMapper {
CheckIn selectByPrimaryKey(Integer checkInId);
CheckIn selectByRoomNumber(String roomNumber);
CheckIn selectLatestByRoomNumber(String roomNumber);
int updateByRoomNumber(String roomNumber);
int checkOut(Integer checkInId);
int updateByPrimaryKeySelective(CheckIn record);
int updateByPrimaryKey(CheckIn record);

View File

@ -5,6 +5,7 @@ import cn.mafangui.hotel.entity.Order;
import cn.mafangui.hotel.entity.Room;
import cn.mafangui.hotel.entity.RoomType;
import cn.mafangui.hotel.enums.OrderStatus;
import cn.mafangui.hotel.enums.RoomStatus;
import cn.mafangui.hotel.mapper.CheckInMapper;
import cn.mafangui.hotel.service.CheckInService;
import cn.mafangui.hotel.service.OrderService;
@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.util.List;
@Service
@ -67,8 +69,11 @@ public class CheckInServiceImpl implements CheckInService {
public int checkOut(String roomNumber) {
Room r = roomService.selectByNumber(roomNumber);
RoomType ty = roomTypeService.selectById(r.getTypeId());
CheckIn checkIn = checkInMapper.selectByPrimaryKey(1);
return 0;
CheckIn checkIn = checkInMapper.selectLatestByRoomNumber(roomNumber);
r.setRoomStatus(RoomStatus.AVAILABLE.getCode());
if(roomService.update(r) <=0 )return -3;
if (roomTypeService.updateRest(ty.getTypeId(),1)<=0)return -2;
return checkInMapper.checkOut(checkIn.getCheckInId());
}
@Override

View File

@ -23,11 +23,11 @@
from check_in
where check_in_id = #{checkInId,jdbcType=INTEGER}
</select>
<select id="selectByRoomNumber" parameterType="String" resultMap="BaseResultMap">
<select id="selectLatestByRoomNumber" parameterType="String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from check_in
where room_number = #{roomNumber,jdbcType=VARCHAR}
where room_number = #{roomNumber,jdbcType=VARCHAR} order by check_in_time desc limit 1
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
@ -45,8 +45,7 @@
update_time)
values (#{checkInId,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER},#{roomId,jdbcType=INTEGER}, #{roomNumber,jdbcType=VARCHAR},
#{peoCount,jdbcType=INTEGER}, #{persons,jdbcType=VARCHAR},
#{ids,jdbcType=VARCHAR}, #{checkInTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
#{ids,jdbcType=VARCHAR}, #{checkInTime,jdbcType=TIMESTAMP}, now(),now())
</insert>
<insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.CheckIn">
insert into check_in
@ -132,6 +131,13 @@
</set>
where check_in_id = #{checkInId,jdbcType=INTEGER}
</update>
<update id="checkOut" parameterType="Integer">
update check_in
set
check_out_time = now(),
update_time = now()
where check_in_id = #{checkInId,jdbcType=INTEGER}
</update>
<update id="updateByRoomNumber" parameterType="String">
update check_in
set