From 3960eebac267559115a44ffe5da5eb502aaaec73 Mon Sep 17 00:00:00 2001 From: gaowdong Date: Wed, 4 Jun 2025 10:29:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/service/impl/OrderCartServiceImpl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderCartServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderCartServiceImpl.java index 57aa246..2a9ae8d 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderCartServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderCartServiceImpl.java @@ -82,9 +82,10 @@ public class OrderCartServiceImpl implements IOrderCartService String filteredOrderDate = orderCartQueryParam.getMenuDateList().stream().filter(orderDate -> orderDate.equals(orderDateStr)) .findFirst().orElse(null); CookDishCheckDTO cookDishCheckDTO = new CookDishCheckDTO(); - Optional maxRecipeId = orderCartList.stream() + Optional maxRecipeId = carts.stream() + .sorted(Comparator.comparing(OrderCart::getCartId).reversed()) .map(OrderCart::getRecipeId) - .max(Long::compareTo); + .findFirst(); if (maxRecipeId.isPresent()) { cookDishCheckDTO.setRecipeId(maxRecipeId.get()); } else { @@ -99,7 +100,7 @@ public class OrderCartServiceImpl implements IOrderCartService } for (OrderCart shoppingCart : carts) { - OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap); + OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap, cookDishCheckDTO.getRecipeId()); if(filteredOrderDate == null) { shoppingCartVO.setIsValid(0); } @@ -111,7 +112,8 @@ public class OrderCartServiceImpl implements IOrderCartService } private OrderCartVO convertToOrderCartVO(OrderCart orderCart, - Map> cookRecipeDishMap) { + Map> cookRecipeDishMap, + Long recipeId) { OrderCartVO orderCartVO = new OrderCartVO(); BeanUtils.copyProperties(orderCart, orderCartVO); orderCartVO.setIsValid(0); @@ -122,7 +124,8 @@ public class OrderCartServiceImpl implements IOrderCartService for (CookH5ReserveRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) { if(CollUtil.isNotEmpty(cookRecipeDishesVO.getDishesDetailList())) { for (CookH5CurrentDishesDetailVO dishesDetailVO : cookRecipeDishesVO.getDishesDetailList()) { - if (orderCart.getGoodsId().equals(dishesDetailVO.getDishesId())) { + if (orderCart.getGoodsId().equals(dishesDetailVO.getDishesId()) + && orderCart.getRecipeId().equals(recipeId)) { orderCartVO.setIsValid(1); break outerLoop; }