From a2ada0db333425e95ebc688dc411921082ea9d6a Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 25 Oct 2024 11:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=88=90=E5=8A=9F=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E5=8F=B0=E6=A1=8C=E5=B0=B1=E9=A4=90=E4=BA=BA=E6=95=B0?= =?UTF-8?q?=E7=AD=89=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/entity/TbShopTable.java | 7 +++++++ .../mpservice/MpShopTableService.java | 6 ++++++ .../mpservice/impl/MpShopTableServiceImpl.java | 17 +++++++++++++++++ .../cashierservice/service/CartService.java | 17 +++++++++-------- .../cashierservice/service/PayService.java | 14 ++------------ 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java index 8d1dca6..a4f2bcd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; +import java.util.Date; @Data public class TbShopTable implements Serializable { @@ -53,6 +54,12 @@ public class TbShopTable implements Serializable { private Integer seatNum; private Integer autoClear; + private Date useTime; + private Date endTime; + private Integer productNum; + private BigDecimal totalAmount; + private BigDecimal realAmount; + private Integer useNum; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/MpShopTableService.java b/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/MpShopTableService.java index cd13742..cc11b5a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/MpShopTableService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/MpShopTableService.java @@ -17,4 +17,10 @@ public interface MpShopTableService extends IService { * @param tableId qrcode */ TbShopTable selectByQrcode(String tableId); + + /** + * 清除台桌状态 + * @param tableId 台桌id + */ + boolean clearTableState(String tableId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/impl/MpShopTableServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/impl/MpShopTableServiceImpl.java index 85b7977..db06283 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/impl/MpShopTableServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/impl/MpShopTableServiceImpl.java @@ -25,4 +25,21 @@ public class MpShopTableServiceImpl extends ServiceImpl() .eq(TbShopTable::getQrcode, tableId)); } + + @Override + public boolean clearTableState(String tableId) { + TbShopTable shopTable = selectByQrcode(tableId); + if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) { + return update(new LambdaUpdateWrapper() + .eq(TbShopTable::getQrcode, tableId) + .set(TbShopTable::getUseTime, null) + .set(TbShopTable::getProductNum, 0) + .set(TbShopTable::getTotalAmount, 0) + .set(TbShopTable::getRealAmount, 0) + .set(TbShopTable::getUseNum, 0) + .set(TbShopTable::getStatus, TableConstant.ShopTable.State.CLEANING.getValue())); + }else { + return updateStateByQrcode(tableId, TableConstant.ShopTable.State.CLEANING); + } + } } 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 d6b5ece..97e86a1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -1110,7 +1110,9 @@ public class CartService { // 去除餐位费信息 List outRecords = new ArrayList<>(); + int totalNum = 0; for (TbCashierCart cashierCart : cashierCartList) { + totalNum += cashierCart.getNumber(); if (!cashierCart.getProductId().equals("-999") && cashierCart.getIsVip().equals((byte) 1)) { List actInRecords = activateInRecordService.queryAllByVipIdAndShopIdAndProId( Integer.valueOf(tbShopUser.getId()), Integer.valueOf(orderInfo.getShopId()), Integer.valueOf(cashierCart.getProductId())); @@ -1143,12 +1145,6 @@ public class CartService { cashierCartList = cashierCartList.stream().filter(item -> !"-999".equals(item.getProductId())).collect(Collectors.toList()); - - // 删除旧的餐位费信息 -// if (shopEatTypeInfoDTO.isTakeout() && seatCartInfo != null) { -// cashierCartMapper.deleteByPrimaryKey(seatCartInfo.getId()); -// } - if (!CollectionUtils.isEmpty(outRecords)) outRecordMapper.insertBatch(outRecords); // 打印票据 @@ -1167,8 +1163,13 @@ public class CartService { } // 修改台桌状态 - if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(tableId)) { - mpShopTableService.updateStateByQrcode(tableId, TableConstant.ShopTable.State.USING); + if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(tableId) && shopTable != null) { + shopTable.setStatus(TableConstant.ShopTable.State.USING.getValue()); + shopTable.setProductNum(totalNum); + shopTable.setTotalAmount(totalAmount); + shopTable.setRealAmount(totalAmount); + shopTable.setSeatNum(seatNum); + mpShopTableService.updateById(shopTable); } // 发送mq消息 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index e689d7f..1322c00 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -527,12 +527,7 @@ public class PayService { // 重置台桌状态 if (StrUtil.isNotBlank(orderInfo.getTableId())) { - TbShopTable shopTable = mpShopTableService.selectByQrcode(orderInfo.getTableId()); - if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) { - mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.IDLE); - }else { - mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.CLEANING); - } + mpShopTableService.clearTableState(orderInfo.getTableId()); } return Result.success(CodeEnum.SUCCESS, "1"); } @@ -1154,12 +1149,7 @@ public class PayService { // 重置台桌状态 if (StrUtil.isNotBlank(orderInfo.getTableId())) { - TbShopTable shopTable = mpShopTableService.selectByQrcode(orderInfo.getTableId()); - if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) { - mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.IDLE); - }else { - mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.CLEANING); - } + mpShopTableService.clearTableState(orderInfo.getTableId()); } return "SUCCESS";