Commit c9025fff by 徐康

套餐固定搭配单规格加料

parent 8a0532a2
...@@ -755,6 +755,83 @@ public class ShoppingCartConvertAdapter { ...@@ -755,6 +755,83 @@ public class ShoppingCartConvertAdapter {
} }
} }
/**
* 更新套餐固定商品、可选商品信息
*
* @param comboxGoods 固定商品或可选商品
* @param parentProductBean 套餐服商品
* @param isComboxGoods 是否是固定商品
* @return
*/
private void updateComboxGoodsInfoForMCoffeeWithMaterial(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods, ProductTypeBeanDTO parentProductBean, boolean isComboxGoods, ProductTypeBeanDTO productTypeBeanDTO) {
if("0".equals(comboxGoods.getGoodsId())){
return;
}
ProductTypeBeanDTO.ProductComboType productComboType = new ProductTypeBeanDTO.ProductComboType();
ProductTypeBeanDTO.ProductGroupType.GroupDetailType groupDetailType = new ProductTypeBeanDTO.ProductGroupType.GroupDetailType();
if (isComboxGoods) {
productComboType = parentProductBean.getProductComboList().stream().filter(p -> ObjectUtils.equals(comboxGoods.getGoodsId(), p.getProductId())).findFirst().orElse(new ProductTypeBeanDTO.ProductComboType());
} else {
Map<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> map = new HashMap<>();
parentProductBean.getProductGroupList().stream().map(t -> t.getGroupDetail()).forEach(group -> group.forEach(detailType -> map.put(detailType.getProductId(), detailType)));
groupDetailType = map.get(comboxGoods.getGoodsId());
}
// 若是固定商品则取商品详情的FinalPrice,若是可选商品则取MarkUpPrice
Long finalPrice = isComboxGoods ? (null != productComboType.getFinalPrice() ? productComboType.getFinalPrice().longValue() : 0L)
: (null != groupDetailType.getMarkUpPrice() ? groupDetailType.getMarkUpPrice().longValue() : 0L);
// 设置商品详情
Map<String, String> attributes = getAttributesNew(comboxGoods.getExtra());
comboxGoods.setSpuId(comboxGoods.getSpuId());
comboxGoods.setName(isComboxGoods ? productComboType.getProductName() : groupDetailType.getProductName());
comboxGoods.setSpuName(comboxGoods.getName());
comboxGoods.setSpecProductId(attributes.get(ATTRIBUTEID));
comboxGoods.setSubName(attributes.get(ATTRIBUTENAME));
comboxGoods.setPic(isComboxGoods ? productComboType.getPicture() : groupDetailType.getPicture());
comboxGoods.setOriginalPrice(isComboxGoods ? (null != productComboType.getFinalPrice() ? productComboType.getFinalPrice().longValue() : 0L)
: (null != groupDetailType.getProductFinalPrice() ? groupDetailType.getProductFinalPrice().longValue() : 0L));
comboxGoods.setOriginalAmount(comboxGoods.getOriginalPrice() * comboxGoods.getQty());
comboxGoods.setAmount(finalPrice * comboxGoods.getQty());
comboxGoods.setCustomerCode(isComboxGoods ? (StringUtils.isNotEmpty(productComboType.getCustomerCode()) ? productComboType.getCustomerCode() : "")
: (StringUtils.isNotEmpty(groupDetailType.getCustomerCode()) ? groupDetailType.getCustomerCode() : ""));
comboxGoods.setFinalPrice(finalPrice);
comboxGoods.setWeightType(isComboxGoods ? CommonsConstant.WEIGHT_PRODUCT.equals(productComboType.getWeightType()) : CommonsConstant.WEIGHT_PRODUCT.equals(groupDetailType.getWeightType()));
comboxGoods.setUnit(isComboxGoods ? (StringUtils.isNotEmpty(productComboType.getUnit()) ? productComboType.getUnit() :"") :
(StringUtils.isNotEmpty(groupDetailType.getUnit()) ? groupDetailType.getUnit() : ""));
comboxGoods.setWeight(isComboxGoods ? (null == productComboType.getWeight() ? 0 : productComboType.getWeight()) :
(null == groupDetailType.getWeight() ? 0:groupDetailType.getWeight()));
comboxGoods.setTax(isComboxGoods ? (null == productComboType.getTax() ? 0 : productComboType.getTax())
: (null == groupDetailType.getTax() ? 0 : groupDetailType.getTax()));
comboxGoods.setTaxId(isComboxGoods ? (StringUtils.isNotEmpty(productComboType.getTaxId()) ? productComboType.getTaxId() : "") :
(StringUtils.isNotEmpty(groupDetailType.getTaxId()) ? groupDetailType.getTaxId() : ""));
//2020/10/22 套餐内可选商品加料,暂无
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
if(CollectionUtils.isNotEmpty(productTypeBeanDTO.getAdditionalGroupList())) {
List<ProductTypeBeanDTO.ProductGroupType> productGroupTypes = productTypeBeanDTO.getAdditionalGroupList();
Map<String, List<ProductTypeBeanDTO.ProductGroupType.GroupDetailType>> productGroupTypeMap = productGroupTypes.stream().collect(
Collectors.toMap(ProductTypeBeanDTO.ProductGroupType::getGroupCode,
ProductTypeBeanDTO.ProductGroupType::getGroupDetail,
(k1,k2) -> k1));
comboxGoods.getProductMaterialList().stream().forEach(o -> {
List<ProductTypeBeanDTO.ProductGroupType.GroupDetailType> list = productGroupTypeMap.get(o.getCustomerCode().split("_")[0]);
for(ProductTypeBeanDTO.ProductGroupType.GroupDetailType groupDetailType1 : list) {
if (groupDetailType1.getProductId() == o.getSpuId()) {
o.setAmount(groupDetailType1.getProductFinalPrice().longValue());
o.setFinalPrice(groupDetailType1.getProductFinalPrice().longValue());
o.setOriginalAmount(groupDetailType1.getProductFinalPrice().longValue());
o.setOriginalPrice(groupDetailType1.getProductFinalPrice().longValue());
o.setSpuName(groupDetailType1.getProductName());
break;
}
}
});
} else {
comboxGoods.setProductMaterialList(new ArrayList<>());
}
}
}
/** /**
* 更新套餐可选商品加料信息 * 更新套餐可选商品加料信息
...@@ -955,8 +1032,7 @@ public class ShoppingCartConvertAdapter { ...@@ -955,8 +1032,7 @@ public class ShoppingCartConvertAdapter {
updateComboxGoodsInfoFor(productCombo, productBeanDTO, true); updateComboxGoodsInfoFor(productCombo, productBeanDTO, true);
}else { }else {
//套餐子商品为单品 //套餐子商品为单品
// updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true); updateComboxGoodsInfoForMCoffeeWithMaterial(productCombo, spuProduct, true, subProductTypeMap.get(productCombo.getGoodsId()));
updateComboxGoodsInfoFor(productCombo, spuProduct, true);
} }
} }
} }
...@@ -970,9 +1046,7 @@ public class ShoppingCartConvertAdapter { ...@@ -970,9 +1046,7 @@ public class ShoppingCartConvertAdapter {
} }
}else { }else {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) { for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
// updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false); updateComboxGoodsInfoForMCoffeeProductGroup(productGroup,spuProduct,subProductTypeMap,false);
updateComboxGoodsInfoForMCoffeeProductGroup(productGroup,spuProduct,subProductTypeMap
,false);
} }
} }
} }
......
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