From 5229aff1f87548ddd41ebf4a21db106370e4d08d Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sun, 29 Sep 2024 11:15:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=BA=97=E9=93=BA=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E9=A4=90=E4=BD=8D=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/dto/ShopEatTypeInfoDTO.java | 2 ++ .../service/ProductService.java | 18 +++++++---- .../system/cashierservice/util/ShopUtils.java | 30 ++++++++++++++++++- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java index 675f8f3..b1117c9 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java @@ -13,4 +13,6 @@ public class ShopEatTypeInfoDTO { private boolean isDineInBefore; private TbShopInfo shopInfo; private String useType; + private boolean isOpenTakeout; + private boolean isOpenDineIn; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 05c4eb7..1a87606 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum; import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum; import com.chaozhanggui.system.cashierservice.entity.Enum.ShopInfoEatModelEnum; import com.chaozhanggui.system.cashierservice.entity.dto.*; @@ -145,12 +146,19 @@ public class ProductService { ConcurrentMap concurrentMap = new ConcurrentHashMap<>(); // 获取当前台桌最新订单id - ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(code, shopInfo.getId()); - TbOrderInfo order = getCurrentOrder(shopEatTypeInfoDTO, code, shopInfo.getId()); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.getEatModel(code, shopInfo.getId()); if (tbShopTable != null) { - tbShopTable.setOrderId(order == null ? null : order.getId()); - TbCashierCart seatCartInfo = getSeatCartInfo(tbShopTable.getShopId(), tbShopTable.getQrcode(), Integer.valueOf(userId), shopEatTypeInfoDTO); - tbShopTable.setChoseCount((shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee().equals(1)) || (seatCartInfo != null && (seatCartInfo.getNumber() != null))); + if (shopEatTypeInfoDTO.isOpenDineIn()) { + TbOrderInfo order = getCurrentOrder(shopEatTypeInfoDTO, code, shopInfo.getId()); + tbShopTable.setOrderId(order == null ? null : order.getId()); + TbCashierCart seatCartInfo = getSeatCartInfo(tbShopTable.getShopId(), tbShopTable.getQrcode(), Integer.valueOf(userId), shopEatTypeInfoDTO); + tbShopTable.setChoseCount((shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee().equals(1)) || (seatCartInfo != null && (seatCartInfo.getNumber() != null))); + }else { + shopEatTypeInfoDTO.setUseType(OrderUseTypeEnum.TAKEOUT.getValue()); + TbOrderInfo order = getCurrentOrder(shopEatTypeInfoDTO, code, shopInfo.getId()); + tbShopTable.setOrderId(order == null ? null : order.getId()); + tbShopTable.setChoseCount(true); + } } concurrentMap.put("shopTableInfo", tbShopTable == null ? "" : tbShopTable); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java index 354984c..c38630f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java @@ -47,7 +47,35 @@ public class ShopUtils { boolean isDineInAfter = !isMunchies && !isTakeout; boolean isDineInBefore = isMunchies && !isTakeout; + boolean isOpenTakeout = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.TAKE_OUT.getValue()); + boolean isOpenDineIn = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.DINE_IN.getValue()); + return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() : - isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue()); + isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue(), isOpenTakeout, isOpenDineIn); + } + + public ShopEatTypeInfoDTO getEatModel(String tableId, Object shopId) { + String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue(); + + TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(TbShopInfo::getId, shopId) + .eq(TbShopInfo::getStatus, 1)); + if (shopInfo == null) { + throw new MsgException("店铺信息不存在"); + } + + boolean isTakeout = ShopInfoEatModelEnum.TAKE_OUT.getValue().equals(eatModel); + // 是否是快餐版/先付费 + boolean isMunchies = StrUtil.isNotBlank(shopInfo.getRegisterType()) && + ShopInfoRegisterlEnum.MUNCHIES.getValue().equals(shopInfo.getRegisterType()); + + boolean isDineInAfter = !isMunchies && !isTakeout; + boolean isDineInBefore = isMunchies && !isTakeout; + + boolean isOpenTakeout = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.TAKE_OUT.getValue()); + boolean isOpenDineIn = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.DINE_IN.getValue()); + + return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() : + isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue(), isOpenTakeout, isOpenDineIn); } }