额外的异常

This commit is contained in:
2025-11-12 13:30:57 +08:00
parent 8634f1a5a6
commit 89762d0589
3 changed files with 9 additions and 38 deletions

View File

@@ -264,7 +264,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
@Override
@Transactional
public OrderInfo createOrder(OrderInfoAddDTO param) {
public OrderInfo createOrder(OrderInfoAddDTO param) throws ValidateException{
ShopInfo shopInfo = shopInfoService.getById(param.getShopId());
AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在");
if (!shopInfo.getEatModel().contains(param.getDineMode())) {
@@ -1596,13 +1596,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean cancelledOrder(Long shopId, Long orderId) {
public Boolean cancelledOrder(Long shopId, Long orderId) throws OrderCancelException {
OrderInfo orderInfo = getById(orderId);
if (orderInfo == null) {
throw new ApiNotPrintException("订单不存在");
throw new OrderCancelException("订单不存在");
}
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
throw new ApiNotPrintException("订单不可取消");
throw new OrderCancelException("订单不可取消");
}
updateChain()
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode())