mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-11-02 21:44:50 +08:00
入住登记完成
This commit is contained in:
@@ -8,6 +8,8 @@ public interface CheckInService {
|
||||
|
||||
int insert(CheckIn checkIn);
|
||||
|
||||
int checkIn(CheckIn checkIn);
|
||||
|
||||
int delete(int checkInId);
|
||||
|
||||
int update(CheckIn checkIn);
|
||||
|
||||
@@ -14,6 +14,8 @@ public interface OrderService {
|
||||
|
||||
Order selectById(Integer orderId);
|
||||
|
||||
Order selectByNameAndPhone(String name,String phone);
|
||||
|
||||
int update(Order record);
|
||||
|
||||
int payOrder(int orderId);
|
||||
|
||||
@@ -10,6 +10,7 @@ public interface RoomService {
|
||||
int delete(int roomId);
|
||||
int update(Room room);
|
||||
Room selectById(int roomId);
|
||||
Room selectByNumber(String roomNumber);
|
||||
List<Room> selectByStatus(int roomStatus);
|
||||
List<Room> selectByType(int typeId);
|
||||
List<Room> selectAll();
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package cn.mafangui.hotel.service.impl;
|
||||
|
||||
import cn.mafangui.hotel.entity.CheckIn;
|
||||
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.mapper.CheckInMapper;
|
||||
import cn.mafangui.hotel.service.CheckInService;
|
||||
import cn.mafangui.hotel.service.OrderService;
|
||||
import cn.mafangui.hotel.service.RoomService;
|
||||
import cn.mafangui.hotel.service.RoomTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,13 +20,57 @@ import java.util.List;
|
||||
public class CheckInServiceImpl implements CheckInService {
|
||||
@Autowired
|
||||
private CheckInMapper checkInMapper;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
@Autowired
|
||||
private RoomTypeService roomTypeService;
|
||||
@Autowired
|
||||
private RoomService roomService;
|
||||
|
||||
@Override
|
||||
public int insert(CheckIn checkIn) {
|
||||
return checkInMapper.insert(checkIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 入住登记
|
||||
* @param checkIn
|
||||
* 1.获取订单
|
||||
* 2.获取房间类型
|
||||
* 3.获取房间
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int checkIn(CheckIn checkIn) {
|
||||
Order order = orderService.selectById(checkIn.getOrderId());
|
||||
RoomType rt = roomTypeService.selectById(order.getRoomTypeId());
|
||||
Room r=roomService.selectById(roomService.inRoom(order.getRoomTypeId()));
|
||||
if (r == null) return -3;
|
||||
checkIn.setRoomId(r.getRoomId());
|
||||
checkIn.setRoomNumber(r.getRoomNumber());
|
||||
if (roomTypeService.updateRest(rt.getTypeId(),-1) <= 0) return -2;
|
||||
order.setOrderStatus(OrderStatus.CHECK_IN.getCode());
|
||||
if (orderService.update(order) <=0 ) return -1;
|
||||
return checkInMapper.insert(checkIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退房登记
|
||||
* 1.获取房间
|
||||
* 2.获取房型
|
||||
* 3.获取checkIn
|
||||
* @param roomNumber
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int checkOut(String roomNumber) {
|
||||
Room r = roomService.selectByNumber(roomNumber);
|
||||
RoomType ty = roomTypeService.selectById(r.getTypeId());
|
||||
CheckIn checkIn = checkInMapper.selectByPrimaryKey(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(int checkInId) {
|
||||
return checkInMapper.deleteByPrimaryKey(checkInId);
|
||||
@@ -30,10 +81,7 @@ public class CheckInServiceImpl implements CheckInService {
|
||||
return checkInMapper.updateByPrimaryKeySelective(checkIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkOut(String roomNumber) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int updateByRoomNumber(String roomNumber) {
|
||||
|
||||
@@ -47,6 +47,14 @@ public class OrderServiceImpl implements OrderService {
|
||||
return orderMapper.selectByPrimaryKey(orderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order selectByNameAndPhone(String name, String phone) {
|
||||
Order order = new Order();
|
||||
order.setName(name);
|
||||
order.setPhone(phone);
|
||||
return orderMapper.selectByNameAndPhone(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Order order) {
|
||||
return orderMapper.updateByPrimaryKeySelective(order);
|
||||
|
||||
@@ -35,6 +35,11 @@ public class RoomServiceImpl implements RoomService {
|
||||
return roomMapper.selectByPrimaryKey(roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Room selectByNumber(String roomNumber) {
|
||||
return roomMapper.selectByNumber(roomNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Room> selectByStatus(int roomStatus) {
|
||||
return roomMapper.selectByStatus(roomStatus);
|
||||
@@ -59,12 +64,19 @@ public class RoomServiceImpl implements RoomService {
|
||||
return roomMapper.updateByPrimaryKeySelective(room);
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间入住
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int inRoom(int typeId) {
|
||||
Room room = roomMapper.randomSelectByTypeAndStatus(typeId,RoomStatus.ORDERED.getCode());
|
||||
if (room == null) return -1;
|
||||
Room room = roomMapper.randomSelectByTypeAndStatus(typeId,RoomStatus.AVAILABLE.getCode());
|
||||
System.out.println(room);
|
||||
room.setRoomStatus(RoomStatus.IN_USE.getCode());
|
||||
return roomMapper.updateByPrimaryKeySelective(room);
|
||||
if (roomMapper.updateByPrimaryKeySelective(room) <= 0)
|
||||
return -1;
|
||||
else return room.getRoomId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user