Commit 3a5f54fa by xiaoer.li@freemud.com

Merge remote-tracking branch 'origin/master'

parents 9e470cc2 4a7ffe93
...@@ -733,7 +733,7 @@ public class ShoppingCartConvertAdapter { ...@@ -733,7 +733,7 @@ public class ShoppingCartConvertAdapter {
comboxGoods.setTaxId(isComboxGoods ? (StringUtils.isNotEmpty(productComboType.getTaxId()) ? productComboType.getTaxId() : "") : comboxGoods.setTaxId(isComboxGoods ? (StringUtils.isNotEmpty(productComboType.getTaxId()) ? productComboType.getTaxId() : "") :
(StringUtils.isNotEmpty(groupDetailType.getTaxId()) ? groupDetailType.getTaxId() : "")); (StringUtils.isNotEmpty(groupDetailType.getTaxId()) ? groupDetailType.getTaxId() : ""));
// TODO: 2020/10/22 套餐内可选商品加料,暂无 //2020/10/22 套餐内可选商品加料,暂无
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){ if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
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<>();
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();
...@@ -742,6 +742,87 @@ public class ShoppingCartConvertAdapter { ...@@ -742,6 +742,87 @@ 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<>();
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<>();
Long materialAmount = 0L;
if (CollectionUtils.isNotEmpty(materialList)){
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods productMaterial :comboxGoods.getProductMaterialList()) {
for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType detailType : materialList) {
// productMaterial.setCustomerCode(StringUtils.isNotEmpty(detailType.getCustomerCode()) ? detailType.getCustomerCode() : "");
if (detailType.getProductId().equals(productMaterial.getSpuId())) {
productMaterial.setAmount(null != detailType.getMarkUpPrice() ? detailType.getMarkUpPrice().longValue() : 0);
productMaterial.setFinalPrice(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() : 0);
productMaterial.setSpuName(StringUtils.isNotEmpty(detailType.getProductName()) ? detailType.getProductName() : "");
productMaterial.setSpuId(StringUtils.isNotEmpty(detailType.getProductId()) ? detailType.getProductId() : "");
productMaterial.setOriginalPrice(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() : 0);
productMaterial.setOriginalAmount(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() * comboxGoods.getQty() : 0);
productMaterialList.add(productMaterial);
materialAmount += detailType.getProductFinalPrice().longValue() * comboxGoods.getQty();
}
}
}
}
comboxGoods.setMaterialAmount(materialAmount);
comboxGoods.setProductMaterialList(productMaterialList);
}
}
private Map<String, String> getAttributesNew(List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.CartGoodsExtra> extra) { private Map<String, String> getAttributesNew(List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.CartGoodsExtra> extra) {
if (CollectionUtils.isEmpty(extra)) { if (CollectionUtils.isEmpty(extra)) {
return new HashMap<>(); return new HashMap<>();
...@@ -756,7 +837,9 @@ public class ShoppingCartConvertAdapter { ...@@ -756,7 +837,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);
...@@ -785,7 +868,9 @@ public class ShoppingCartConvertAdapter { ...@@ -785,7 +868,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());
...@@ -871,10 +956,18 @@ public class ShoppingCartConvertAdapter { ...@@ -871,10 +956,18 @@ 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); // updateComboxGoodsInfoForMCoffee(productGroup, spuProduct, false);
updateComboxGoodsInfoForMCoffeeProductGroup(productGroup,spuProduct,subProductTypeMap
,false);
} }
} }
} }
//可选商品组加料价格加到购物车行记录上
Long materialAmount =
cartGoods.getProductGroupList().stream().mapToLong(group -> (null != group.getMaterialAmount() ? group.getMaterialAmount() : 0)).sum();
cartGoods.setOriginalMaterialAmount(materialAmount);
cartGoods.setMaterialAmount(materialAmount);
cartGoods.setOriginalAmount(cartGoods.getOriginalPrice()*cartGoods.getQty() + materialAmount);
} }
} }
//更新当前商品行价格 //更新当前商品行价格
...@@ -902,12 +995,16 @@ public class ShoppingCartConvertAdapter { ...@@ -902,12 +995,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);
} }
...@@ -1045,7 +1142,7 @@ public class ShoppingCartConvertAdapter { ...@@ -1045,7 +1142,7 @@ public class ShoppingCartConvertAdapter {
; ;
materialSubName = materialSubName + "/" + detail.getProductName(); materialSubName = materialSubName + "/" + detail.getProductName();
} }
//设置购物车行记录 //设置购物车行加料列表
cartGoods.setProductMaterialList(materialGoodsList); cartGoods.setProductMaterialList(materialGoodsList);
//加料行记录现价总价 //加料行记录现价总价
cartGoods.setMaterialAmount(materialAmount); cartGoods.setMaterialAmount(materialAmount);
......
...@@ -425,6 +425,9 @@ public class CartGoods { ...@@ -425,6 +425,9 @@ public class CartGoods {
if (CollectionUtils.isNotEmpty(productGroupList)) { if (CollectionUtils.isNotEmpty(productGroupList)) {
for (ComboxGoods goods : productGroupList) { for (ComboxGoods goods : productGroupList) {
originalString.append(goods.toString()); originalString.append(goods.toString());
if (CollectionUtils.isNotEmpty(goods.getProductMaterialList())) {
goods.getProductMaterialList().stream().sorted(Comparator.comparing(MaterialGoods::getSpuId)).forEach(e -> originalString.append(e.getSpuId()));
}
} }
} }
if (CollectionUtils.isNotEmpty(productMaterialList)) { if (CollectionUtils.isNotEmpty(productMaterialList)) {
......
...@@ -1368,6 +1368,19 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1368,6 +1368,19 @@ public class ShoppingCartMCoffeeServiceImpl {
cartGoods.setTax(productBeanListSpuClass.get(0).getTax()); cartGoods.setTax(productBeanListSpuClass.get(0).getTax());
cartGoods.setTaxId(productBeanListSpuClass.get(0).getTaxId()); cartGoods.setTaxId(productBeanListSpuClass.get(0).getTaxId());
//套餐固定商品赋值
if (CollectionUtils.isNotEmpty(productBeanListSpuClass.get(0).getProductComboList())){
if (CollectionUtils.isNotEmpty(cartGoods.getProductComboList())){
for (CartGoods.ComboxGoods comboxGoods : cartGoods.getProductComboList()) {
for (ProductBeanDTO.ProductComboType comboType: productBeanListSpuClass.get(0).getProductComboList()){
if (comboxGoods.getGoodsId().equals(comboType.getProductId()) && comboType.getQuantity()>0){
comboxGoods.setQty(comboType.getQuantity());
}
}
}
}
}
//套餐可选商品赋值 //套餐可选商品赋值
if (CollectionUtils.isNotEmpty(productBeanListSpuClass.get(0).getProductGroupList())){ if (CollectionUtils.isNotEmpty(productBeanListSpuClass.get(0).getProductGroupList())){
for (ProductBeanDTO.ProductGroupType groupType : productBeanListSpuClass.get(0).getProductGroupList()) { for (ProductBeanDTO.ProductGroupType groupType : productBeanListSpuClass.get(0).getProductGroupList()) {
...@@ -1476,6 +1489,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1476,6 +1489,7 @@ public class ShoppingCartMCoffeeServiceImpl {
CartGoods.MaterialGoods materialGoods = new CartGoods.MaterialGoods(); CartGoods.MaterialGoods materialGoods = new CartGoods.MaterialGoods();
materialGoods.setSpuId(materialRequestVo.getSpuId()); materialGoods.setSpuId(materialRequestVo.getSpuId());
materialGoods.setGroupId(materialRequestVo.getGroupId()); materialGoods.setGroupId(materialRequestVo.getGroupId());
materialGoods.setCustomerCode(materialRequestVo.getCustomerCode());
comboxMaterialGoodsList.add(materialGoods); comboxMaterialGoodsList.add(materialGoods);
} }
productCombox.setProductMaterialList(comboxMaterialGoodsList); productCombox.setProductMaterialList(comboxMaterialGoodsList);
......
...@@ -82,12 +82,8 @@ public class CalculationServiceImpl { ...@@ -82,12 +82,8 @@ public class CalculationServiceImpl {
@Autowired @Autowired
private MaterialCalculation materialCalculation; private MaterialCalculation materialCalculation;
// @Autowired
// private ShoppingCartConvertAdapter shoppingCartConvertAdapter;
@Autowired @Autowired
private ShoppingCartMccafeAdapter shoppingCartMccafeAdapter; private ShoppingCartMccafeAdapter shoppingCartMccafeAdapter;
// @Autowired
// private ItemServiceImpl itemService;
/** /**
* 更新购物车行优惠信息 * 更新购物车行优惠信息
...@@ -414,15 +410,28 @@ public class CalculationServiceImpl { ...@@ -414,15 +410,28 @@ public class CalculationServiceImpl {
if("0".equals(materialGoods.getGoodsId())){ if("0".equals(materialGoods.getGoodsId())){
continue; continue;
} }
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material(); ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material productGroup =
material.setType(2); new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
material.setGoodsId(materialGoods.getGoodsId()); productGroup.setType(2);
material.setGoodsQuantity(materialGoods.getQty()); productGroup.setGoodsId(materialGoods.getGoodsId());
material.setOriginalPrice(null != materialGoods.getFinalPrice() ? productGroup.setGoodsQuantity(materialGoods.getQty());
productGroup.setOriginalPrice(null != materialGoods.getFinalPrice() ?
materialGoods.getFinalPrice() : 0); materialGoods.getFinalPrice() : 0);
materials.add(productGroup);
if (CollectionUtils.isNotEmpty(materialGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods goods : materialGoods.getProductMaterialList()) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
material.setType(1);
material.setGoodsId(goods.getSpuId());
material.setGoodsQuantity(1);
material.setOriginalPrice(null != goods.getFinalPrice() ?
goods.getFinalPrice() : 0);
materials.add(material); materials.add(material);
} }
} }
}
}
//固定商品 //固定商品
if (cartGoods != null && CollectionUtils.isNotEmpty(cartGoods.getProductComboList())) { if (cartGoods != null && CollectionUtils.isNotEmpty(cartGoods.getProductComboList())) {
...@@ -508,7 +517,7 @@ public class CalculationServiceImpl { ...@@ -508,7 +517,7 @@ public class CalculationServiceImpl {
//单品、多规格加料 //单品、多规格加料
if(CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())){ if(CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()){ for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()){
materialPrice+= materialGoods.getFinalPrice() * cartGoods.getQty(); materialPrice+= (null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice() : 0) * (null != cartGoods.getQty() ? cartGoods.getQty() : 0);
} }
} }
return materialPrice; return materialPrice;
......
...@@ -98,6 +98,21 @@ public class SetMealCalculation { ...@@ -98,6 +98,21 @@ public class SetMealCalculation {
productGroupTotalAmount + productComboTotalAmount + materialPrice; productGroupTotalAmount + productComboTotalAmount + materialPrice;
cartGoods.setAmount(amount); cartGoods.setAmount(amount);
} }
//套餐可选商品加料
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 comboOriginalPriceAmount = null != cartGoods.getOriginalAmount() ? cartGoods.getOriginalAmount() : Long comboOriginalPriceAmount = null != cartGoods.getOriginalAmount() ? cartGoods.getOriginalAmount() :
productComboTotalAmount; productComboTotalAmount;
cartGoods.setOriginalAmount(productGroupTotalAmount + comboOriginalPriceAmount + materialPrice); cartGoods.setOriginalAmount(productGroupTotalAmount + comboOriginalPriceAmount + 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