From 2cde01495333cd4c2727537045afb031c4ef4cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Sat, 9 Nov 2024 11:01:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=87=E6=8D=A2=E5=B0=B1=E9=A4=90?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8D=E4=BB=8Etoken=E8=8E=B7=E5=8F=96user?= =?UTF-8?q?id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductController.java | 3 ++- .../entity/dto/ChoseEatModelDTO.java | 1 + .../cashierservice/service/CartService.java | 15 +++------------ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java index 151cc76..397d3cd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -118,7 +118,8 @@ public class ProductController { } @PostMapping("/choseEatModel") - public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) { + public Result choseEatModel(@RequestHeader("id") Integer userId, @Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) { + choseEatModelDTO.setUserId(userId); List cashierCartList = cartService.choseEatModel(choseEatModelDTO); BigDecimal amount = BigDecimal.ZERO; BigDecimal memberAmount = BigDecimal.ZERO; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java index 6760671..88feb91 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java @@ -17,4 +17,5 @@ public class ChoseEatModelDTO { @Min(0) // 0切换店内 1切换外带 private Integer type; + private Integer userId; } 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 e2fb9d8..d1db8c4 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -1479,25 +1479,17 @@ public class CartService { } public List choseEatModel(ChoseEatModelDTO choseEatModelDTO) { - Integer userId = TokenUtil.getUserId(); List cashierCartList; + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseEatModelDTO.getTableId(), choseEatModelDTO.getShopId()); // 外带模式 if (choseEatModelDTO.getType() == 1) { - // 查询购物车所有信息 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .eq(TbCashierCart::getShopId, choseEatModelDTO.getShopId()) - .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) - .isNull(TbCashierCart::getOrderId) - .ne(TbCashierCart::getProductId, "-999") - .eq(TbCashierCart::getStatus, "create"); - queryWrapper.eq(TbCashierCart::getUserId, userId); - cashierCartList = mpCashierCartMapper.selectList(queryWrapper); + cashierCartList = cashierCartService.selectByShopEatTypeInfo(shopEatTypeInfoDTO, choseEatModelDTO.getUserId()); + cashierCartList = cashierCartList.stream().filter(item -> !TableConstant.CART_SEAT_ID.equals(item.getProductId())).collect(Collectors.toList()); // 计算打包费 if (cashierCartList.isEmpty()) { return new ArrayList<>(); } - List productIds = cashierCartList.stream().map(TbCashierCart::getProductId).collect(Collectors.toList()); Map productMap = productMapper.selectByIds(productIds).stream() .collect(Collectors.toMap( @@ -1516,7 +1508,6 @@ public class CartService { } else { // 查询购物车所有信息 - ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseEatModelDTO.getTableId(), choseEatModelDTO.getShopId()); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, choseEatModelDTO.getShopId()) .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())