From 82ded6429057b9d7d75c801dd6c4ce0e5669446c Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sun, 29 Sep 2024 16:10:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=9B=E5=BB=BA=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=20=E5=88=87=E6=8D=A2=E5=B0=B1=E9=A4=90=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductController.java | 14 +++++++++++++- .../system/cashierservice/service/CartService.java | 2 +- 2 files changed, 14 insertions(+), 2 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 266a9d8..f63025f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -4,6 +4,7 @@ package com.chaozhanggui.system.cashierservice.controller; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.system.cashierservice.entity.TbCashierCart; import com.chaozhanggui.system.cashierservice.entity.dto.ChoseCountDTO; import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO; import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO; @@ -16,6 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; import java.util.Map; @CrossOrigin(origins = "*") @@ -113,7 +117,15 @@ public class ProductController { @PostMapping("/choseEatModel") public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) { - return Result.success(CodeEnum.SUCCESS, cartService.choseEatModel(choseEatModelDTO)); + List cashierCartList = cartService.choseEatModel(choseEatModelDTO); + BigDecimal amount = BigDecimal.ZERO; + for (TbCashierCart item : cashierCartList) { + amount = amount.add(item.getTotalAmount()); + } + HashMap data = new HashMap<>(); + data.put("amount", amount); + data.put("info", cashierCartList); + return Result.success(CodeEnum.SUCCESS, data); } @PostMapping("cleanCart") 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 421974d..8d1cbf6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -1581,7 +1581,7 @@ public class CartService { } } - public Object choseEatModel(ChoseEatModelDTO choseEatModelDTO) { + public List choseEatModel(ChoseEatModelDTO choseEatModelDTO) { Integer userId = TokenUtil.getUserId(); // 查询购物车所有信息 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper()