|
@@ -303,9 +303,6 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
|
|
}
|
|
}
|
|
List<Cart> updateCartList = new ArrayList<>();
|
|
List<Cart> updateCartList = new ArrayList<>();
|
|
List<Cart> addCartList = new ArrayList<>();
|
|
List<Cart> addCartList = new ArrayList<>();
|
|
- //购物车分享
|
|
|
|
- List<CartShare> updateCartShareList = new ArrayList<>();
|
|
|
|
- List<CartShare> addCartShareList = new ArrayList<>();
|
|
|
|
User currentUser = userService.getInfo();
|
|
User currentUser = userService.getInfo();
|
|
cartListRequest.forEach(cartRequest -> {
|
|
cartListRequest.forEach(cartRequest -> {
|
|
// 判断商品正常
|
|
// 判断商品正常
|
|
@@ -324,36 +321,23 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
|
|
// 普通商品部分(只有普通商品才能添加购物车)
|
|
// 普通商品部分(只有普通商品才能添加购物车)
|
|
// 是否已经有同类型商品在购物车,有则添加数量没有则新增
|
|
// 是否已经有同类型商品在购物车,有则添加数量没有则新增
|
|
Cart forUpdateStoreCart = getByUniqueAndUid(cartRequest.getProductAttrUnique(), currentUser.getId());
|
|
Cart forUpdateStoreCart = getByUniqueAndUid(cartRequest.getProductAttrUnique(), currentUser.getId());
|
|
- CartShare forUpdateStoreCartShare = getCartShareByUniqueAndUid(cartRequest.getProductAttrUnique(), currentUser.getId());
|
|
|
|
|
|
|
|
- if (ObjectUtil.isNotNull(forUpdateStoreCart) && ObjectUtil.isNotNull(forUpdateStoreCartShare)) { // 购物车添加数量
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(forUpdateStoreCart) ) { // 购物车添加数量
|
|
forUpdateStoreCart.setCartNum(forUpdateStoreCart.getCartNum() + cartRequest.getCartNum());
|
|
forUpdateStoreCart.setCartNum(forUpdateStoreCart.getCartNum() + cartRequest.getCartNum());
|
|
updateCartList.add(forUpdateStoreCart);
|
|
updateCartList.add(forUpdateStoreCart);
|
|
|
|
|
|
- forUpdateStoreCartShare.setCartNum(forUpdateStoreCart.getCartNum() + cartRequest.getCartNum());
|
|
|
|
- updateCartShareList.add(forUpdateStoreCartShare);
|
|
|
|
|
|
+
|
|
} else {// 新增购物车数据
|
|
} else {// 新增购物车数据
|
|
Cart cart = new Cart();
|
|
Cart cart = new Cart();
|
|
BeanUtils.copyProperties(cartRequest, cart);
|
|
BeanUtils.copyProperties(cartRequest, cart);
|
|
cart.setUid(currentUser.getId());
|
|
cart.setUid(currentUser.getId());
|
|
cart.setMerId(product.getMerId());
|
|
cart.setMerId(product.getMerId());
|
|
addCartList.add(cart);
|
|
addCartList.add(cart);
|
|
-
|
|
|
|
- CartShare cartShare = new CartShare();
|
|
|
|
- BeanUtils.copyProperties(cart, cartShare);
|
|
|
|
- cartShare.setUid(currentUser.getId());
|
|
|
|
- cartShare.setMerId(product.getMerId());
|
|
|
|
- cartShare.setCartNum(cart.getCartNum());
|
|
|
|
- addCartShareList.add(cartShare);
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
Boolean execute = transactionTemplate.execute(exec -> {
|
|
Boolean execute = transactionTemplate.execute(exec -> {
|
|
saveBatch(addCartList);
|
|
saveBatch(addCartList);
|
|
updateBatchById(updateCartList);
|
|
updateBatchById(updateCartList);
|
|
- //分享表数据
|
|
|
|
- cartShareService.saveBatch(addCartShareList);
|
|
|
|
- cartShareService.updateBatchById(updateCartShareList);
|
|
|
|
return Boolean.TRUE;
|
|
return Boolean.TRUE;
|
|
});
|
|
});
|
|
if (execute) {
|
|
if (execute) {
|