|
@@ -19,9 +19,11 @@ import com.google.common.collect.Lists;
|
|
|
import com.google.common.util.concurrent.AtomicDouble;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.aspectj.weaver.ast.Var;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import redis.clients.jedis.Jedis;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -153,6 +155,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
Iterator<CartItemVo> productIterator = productList.iterator();
|
|
|
while (productIterator.hasNext()) {
|
|
|
CartItemVo cartItemVo = productIterator.next();
|
|
|
+ cartItemVo.setSkus(orderClubMapper.findSkus(cartItemVo.getProductId()));
|
|
|
// 设置商品图片及税费
|
|
|
boolean taxFlag = productService.setCartItemImgAndTax(cartItemVo);
|
|
|
// 商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
|
|
@@ -170,8 +173,9 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
cartItemVo.setIsChecked(false);
|
|
|
// 价格可见度: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
|
|
|
boolean priceVisible = (cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getPriceFlag() == 3 && finalUserClubType == 1));
|
|
|
- // 是否库存充足
|
|
|
- boolean isStocked = (cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber());
|
|
|
+ // 是否库存充足 只看所有sku的stock是否为0
|
|
|
+// boolean isStocked = (cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber());
|
|
|
+ boolean isStocked = orderCommonMapper.findMaxStock(cartItemVo.getProductId()) > 0;
|
|
|
if (priceVisible && isStocked) {
|
|
|
if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
// 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
@@ -672,7 +676,8 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
return ResponseJson.success("添加成功!返回购物车数量", cartCount);
|
|
|
}
|
|
|
|
|
|
- private void saveShoppingCart(CartDto cartDto) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void saveShoppingCart(CartDto cartDto) {
|
|
|
CartPo cart = cartClubMapper.getCartPo(cartDto);
|
|
|
if (cart != null) {
|
|
|
// 购物车已存在该商品,更新数量
|
|
@@ -683,11 +688,8 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 添加新购物车
|
|
|
cart = new CartPo();
|
|
|
cart.setUserId(cartDto.getUserId());
|
|
|
- cart.setProductId(cartDto.getProductId());
|
|
|
cart.setProductCount(cartDto.getProductCount());
|
|
|
cart.setSkuId(cartDto.getSkuId());
|
|
|
- Integer shopId = baseMapper.getShopIdByproductId(cartDto.getProductId());
|
|
|
- cart.setShopId(shopId);
|
|
|
//判断是否是再次购买 由商品id改为skuid
|
|
|
Double repurchase = baseMapper.getRepurchasePrice(cartDto.getSkuId(), cartDto.getUserId());
|
|
|
if (null != repurchase && repurchase > 0) {
|
|
@@ -843,9 +845,9 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
/**
|
|
|
* 购物车结算
|
|
|
*
|
|
|
- * @param userId 用户ID
|
|
|
- * @param skuIds skuIds,逗号隔开
|
|
|
- * @param source 来源 : 1 网站 ; 2 小程序
|
|
|
+ * @param userId 用户ID
|
|
|
+ * @param skuIds skuIds,逗号隔开
|
|
|
+ * @param source 来源 : 1 网站 ; 2 小程序
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<Map<String, Object>> settlementShoppingCart(Integer userId, String skuIds, Integer source) {
|
|
@@ -1202,7 +1204,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
* 组合商品立即购买
|
|
|
*
|
|
|
* @param userId 用户ID
|
|
|
- * @param productInfo 组合商品信息:Json字符串格式[{"id":4351,"count":1},{}]
|
|
|
+ * @param productInfo 组合商品信息:Json字符串格式[{"id":4351,"count":1,"skuId":123},{}]
|
|
|
* @param source 来源 : 1 网站 ; 2 小程序
|
|
|
* @return
|
|
|
*/
|
|
@@ -1301,7 +1303,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 供应商下商品列表
|
|
|
// 过滤保存已上架商品
|
|
|
List<CartItemVo> productList = cartClubMapper.getProductsByShopIdAndProductIds(shop.getShopId(), finalIdList);
|
|
|
- productList.forEach(p -> p.setNumber(productInfos.get(p.getProductId().toString())));
|
|
|
+ productList.forEach(p -> p.setNumber(productInfos.get(p.getSkuId().toString())));
|
|
|
if (null != productList && productList.size() > 0) {
|
|
|
// 去除不可见商品,visibility商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
|
|
|
productList.removeIf(cartItemVo -> !(cartItemVo.getVisibility() == 3 || cartItemVo.getVisibility() == 2 || (cartItemVo.getVisibility() == 1 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getVisibility() == 4 && finalUserClubType == 1)));
|
|
@@ -1566,6 +1568,17 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
return ResponseJson.success(resultData);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseJson checkSkuId(Integer userId, Integer oldSkuId, Integer newSkuId, Integer count) {
|
|
|
+ cartClubMapper.deleteCartSku(userId, oldSkuId);
|
|
|
+ CartDto cartDto = new CartDto();
|
|
|
+ cartDto.setUserId(userId);
|
|
|
+ cartDto.setSkuId(newSkuId);
|
|
|
+ cartDto.setProductCount(count);
|
|
|
+ saveShoppingCart(cartDto);
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 立即购买
|
|
|
*
|