mirror of
https://github.com/FreeeBird/hotel.git
synced 2026-05-01 08:20:26 +08:00
枚举类编写
This commit is contained in:
@@ -25,4 +25,6 @@ public interface RoomTypeService {
|
||||
int addRest(int typeId);
|
||||
|
||||
int minusRest(int typeId);
|
||||
|
||||
List<RoomType> findAllRestType();
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
* 1.更改订单状态
|
||||
* 2.修改房型余量
|
||||
* 3.修改房间状态
|
||||
* 1.更改订单状态 -3
|
||||
* 2.修改房型余量 -2
|
||||
* 3.修改房间状态 -1
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@@ -63,8 +63,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Transactional
|
||||
public int payOrder(int orderId) {
|
||||
Order order = orderMapper.selectByPrimaryKey(orderId);
|
||||
if (order == null | order.getOrderStatus() != OrderStatus.UNPAID.getCode()) return -1;
|
||||
if (roomTypeService.updateRest(order.getRoomTypeId(),-1) != 1) return -1;
|
||||
if (order == null | order.getOrderStatus() != OrderStatus.UNPAID.getCode()) return -3;
|
||||
if (roomTypeService.updateRest(order.getRoomTypeId(),-1) != 1) return -2;
|
||||
return roomService.orderRoom(order.getRoomTypeId());
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ public class RoomTypeServiceImpl implements RoomTypeService {
|
||||
@Override
|
||||
public int updateRest(int typeId, int num) {
|
||||
RoomType rt =roomTypeMapper.selectByPrimaryKey(typeId);
|
||||
rt.setTypeId(rt.getRest() + num);
|
||||
if (rt.getRest() <= 0) return -1;
|
||||
rt.setRest(rt.getRest() + num);
|
||||
return roomTypeMapper.updateByPrimaryKeySelective(rt);
|
||||
}
|
||||
|
||||
@@ -64,4 +65,9 @@ public class RoomTypeServiceImpl implements RoomTypeService {
|
||||
rt.setTypeId(rt.getRest() -1);
|
||||
return roomTypeMapper.updateByPrimaryKeySelective(rt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoomType> findAllRestType() {
|
||||
return roomTypeMapper.selectAllWithRest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user