mirror of
https://github.com/FreeeBird/hotel.git
synced 2026-05-01 08:20:26 +08:00
订单支付完成
This commit is contained in:
@@ -12,6 +12,8 @@ public interface CheckInService {
|
||||
|
||||
int update(CheckIn checkIn);
|
||||
|
||||
int checkOut(String roomNumber);
|
||||
|
||||
int updateByRoomNumber(String roomNumber);
|
||||
|
||||
CheckIn selectById(int checkInId);
|
||||
|
||||
@@ -18,6 +18,8 @@ public interface OrderService {
|
||||
|
||||
int payOrder(int orderId);
|
||||
|
||||
int cancelOrder(int orderId);
|
||||
|
||||
List<Order> selectByUserId(int userId);
|
||||
|
||||
List<Order> AllOrders();
|
||||
|
||||
@@ -9,6 +9,8 @@ public interface UserService {
|
||||
|
||||
User selectById(int userId);
|
||||
|
||||
int addUser(User user);
|
||||
|
||||
int insertUser(User user);
|
||||
|
||||
int deleteUser(int userId);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.mafangui.hotel.service.impl;
|
||||
|
||||
import cn.mafangui.hotel.entity.CheckIn;
|
||||
import cn.mafangui.hotel.entity.Room;
|
||||
import cn.mafangui.hotel.mapper.CheckInMapper;
|
||||
import cn.mafangui.hotel.service.CheckInService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -29,6 +30,11 @@ public class CheckInServiceImpl implements CheckInService {
|
||||
return checkInMapper.updateByPrimaryKeySelective(checkIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkOut(String roomNumber) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByRoomNumber(String roomNumber) {
|
||||
return checkInMapper.updateByRoomNumber(roomNumber);
|
||||
|
||||
@@ -71,10 +71,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return -2;
|
||||
}
|
||||
if (roomService.orderRoom(order.getRoomTypeId()) != 1){
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return -1;
|
||||
}
|
||||
order.setOrderStatus(OrderStatus.PAID.getCode());
|
||||
if (orderMapper.updateByPrimaryKeySelective(order) != 1){
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
@@ -83,6 +79,24 @@ public class OrderServiceImpl implements OrderService {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
* 1. 更改订单状态 -3
|
||||
* 2. 修改房型余量(已付款)-2
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int cancelOrder(int orderId) {
|
||||
Order order = orderMapper.selectByPrimaryKey(orderId);
|
||||
if (order == null ) return -3;
|
||||
order.setOrderStatus(OrderStatus.WAS_CANCELED.getCode());
|
||||
if (roomTypeService.updateRest(order.getRoomTypeId(),1) != 1){
|
||||
return -2;
|
||||
}
|
||||
return orderMapper.updateByPrimaryKeySelective(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Order> selectByUserId(int userId) {
|
||||
return orderMapper.selectByUserId(userId);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RoomTypeServiceImpl implements RoomTypeService {
|
||||
@Override
|
||||
public int updateRest(int typeId, int num) {
|
||||
RoomType rt =roomTypeMapper.selectByPrimaryKey(typeId);
|
||||
if (rt.getRest() <= 0) return -1;
|
||||
if (rt.getRest() <= 0 && num < 0) return -1;
|
||||
rt.setRest(rt.getRest() + num);
|
||||
return roomTypeMapper.updateByPrimaryKeySelective(rt);
|
||||
}
|
||||
|
||||
@@ -19,10 +19,15 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertUser(User user) {
|
||||
public int addUser(User user) {
|
||||
return userMapper.insertSelective(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertUser(User user) {
|
||||
return userMapper.insert(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteUser(int userId) {
|
||||
return userMapper.deleteByPrimaryKey(userId);
|
||||
|
||||
Reference in New Issue
Block a user