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()