Commit 4a5772eb by 周晓航

一键加购 需求

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