diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 077e0a5..1863637 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -629,26 +629,6 @@ public class CartService { if (shopTable == null) { throw new MsgException("台桌不存在"); } - - // 设置餐位费 - TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); - if (!shopEatTypeInfoDTO.isTakeout() && shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0) { - seatNum = jsonObject.getInteger("dinersNum"); - if (seatNum == null) { - MsgException.throwException("dinersNum不能为空"); - } - if (shopTable.getMaxCapacity() < seatNum) { - throw new MsgException("当前台桌最大人数为: " + shopTable.getMaxCapacity()); - } - seatCost = shopInfo.getTableFee().multiply(BigDecimal.valueOf(seatNum)); - - ChoseCountDTO choseCountDTO = new ChoseCountDTO(); - choseCountDTO.setTableId(tableId); - choseCountDTO.setShopId(Integer.valueOf(shopId)); - choseCountDTO.setNum(seatNum); - choseCountDTO.setUserId(userId); - productService.choseCount(choseCountDTO); - } } // 所有订单信息 @@ -852,6 +832,25 @@ public class CartService { } + // 设置餐位费 + TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); + if (!shopEatTypeInfoDTO.isTakeout() && shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0 && (orderInfo == null || orderInfo.getSeatCount() == null)) { + seatNum = jsonObject.getInteger("dinersNum"); + if (seatNum == null) { + MsgException.throwException("dinersNum不能为空"); + } + if (shopTable.getMaxCapacity() < seatNum) { + throw new MsgException("当前台桌最大人数为: " + shopTable.getMaxCapacity()); + } + seatCost = shopInfo.getTableFee().multiply(BigDecimal.valueOf(seatNum)); + + ChoseCountDTO choseCountDTO = new ChoseCountDTO(); + choseCountDTO.setTableId(tableId); + choseCountDTO.setShopId(Integer.valueOf(shopId)); + choseCountDTO.setNum(seatNum); + choseCountDTO.setUserId(userId); + productService.choseCount(choseCountDTO); + } if (orderInfo != null) { log.info("订单状态:" + orderInfo.getStatus()); if (!"unpaid".equals(orderInfo.getStatus())) {