Commit 8b79abd5 by xiaoer.li

增加小料商品变化异常校验

parent a5e0238b
......@@ -45,7 +45,7 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.3.734.RELEASE</version>
<version>1.1.3.735.RELEASE</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......
......@@ -181,7 +181,6 @@ public class GetMenuResponseDto {
private List<SpecificationGroupBean> specificationGroupList;
//Sku 规格 如果 当前是sku 则有值
private List<SkuProductBean.SkuSpecValue> skuSpecValues;
private List<ProductGroupType> additionalGroupList;
@NoArgsConstructor
@Data
public static class SkuProductBean {
......@@ -312,104 +311,6 @@ public class GetMenuResponseDto {
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;
}
}
}
}
}
......
......@@ -45,5 +45,4 @@ public class GetProductsVo {
* 分类名称
*/
private String categoryName;
private List<String> materialSpuIds;
}
\ No newline at end of file
......@@ -20,8 +20,8 @@ public enum GoodsTypeEnum {
SET_MEAL_GOODS(3, "套餐商品"),
SKU_GOODS(4, "sku商品"),
SPU_GOODS(5, "spu商品"),
MATERIAL(88, "有加料的商品");
MATERIAL(88, "有加料的商品"),
EXCEPTION_GOODS(99, "异常商品:商品菜单变化导致和购物车不商品匹配");
private Integer goodsType;
private String desc;
......
......@@ -173,16 +173,6 @@ public class ItemServiceImpl implements ItemService {
getProductsVo.setCustomerCode(productBean.getCustomerCode());
getProductsVo.setCategory(productBean.getCategory());
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);
getProductsVo.setType(1);
// 规格ID 剔除单品
......
......@@ -254,11 +254,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
*/
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
//查询多个商品库存信息
queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
this.checkMaterial(productBeanListSpuClass, cartGoods);
//ShoppingCartConvertAdapter.setClassification(cartGoods, productBeanListSpuClass);
String productName = null;
// 当添加的商品不是商品券时
if (!spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
......@@ -269,7 +266,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo,
spuId, allCartGoodsList, productBeanListSpuClass);
}
//todo 加料校验
this.checkMaterial(allCartGoodsList);
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// 获取优惠信息
......@@ -362,6 +360,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
this.checkMaterial(cartGoodsList);
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, updateShoppingCartGoodsQtyRequestVo.getSessionId(), "", shoppingCartBaseService);
......@@ -405,29 +406,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
List<String> pids = new ArrayList<>();
pids.add(cartGoods.getGoodsId());
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());
// 商品没有库存限制
if (getProductsVo == null) {
if (getProductsVo == null || getProductsVo.getStockLimit() != 1) {
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);
GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
requestDto.setChannel(BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode());
......@@ -483,6 +468,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
this.checkMaterial(cartGoodsList);
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), "", this.shoppingCartBaseService);
}
......@@ -637,7 +623,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(cartGoodsResponseVo.getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
this.checkMaterial(cartGoodsList);
// 多规格的sku商品计算包装费
//this.checkSkuOnVersion(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo);
// 重新存储最新购物车
......@@ -1647,22 +1633,14 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
}
public void checkMaterial(List<ProductBeanDTO> productBeanListSpuClass, CartGoods cartGoods) {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
if (CollectionUtils.isEmpty(productBeanListSpuClass.get(0).getAdditionalGroupList())) {
/**
*用商品行信息来识别加料信息是否有效
* @param allCartGoodsList
*/
public void checkMaterial(List<CartGoods> allCartGoodsList) {
if (CollectionUtils.isEmpty(allCartGoodsList)) return;
if(allCartGoodsList.stream().filter(e->e.getGoodsType().equals(GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType())).count()>0) {
throw new ServiceException(ResponseResult.SHOPPING_CART_MATERIAL_ERROR);
}
Boolean tips = false;
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
for (ProductBeanDTO.ProductGroupType productGroupType : productBeanListSpuClass.get(0).getAdditionalGroupList()) {
long l = productGroupType.getGroupDetail().stream().filter(e -> e.getProductId().equals(materialGoods.getSpuId())).count();
if (l == 0) {
tips = true;
break;
}
}
if (tips) break;
}
if (tips) throw new ServiceException(ResponseResult.SHOPPING_CART_MATERIAL_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