Commit fabd82a1 by 孙昱

Merge branch 'feature/20201125_多规格商品下添加单规格商品_yu.sun' into feature/20201210_可选商品加料需求_yu.sun

parents 1b122167 372d54c7
# Created by .ignore support plugin (hsz.mobi) # Created by .ignore support plugin (hsz.mobi)
.gitignore .gitignore
.idea/ .idea/
.DS_Store
assortment-ordercenter-sdk/assortment-ordercenter-sdk.iml assortment-ordercenter-sdk/assortment-ordercenter-sdk.iml
assortment-ordercenter-sdk/target/ assortment-ordercenter-sdk/target/
assortment-shoppingcart-sdk/assortment-shoppingcart-sdk.iml assortment-shoppingcart-sdk/assortment-shoppingcart-sdk.iml
......
...@@ -15,10 +15,7 @@ package cn.freemud.adapter; ...@@ -15,10 +15,7 @@ package cn.freemud.adapter;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto; import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.openplatform.WeixinProductRequestDto; import cn.freemud.entities.dto.openplatform.WeixinProductRequestDto;
import cn.freemud.entities.dto.product.ProductAttributeValueType; import cn.freemud.entities.dto.product.*;
import cn.freemud.entities.dto.product.ValidateShopProductRequest;
import cn.freemud.entities.dto.product.ValidateShopProductType;
import cn.freemud.entities.dto.product.ValidateSkuProductType;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityTypeEnum; import cn.freemud.enums.ActivityTypeEnum;
...@@ -292,7 +289,7 @@ public class ShoppingCartConvertAdapter { ...@@ -292,7 +289,7 @@ public class ShoppingCartConvertAdapter {
ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods goods = new ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods(); ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods goods = new ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods();
goods.setSpuId(materialGoods.getSpuId()); goods.setSpuId(materialGoods.getSpuId());
goods.setSpuName(materialGoods.getSpuName()); goods.setSpuName(materialGoods.getSpuName());
goods.setOriginalPrice(materialGoods.getOriginalPrice()); goods.setOriginalPrice(null != materialGoods.getOriginalPrice() ? materialGoods.getOriginalPrice() : 0);
goods.setSalePrice(materialGoods.getFinalPrice()); goods.setSalePrice(materialGoods.getFinalPrice());
goods.setQty(cartGoods.getQty()); goods.setQty(cartGoods.getQty());
goods.setTotalDiscountAmount(0); goods.setTotalDiscountAmount(0);
...@@ -565,18 +562,18 @@ public class ShoppingCartConvertAdapter { ...@@ -565,18 +562,18 @@ public class ShoppingCartConvertAdapter {
* @param cartGoods 当前购物车商品行 * @param cartGoods 当前购物车商品行
* @param productBeans 购物车中所有的productId对应的商品详情 * @param productBeans 购物车中所有的productId对应的商品详情
*/ */
public void updateCartGoodsInfoForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, List<ProductBeanDTO> productBeans) { public void updateCartGoodsInfoForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, List<ProductTypeBeanDTO> productBeans) {
try { try {
Optional<ProductBeanDTO> firstProduct = productBeans.stream().filter(p -> ObjectUtils.equals(p.getPid(), cartGoods.getSpuId())).findFirst(); Optional<ProductTypeBeanDTO> firstProduct = productBeans.stream().filter(p -> ObjectUtils.equals(p.getPid(), cartGoods.getSpuId())).findFirst();
if (!firstProduct.isPresent()) { if (!firstProduct.isPresent()) {
return; return;
} }
ProductBeanDTO spuProduct = firstProduct.get(); ProductTypeBeanDTO spuProduct = firstProduct.get();
//是否是sku商品 //是否是sku商品
boolean isSkuProduct = ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.SKU_GOODS.getGoodsType(), cartGoods.getGoodsType()); boolean isSkuProduct = ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.SKU_GOODS.getGoodsType(), cartGoods.getGoodsType());
// 如果是套餐商品,更新套餐内固定商品&可选商品的详细信息 // 如果是套餐商品,更新套餐内固定商品&可选商品的详细信息
boolean isSetMealProduct = ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.ProductType.SetMeal.getCode(), spuProduct.getType()) || ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.ProductType.IncreasedPackage.getCode(), spuProduct.getType()); boolean isSetMealProduct = ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.ProductType.SetMeal.getCode(), spuProduct.getType()) || ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.ProductType.IncreasedPackage.getCode(), spuProduct.getType());
ProductBeanDTO.SkuProductBean skuProduct = isSkuProduct ? spuProduct.getSkuList().stream().filter(p -> ObjectUtils.equals(cartGoods.getSkuId(), p.getSkuId())).findFirst().get() : null; ProductTypeBeanDTO.SkuProductBean skuProduct = isSkuProduct ? spuProduct.getSkuList().stream().filter(p -> ObjectUtils.equals(cartGoods.getSkuId(), p.getSkuId())).findFirst().get() : null;
Map<String, String> attributes = getAttributesNew(cartGoods.getExtra()); Map<String, String> attributes = getAttributesNew(cartGoods.getExtra());
if(!"早餐啡常搭".equals(cartGoods.getName()) && !"早餐啡常搭".equals(cartGoods.getSkuName()) && !"早餐啡常搭".equals(cartGoods.getSpuName()) if(!"早餐啡常搭".equals(cartGoods.getName()) && !"早餐啡常搭".equals(cartGoods.getSkuName()) && !"早餐啡常搭".equals(cartGoods.getSpuName())
...@@ -669,16 +666,16 @@ public class ShoppingCartConvertAdapter { ...@@ -669,16 +666,16 @@ public class ShoppingCartConvertAdapter {
* @param isComboxGoods 是否是固定商品 * @param isComboxGoods 是否是固定商品
* @return * @return
*/ */
private void updateComboxGoodsInfoForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods, ProductBeanDTO parentProductBean, boolean isComboxGoods) { private void updateComboxGoodsInfoForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods, ProductTypeBeanDTO parentProductBean, boolean isComboxGoods) {
if("0".equals(comboxGoods.getGoodsId())){ if("0".equals(comboxGoods.getGoodsId())){
return; return;
} }
ProductBeanDTO.ProductComboType productComboType = new ProductBeanDTO.ProductComboType(); ProductTypeBeanDTO.ProductComboType productComboType = new ProductTypeBeanDTO.ProductComboType();
ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType = new ProductBeanDTO.ProductGroupType.GroupDetailType(); ProductTypeBeanDTO.ProductGroupType.GroupDetailType groupDetailType = new ProductTypeBeanDTO.ProductGroupType.GroupDetailType();
if (isComboxGoods) { if (isComboxGoods) {
productComboType = parentProductBean.getProductComboList().stream().filter(p -> ObjectUtils.equals(comboxGoods.getGoodsId(), p.getProductId())).findFirst().orElse(new ProductBeanDTO.ProductComboType()); productComboType = parentProductBean.getProductComboList().stream().filter(p -> ObjectUtils.equals(comboxGoods.getGoodsId(), p.getProductId())).findFirst().orElse(new ProductTypeBeanDTO.ProductComboType());
} else { } else {
Map<String, ProductBeanDTO.ProductGroupType.GroupDetailType> map = new HashMap<>(); 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))); 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());
} }
...@@ -739,23 +736,22 @@ public class ShoppingCartConvertAdapter { ...@@ -739,23 +736,22 @@ public class ShoppingCartConvertAdapter {
return result; return result;
} }
private void checkMaterialProductForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, ProductBeanDTO 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())) {
cartGoods.setGoodsType(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType()); checkSkuMaterialProductForMccafe(cartGoods,spuProduct);
cartGoods.setProductMaterialList(new ArrayList<>());
return; return;
} }
//提取加料信息 //提取加料信息
List<String> materialSpu = new ArrayList<>(); List<String> materialSpu = new ArrayList<>();
List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>(); List<ProductTypeBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>();
for (ProductBeanDTO.ProductGroupType productGroupType : spuProduct.getAdditionalGroupList()){ for (ProductTypeBeanDTO.ProductGroupType productGroupType : spuProduct.getAdditionalGroupList()){
groupDetail.addAll(productGroupType.getGroupDetail()); groupDetail.addAll(productGroupType.getGroupDetail());
} }
HashMap<String, ProductBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>(); HashMap<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>();
for (ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail) { for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail) {
materialHash.put(groupDetailType.getProductId(), groupDetailType); materialHash.put(groupDetailType.getProductId(), groupDetailType);
materialSpu.add(groupDetailType.getProductId()); materialSpu.add(groupDetailType.getProductId());
} }
...@@ -770,7 +766,7 @@ public class ShoppingCartConvertAdapter { ...@@ -770,7 +766,7 @@ public class ShoppingCartConvertAdapter {
Long originalMaterAmount = 0L; Long originalMaterAmount = 0L;
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()) {
ProductBeanDTO.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());
...@@ -797,14 +793,14 @@ public class ShoppingCartConvertAdapter { ...@@ -797,14 +793,14 @@ public class ShoppingCartConvertAdapter {
} }
public void updateCartGoodsInfo(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, ProductBeanDTO spuProduct,Map<String,ProductBeanDTO> subProductTypeMap) { public void updateCartGoodsInfo(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, ProductTypeBeanDTO spuProduct,Map<String,ProductTypeBeanDTO> subProductTypeMap) {
try { try {
//是否是sku商品 //是否是sku商品
boolean isSkuProduct = ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.SKU_GOODS.getGoodsType(), cartGoods.getGoodsType()) boolean isSkuProduct = ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.SKU_GOODS.getGoodsType(), cartGoods.getGoodsType())
|| !ObjectUtils.equals(cartGoods.getSpuId(),cartGoods.getSkuId()); || !ObjectUtils.equals(cartGoods.getSpuId(),cartGoods.getSkuId());
// 如果是套餐商品,更新套餐内固定商品&可选商品的详细信息 // 如果是套餐商品,更新套餐内固定商品&可选商品的详细信息
boolean isSetMealProduct = ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.ProductType.SetMeal.getCode(), spuProduct.getType()) || ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.ProductType.IncreasedPackage.getCode(), spuProduct.getType()); boolean isSetMealProduct = ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.ProductType.SetMeal.getCode(), spuProduct.getType()) || ObjectUtils.equals(com.freemud.sdk.api.assortment.shoppingcart.constant.ProductType.IncreasedPackage.getCode(), spuProduct.getType());
ProductBeanDTO.SkuProductBean skuProduct = isSkuProduct ? spuProduct.getSkuList().stream().filter(p -> ObjectUtils.equals(cartGoods.getSkuId(), p.getSkuId())).findFirst().get() : null; ProductTypeBeanDTO.SkuProductBean skuProduct = isSkuProduct ? spuProduct.getSkuList().stream().filter(p -> ObjectUtils.equals(cartGoods.getSkuId(), p.getSkuId())).findFirst().get() : null;
Map<String, String> attributes = getAttributesNew(cartGoods.getExtra()); Map<String, String> attributes = getAttributesNew(cartGoods.getExtra());
if(!"早餐啡常搭".equals(cartGoods.getName()) && !"早餐啡常搭".equals(cartGoods.getSkuName()) && !"早餐啡常搭".equals(cartGoods.getSpuName()) if(!"早餐啡常搭".equals(cartGoods.getName()) && !"早餐啡常搭".equals(cartGoods.getSkuName()) && !"早餐啡常搭".equals(cartGoods.getSpuName())
...@@ -839,7 +835,7 @@ public class ShoppingCartConvertAdapter { ...@@ -839,7 +835,7 @@ public class ShoppingCartConvertAdapter {
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productCombo : cartGoods.getProductComboList()){ for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods productCombo : cartGoods.getProductComboList()){
//套餐子商品多规格商品 //套餐子商品多规格商品
if(productCombo.getSpuId() != null && !productCombo.getSkuId().equals(productCombo.getSpuId()) ){ if(productCombo.getSpuId() != null && !productCombo.getSkuId().equals(productCombo.getSpuId()) ){
ProductBeanDTO productBeanDTO = subProductTypeMap.get(productCombo.getSpuId()); ProductTypeBeanDTO productBeanDTO = subProductTypeMap.get(productCombo.getSpuId());
updateComboxGoodsInfoFor(productCombo, productBeanDTO, true); updateComboxGoodsInfoFor(productCombo, productBeanDTO, true);
}else { }else {
//套餐子商品为单品 //套餐子商品为单品
...@@ -899,12 +895,12 @@ public class ShoppingCartConvertAdapter { ...@@ -899,12 +895,12 @@ public class ShoppingCartConvertAdapter {
} }
private void updateComboxGoodsInfoFor(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods, ProductBeanDTO productBeanDTO, boolean isComboxGoods) { private void updateComboxGoodsInfoFor(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.ComboxGoods comboxGoods, ProductTypeBeanDTO productBeanDTO, boolean isComboxGoods) {
if(CollectionUtils.isEmpty(productBeanDTO.getSkuList())){ if(CollectionUtils.isEmpty(productBeanDTO.getSkuList())){
return; return;
} }
ProductBeanDTO.SkuProductBean comboxGoodsSkuProductBean = null; ProductTypeBeanDTO.SkuProductBean comboxGoodsSkuProductBean = null;
for (ProductBeanDTO.SkuProductBean skuProductBean : productBeanDTO.getSkuList()){ for (ProductTypeBeanDTO.SkuProductBean skuProductBean : productBeanDTO.getSkuList()){
if(comboxGoods.getSkuId().equals(skuProductBean.getSkuId())){ if(comboxGoods.getSkuId().equals(skuProductBean.getSkuId())){
comboxGoodsSkuProductBean = skuProductBean; comboxGoodsSkuProductBean = skuProductBean;
break; break;
...@@ -936,12 +932,30 @@ public class ShoppingCartConvertAdapter { ...@@ -936,12 +932,30 @@ public class ShoppingCartConvertAdapter {
//套餐内商品加料 //套餐内商品加料
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){ if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
if (CollectionUtils.isNotEmpty(productBeanDTO.getAdditionalGroupList())) { if (CollectionUtils.isNotEmpty(productBeanDTO.getAdditionalGroupList())) {
List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>(); List<ProductTypeBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>();
for (ProductBeanDTO.ProductGroupType productGroupType : productBeanDTO.getAdditionalGroupList()){ for (ProductTypeBeanDTO.ProductGroupType productGroupType : productBeanDTO.getAdditionalGroupList()){
groupDetail.addAll(productGroupType.getGroupDetail());
}
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods productMaterial :comboxGoods.getProductMaterialList()){
for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail){
if(groupDetailType.getProductId().equals(productMaterial.getSpuId())){
productMaterial.setSpuId(groupDetailType.getProductId());
productMaterial.setAmount(groupDetailType.getProductFinalPrice().longValue());
productMaterial.setFinalPrice(groupDetailType.getProductFinalPrice().longValue());
productMaterial.setOriginalAmount(groupDetailType.getProductFinalPrice().longValue());
productMaterial.setOriginalPrice(groupDetailType.getProductFinalPrice().longValue());
productMaterial.setSpuName(groupDetailType.getProductName());
}
}
}
}else {
if(CollectionUtils.isNotEmpty(comboxGoodsSkuProductBean.getAdditionalGroupList())){
List<ProductTypeBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>();
for (ProductTypeBeanDTO.ProductGroupType productGroupType : comboxGoodsSkuProductBean.getAdditionalGroupList()){
groupDetail.addAll(productGroupType.getGroupDetail()); groupDetail.addAll(productGroupType.getGroupDetail());
} }
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods productMaterial :comboxGoods.getProductMaterialList()){ for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods productMaterial :comboxGoods.getProductMaterialList()){
for (ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail){ for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail){
if(groupDetailType.getProductId().equals(productMaterial.getSpuId())){ if(groupDetailType.getProductId().equals(productMaterial.getSpuId())){
productMaterial.setSpuId(groupDetailType.getProductId()); productMaterial.setSpuId(groupDetailType.getProductId());
productMaterial.setAmount(groupDetailType.getProductFinalPrice().longValue()); productMaterial.setAmount(groupDetailType.getProductFinalPrice().longValue());
...@@ -952,7 +966,80 @@ public class ShoppingCartConvertAdapter { ...@@ -952,7 +966,80 @@ public class ShoppingCartConvertAdapter {
} }
} }
} }
}else {
//都不存在移除商品
comboxGoods.setProductMaterialList(new ArrayList<>());
}
}
}
}
/**
* 多规格商品下添加单规格作为子商品,校验子商品的加料信息
* @param cartGoods
* @param spuProduct
*/
private void checkSkuMaterialProductForMccafe(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods,ProductTypeBeanDTO spuProduct) {
if (CollectionUtils.isNotEmpty(spuProduct.getSkuList())) {
spuProduct.getSkuList().stream().filter(sku-> sku.getSkuId().equals(cartGoods.getGoodsId())).collect(Collectors.toList()).forEach(
skuProductBean -> {
if (CollectionUtils.isNotEmpty(skuProductBean.getAdditionalGroupList())){
List<String> materialSpu = new ArrayList<>();
HashMap<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>();
for (ProductTypeBeanDTO.ProductGroupType productGroupType : skuProductBean.getAdditionalGroupList()) {
//提取加料信息
List<ProductTypeBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>();
groupDetail.addAll(productGroupType.getGroupDetail());
for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail) {
materialHash.put(groupDetailType.getProductId(), groupDetailType);
materialSpu.add(groupDetailType.getProductId());
}
}
//加车小料和商品小料没有交集则提示商品信息有异常
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList().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<>());
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()) {
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();
material.setSpuName(detail.getProductName());
material.setSpuId(detail.getProductId());
//行单价 \ 行总价
material.setFinalPrice(detail.getProductFinalPrice().longValue());
material.setAmount(detail.getProductFinalPrice().longValue() * cartGoods.getQty());
//原行单价*数量
material.setOriginalAmount(detail.getProductFinalPrice().longValue() * cartGoods.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();
;
materialSubName = materialSubName + "/" + detail.getProductName();
}
//设置购物车行记录
cartGoods.setProductMaterialList(materialGoodsList);
//加料行记录现价总价
cartGoods.setMaterialAmount(materialAmount);
//加料行记录原价总价
cartGoods.setOriginalMaterialAmount(originalMaterAmount);
}else{
cartGoods.setGoodsType(com.freemud.sdk.api.assortment.shoppingcart.constant.GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType());
cartGoods.setProductMaterialList(new ArrayList<>());
return;
}
} }
);
} }
} }
......
package cn.freemud.entities.dto.product;
import lombok.Data;
import java.util.List;
/**
* All rights Reserved, Designed By sunary.site
*
* @version v1.0
* @Title: IntelliJ IDEA
* @Package cn.freemud.entities.dto.product
* @Description: 请简单描述下这个类是做什么用的
* @author: yu.sun
* @date: 2020-11-25 11:51:44
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
*/
@Data
public class ProductTypeBeanDTO {
private String businessNo;
private String barcode;
private String brandId;
private String brandName;
private String category;
private String categoryName;
private String companyId;
private String customerCode;
private String productCode;
private Long finalPrice;
private Integer isSkuProduct;
private String name;
private Long originalPrice;
private Long packPrice;
private String picture;
private String pid;
private String specification;
private Integer status;
private Integer stock;
private Integer stockLimit;
private int type;
private String unit;
private Integer riseSell;
private String rawMaterial;
private Double tax;
private String taxId;
private Integer openMemberDiscount;
private Integer memberDiscount;
private List<ProductAttributeGroupListBean> productAttributeGroupList;
private List<ProductPictureListBean> productPictureList;
private List<SkuProductBean> skuList;
private List<ProductComboType> productComboList;
private List<ProductGroupType> productGroupList;
private List<SkuProductBean.SkuSpecValue> skuSpecValues;
private List<PackageProductTypeDto> packageProductTypes;
private List<ProductGroupType> additionalGroupList;
private List<ProductComboDetailTypeDto> productComboInfos;
private Integer isDishware;
private Integer weightType;
private Double weight;
public Integer getMemberDiscountResult() {
return this.openMemberDiscount != null && this.openMemberDiscount == 1 ? this.memberDiscount : 100;
}
public ProductTypeBeanDTO() {
}
@Data
public static class ProductComboDetailTypeDto {
private String productId;
private Integer quantity;
private Integer sequence;
public ProductComboDetailTypeDto() {
}
}
@Data
public static class ProductAttributeGroupListBean {
private String attributeName;
private Integer attributeType;
private List<AttributeValueBean> attributeValues;
public ProductAttributeGroupListBean() {
}
}
@Data
public static class AttributeValueBean {
private String attributeId;
private String attributeValue;
private Long id;
private Long price;
private Integer sequence;
private Integer status;
public AttributeValueBean() {
}
}
@Data
public static class PackageProductTypeDto {
private Long groupId;
private Integer sequence;
public PackageProductTypeDto() {
}
}
@Data
public static class ProductGroupType {
private String pgid;
private String linkId;
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<ProductGroupType.GroupDetailType> groupDetail;
public ProductGroupType() {
}
@Data
public static class GroupDetailType {
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;
protected String productCode;
private Integer weightType;
private Double weight;
private Double tax;
private String taxId;
}
}
@Data
public static class ProductComboType {
private String productId;
private String productName;
private String customerCode;
private Integer originalPrice;
protected Integer finalPrice;
protected Integer packPrice;
private String picture;
protected String unit;
protected String productCode;
private Integer quantity;
private Integer weightType;
private Double weight;
private Double tax;
private String taxId;
}
@Data
public static class ProductPictureListBean {
private String pictureId;
private String productId;
private String sequence;
private String type;
private String url;
@Data
public static class AttributeValueBean {
private String attributeId;
private String attributeValue;
private Long id;
private Long price;
private Integer sequence;
private Integer status;
public AttributeValueBean() {
}
}
}
@Data
public static class ProductLabelNameListBean {
private String id;
private String name;
private String partnerId;
List<?> productList;
private String storeId;
private String type;
public ProductLabelNameListBean() {
}
}
@Data
public static class SpecificationGroupBean {
private String partnerId;
private Integer sequence;
private String specId;
private String specName;
private List<SpecificationGroupBean.SpecValueVo> specValueVos;
public SpecificationGroupBean() {
}
@Data
public static class SpecValueVo {
private Integer sequence;
private String specId;
private String specValue;
private String specValueId;
public SpecValueVo() {
}
}
}
@Data
public static class SkuProductBean {
private String customerCode;
private String productCode;
private Long finalPrice;
private Long originalPrice;
private String productName;
private Integer productType;
private Integer sequence;
private String skuCode;
private String skuId;
private Integer status;
private Integer stockLimit;
private Integer stockQty;
private Long packPrice;
private Integer riseSell;
private String rawMaterial;
private Double tax;
private String taxId;
private List<SkuProductBean.SkuSpecValue> skuSpecValues;
private List<ProductGroupType> additionalGroupList;
private Double weight;
protected String unit;
private Integer openMemberDiscount;
private Integer memberDiscount;
public Integer getMemberDiscountResult() {
return this.openMemberDiscount != null && this.openMemberDiscount == 1 ? this.memberDiscount : 100;
}
public SkuProductBean() {
}
@Data
public static class SkuSpecValue {
private String productId;
private Integer sequence;
private String specId;
private String specName;
private String specValue;
private String specValueId;
public SkuSpecValue() {
}
}
@Data
public static class PackageProductTypeDto {
private Long groupId;
private Integer sequence;
public PackageProductTypeDto() {
}
}
}
}
package cn.freemud.entities.dto.product; package cn.freemud.entities.dto.product;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import lombok.Data; import lombok.Data;
import java.util.Map; import java.util.Map;
...@@ -24,9 +24,9 @@ public class ValiadShopProductResult { ...@@ -24,9 +24,9 @@ public class ValiadShopProductResult {
private String message; private String message;
private String skuId; private String skuId;
private String spuId; private String spuId;
private ProductBeanDTO productType; private ProductTypeBeanDTO productType;
private String uuid; private String uuid;
private Map<String,ProductBeanDTO> subProductTypeMap; private Map<String,ProductTypeBeanDTO> subProductTypeMap;
} }
...@@ -9,6 +9,7 @@ import cn.freemud.constant.ShoppingCartConstant; ...@@ -9,6 +9,7 @@ import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityQueryDto; import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.activity.ActivityQueryResponseDto; import cn.freemud.entities.dto.activity.ActivityQueryResponseDto;
import cn.freemud.entities.dto.product.ProductTypeBeanDTO;
import cn.freemud.entities.dto.product.ValiadShopProductResponse; import cn.freemud.entities.dto.product.ValiadShopProductResponse;
import cn.freemud.entities.dto.product.ValiadShopProductResult; import cn.freemud.entities.dto.product.ValiadShopProductResult;
import cn.freemud.entities.dto.product.ValidateShopProductRequest; import cn.freemud.entities.dto.product.ValidateShopProductRequest;
...@@ -33,6 +34,7 @@ import cn.freemud.service.thirdparty.CustomerApplicationClient; ...@@ -33,6 +34,7 @@ import cn.freemud.service.thirdparty.CustomerApplicationClient;
import cn.freemud.utils.BeanUtil; import cn.freemud.utils.BeanUtil;
import cn.freemud.service.thirdparty.ProductClient; import cn.freemud.service.thirdparty.ProductClient;
import cn.freemud.utils.ResponseUtil; import cn.freemud.utils.ResponseUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare; import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
...@@ -169,7 +171,6 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -169,7 +171,6 @@ public class ShoppingCartMCoffeeServiceImpl {
if (CollectionUtils.isEmpty(oldCartGoodsList)) { if (CollectionUtils.isEmpty(oldCartGoodsList)) {
oldCartGoodsList = new ArrayList<>(); oldCartGoodsList = new ArrayList<>();
} }
//商品券已添加情况校验 //商品券已添加情况校验
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = checkGoodsCoupon(oldCartGoodsList, operationType, couponCode,goodsId, addShoppingCartGoodsRequestVo); List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = checkGoodsCoupon(oldCartGoodsList, operationType, couponCode,goodsId, addShoppingCartGoodsRequestVo);
CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo, goodsId ,vo); CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo, goodsId ,vo);
...@@ -1039,7 +1040,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1039,7 +1040,7 @@ public class ShoppingCartMCoffeeServiceImpl {
newCartGoods.add(addCartGoods); newCartGoods.add(addCartGoods);
//加购商品校验 //加购商品校验
List<CartGoods> allCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, newCartGoods); List<CartGoods> allCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType,shoppingCartGoodsResponseVo, newCartGoods);
List<CartGoods> nowCartGoodsList = new ArrayList<>(); List<CartGoods> nowCartGoodsList = new ArrayList<>();
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1 //判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
...@@ -1482,7 +1483,6 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1482,7 +1483,6 @@ public class ShoppingCartMCoffeeServiceImpl {
try { try {
ValidateShopProductRequest validateShopProductRequest = shoppingCartConvertAdapter.getValidateShopProductRequest(checkCartRequest); ValidateShopProductRequest validateShopProductRequest = shoppingCartConvertAdapter.getValidateShopProductRequest(checkCartRequest);
ProductBaseResponse<ValiadShopProductResponse> valiadResponse = productClient.validateShopProductAboutReason(validateShopProductRequest); ProductBaseResponse<ValiadShopProductResponse> valiadResponse = productClient.validateShopProductAboutReason(validateShopProductRequest);
if (valiadResponse == null || !CartResponseConstant.SUCCESS.getCode().equals(valiadResponse.getErrcode().toString()) || valiadResponse.getData()==null) { if (valiadResponse == null || !CartResponseConstant.SUCCESS.getCode().equals(valiadResponse.getErrcode().toString()) || valiadResponse.getData()==null) {
checkCartRequest.getCartGoodsList().clear(); checkCartRequest.getCartGoodsList().clear();
checkCartRequest.getShoppingCartGoodsResponseVo().setChanged(true); checkCartRequest.getShoppingCartGoodsResponseVo().setChanged(true);
...@@ -1526,7 +1526,8 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1526,7 +1526,8 @@ public class ShoppingCartMCoffeeServiceImpl {
} }
if (PRODUCT_PRICE_CHANGE == validaProduct.getCode()) { if (PRODUCT_PRICE_CHANGE == validaProduct.getCode()) {
changePriceSpu.add(spuName); changePriceSpu.add(spuName);
List<ProductBeanDTO> productList = validateResult.getFailureList().stream().map(ValiadShopProductResult::getProductType).collect(Collectors.toList()); List<ProductTypeBeanDTO> productList =
validateResult.getFailureList().stream().map(ValiadShopProductResult::getProductType).collect(Collectors.toList());
shoppingCartConvertAdapter.updateCartGoodsInfoForMCoffee(cartGoods, productList); shoppingCartConvertAdapter.updateCartGoodsInfoForMCoffee(cartGoods, productList);
} }
if (PRODUCT_GROUP_EMPTY == validaProduct.getCode()) { if (PRODUCT_GROUP_EMPTY == validaProduct.getCode()) {
...@@ -1565,9 +1566,9 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1565,9 +1566,9 @@ public class ShoppingCartMCoffeeServiceImpl {
continue; continue;
} }
for (ValiadShopProductResult valiadShopProductResult : validateResult.getSuccessList()){ for (ValiadShopProductResult valiadShopProductResult : validateResult.getSuccessList()){
ProductBeanDTO productType = valiadShopProductResult.getProductType(); ProductTypeBeanDTO productType = valiadShopProductResult.getProductType();
if(ObjectUtils.equals(productType.getPid(), cartGoods.getSpuId())){ if(ObjectUtils.equals(productType.getPid(), cartGoods.getSpuId())){
Map<String,ProductBeanDTO> subProductTypeMap = valiadShopProductResult.getSubProductTypeMap(); Map<String,ProductTypeBeanDTO> subProductTypeMap = valiadShopProductResult.getSubProductTypeMap();
shoppingCartConvertAdapter.updateCartGoodsInfo(cartGoods, productType,subProductTypeMap); shoppingCartConvertAdapter.updateCartGoodsInfo(cartGoods, productType,subProductTypeMap);
break; break;
} }
......
...@@ -412,7 +412,8 @@ public class CalculationServiceImpl { ...@@ -412,7 +412,8 @@ public class CalculationServiceImpl {
material.setType(2); material.setType(2);
material.setGoodsId(materialGoods.getGoodsId()); material.setGoodsId(materialGoods.getGoodsId());
material.setGoodsQuantity(materialGoods.getQty()); material.setGoodsQuantity(materialGoods.getQty());
material.setOriginalPrice(materialGoods.getFinalPrice()); material.setOriginalPrice(null != materialGoods.getFinalPrice() ?
materialGoods.getFinalPrice() : 0);
materials.add(material); materials.add(material);
} }
} }
...@@ -430,7 +431,8 @@ public class CalculationServiceImpl { ...@@ -430,7 +431,8 @@ public class CalculationServiceImpl {
material.setType(1); material.setType(1);
material.setGoodsId(materialGoods2.getSpuId()); material.setGoodsId(materialGoods2.getSpuId());
material.setGoodsQuantity(1); material.setGoodsQuantity(1);
material.setOriginalPrice(materialGoods2.getFinalPrice()); material.setOriginalPrice(null != materialGoods2.getFinalPrice() ?
materialGoods2.getFinalPrice() : 0);
materials.add(material); materials.add(material);
} }
} }
...@@ -438,14 +440,15 @@ public class CalculationServiceImpl { ...@@ -438,14 +440,15 @@ public class CalculationServiceImpl {
} }
//加料 //加料
if (cartGoods != null && CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) { if (null != cartGoods && CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) { for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material(); ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
material.setType(1); material.setType(1);
material.setGoodsId(materialGoods.getSpuId()); material.setGoodsId(materialGoods.getSpuId());
material.setGoodsQuantity(1); material.setGoodsQuantity(1);
material.setOriginalPrice(materialGoods.getOriginalPrice()); material.setOriginalPrice(null != materialGoods.getOriginalPrice() ?
material.setNowPrice(materialGoods.getFinalPrice().intValue()); materialGoods.getOriginalPrice() : 0);
material.setNowPrice(null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice().intValue():0);
materials.add(material); materials.add(material);
} }
} }
......
...@@ -76,7 +76,7 @@ public class SetMealCalculation { ...@@ -76,7 +76,7 @@ public class SetMealCalculation {
Long comboxmaterialPrice = 0L; Long comboxmaterialPrice = 0L;
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){ if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods materialGoods : comboxGoods.getProductMaterialList()){ for (CartGoods.MaterialGoods materialGoods : comboxGoods.getProductMaterialList()){
comboxmaterialPrice+= materialGoods.getFinalPrice() * cartGoods.getQty(); comboxmaterialPrice+= null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice() * cartGoods.getQty() : 0;
} }
} }
comboxGoods.setAmount(comboxGoods.getAmount()+comboxmaterialPrice); comboxGoods.setAmount(comboxGoods.getAmount()+comboxmaterialPrice);
......
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