diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 12b5823e..f66ac564 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -966,6 +966,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean addMaterId, boolean isPrint) { return Utils.runFunAndCheckKey(() -> { + TbShopInfo shopInfo = shopInfoRepository.findById(createOrderDTO.getShopId()).orElse(null); + if (shopInfo == null) throw new BadRequestException("店铺信息不存在"); + TbShopTable tbShopTable = null; boolean tableFlag = StrUtil.isNotBlank(createOrderDTO.getTableId()); if (tableFlag) { @@ -1075,7 +1078,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setPlaceNum(placeNum); } - if ((OrderUseTypeEnum.DINE_IN_BEFORE.getValue().equals(createOrderDTO.getUseType()) || OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(createOrderDTO.getUseType())) + if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0 + &&(OrderUseTypeEnum.DINE_IN_BEFORE.getValue().equals(createOrderDTO.getUseType()) || OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(createOrderDTO.getUseType())) && mealNum == null) { throw new BadRequestException("请选择用餐人数"); } @@ -1599,6 +1603,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public Object choseCount(ChoseCountDTO choseCountDTO) { + TbShopInfo shopInfo = shopInfoRepository.findById(choseCountDTO.getShopId()).orElse(null); + if (shopInfo == null) throw new BadRequestException("店铺信息不存在"); + + if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1) { + throw new BadRequestException("当前店铺无需选择餐位费"); + } + TbShopTable shopTable = mpShopTableService.lambdaQuery().eq(TbShopTable::getQrcode, choseCountDTO.getTableId()).one(); if (shopTable == null) { throw new BadRequestException("台桌不存在"); @@ -1624,12 +1635,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setCreatedAt(System.currentTimeMillis()); tbCashierCart.setTableId(Long.valueOf(choseCountDTO.getTableId())); tbCashierCart.setName("客座费"); - tbCashierCart.setSalePrice(BigDecimal.ONE); + tbCashierCart.setSalePrice(shopInfo.getTableFee()); tbCashierCart.setMasterId(choseCountDTO.getMasterId()); tbCashierCart.setShopId(String.valueOf(choseCountDTO.getShopId())); tbCashierCart.setTradeDay(DateUtils.getDay()); tbCashierCart.setStatus("create"); - tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(BigDecimal.ONE)); + tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee())); tbCashierCart.setPlaceNum(1); tbCashierCart.setProductId("-999"); tbCashierCart.setSkuId("-999"); @@ -1638,7 +1649,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setTotalNumber(choseCountDTO.getNum()); tbCashierCartMapper.insert(tbCashierCart); } else { - tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(BigDecimal.ONE)); + tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee())); tbCashierCart.setNumber(choseCountDTO.getNum()); tbCashierCart.setTotalNumber(choseCountDTO.getNum()); tbCashierCartMapper.updateById(tbCashierCart);