枚举类编写

This commit is contained in:
freeebird
2018-11-29 11:51:42 +08:00
parent ed0f7f87aa
commit 1cdb072ec6
18 changed files with 214 additions and 191 deletions

View File

@@ -25,4 +25,6 @@ public interface RoomTypeService {
int addRest(int typeId);
int minusRest(int typeId);
List<RoomType> findAllRestType();
}

View File

@@ -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());
}

View File

@@ -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();
}
}