From efb7e64323654fb15505687bd01c918673a849e5 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Thu, 26 Sep 2024 16:22:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) 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 8a16701e..f798d3a8 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 @@ -144,9 +144,18 @@ public class TbShopTableServiceImpl implements TbShopTableService { return orderInfo; } + /** + * 校验就餐模式是否存在并返回就餐类型信息 + * @param tableId 台桌id + * @param shopId 店铺id + * @return 就餐类型信息 + */ + public ShopEatTypeInfoDTO checkEatModel(Object tableId, Object shopId) { + String eatModel = StrUtil.isBlank(tableId.toString()) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue(); + return getShopEatTypeInfoDTO(shopId, eatModel); + } - private ShopEatTypeInfoDTO checkEatModel(Integer shopId, String useType) { - String eatModel = OrderUseTypeEnum.TAKEOUT.getValue().equals(useType) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue(); + private ShopEatTypeInfoDTO getShopEatTypeInfoDTO(Object shopId, String eatModel) { TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper() .eq(TbShopInfo::getId, shopId) .eq(TbShopInfo::getStatus, 1)); @@ -170,6 +179,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { } + private ShopEatTypeInfoDTO checkEatModel(Integer shopId, String useType) { + String eatModel = OrderUseTypeEnum.TAKEOUT.getValue().equals(useType) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue(); + return getShopEatTypeInfoDTO(shopId, eatModel); + } + + @Override public Map queryAll(TbShopTableQueryCriteria criteria, Pageable pageable) { if (criteria.getAreaId() == 0) { @@ -327,7 +342,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("购物车商品不存在"); } - int currentPlaceNum = getCurrentPlaceNum(tbCashierCart.getTableId().toString(), tbCashierCart.getShopId(), tbCashierCart.getUseType()); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(updateCartDTO.getShopId(), tbCashierCart.getUseType()); + int currentPlaceNum = getCurrentPlaceNum(tbCashierCart.getTableId().toString(), tbCashierCart.getShopId(), shopEatTypeInfoDTO); if (tbCashierCart.getPlaceNum() != null && !tbCashierCart.getPlaceNum().equals(currentPlaceNum)) { throw new BadRequestException("已下单商品仅支持退单操作"); @@ -543,7 +559,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public void removeCart(RemoveCartDTO removeCartDTO) { - int currentPlaceNum = getCurrentPlaceNum(removeCartDTO.getTableId() == null ? "" : removeCartDTO.getTableId().toString(), removeCartDTO.getShopId().toString(), removeCartDTO.getUseType()); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(removeCartDTO.getTableId(), removeCartDTO.getShopId()); + + int currentPlaceNum = getCurrentPlaceNum(removeCartDTO.getTableId() == null ? "" : removeCartDTO.getTableId().toString(), removeCartDTO.getShopId().toString(), shopEatTypeInfoDTO); // 会员点单 TbCashierCart cashierCart = cashierCartMapper.selectOne(new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, removeCartDTO.getShopId()) @@ -1095,7 +1113,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal feeAmount = BigDecimal.ZERO; BigDecimal saleAmount = BigDecimal.ZERO; // 当前下单次数 - int placeNum = getCurrentPlaceNum(createOrderDTO.getTableId(), String.valueOf(createOrderDTO.getShopId()), createOrderDTO.getUseType()); + int placeNum = getCurrentPlaceNum(createOrderDTO.getTableId(), String.valueOf(createOrderDTO.getShopId()), shopEatTypeInfoDTO); List orderDetails = new ArrayList<>(); BigDecimal mealAmount = null;