Commit 7aefb02a by yu.sun

sunyu::update::productGroup material price calculate

parent 28acd1fa
...@@ -751,7 +751,6 @@ public class ShoppingCartConvertAdapter { ...@@ -751,7 +751,6 @@ public class ShoppingCartConvertAdapter {
productComboType = parentProductBean.getProductComboList().stream().filter(p -> ObjectUtils.equals(comboxGoods.getGoodsId(), p.getProductId())).findFirst().orElse(new ProductTypeBeanDTO.ProductComboType()); productComboType = parentProductBean.getProductComboList().stream().filter(p -> ObjectUtils.equals(comboxGoods.getGoodsId(), p.getProductId())).findFirst().orElse(new ProductTypeBeanDTO.ProductComboType());
} else { } else {
Map<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> map = new HashMap<>(); 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))); parentProductBean.getProductGroupList().stream().map(t -> t.getGroupDetail()).forEach(group -> group.forEach(detailType -> map.put(detailType.getProductId(), detailType)));
groupDetailType = map.get(comboxGoods.getGoodsId()); groupDetailType = map.get(comboxGoods.getGoodsId());
} }
...@@ -793,26 +792,26 @@ public class ShoppingCartConvertAdapter { ...@@ -793,26 +792,26 @@ public class ShoppingCartConvertAdapter {
comboxGoods.getProductMaterialList().stream().forEach(materialGood -> materialList.add(materialMap.get(materialGood.getSpuId()))); comboxGoods.getProductMaterialList().stream().forEach(materialGood -> materialList.add(materialMap.get(materialGood.getSpuId())));
List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> productMaterialList = new ArrayList<>(); List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> productMaterialList = new ArrayList<>();
Long materialAmount = 0L;
Long originalMaterAmount = 0L;
if (CollectionUtils.isNotEmpty(materialList)){ if (CollectionUtils.isNotEmpty(materialList)){
for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType detailType : 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(); 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()) ? materialGoods.setCustomerCode(StringUtils.isNotEmpty(detailType.getCustomerCode()) ? detailType.getCustomerCode() : "");
detailType.getCustomerCode() : ""); materialGoods.setAmount(null != detailType.getMarkUpPrice() ? detailType.getMarkUpPrice().longValue() : 0);
materialGoods.setAmount(null != detailType.getMarkUpPrice() ? materialGoods.setFinalPrice(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() : 0);
detailType.getMarkUpPrice().longValue() : 0); materialGoods.setSpuName(StringUtils.isNotEmpty(detailType.getProductName()) ? detailType.getProductName() : "");
materialGoods.setFinalPrice(null != detailType.getProductFinalPrice() ? materialGoods.setSpuId(StringUtils.isNotEmpty(detailType.getProductId()) ? detailType.getProductId() : "");
detailType.getProductFinalPrice().longValue() : 0); materialGoods.setOriginalPrice(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() : 0);
materialGoods.setSpuName(StringUtils.isNotEmpty(detailType.getProductName()) ? materialGoods.setOriginalAmount(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() * comboxGoods.getQty() : 0);
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); productMaterialList.add(materialGoods);
materialAmount += detailType.getProductFinalPrice().longValue() * comboxGoods.getQty();
originalMaterAmount += detailType.getProductFinalPrice().longValue() * comboxGoods.getQty();
} }
} }
comboxGoods.setMaterialAmount(materialAmount);
comboxGoods.setProductMaterialList(productMaterialList); comboxGoods.setProductMaterialList(productMaterialList);
} }
} }
...@@ -832,7 +831,9 @@ public class ShoppingCartConvertAdapter { ...@@ -832,7 +831,9 @@ public class ShoppingCartConvertAdapter {
private void checkMaterialProductForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, ProductTypeBeanDTO spuProduct) { private void checkMaterialProductForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, ProductTypeBeanDTO spuProduct) {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return; if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) {
return;
}
//加料信息为空 //加料信息为空
if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) { if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) {
checkSkuMaterialProductForMccafe(cartGoods,spuProduct); checkSkuMaterialProductForMccafe(cartGoods,spuProduct);
...@@ -861,7 +862,9 @@ public class ShoppingCartConvertAdapter { ...@@ -861,7 +862,9 @@ public class ShoppingCartConvertAdapter {
String materialSubName = cartGoods.getSubName(); String materialSubName = cartGoods.getSubName();
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) { for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ProductTypeBeanDTO.ProductGroupType.GroupDetailType detail = materialHash.get(materialGoods.getSpuId()); ProductTypeBeanDTO.ProductGroupType.GroupDetailType detail = materialHash.get(materialGoods.getSpuId());
if (detail == null) continue; if (detail == null) {
continue;
}
com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods material = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods(); com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods material = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods();
material.setSpuName(detail.getProductName()); material.setSpuName(detail.getProductName());
material.setSpuId(detail.getProductId()); material.setSpuId(detail.getProductId());
...@@ -953,6 +956,11 @@ public class ShoppingCartConvertAdapter { ...@@ -953,6 +956,11 @@ public class ShoppingCartConvertAdapter {
} }
} }
} }
//可选商品组加料价格加到购物车行记录上
Long materialAmount =
cartGoods.getProductGroupList().stream().mapToLong(group -> (null != group.getMaterialAmount() ? group.getMaterialAmount() : 0)).sum();
cartGoods.setOriginalMaterialAmount(materialAmount);
cartGoods.setMaterialAmount(materialAmount);
} }
} }
//更新当前商品行价格 //更新当前商品行价格
...@@ -980,12 +988,16 @@ public class ShoppingCartConvertAdapter { ...@@ -980,12 +988,16 @@ public class ShoppingCartConvertAdapter {
cartGoods.setWeight(isSkuProduct ? skuProduct.getWeight() : spuProduct.getWeight()); cartGoods.setWeight(isSkuProduct ? skuProduct.getWeight() : spuProduct.getWeight());
cartGoods.setUnit(isSkuProduct ? skuProduct.getUnit() : spuProduct.getUnit()); cartGoods.setUnit(isSkuProduct ? skuProduct.getUnit() : spuProduct.getUnit());
cartGoods.setWeightType(CommonsConstant.WEIGHT_PRODUCT.equals(spuProduct.getWeightType())); cartGoods.setWeightType(CommonsConstant.WEIGHT_PRODUCT.equals(spuProduct.getWeightType()));
if (null == cartGoods.getMaterialAmount()) {
cartGoods.setMaterialAmount(0L); cartGoods.setMaterialAmount(0L);
}
if (null == cartGoods.getOriginalMaterialAmount()) {
cartGoods.setOriginalMaterialAmount(0L); cartGoods.setOriginalMaterialAmount(0L);
}
// todo 设置加料 // todo 设置加料
this.checkMaterialProductForMCoffee(cartGoods, spuProduct); this.checkMaterialProductForMCoffee(cartGoods, spuProduct);
} catch (Exception ex) { } catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
ErrorLog.infoConvertJson(this.getClass(), "updateCartGoodsInfoForMCoffee_Error", ex); ErrorLog.infoConvertJson(this.getClass(), "updateCartGoodsInfoForMCoffee_Error", ex);
cartGoods.setCartGoodsUid(null); cartGoods.setCartGoodsUid(null);
} }
......
...@@ -92,6 +92,21 @@ public class SetMealCalculation { ...@@ -92,6 +92,21 @@ public class SetMealCalculation {
} }
} }
//套餐可选商品加料
if(CollectionUtils.isNotEmpty(cartGoods.getProductGroupList())){
for (CartGoods.ComboxGoods comboxGoods : cartGoods.getProductGroupList()){
Long productGroupmaterialPrice = 0L;
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods materialGoods : comboxGoods.getProductMaterialList()){
productGroupmaterialPrice+= null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice() * cartGoods.getQty() : 0;
}
}
comboxGoods.setAmount((null == comboxGoods.getAmount() ? 0 :
comboxGoods.getAmount())+productGroupmaterialPrice);
materialPrice = materialPrice + productGroupmaterialPrice;
}
}
Long amount = null != cartGoods.getFinalPrice() ? cartGoods.getFinalPrice()*cartGoods.getQty() + productGroupTotalAmount + materialPrice : Long amount = null != cartGoods.getFinalPrice() ? cartGoods.getFinalPrice()*cartGoods.getQty() + productGroupTotalAmount + materialPrice :
productGroupTotalAmount + productComboTotalAmount + materialPrice; productGroupTotalAmount + productComboTotalAmount + materialPrice;
......
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