Commit 07ed3de5 by xiaoer.li@freemud.com

增加加料商品变化校验

parent f13fc5fb
...@@ -342,7 +342,10 @@ public class ShoppingCartAdapter { ...@@ -342,7 +342,10 @@ public class ShoppingCartAdapter {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return; if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
//加料信息为空 //加料信息为空
if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) return; if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) {
cartGoods.setProductMaterialList(new ArrayList<>());
return;
}
//提取加料信息 //提取加料信息
List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = spuProduct.getAdditionalGroupList().get(0).getGroupDetail(); List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = spuProduct.getAdditionalGroupList().get(0).getGroupDetail();
HashMap<String, ProductBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>(); HashMap<String, ProductBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>();
......
...@@ -181,7 +181,7 @@ public class GetMenuResponseDto { ...@@ -181,7 +181,7 @@ public class GetMenuResponseDto {
private List<SpecificationGroupBean> specificationGroupList; private List<SpecificationGroupBean> specificationGroupList;
//Sku 规格 如果 当前是sku 则有值 //Sku 规格 如果 当前是sku 则有值
private List<SkuProductBean.SkuSpecValue> skuSpecValues; private List<SkuProductBean.SkuSpecValue> skuSpecValues;
private List<ProductGroupType> additionalGroupList;
@NoArgsConstructor @NoArgsConstructor
@Data @Data
public static class SkuProductBean { public static class SkuProductBean {
...@@ -311,6 +311,105 @@ public class GetMenuResponseDto { ...@@ -311,6 +311,105 @@ public class GetMenuResponseDto {
private String type; private String type;
private String url; private String url;
} }
@NoArgsConstructor
@Data
public static class ProductGroupType {
//商品组ID
private String pgid;
//商户ID
private String linkId;
//商品组编号,跟groupId一样确认商品组唯一的字段
private String groupCode;
//扩展字段
private String options;
//商品组名")
private String name;
//商品组规则-是否必选
private Integer must;
//商品组规则-是否允许重复选
private Integer allowRepeat;
//商品组规则-选择的最小数量
private Integer minNumber;
//商品组规则-选择的最大数量
private Integer maxNumber;
//商品组备注
private String remark;
//商品组下子商品总数量
private Integer total;
/**
* 商品组详情
*/
private List<GroupDetailType> groupDetail;
@NoArgsConstructor
@Data
public static class GroupDetailType {
/**
* 商品ID
*/
private String productId;
/**
* 商品名称
*/
private String productName;
/**
* 第三方商品编码
*/
private String customerCode;
/**
* 标准售价
*/
private Integer productPrice;
/**
* 最终售价
*/
protected Integer productFinalPrice;
/**
* 最终售价
*/
protected Integer markUpPrice;
/**
* 商品默认图片
*/
private String picture;
/**
* 是否设置库存
*/
private Integer stockLimit;
/**
* 单位
*/
protected String unit;
/**
* 商品Code
*/
protected String productCode;
}
}
} }
} }
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
package cn.freemud.entities.dto; package cn.freemud.entities.dto;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
...@@ -40,4 +41,96 @@ public class GetProductInfoDto { ...@@ -40,4 +41,96 @@ public class GetProductInfoDto {
* 门店商品渠道,不传则默认为default,仅对开放了门店商品渠道信息商户使用,请慎用该参数 * 门店商品渠道,不传则默认为default,仅对开放了门店商品渠道信息商户使用,请慎用该参数
*/ */
private String channel; private String channel;
/**
* 加料商品
*/
private List<ProductGroupType> additionalGroupList;
@NoArgsConstructor
@Data
public static class ProductGroupType {
//商品组ID
private String pgid;
//商户ID
private String linkId;
//商品组编号,跟groupId一样确认商品组唯一的字段
private String groupCode;
//扩展字段
private String options;
//商品组名")
private String name;
//商品组规则-是否必选
private Integer must;
//商品组规则-是否允许重复选
private Integer allowRepeat;
//商品组规则-选择的最小数量
private Integer minNumber;
//商品组规则-选择的最大数量
private Integer maxNumber;
//商品组备注
private String remark;
//商品组下子商品总数量
private Integer total;
/**
* 商品组详情
*/
private List<GroupDetailType> groupDetail;
@NoArgsConstructor
@Data
public static class GroupDetailType {
/**
* 商品ID
*/
private String productId;
/**
* 商品名称
*/
private String productName;
/**
* 第三方商品编码
*/
private String customerCode;
/**
* 标准售价
*/
private Integer productPrice;
/**
* 最终售价
*/
protected Integer productFinalPrice;
/**
* 最终售价
*/
protected Integer markUpPrice;
/**
* 是否设置库存
*/
private Integer stockLimit;
/**
* 商品Code
*/
protected String productCode;
}
}
} }
...@@ -45,4 +45,5 @@ public class GetProductsVo { ...@@ -45,4 +45,5 @@ public class GetProductsVo {
* 分类名称 * 分类名称
*/ */
private String categoryName; private String categoryName;
private List<String> materialSpuIds;
} }
\ No newline at end of file
...@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; ...@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.Array;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -172,6 +173,16 @@ public class ItemServiceImpl implements ItemService { ...@@ -172,6 +173,16 @@ public class ItemServiceImpl implements ItemService {
getProductsVo.setCustomerCode(productBean.getCustomerCode()); getProductsVo.setCustomerCode(productBean.getCustomerCode());
getProductsVo.setCategory(productBean.getCategory()); getProductsVo.setCategory(productBean.getCategory());
getProductsVo.setCategoryName(productBean.getCategoryName()); getProductsVo.setCategoryName(productBean.getCategoryName());
if (CollectionUtils.isNotEmpty(productBean.getAdditionalGroupList())) {
ArrayList<String> spuIds = new ArrayList<>();
List<ProductBean.ProductGroupType> additionalGroupList = productBean.getAdditionalGroupList();
for (ProductBean.ProductGroupType productGroupType : additionalGroupList) {
for (ProductBean.ProductGroupType.GroupDetailType groupDetailType : productGroupType.getGroupDetail()) {
spuIds.add(groupDetailType.getProductId());
}
}
getProductsVo.setMaterialSpuIds(spuIds);
}
resultMap.put(productBean.getPid(), getProductsVo); resultMap.put(productBean.getPid(), getProductsVo);
getProductsVo.setType(1); getProductsVo.setType(1);
// 规格ID 剔除单品 // 规格ID 剔除单品
......
...@@ -160,7 +160,7 @@ public class SetMealServiceImpl implements IPromotionService { ...@@ -160,7 +160,7 @@ public class SetMealServiceImpl implements IPromotionService {
return number - cartGoods.getQty() < 0 ? "该商品限" + number + "份优惠 超出按照原价计算哦" : ""; return number - cartGoods.getQty() < 0 ? "该商品限" + number + "份优惠 超出按照原价计算哦" : "";
} else { } else {
cartGoods.setAmount((cartGoods.getFinalPrice() + productGroupAmount) * cartGoods.getQty()); cartGoods.setAmount((cartGoods.getFinalPrice() + productGroupAmount) * cartGoods.getQty());
return "该商品限" + goodsMap.get(cartGoods.getGoodsId()).getActualGoodsNumber() + "份优惠 超出按照原价计算哦"; return "该商品限" + goodsMap.get(cartGoods.getGoodsId()).getDiscounts().get(0).getActualGoodsNumber() + "份优惠 超出按照原价计算哦";
} }
} }
} }
...@@ -257,7 +257,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -257,7 +257,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//查询多个商品库存信息 //查询多个商品库存信息
queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty); queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
this.checkMaterial(productBeanListSpuClass, cartGoods);
//ShoppingCartConvertAdapter.setClassification(cartGoods, productBeanListSpuClass); //ShoppingCartConvertAdapter.setClassification(cartGoods, productBeanListSpuClass);
String productName = null; String productName = null;
// 当添加的商品不是商品券时 // 当添加的商品不是商品券时
...@@ -404,13 +404,28 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -404,13 +404,28 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//查询商品信息 //查询商品信息
List<String> pids = new ArrayList<>(); List<String> pids = new ArrayList<>();
pids.add(cartGoods.getGoodsId()); pids.add(cartGoods.getGoodsId());
Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId,BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode()); Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId, BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode());
//if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
//if (CollectionUtils.isEmpty(products.getAdditionalGroupList())) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_VERSION_ERROR);
//}
GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId()); GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId());
// 商品没有库存限制 // 商品没有库存限制
if ((getProductsVo == null) || (getProductsVo.getStockLimit() != 1)) { if (getProductsVo == null) {
return; return;
} }
//Todo 增加小料商品是否变化
if (CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
if (CollectionUtils.isEmpty(getProductsVo.getMaterialSpuIds())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_VERSION_ERROR);
}
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
if (!getProductsVo.getMaterialSpuIds().contains(materialGoods.getSpuId())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_VERSION_ERROR);
}
}
}
if (getProductsVo.getStockLimit() != 1) return;
ShoppingCartConvertAdapter.setClassification(cartGoods, getProductsVo); ShoppingCartConvertAdapter.setClassification(cartGoods, getProductsVo);
GetProductStockRequestDto requestDto = new GetProductStockRequestDto(); GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
requestDto.setChannel(BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode()); requestDto.setChannel(BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode());
...@@ -1629,4 +1644,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1629,4 +1644,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(""); shoppingCartGoodsResponseVo.setToastMsg("");
} }
} }
public void checkMaterial(List<ProductBeanDTO> productBeanListSpuClass, CartGoods cartGoods) {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
if (CollectionUtils.isEmpty(productBeanListSpuClass.get(0).getAdditionalGroupList())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_VERSION_ERROR);
}
}
} }
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