订单支付完成

This commit is contained in:
FreeeBird
2018-12-06 19:08:44 +08:00
parent fe8d5e521a
commit 7ebdc00b16
26 changed files with 272 additions and 602 deletions

View File

@@ -12,6 +12,8 @@ public interface CheckInService {
int update(CheckIn checkIn);
int checkOut(String roomNumber);
int updateByRoomNumber(String roomNumber);
CheckIn selectById(int checkInId);

View File

@@ -18,6 +18,8 @@ public interface OrderService {
int payOrder(int orderId);
int cancelOrder(int orderId);
List<Order> selectByUserId(int userId);
List<Order> AllOrders();

View File

@@ -9,6 +9,8 @@ public interface UserService {
User selectById(int userId);
int addUser(User user);
int insertUser(User user);
int deleteUser(int userId);

View File

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

View File

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

View File

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

View File

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