Commit 4a5772eb by 周晓航

一键加购 需求

parent d09cd2b8
......@@ -31,6 +31,7 @@ public class ShopGoodsReplaceVo extends BaseRequestVo {
private String menuType ;
// 我需要的字段----------
@NotEmpty(message = "oldShopId不能为空")
private String oldShopId;
/**
......
......@@ -2917,9 +2917,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
* @return
*/
public BaseResponse replaceGoodsByShop(ShopGoodsReplaceVo replaceGoodsRequestVo) {
if (StringUtils.isEmpty(replaceGoodsRequestVo.getShopId())){
if (StringUtils.isEmpty(replaceGoodsRequestVo.getShopId())
|| StringUtils.isEmpty(replaceGoodsRequestVo.getOldShopId())){
throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
}
if (replaceGoodsRequestVo.getShopId().equals(replaceGoodsRequestVo.getOldShopId())) {
// 门店号 一致 不作处理 测试结束 需要放开
return ResponseUtil.success();
}
// 获取用户登录信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(replaceGoodsRequestVo.getSessionId());
UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo);
......@@ -2967,36 +2973,39 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 校验 获取到的商品数量 规格是否和 上家门店规格一直 sku spu
List<String> productIds = productBeanListSpuClass.stream().map(ProductBean::getPid).collect(toList());
boolean fullReplace = true;
if (productIds.containsAll(spuIds)) {
// 全部包含的情况 再次校验 sku是否包含
List<ProductBean.SkuProductBean> skuListAll = new ArrayList<>();
productBeanListSpuClass.forEach(productBean -> skuListAll.addAll(productBean.getSkuList()));
List<String> productSkuIds = skuListAll.stream().map(ProductBean.SkuProductBean::getSkuId).collect(toList());
List<String> excludeSkuList = excludeGoods.stream().map(CartGoods::getSkuId).collect(toList());
// 删除 不对等的sku存在
if (!productSkuIds.containsAll(excludeSkuList)) {
List<String> skuList = new ArrayList<>();
excludeSkuList.forEach(sku ->{
if (!productSkuIds.contains(sku)) {
skuList.add(sku);
}
});
excludeGoods = excludeGoods.stream().filter(cartGoods -> !skuList.contains(cartGoods.getSpuId())).collect(Collectors.toList());
fullReplace = false;
}
// 全部包含,直接使用
}else {
// 不全部包含
List<String> spuList = new ArrayList<>();
productIds.forEach(s -> {
if (!spuIds.contains(s)) {
spuList.add(s);
}
});
excludeGoods = excludeGoods.stream().filter(cartGoods -> !spuList.contains(cartGoods.getSpuId())).collect(Collectors.toList());
fullReplace = false;
}
// if (productIds.containsAll(spuIds)) {
// // 全部包含的情况 再次校验 sku是否包含
// List<ProductBean.SkuProductBean> skuListAll = new ArrayList<>();
// productBeanListSpuClass.forEach(productBean -> skuListAll.addAll(productBean.getSkuList()));
//
// List<String> productSkuIds = skuListAll.stream().map(ProductBean.SkuProductBean::getSkuId).collect(toList());
// List<String> excludeSkuList = excludeGoods.stream().map(CartGoods::getSkuId).collect(toList());
// // 删除 不对等的sku存在
// if (!productSkuIds.containsAll(excludeSkuList)) {
// List<String> skuList = new ArrayList<>();
// excludeSkuList.forEach(sku ->{
// if (!productSkuIds.contains(sku)) {
// skuList.add(sku);
// }
// });
// excludeGoods = excludeGoods.stream().filter(cartGoods -> !skuList.contains(cartGoods.getSpuId())).collect(Collectors.toList());
// fullReplace = false;
// }
// // 全部包含,直接使用
// }else {
// // 不全部包含
// List<String> spuList = new ArrayList<>();
// productIds.forEach(s -> {
// if (!spuIds.contains(s)) {
// spuList.add(s);
// }
// });
// excludeGoods = excludeGoods.stream().filter(cartGoods -> !spuList.contains(cartGoods.getSpuId())).collect(Collectors.toList());
// fullReplace = false;
// }
// 商品小料数量 没校验
// 购物车添加数量限制
// Integer productsCount = limitGoodsQty(excludeGoods, null, appId);
......@@ -3031,6 +3040,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
fullReplace = false;
return fullReplace;
}
if (allCartGoodsList.size() != excludeGoods.size()){
// 表示有数据被删除
fullReplace = false;
}
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
allCartGoodsList.forEach(oldCartGoods -> {
int index;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment