|
@@ -73,7 +73,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<Map<String, Object>> getShoppingCartList(Integer userId, Integer source) {
|
|
|
- /*
|
|
|
+ /**
|
|
|
* 初始化返回数据
|
|
|
*/
|
|
|
// 购物车供应商列表
|
|
@@ -92,7 +92,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
AtomicDouble svipReducedPrice = new AtomicDouble(0);
|
|
|
// 统计总划线价
|
|
|
AtomicDouble totalOriginalPrice = new AtomicDouble(0);
|
|
|
- /*
|
|
|
+ /**
|
|
|
* 处理数据
|
|
|
*/
|
|
|
// 促销活动(总)
|
|
@@ -113,7 +113,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
userIdentity = null == userIdentity ? 0 : userIdentity;
|
|
|
// 会员机构类型:1医美,2生美
|
|
|
Integer userClubType = 0;
|
|
|
- if (null != userIdentity && userIdentity == 2) {
|
|
|
+ if (userIdentity == 2) {
|
|
|
userClubType = cartClubMapper.getClubTypeById(userId);
|
|
|
userClubType = null == userClubType ? 0 : userClubType;
|
|
|
}
|
|
@@ -230,7 +230,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
} else {
|
|
|
// 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), userId);
|
|
|
if (null != repurchase && repurchase > 0) {
|
|
|
if (taxFlag) {
|
|
|
BigDecimal cartItemTax = MathUtil.div(MathUtil.mul(repurchase, cartItemVo.getTaxRate()), 100, 2);
|
|
@@ -603,7 +603,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
cartItemVo.setLadderPrices(null);
|
|
|
} else {
|
|
|
// 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), userId);
|
|
|
if (null != repurchase && repurchase > 0) {
|
|
|
if (taxFlag) {
|
|
|
BigDecimal cartItemTax = MathUtil.div(MathUtil.mul(repurchase, cartItemVo.getTaxRate()), 100, 2);
|
|
@@ -685,10 +685,11 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
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);
|
|
|
- //判断是否是再次购买
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartDto.getProductId(), cartDto.getUserId());
|
|
|
+ //判断是否是再次购买 由商品id改为skuid
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartDto.getSkuId(), cartDto.getUserId());
|
|
|
if (null != repurchase && repurchase > 0) {
|
|
|
// 再次购买
|
|
|
cart.setReBuyFlag(1);
|
|
@@ -705,9 +706,9 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
*
|
|
|
* @param cartDto {
|
|
|
* userId 用户ID
|
|
|
- * productInfo 商品及数量信息:[ // 商品id,数量
|
|
|
- * {"productId": 2789, "productCount": 1},
|
|
|
- * {"productId": 2790, "productCount": 1}
|
|
|
+ * productInfo 商品及数量信息:[ // 商品id,skuId,数量
|
|
|
+ * {"productId": 2789, "skuId":123, "productCount": 1},
|
|
|
+ * {"productId": 2790, "skuId":123, "productCount": 1}
|
|
|
* ]
|
|
|
* }
|
|
|
*/
|
|
@@ -727,10 +728,12 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
JSONObject tempObj = (JSONObject) infoObject;
|
|
|
Integer productId = (Integer) tempObj.get("productId");
|
|
|
Integer productCount = (Integer) tempObj.get("productCount");
|
|
|
+ Integer skuId = (Integer) tempObj.get("skuId");
|
|
|
CartDto cartBo = new CartDto();
|
|
|
cartBo.setUserId(cartDto.getUserId());
|
|
|
cartBo.setProductId(productId);
|
|
|
cartBo.setProductCount(productCount);
|
|
|
+ cartBo.setSkuId(skuId);
|
|
|
saveShoppingCart(cartBo);
|
|
|
}
|
|
|
// 获取购物车数量(商品种类数)
|
|
@@ -770,14 +773,14 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<Integer> deleteShoppingCart(CartDto cartDto) {
|
|
|
- List<String> productIdList = Lists.newArrayList();
|
|
|
- if (cartDto.getProductIds().contains(",")) {
|
|
|
- String[] productArr = cartDto.getProductIds().split(",");
|
|
|
- Collections.addAll(productIdList, productArr);
|
|
|
+ List<String> skuIdList = Lists.newArrayList();
|
|
|
+ if (cartDto.getSkuIds().contains(",")) {
|
|
|
+ String[] productArr = cartDto.getSkuIds().split(",");
|
|
|
+ Collections.addAll(skuIdList, productArr);
|
|
|
} else {
|
|
|
- productIdList.add(cartDto.getProductIds());
|
|
|
+ skuIdList.add(cartDto.getSkuIds());
|
|
|
}
|
|
|
- cartClubMapper.deleteCartByProductIds(cartDto.getUserId(), productIdList);
|
|
|
+ cartClubMapper.deleteCartByProductIds(cartDto.getUserId(), skuIdList);
|
|
|
// 获取购物车数量(商品种类数)
|
|
|
int cartCount = getCartCount(cartDto.getUserId());
|
|
|
return ResponseJson.success("删除成功!返回购物车数量", cartCount);
|
|
@@ -841,11 +844,11 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
* 购物车结算
|
|
|
*
|
|
|
* @param userId 用户ID
|
|
|
- * @param productIds 商品ids,逗号隔开
|
|
|
+ * @param skuIds skuIds,逗号隔开
|
|
|
* @param source 来源 : 1 网站 ; 2 小程序
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson<Map<String, Object>> settlementShoppingCart(Integer userId, String productIds, Integer source) {
|
|
|
+ public ResponseJson<Map<String, Object>> settlementShoppingCart(Integer userId, String skuIds, Integer source) {
|
|
|
log.info("¥¥¥¥¥¥¥¥¥¥ > 商品结算");
|
|
|
// 商品种类
|
|
|
AtomicInteger kindCount = new AtomicInteger(0);
|
|
@@ -887,24 +890,24 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
boolean svipUserFlag = null != svipUserId;
|
|
|
|
|
|
// 前端接收商品Id信息
|
|
|
- List<String> productIdList = new ArrayList<>();
|
|
|
- if (productIds.contains(",")) {
|
|
|
- productIdList = Stream.of(productIds.split(",")).collect(Collectors.toList());
|
|
|
+ List<String> skuIdList = new ArrayList<>();
|
|
|
+ if (skuIds.contains(",")) {
|
|
|
+ skuIdList = Stream.of(skuIds.split(",")).collect(Collectors.toList());
|
|
|
} else {
|
|
|
- productIdList.add(productIds);
|
|
|
+ skuIdList.add(skuIds);
|
|
|
}
|
|
|
|
|
|
// 购物车商品的分帐号分组的供应商列表
|
|
|
// 1带分账号,2不带
|
|
|
- List<CartShopVo> shopList = cartClubMapper.getCartShopsByProductIds(userId, productIdList,1);
|
|
|
+ List<CartShopVo> shopList = cartClubMapper.getCartShopsByProductIds(userId, skuIdList, 1);
|
|
|
int firstSize = shopList.size();
|
|
|
- shopList.removeIf(s->StringUtils.isBlank(s.getSplitCode()));
|
|
|
- if(firstSize!=shopList.size()){
|
|
|
- shopList=cartClubMapper.getCartShopsByProductIds(userId, productIdList,2);
|
|
|
+ shopList.removeIf(s -> StringUtils.isBlank(s.getSplitCode()));
|
|
|
+ if (firstSize != shopList.size()) {
|
|
|
+ shopList = cartClubMapper.getCartShopsByProductIds(userId, skuIdList, 2);
|
|
|
}
|
|
|
if (null != shopList && shopList.size() > 0) {
|
|
|
// 遍历供应商列表
|
|
|
- List<String> finalIdList = productIdList;//购物车商品id列表
|
|
|
+ List<String> finalIdList = skuIdList;//购物车商品skuId列表
|
|
|
Integer finalUserIdentity = userIdentity;
|
|
|
Integer finalUserClubType = userClubType;
|
|
|
Integer finalUserIdentity1 = userIdentity;
|
|
@@ -929,7 +932,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
}
|
|
|
// 供应商下商品列表
|
|
|
// 过滤保存已上架商品
|
|
|
- List<CartItemVo> productList = cartClubMapper.getCartProductsByShopIdAndProductIds(userId, shop.getShopId(), finalIdList,shop.getSplitCode());
|
|
|
+ List<CartItemVo> productList = cartClubMapper.getCartProductsByShopIdAndProductIds(userId, shop.getShopId(), finalIdList, shop.getSplitCode());
|
|
|
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)));
|
|
@@ -1006,7 +1009,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
} else {
|
|
|
// 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), userId);
|
|
|
if (null != repurchase && repurchase > 0) {
|
|
|
if (taxFlag) {
|
|
|
BigDecimal cartItemTax = MathUtil.div(MathUtil.mul(repurchase, cartItemVo.getTaxRate()), 100, 2);
|
|
@@ -1232,6 +1235,8 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
Map<String, Integer> productInfos = new HashMap<>();
|
|
|
// 前端接收商品Id信息
|
|
|
List<String> productIdList = new ArrayList<>();
|
|
|
+ //skuIdList
|
|
|
+ List<Integer> skuIdList = new ArrayList<>();
|
|
|
// 用户身份
|
|
|
Integer userIdentity = baseMapper.getIdentityByUserId(userId);
|
|
|
if (null == userIdentity) {
|
|
@@ -1255,8 +1260,10 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
JSONObject product = (JSONObject) o;
|
|
|
String productId = product.getString("id");
|
|
|
Integer productCount = product.getInteger("count");
|
|
|
- productInfos.put(productId, productCount);
|
|
|
+ Integer skuId = product.getInteger("skuId");
|
|
|
+ productInfos.put(skuId.toString(), productCount);
|
|
|
productIdList.add(productId);
|
|
|
+ skuIdList.add(skuId);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("组合商品信息格式错误", e);
|
|
@@ -1268,7 +1275,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
//按供应商分类统计商品
|
|
|
if (null != shopList && shopList.size() > 0) {
|
|
|
// 遍历供应商列表
|
|
|
- List<String> finalIdList = productIdList;//商品id列表
|
|
|
+ List<Integer> finalIdList = skuIdList;//商品id列表
|
|
|
Integer finalUserIdentity = userIdentity;
|
|
|
Integer finalUserClubType = userClubType;
|
|
|
Integer finalUserIdentity1 = userIdentity;
|
|
@@ -1371,7 +1378,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
} else {
|
|
|
// 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), userId);
|
|
|
if (null != repurchase && repurchase > 0) {
|
|
|
if (taxFlag) {
|
|
|
BigDecimal cartItemTax = MathUtil.div(MathUtil.mul(repurchase, cartItemVo.getTaxRate()), 100, 2);
|
|
@@ -1577,7 +1584,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
if (null == shop) {
|
|
|
return ResponseJson.error("商品供应商异常!", null);
|
|
|
}
|
|
|
- CartItemVo cartItemVo = cartClubMapper.getCartItemByProductId(cartDto.getProductId());
|
|
|
+ CartItemVo cartItemVo = cartClubMapper.getCartItemByProductId(cartDto.getSkuId());
|
|
|
if (null == cartItemVo) {
|
|
|
return ResponseJson.error("商品数据异常!", null);
|
|
|
}
|
|
@@ -1701,7 +1708,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
} else {
|
|
|
// 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), cartDto.getUserId());
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), cartDto.getUserId());
|
|
|
if (null != repurchase && repurchase > 0) {
|
|
|
if (taxFlag) {
|
|
|
BigDecimal cartItemTax = MathUtil.div(MathUtil.mul(repurchase, cartItemVo.getTaxRate()), 100, 2);
|