diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CartController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CartController.java index b4a770b..9bc06fa 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CartController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CartController.java @@ -1,6 +1,7 @@ package com.wayn.mobile.api.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.wayn.common.base.BaseController; import com.wayn.common.util.R; import com.wayn.mobile.api.domain.Cart; @@ -9,6 +10,9 @@ import com.wayn.mobile.framework.security.util.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.math.BigDecimal; +import java.util.List; + /** *

* 购物车商品表 前端控制器 @@ -59,4 +63,16 @@ public class CartController extends BaseController { public R goodsCount() { return iCartService.goodsCount(); } + + @PostMapping("getCheckedGoods") + public R getCheckedGoods() { + Long userId = SecurityUtils.getLoginUser().getMember().getId(); + List cartList = iCartService.list(new QueryWrapper() + .eq("user_id", userId).eq("checked", true)); + BigDecimal amount = new BigDecimal(0.00); + for (Cart cart : cartList) { + amount = amount.add(cart.getPrice().multiply(new BigDecimal(cart.getNumber()))); + } + return R.success().add("data", cartList).add("amount", amount); + } }