Commit 59b98e22 by yu.sun

sunyu::update::可选商品加料

parent 7ea84534
......@@ -726,7 +726,7 @@ public class ShoppingCartConvertAdapter {
comboxGoods.setTaxId(isComboxGoods ? (StringUtils.isNotEmpty(productComboType.getTaxId()) ? productComboType.getTaxId() : "") :
(StringUtils.isNotEmpty(groupDetailType.getTaxId()) ? groupDetailType.getTaxId() : ""));
// TODO: 2020/10/22 套餐内可选商品加料,暂无
//2020/10/22 套餐内可选商品加料,暂无
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> productMaterialList = new ArrayList<>();
com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods();
......@@ -735,6 +735,89 @@ public class ShoppingCartConvertAdapter {
}
}
/**
* 更新套餐可选商品加料信息
*/
private void updateComboxGoodsInfoForMCoffeeProductGroup(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods, ProductTypeBeanDTO parentProductBean,
Map<String,ProductTypeBeanDTO> subProductTypeMap,
boolean isComboxGoods) {
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<>();
// subProductTypeMap.get(comboxGoods.getSkuId()).getAdditionalGroupList().stream().map(t->t.getGroupDetail()).forEach(group->group.forEach(detailType-> map.put(detailType.getProductId(),detailType)));
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())){
Map<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> materialMap = new HashMap<>();
subProductTypeMap.get(comboxGoods.getSkuId()).getAdditionalGroupList().stream().map(t->t.getGroupDetail()).forEach(group->group.forEach(detailType-> materialMap.put(detailType.getProductId(),detailType)));
List<ProductTypeBeanDTO.ProductGroupType.GroupDetailType> materialList = new ArrayList<>();
comboxGoods.getProductMaterialList().stream().forEach(materialGood -> materialList.add(materialMap.get(materialGood.getSpuId())));
List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> productMaterialList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(materialList)){
for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType detailType : materialList) {
com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods();
materialGoods.setCustomerCode(StringUtils.isNotEmpty(detailType.getCustomerCode()) ?
detailType.getCustomerCode() : "");
materialGoods.setAmount(null != detailType.getMarkUpPrice() ?
detailType.getMarkUpPrice().longValue() : 0);
materialGoods.setFinalPrice(null != detailType.getProductFinalPrice() ?
detailType.getProductFinalPrice().longValue() : 0);
materialGoods.setSpuName(StringUtils.isNotEmpty(detailType.getProductName()) ?
detailType.getProductName() : "");
materialGoods.setSpuId(StringUtils.isNotEmpty(detailType.getProductId()) ?
detailType.getProductId() : "");
materialGoods.setOriginalPrice(null != detailType.getProductFinalPrice() ?
detailType.getProductFinalPrice().longValue() : 0);
materialGoods.setOriginalAmount(null != detailType.getProductFinalPrice() ?
detailType.getProductFinalPrice().longValue() : 0);
productMaterialList.add(materialGoods);
}
}
comboxGoods.setProductMaterialList(productMaterialList);
}
}
private Map<String, String> getAttributesNew(List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.CartGoodsExtra> extra) {
if (CollectionUtils.isEmpty(extra)) {
return new HashMap<>();
......@@ -864,7 +947,9 @@ public class ShoppingCartConvertAdapter {
}
}else {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
// updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
updateComboxGoodsInfoForMCoffeeProductGroup(productGroup,spuProduct,subProductTypeMap
,false);
}
}
}
......
......@@ -1392,6 +1392,7 @@ public class ShoppingCartMCoffeeServiceImpl {
CartGoods.MaterialGoods materialGoods = new CartGoods.MaterialGoods();
materialGoods.setSpuId(materialRequestVo.getSpuId());
materialGoods.setGroupId(materialRequestVo.getGroupId());
materialGoods.setCustomerCode(materialRequestVo.getCustomerCode());
comboxMaterialGoodsList.add(materialGoods);
}
productCombox.setProductMaterialList(comboxMaterialGoodsList);
......
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