From 2a48cfa63f46c274d4da8e4562f142a27545a43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 17 Dec 2024 13:21:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A0=E5=8F=B0=E6=A1=8C=E4=B8=8D?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=B0=B1=E9=A4=90=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/OrderService.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java index f9e1b49..33cd4e0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java @@ -159,7 +159,12 @@ public class OrderService { */ public ShopEatTypeInfoDTO checkEatModel(Object shopId, String tableId) { String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue(); - return getShopEatTypeInfoDTO(shopId, eatModel, tableId); + return getShopEatTypeInfoDTO(shopId, eatModel, tableId, true); + } + + public ShopEatTypeInfoDTO getEatModelUnCheck(Object shopId, String tableId) { + String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue(); + return getShopEatTypeInfoDTO(shopId, eatModel, tableId, false); } /** @@ -171,7 +176,7 @@ public class OrderService { */ public ShopEatTypeInfoDTO checkEatModel(Object shopId, String tableId, String useType) { String eatModel = OrderUseTypeEnum.TAKEOUT.getValue().equals(useType) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue(); - return getShopEatTypeInfoDTO(shopId, eatModel, tableId); + return getShopEatTypeInfoDTO(shopId, eatModel, tableId, true); } /** @@ -182,14 +187,14 @@ public class OrderService { * @param tableId 台桌id * @return just餐类型信息 */ - private ShopEatTypeInfoDTO getShopEatTypeInfoDTO(Object shopId, String eatModel, String tableId) { + private ShopEatTypeInfoDTO getShopEatTypeInfoDTO(Object shopId, String eatModel, String tableId, boolean isCheckModel) { TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper() .eq(TbShopInfo::getId, shopId)); if (shopInfo == null) { throw new MsgException("店铺信息不存在"); } - if (!shopInfo.getEatModel().contains(eatModel)) { + if (!shopInfo.getEatModel().contains(eatModel) && isCheckModel) { throw new MsgException("当前店铺未开启此就餐模式"); } boolean isTakeout = ShopInfoEatModelEnum.TAKE_OUT.getValue().equals(eatModel); @@ -273,8 +278,13 @@ public class OrderService { if (number == null) { return Result.fail(CodeEnum.PARAM); } - ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(shopId, tableId); + ShopEatTypeInfoDTO shopEatTypeInfoDTO; + if (StrUtil.isBlank(tableId)) { + shopEatTypeInfoDTO = getEatModelUnCheck(shopId, tableId); + }else { + shopEatTypeInfoDTO = checkEatModel(shopId, tableId); + } // 台桌点单 boolean isSeatCart = productId != null && TableConstant.CashierCart.ID.equals(productId.toString()); @@ -889,8 +899,12 @@ public class OrderService { if (shopInfo == null) { throw new MsgException("店铺信息不存在"); } - - ShopEatTypeInfoDTO eatTypeInfoDTO = checkEatModel(orderVo.getShopId(), orderVo.getTableId()); + ShopEatTypeInfoDTO eatTypeInfoDTO; + if (StrUtil.isBlank(orderVo.getTableId())) { + eatTypeInfoDTO = getEatModelUnCheck(orderVo.getShopId(), orderVo.getTableId()); + }else { + eatTypeInfoDTO = checkEatModel(orderVo.getShopId(), orderVo.getTableId()); + } if (ShopInfoEatModelEnum.DINE_IN.getValue().equals(eatTypeInfoDTO.getUseType()) && StrUtil.isBlank(eatTypeInfoDTO.getUseType())) { throw new MsgException("店内就餐必须选择桌码");