Commit 9a5d07bd by 孙昱

sunyu::update::fix bug about groupProduct add Material

parent 2a6aa1ac
......@@ -612,10 +612,10 @@ public class ShoppingCartConvertAdapter {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productCombo : cartGoods.getProductComboList()){
//套餐子商品多规格商品
if(productCombo.getSpuId() == null && !productCombo.getSkuId().equals(productCombo.getSpuId()) ){
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true);
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true,null);
}else {
//套餐子商品为单品
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true);
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true,null);
}
}
}
......@@ -625,11 +625,11 @@ public class ShoppingCartConvertAdapter {
//套餐子商品多规格商品
if(comboxGoods.getSpuId() == null && !comboxGoods.getSkuId().equals(comboxGoods.getSpuId()) ){
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false,null);
}
}else {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false,null);
}
}
}
......@@ -674,7 +674,8 @@ public class ShoppingCartConvertAdapter {
* @param isComboxGoods 是否是固定商品
* @return
*/
private void updateComboxGoodsInfoForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods, ProductTypeBeanDTO parentProductBean, boolean isComboxGoods) {
private void updateComboxGoodsInfoForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods,
ProductTypeBeanDTO parentProductBean, boolean isComboxGoods,Map<String,ProductTypeBeanDTO> subProductTypeMap) {
if("0".equals(comboxGoods.getGoodsId())){
return;
}
......@@ -720,24 +721,7 @@ public class ShoppingCartConvertAdapter {
//2020/12/10 套餐内可选商品加料
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
if (CollectionUtils.isNotEmpty(parentProductBean.getAdditionalGroupList())) {
List<ProductTypeBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>();
for (ProductTypeBeanDTO.ProductGroupType productGroupType : parentProductBean.getAdditionalGroupList()){
groupDetail.addAll(productGroupType.getGroupDetail());
}
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods productMaterial :comboxGoods.getProductMaterialList()){
for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType detailType : groupDetail){
if(detailType.getProductId().equals(productMaterial.getSpuId())){
productMaterial.setSpuId(detailType.getProductId());
productMaterial.setAmount(detailType.getProductFinalPrice().longValue());
productMaterial.setFinalPrice(detailType.getProductFinalPrice().longValue());
productMaterial.setOriginalAmount(detailType.getProductFinalPrice().longValue());
productMaterial.setOriginalPrice(detailType.getProductFinalPrice().longValue());
productMaterial.setSpuName(detailType.getProductName());
}
}
}
}
resolveMaterialForProductGroup(comboxGoods,subProductTypeMap);
}
}
......@@ -811,19 +795,17 @@ public class ShoppingCartConvertAdapter {
/**
* 可选商品组加料处理逻辑
* @param cartGoods
* @param spuProduct
* @param comboxGoods
* @param subProductTypeMap
*/
private void resolveMaterialForProductGroup(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, ProductTypeBeanDTO spuProduct,Map<String,ProductTypeBeanDTO> subProductTypeMap){
private void resolveMaterialForProductGroup(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods, Map<String,ProductTypeBeanDTO> subProductTypeMap){
//可选商品加料信息提取
List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> groupProductMaterial = new ArrayList<>();
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods : cartGoods.getProductGroupList()) {
groupProductMaterial.addAll(comboxGoods.getProductMaterialList());
}
groupProductMaterial.addAll(comboxGoods.getProductMaterialList());
if (null != subProductTypeMap && !subProductTypeMap.isEmpty()) {
ProductTypeBeanDTO productTypeBeanDTO = subProductTypeMap.get(cartGoods);
ProductTypeBeanDTO productTypeBeanDTO = subProductTypeMap.get(comboxGoods.getSkuId());
if (CollectionUtils.isNotEmpty(productTypeBeanDTO.getAdditionalGroupList())){
List<String> materialSpu = new ArrayList<>();
HashMap<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>();
......@@ -840,15 +822,15 @@ public class ShoppingCartConvertAdapter {
//加车小料和商品小料没有交集则提示商品信息有异常
if (CollectionUtils.isEmpty(groupProductMaterial.stream().filter(e -> materialSpu.contains(e.getSpuId())).collect(Collectors.toList()))) {
cartGoods.setGoodsType(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType());
cartGoods.setProductMaterialList(new ArrayList<>());
// comboxGoods.setGoodsType(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType());
comboxGoods.setProductMaterialList(new ArrayList<>());
return;
}
ArrayList<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> materialGoodsList = new ArrayList<>();
Long materialAmount = 0L;
Long originalMaterAmount = 0L;
String materialSubName = cartGoods.getSubName();
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
String materialSubName = comboxGoods.getSubName();
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods : comboxGoods.getProductMaterialList()) {
ProductTypeBeanDTO.ProductGroupType.GroupDetailType detail = materialHash.get(materialGoods.getSpuId());
if (detail == null) continue;
com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods material = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods();
......@@ -856,27 +838,27 @@ public class ShoppingCartConvertAdapter {
material.setSpuId(detail.getProductId());
//行单价 \ 行总价
material.setFinalPrice(detail.getProductFinalPrice().longValue());
material.setAmount(detail.getProductFinalPrice().longValue() * cartGoods.getQty());
material.setAmount(detail.getProductFinalPrice().longValue() * comboxGoods.getQty());
//原行单价*数量
material.setOriginalAmount(detail.getProductFinalPrice().longValue() * cartGoods.getQty());
material.setOriginalAmount(detail.getProductFinalPrice().longValue() * comboxGoods.getQty());
material.setOriginalPrice(detail.getProductFinalPrice().longValue());
material.setCustomerCode(materialGoods.getCustomerCode());
materialGoodsList.add(material);
materialAmount += detail.getProductFinalPrice().longValue() * cartGoods.getQty();
originalMaterAmount += detail.getProductFinalPrice().longValue() * cartGoods.getQty();
materialAmount += detail.getProductFinalPrice().longValue() * comboxGoods.getQty();
originalMaterAmount += detail.getProductFinalPrice().longValue() * comboxGoods.getQty();
;
materialSubName = materialSubName + "/" + detail.getProductName();
}
//设置购物车行记录
cartGoods.setProductMaterialList(materialGoodsList);
comboxGoods.setProductMaterialList(materialGoodsList);
//加料行记录现价总价
cartGoods.setMaterialAmount(materialAmount);
comboxGoods.setMaterialAmount(materialAmount);
//加料行记录原价总价
cartGoods.setOriginalMaterialAmount(originalMaterAmount);
// comboxGoods.setOriginalMaterialAmount(originalMaterAmount);
}else{
cartGoods.setGoodsType(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType());
cartGoods.setProductMaterialList(new ArrayList<>());
// comboxGoods.setGoodsType(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType());
comboxGoods.setProductMaterialList(new ArrayList<>());
return;
}
}
......@@ -929,7 +911,7 @@ public class ShoppingCartConvertAdapter {
updateComboxGoodsInfoFor(productCombo, productBeanDTO, true);
}else {
//套餐子商品为单品
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true);
updateComboxGoodsInfoForMCoffee(productCombo, spuProduct, true,null);
}
}
}
......@@ -939,11 +921,11 @@ public class ShoppingCartConvertAdapter {
//套餐子商品多规格商品
if(comboxGoods.getSpuId() != null && !comboxGoods.getSkuId().equals(comboxGoods.getSpuId()) ){
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false,subProductTypeMap);
}
}else {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productGroup : cartGoods.getProductGroupList()) {
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false,subProductTypeMap);
}
}
}
......
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