mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-05-06 19:49:26 +08:00
订单支付完成
This commit is contained in:
parent
1cdb072ec6
commit
fe8d5e521a
@ -13,6 +13,7 @@ import cn.mafangui.hotel.service.RoomTypeService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -63,9 +64,23 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public int payOrder(int orderId) {
|
public int payOrder(int orderId) {
|
||||||
Order order = orderMapper.selectByPrimaryKey(orderId);
|
Order order = orderMapper.selectByPrimaryKey(orderId);
|
||||||
if (order == null | order.getOrderStatus() != OrderStatus.UNPAID.getCode()) return -3;
|
if (order == null | order.getOrderStatus() != OrderStatus.UNPAID.getCode()) {
|
||||||
if (roomTypeService.updateRest(order.getRoomTypeId(),-1) != 1) return -2;
|
return -3;
|
||||||
return roomService.orderRoom(order.getRoomTypeId());
|
}
|
||||||
|
if (roomTypeService.updateRest(order.getRoomTypeId(),-1) != 1){
|
||||||
|
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();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user