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 2ceca3c..1cde8ed 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -848,8 +848,14 @@ public class CartService { }); boolean hasNewInfo = false; + // 外带模式去除餐位费 + TbCashierCart seatCartInfo = null; //校验 库存 耗材 for (TbCashierCart cart : cashierCartList) { + if (shopEatTypeInfoDTO.isTakeout() && "-999".equals(cart.getProductId())) { + seatCartInfo = cart; + continue; + } // 设置用餐类型 cart.setUseType(shopEatTypeInfoDTO.getUseType()); // 设置打包费 @@ -927,7 +933,6 @@ public class CartService { } else { tbProduct = null; saleAmount = saleAmount.add(shopEatTypeInfoDTO.getShopInfo().getTableFee()); - } totalAmount = totalAmount.add(cart.getTotalAmount()); @@ -981,7 +986,6 @@ public class CartService { } } - //生成订单 TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId); @@ -1122,6 +1126,9 @@ public class CartService { } } + // 去除餐位费信息 + cashierCartList = cashierCartList.stream().filter(item -> !"-999".equals(item.getProductId())).collect(Collectors.toList()); + List outRecords = new ArrayList<>(); for (TbCashierCart cashierCart : cashierCartList) { if (cashierCart.getIsVip().equals((byte) 1)) { @@ -1154,6 +1161,11 @@ public class CartService { mpCashierCartMapper.updateById(cashierCart); } + // 删除旧的餐位费信息 + if (shopEatTypeInfoDTO.isTakeout() && seatCartInfo != null) { + cashierCartMapper.deleteByPrimaryKey(seatCartInfo.getId()); + } + if (!CollectionUtils.isEmpty(outRecords)) outRecordMapper.insertBatch(outRecords); // 打印票据