|
@@ -1,12 +1,12 @@
|
|
|
package com.caimei365.order.service.impl;
|
|
|
|
|
|
import com.caimei365.order.mapper.BaseMapper;
|
|
|
-import com.caimei365.order.mapper.CartMapper;
|
|
|
+import com.caimei365.order.mapper.CartClubMapper;
|
|
|
import com.caimei365.order.model.ResponseJson;
|
|
|
import com.caimei365.order.model.dto.CartDto;
|
|
|
import com.caimei365.order.model.po.CartPo;
|
|
|
import com.caimei365.order.model.vo.*;
|
|
|
-import com.caimei365.order.service.CartService;
|
|
|
+import com.caimei365.order.service.CartClubService;
|
|
|
import com.caimei365.order.utils.MathUtil;
|
|
|
import com.caimei365.order.utils.ProductUtil;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -31,13 +31,13 @@ import java.util.stream.IntStream;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class CartServiceImpl implements CartService {
|
|
|
+public class CartClubServiceImpl implements CartClubService {
|
|
|
@Value("${caimei.wwwDomain}")
|
|
|
private String domain;
|
|
|
@Resource
|
|
|
private BaseMapper baseMapper;
|
|
|
@Resource
|
|
|
- private CartMapper cartMapper;
|
|
|
+ private CartClubMapper cartClubMapper;
|
|
|
|
|
|
/**
|
|
|
* 购物车列表详细数据
|
|
@@ -50,7 +50,7 @@ public class CartServiceImpl implements CartService {
|
|
|
* 初始化返回数据
|
|
|
*/
|
|
|
// 购物车供应商列表
|
|
|
- List<CartShopVo> shopInfoList = cartMapper.getCartShops(userId);
|
|
|
+ List<CartShopVo> shopInfoList = cartClubMapper.getCartShops(userId);
|
|
|
// 失效商品列表
|
|
|
List<CartItemVo> invalidList = new ArrayList<>();
|
|
|
// 商品总数量
|
|
@@ -81,9 +81,9 @@ public class CartServiceImpl implements CartService {
|
|
|
// 该供应商满减金额(供应商满减,单品满减)
|
|
|
AtomicDouble shopReducedPrice = new AtomicDouble(0);
|
|
|
// 供应商促销优惠活动
|
|
|
- CartPromotionsVo shopPromotion = cartMapper.getPromotionByShopId(shop.getShopId());
|
|
|
+ CartPromotionsVo shopPromotion = cartClubMapper.getPromotionByShopId(shop.getShopId());
|
|
|
// 供应商下商品列表
|
|
|
- List<CartItemVo> productList = cartMapper.getCartProductsByShopId(shop.getShopId(), userId);
|
|
|
+ List<CartItemVo> productList = cartClubMapper.getCartProductsByShopId(shop.getShopId(), userId);
|
|
|
|
|
|
// 迭代器设置商品信息
|
|
|
Iterator<CartItemVo> productIterator = productList.iterator();
|
|
@@ -105,7 +105,7 @@ public class CartServiceImpl implements CartService {
|
|
|
// 没有店铺促销时,商品促销才有效
|
|
|
if (null == shopPromotion) {
|
|
|
// 获取商品促销信息
|
|
|
- promotions = cartMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
+ promotions = cartClubMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
/*
|
|
|
* 设置商品促销优惠
|
|
|
*/
|
|
@@ -194,7 +194,7 @@ public class CartServiceImpl implements CartService {
|
|
|
// 店铺满赠
|
|
|
if (shopPromotion.getMode() == 3) {
|
|
|
// 获取赠品
|
|
|
- List<CartItemVo> giftList = cartMapper.getPromotionGifts(shopPromotion.getId());
|
|
|
+ List<CartItemVo> giftList = cartClubMapper.getPromotionGifts(shopPromotion.getId());
|
|
|
shopPromotion.setGiftList(giftList);
|
|
|
}
|
|
|
// 设置该优惠下的商品列表
|
|
@@ -296,7 +296,7 @@ public class CartServiceImpl implements CartService {
|
|
|
// 用户身份
|
|
|
Integer userIdentity = baseMapper.getIdentityByUserId(userId);
|
|
|
// 获取购物车商品列表(不区分供应商)
|
|
|
- cartList = cartMapper.getCartProductList(userId);
|
|
|
+ cartList = cartClubMapper.getCartProductList(userId);
|
|
|
if (null != cartList && cartList.size()>0) {
|
|
|
// 移除价格不可见商品
|
|
|
cartList.removeIf(cartItemVo -> !(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && userIdentity == 2)));
|
|
@@ -304,7 +304,7 @@ public class CartServiceImpl implements CartService {
|
|
|
// 设置商品图片及税费
|
|
|
boolean taxFlag = setCartItemImgAndTax(cartItemVo);
|
|
|
// 获取商品促销信息
|
|
|
- CartPromotionsVo promotions = cartMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
+ CartPromotionsVo promotions = cartClubMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
/*
|
|
|
* 设置商品促销优惠
|
|
|
*/
|
|
@@ -374,12 +374,12 @@ public class CartServiceImpl implements CartService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<Integer> addShoppingCart(CartDto cartDto) {
|
|
|
- CartPo cart = cartMapper.getCartPo(cartDto);
|
|
|
+ CartPo cart = cartClubMapper.getCartPo(cartDto);
|
|
|
if (cart != null) {
|
|
|
// 购物车已存在该商品,更新数量
|
|
|
cart.setProductCount(cart.getProductCount() + cartDto.getProductCount());
|
|
|
cart.setAddTime(new Date());
|
|
|
- cartMapper.updateCart(cart);
|
|
|
+ cartClubMapper.updateCart(cart);
|
|
|
} else {
|
|
|
// 添加新购物车
|
|
|
cart = new CartPo();
|
|
@@ -395,7 +395,7 @@ public class CartServiceImpl implements CartService {
|
|
|
cart.setReBuyFlag(0);
|
|
|
}
|
|
|
cart.setAddTime(new Date());
|
|
|
- cartMapper.insertCart(cart);
|
|
|
+ cartClubMapper.insertCart(cart);
|
|
|
}
|
|
|
// 获取购物车数量(商品种类数)
|
|
|
int cartCount = getCartCount(cartDto.getUserId());
|
|
@@ -418,7 +418,7 @@ public class CartServiceImpl implements CartService {
|
|
|
cart.setProductId(cartDto.getProductId());
|
|
|
cart.setProductCount(cartDto.getProductCount());
|
|
|
cart.setAddTime(new Date());
|
|
|
- cartMapper.updateCart(cart);
|
|
|
+ cartClubMapper.updateCart(cart);
|
|
|
// 获取购物车数量(商品种类数)
|
|
|
int cartCount = getCartCount(cartDto.getUserId());
|
|
|
return ResponseJson.success("更新成功!返回购物车数量", cartCount);
|
|
@@ -443,7 +443,7 @@ public class CartServiceImpl implements CartService {
|
|
|
} else {
|
|
|
productIdList.add(Integer.parseInt(cartDto.getProductIds()));
|
|
|
}
|
|
|
- cartMapper.deleteCartByProductIds(cartDto.getUserId(), productIdList);
|
|
|
+ cartClubMapper.deleteCartByProductIds(cartDto.getUserId(), productIdList);
|
|
|
// 获取购物车数量(商品种类数)
|
|
|
int cartCount = getCartCount(cartDto.getUserId());
|
|
|
return ResponseJson.success("删除成功!返回购物车数量", cartCount);
|
|
@@ -459,7 +459,7 @@ public class CartServiceImpl implements CartService {
|
|
|
return 0;
|
|
|
}
|
|
|
// 获取购物车商品列表(不区分供应商)
|
|
|
- List<CartItemVo> cartList = cartMapper.getCartProductList(userId);
|
|
|
+ List<CartItemVo> cartList = cartClubMapper.getCartProductList(userId);
|
|
|
if (null != cartList && cartList.size()>0) {
|
|
|
// 用户身份
|
|
|
Integer userIdentity = baseMapper.getIdentityByUserId(userId);
|
|
@@ -579,7 +579,7 @@ public class CartServiceImpl implements CartService {
|
|
|
promotionsIds.add(promotions.getId());
|
|
|
if (promotions.getMode() == 3) {
|
|
|
// 获取赠品
|
|
|
- List<CartItemVo> giftList = cartMapper.getPromotionGifts(promotions.getId());
|
|
|
+ List<CartItemVo> giftList = cartClubMapper.getPromotionGifts(promotions.getId());
|
|
|
promotions.setGiftList(giftList);
|
|
|
}
|
|
|
promotions.setProductList(promotionPriceList);
|