12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package com.caimei.service.impl;
- import com.caimei.mapper.ShoppingCartMapper;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.dto.CartDto;
- import com.caimei.model.po.CmMallCartPo;
- import com.caimei.model.vo.ShopVo;
- import com.caimei.service.ShoppingCartService;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * Description
- *
- * @author : plf
- * @date : 2021/3/23
- */
- @Service
- public class ShoppingCartServiceImpl implements ShoppingCartService {
- @Resource
- private ShoppingCartMapper shoppingCartMapper;
- @Override
- public ResponseJson<Integer> addShoppingCart(CartDto cart) {
- CmMallCartPo cartPo = shoppingCartMapper.findCartProduct(cart.getUserId(), cart.getProductId());
- if (cartPo == null) {
- shoppingCartMapper.insertCart(cart);
- } else {
- int productCount = cartPo.getProductCount() + cart.getProductCount();
- shoppingCartMapper.updateByProductCount(cartPo.getId(), productCount);
- }
- Integer cartQuantity = shoppingCartMapper.getCartQuantity(cart.getUserId());
- return ResponseJson.success(cartQuantity);
- }
- @Override
- public ResponseJson<Integer> getCartQuantity(Integer userId) {
- Integer cartQuantity = shoppingCartMapper.getCartQuantity(userId);
- return ResponseJson.success(cartQuantity);
- }
- @Override
- public ResponseJson<Map<String, Object>> shoppingInfo(Integer userId) {
- Map<String, Object> map = new HashMap<>(3);
- List<ShopVo> shopList = shoppingCartMapper.findCartShop(userId);
- shopList.forEach(shop -> {
- });
- return null;
- }
- }
|