Commit d6e507d3 by 徐康

Merge branch 'feature-yu.sun-material-20201030' into 2020/10/29-fabu-huiyang

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
parents 8a7a2977 37088832
...@@ -380,5 +380,9 @@ public class CartGoods { ...@@ -380,5 +380,9 @@ public class CartGoods {
* 购物车一行商品的总现价 * 购物车一行商品的总现价
*/ */
private Long amount; private Long amount;
/**
* 麦咖啡入机键位
*/
private String customerCode;
} }
} }
...@@ -133,6 +133,8 @@ public class ShoppingCartConvertAdapter { ...@@ -133,6 +133,8 @@ public class ShoppingCartConvertAdapter {
goods.setSpuName(materialGoods.getSpuName()); goods.setSpuName(materialGoods.getSpuName());
goods.setOriginalPrice(materialGoods.getOriginalPrice()); goods.setOriginalPrice(materialGoods.getOriginalPrice());
goods.setSalePrice(materialGoods.getFinalPrice()); goods.setSalePrice(materialGoods.getFinalPrice());
goods.setCustomerCode(materialGoods.getCustomerCode());
goods.setProductCode(materialGoods.getCustomerCode());
goods.setQty(cartGoods.getQty()); goods.setQty(cartGoods.getQty());
goods.setTotalDiscountAmount(0); goods.setTotalDiscountAmount(0);
materialList.add(goods); materialList.add(goods);
...@@ -265,7 +267,7 @@ public class ShoppingCartConvertAdapter { ...@@ -265,7 +267,7 @@ public class ShoppingCartConvertAdapter {
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = new ShoppingCartGoodsDto.CartGoodsDetailDto(); ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = new ShoppingCartGoodsDto.CartGoodsDetailDto();
cartGoodsDetailDto.setTaxId(cartGoods.getTaxId()); cartGoodsDetailDto.setTaxId(cartGoods.getTaxId());
cartGoodsDetailDto.setTax(cartGoods.getTax()); cartGoodsDetailDto.setTax(cartGoods.getTax());
cartGoodsDetailDto.setSpuId(comboxGoods.getGoodsId()); cartGoodsDetailDto.setSpuId(comboxGoods.getSpuId());
cartGoodsDetailDto.setSpuName(comboxGoods.getSpuName()); cartGoodsDetailDto.setSpuName(comboxGoods.getSpuName());
cartGoodsDetailDto.setSkuId(comboxGoods.getGoodsId()); cartGoodsDetailDto.setSkuId(comboxGoods.getGoodsId());
cartGoodsDetailDto.setSkuName(StringUtils.isEmpty(comboxGoods.getSkuName()) ? comboxGoods.getSpuName() : comboxGoods.getSkuName()); cartGoodsDetailDto.setSkuName(StringUtils.isEmpty(comboxGoods.getSkuName()) ? comboxGoods.getSpuName() : comboxGoods.getSkuName());
...@@ -294,6 +296,8 @@ public class ShoppingCartConvertAdapter { ...@@ -294,6 +296,8 @@ public class ShoppingCartConvertAdapter {
goods.setSalePrice(materialGoods.getFinalPrice()); goods.setSalePrice(materialGoods.getFinalPrice());
goods.setQty(cartGoods.getQty()); goods.setQty(cartGoods.getQty());
goods.setTotalDiscountAmount(0); goods.setTotalDiscountAmount(0);
goods.setProductCode(materialGoods.getCustomerCode());
goods.setCustomerCode(materialGoods.getCustomerCode());
materialList.add(goods); materialList.add(goods);
} }
cartGoodsDetailDto.setMaterialList(materialList); cartGoodsDetailDto.setMaterialList(materialList);
...@@ -699,7 +703,7 @@ public class ShoppingCartConvertAdapter { ...@@ -699,7 +703,7 @@ public class ShoppingCartConvertAdapter {
comboxGoods.setTax(isComboxGoods ? productComboType.getTax() : groupDetailType.getTax()); comboxGoods.setTax(isComboxGoods ? productComboType.getTax() : groupDetailType.getTax());
comboxGoods.setTaxId(isComboxGoods ? productComboType.getTaxId() : groupDetailType.getTaxId()); comboxGoods.setTaxId(isComboxGoods ? productComboType.getTaxId() : groupDetailType.getTaxId());
//套餐内商品加料 // TODO: 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();
...@@ -731,7 +735,10 @@ public class ShoppingCartConvertAdapter { ...@@ -731,7 +735,10 @@ public class ShoppingCartConvertAdapter {
} }
//提取加料信息 //提取加料信息
List<String> materialSpu = new ArrayList<>(); List<String> materialSpu = new ArrayList<>();
List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = spuProduct.getAdditionalGroupList().get(0).getGroupDetail(); List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>();
for (ProductBeanDTO.ProductGroupType productGroupType : spuProduct.getAdditionalGroupList()){
groupDetail.addAll(productGroupType.getGroupDetail());
}
HashMap<String, ProductBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>(); HashMap<String, ProductBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>();
for (ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail) { for (ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail) {
materialHash.put(groupDetailType.getProductId(), groupDetailType); materialHash.put(groupDetailType.getProductId(), groupDetailType);
...@@ -759,6 +766,7 @@ public class ShoppingCartConvertAdapter { ...@@ -759,6 +766,7 @@ public class ShoppingCartConvertAdapter {
//原行单价*数量 //原行单价*数量
material.setOriginalAmount(detail.getProductFinalPrice().longValue() * cartGoods.getQty()); material.setOriginalAmount(detail.getProductFinalPrice().longValue() * cartGoods.getQty());
material.setOriginalPrice(detail.getProductFinalPrice().longValue()); material.setOriginalPrice(detail.getProductFinalPrice().longValue());
material.setCustomerCode(materialGoods.getCustomerCode());
materialGoodsList.add(material); materialGoodsList.add(material);
materialAmount += detail.getProductFinalPrice().longValue() * cartGoods.getQty(); materialAmount += detail.getProductFinalPrice().longValue() * cartGoods.getQty();
originalMaterAmount += detail.getProductFinalPrice().longValue() * cartGoods.getQty(); originalMaterAmount += detail.getProductFinalPrice().longValue() * cartGoods.getQty();
...@@ -912,29 +920,22 @@ public class ShoppingCartConvertAdapter { ...@@ -912,29 +920,22 @@ 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 = productBeanDTO.getAdditionalGroupList().get(0).getGroupDetail(); List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = new ArrayList<>();
ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType1 = null; for (ProductBeanDTO.ProductGroupType productGroupType : productBeanDTO.getAdditionalGroupList()){
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods productMaterialList :comboxGoods.getProductMaterialList()){ groupDetail.addAll(productGroupType.getGroupDetail());
}
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods productMaterial :comboxGoods.getProductMaterialList()){
for (ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail){ for (ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail){
if(groupDetailType.getProductId().equals(productMaterialList.getSpuId())){ if(groupDetailType.getProductId().equals(productMaterial.getSpuId())){
groupDetailType1 = groupDetailType; productMaterial.setSpuId(groupDetailType.getProductId());
break; productMaterial.setAmount(groupDetailType.getProductFinalPrice().longValue());
productMaterial.setFinalPrice(groupDetailType.getProductFinalPrice().longValue());
productMaterial.setOriginalAmount(groupDetailType.getProductFinalPrice().longValue());
productMaterial.setOriginalPrice(groupDetailType.getProductFinalPrice().longValue());
productMaterial.setSpuName(groupDetailType.getProductName());
} }
} }
} }
if(groupDetailType1 == null){
return;
}
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();
materialGoods.setSpuId(groupDetailType1.getProductId());
materialGoods.setAmount(groupDetailType1.getProductPrice().longValue());
materialGoods.setFinalPrice(groupDetailType1.getProductFinalPrice().longValue());
materialGoods.setOriginalAmount(groupDetailType1.getProductPrice().longValue());
materialGoods.setOriginalPrice(groupDetailType1.getProductPrice().longValue());
materialGoods.setSpuName(groupDetailType1.getProductName());
productMaterialList.add(materialGoods);
comboxGoods.setProductMaterialList(productMaterialList);
} }
} }
} }
......
...@@ -156,10 +156,14 @@ public class ActivityCalculationDiscountRequestDto { ...@@ -156,10 +156,14 @@ public class ActivityCalculationDiscountRequestDto {
*/ */
private Integer goodsQuantity; private Integer goodsQuantity;
/** /**
* 加料 * 加料
*/ */
private Long originalPrice; private Long originalPrice;
/** /**
* 加料现价
*/
private Integer nowPrice;
/**
* 1 :小料、2:可选搭配 * 1 :小料、2:可选搭配
*/ */
private int type; private int type;
......
...@@ -229,6 +229,10 @@ public class ActivityCalculationDiscountResponseDto { ...@@ -229,6 +229,10 @@ public class ActivityCalculationDiscountResponseDto {
*/ */
private String artNo; private String artNo;
/**
* 小料节点
*/
private List<GoodsMaterial> smallMaterial;
@Data @Data
public static class GoodsDiscount { public static class GoodsDiscount {
...@@ -263,6 +267,38 @@ public class ActivityCalculationDiscountResponseDto { ...@@ -263,6 +267,38 @@ public class ActivityCalculationDiscountResponseDto {
*/ */
private Integer actualGoodsNumber; private Integer actualGoodsNumber;
} }
@Data
public static class GoodsMaterial{
/**
* 子商品类型:1-小料;2-可选商品
*/
private Integer type;
/**
* 小料商品ID
*/
private String goodsId;
/**
* 小料数量
*/
private Integer goodsQuantity;
/**
* 商品原价(单位:分)
*/
private Integer originalPrice;
/**
* 商品现价(单位:分)
*/
private Integer nowPrice;
/**
* 分摊到商品上的优惠总金额
*/
private Integer discountAmount;
/**
* 商品实付金额
*/
private Integer realAmount;
}
} }
@Data @Data
......
...@@ -307,6 +307,10 @@ public class ShoppingCartGoodsDto { ...@@ -307,6 +307,10 @@ public class ShoppingCartGoodsDto {
* 商品行优惠总金额=数量*单个商品优惠金额 * 商品行优惠总金额=数量*单个商品优惠金额
*/ */
private Integer totalDiscountAmount; private Integer totalDiscountAmount;
private String productCode;
private String customerCode;
/** /**
* 当前商品享受的促销活动 * 当前商品享受的促销活动
*/ */
......
...@@ -376,6 +376,9 @@ public class CartGoods { ...@@ -376,6 +376,9 @@ public class CartGoods {
if (CollectionUtils.isNotEmpty(goods.getSpecialExtra())) { if (CollectionUtils.isNotEmpty(goods.getSpecialExtra())) {
goods.getSpecialExtra().stream().sorted(Comparator.comparing(SpecialExtra::getAttributeId)).forEach(e -> originalString.append(e.getAttributeId())); goods.getSpecialExtra().stream().sorted(Comparator.comparing(SpecialExtra::getAttributeId)).forEach(e -> originalString.append(e.getAttributeId()));
} }
if (CollectionUtils.isNotEmpty(goods.getProductMaterialList())) {
goods.getProductMaterialList().stream().sorted(Comparator.comparing(MaterialGoods::getSpuId)).forEach(e -> originalString.append(e.getSpuId()));
}
} }
} }
if (CollectionUtils.isNotEmpty(productGroupList)) { if (CollectionUtils.isNotEmpty(productGroupList)) {
...@@ -404,6 +407,9 @@ public class CartGoods { ...@@ -404,6 +407,9 @@ public class CartGoods {
if (CollectionUtils.isNotEmpty(goods.getSpecialExtra())) { if (CollectionUtils.isNotEmpty(goods.getSpecialExtra())) {
goods.getSpecialExtra().stream().sorted(Comparator.comparing(SpecialExtra::getAttributeId)).forEach(e -> currentString.append(e.getAttributeId())); goods.getSpecialExtra().stream().sorted(Comparator.comparing(SpecialExtra::getAttributeId)).forEach(e -> currentString.append(e.getAttributeId()));
} }
if (CollectionUtils.isNotEmpty(goods.getProductMaterialList())) {
goods.getProductMaterialList().stream().sorted(Comparator.comparing(MaterialGoods::getSpuId)).forEach(e -> currentString.append(e.getSpuId()));
}
} }
} }
if (CollectionUtils.isNotEmpty(cartGoods.getProductGroupList())) { if (CollectionUtils.isNotEmpty(cartGoods.getProductGroupList())) {
...@@ -467,6 +473,10 @@ public class CartGoods { ...@@ -467,6 +473,10 @@ public class CartGoods {
*/ */
private String spuId; private String spuId;
/** /**
* 加料组id(对应入机键位)
*/
private String groupId;
/**
* 加料名称 * 加料名称
*/ */
private String spuName; private String spuName;
...@@ -486,5 +496,10 @@ public class CartGoods { ...@@ -486,5 +496,10 @@ public class CartGoods {
* 购物车一行商品的现价*数量 * 购物车一行商品的现价*数量
*/ */
private Long amount; private Long amount;
/**
* 麦咖啡入机键位
*/
private String customerCode;
} }
} }
...@@ -20,4 +20,13 @@ public class MaterialRequestVo { ...@@ -20,4 +20,13 @@ public class MaterialRequestVo {
* 加料商品ID * 加料商品ID
*/ */
private String spuId; private String spuId;
/**
* 加料商品组ID
*/
private String groupId;
/**
* 麦咖啡入机键位
*/
private String customerCode;
} }
...@@ -80,6 +80,8 @@ public class CalculationServiceImpl { ...@@ -80,6 +80,8 @@ public class CalculationServiceImpl {
private SetMealCalculation setMealCalculation; private SetMealCalculation setMealCalculation;
@Autowired @Autowired
private MaterialCalculation materialCalculation;
@Autowired
private ShoppingCartConvertAdapter shoppingCartConvertAdapter; private ShoppingCartConvertAdapter shoppingCartConvertAdapter;
/** /**
...@@ -110,6 +112,8 @@ public class CalculationServiceImpl { ...@@ -110,6 +112,8 @@ public class CalculationServiceImpl {
//套餐 //套餐
setMealCalculation.updateShoppingCartGoodsDiscount(calculationDiscount,cartGoodsList,shoppingCartGoodsResponseVo); setMealCalculation.updateShoppingCartGoodsDiscount(calculationDiscount,cartGoodsList,shoppingCartGoodsResponseVo);
//加料
materialCalculation.updateShoppingCartGoodsApportion(calculationDiscount,cartGoodsList);
return calculationDiscount; return calculationDiscount;
} }
...@@ -422,7 +426,7 @@ public class CalculationServiceImpl { ...@@ -422,7 +426,7 @@ public class CalculationServiceImpl {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material(); ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
material.setType(1); material.setType(1);
material.setGoodsId(materialGoods2.getSpuId()); material.setGoodsId(materialGoods2.getSpuId());
material.setGoodsQuantity(cartGoods.getQty()); material.setGoodsQuantity(1);
material.setOriginalPrice(materialGoods2.getFinalPrice()); material.setOriginalPrice(materialGoods2.getFinalPrice());
materials.add(material); materials.add(material);
} }
...@@ -436,8 +440,9 @@ public class CalculationServiceImpl { ...@@ -436,8 +440,9 @@ public class CalculationServiceImpl {
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(cartGoods.getQty()); material.setGoodsQuantity(1);
material.setOriginalPrice(materialGoods.getFinalPrice()); material.setOriginalPrice(materialGoods.getOriginalPrice());
material.setNowPrice(materialGoods.getFinalPrice().intValue());
materials.add(material); materials.add(material);
} }
} }
...@@ -462,14 +467,15 @@ public class CalculationServiceImpl { ...@@ -462,14 +467,15 @@ public class CalculationServiceImpl {
long totalPackgeAmount = 0L; long totalPackgeAmount = 0L;
for (CartGoods cartGoods : cartGoodsList) { for (CartGoods cartGoods : cartGoodsList) {
// 设置商品原价与商品现价的初始值 // 设置商品原价与商品现价的初始值
long originalAmount = null != cartGoods.getOriginalPrice() ? cartGoods.getOriginalPrice() : 0; long originalAmount = null != cartGoods.getOriginalPrice() ? cartGoods.getOriginalPrice()* cartGoods.getQty() : 0;
long amount = null != cartGoods.getOriginalPrice() ? cartGoods.getOriginalPrice() : 0; long amount = null != cartGoods.getOriginalPrice() ? cartGoods.getOriginalPrice()* cartGoods.getQty() : 0;
long packAmount = null != cartGoods.getPackPrice() ? cartGoods.getPackPrice() : 0; long packAmount = null != cartGoods.getPackPrice() ? cartGoods.getPackPrice()* cartGoods.getQty() : 0;
totalOriginalAmount += originalAmount; totalOriginalAmount += originalAmount;
totalAmount += amount; totalAmount += amount;
totalPackgeAmount += packAmount; totalPackgeAmount += packAmount;
cartGoods.setOriginalAmount(originalAmount); long materialPrice = getMaterialPrice(cartGoods);
cartGoods.setAmount(amount); cartGoods.setOriginalAmount(originalAmount + materialPrice);
cartGoods.setAmount(amount + materialPrice);
cartGoods.setPackPrice(packAmount); cartGoods.setPackPrice(packAmount);
} }
shoppingCartGoodsResponseVo.setOriginalTotalAmount(calculationDiscount == null ? totalOriginalAmount : calculationDiscount.getOriginalTotalAmount()); shoppingCartGoodsResponseVo.setOriginalTotalAmount(calculationDiscount == null ? totalOriginalAmount : calculationDiscount.getOriginalTotalAmount());
...@@ -484,4 +490,17 @@ public class CalculationServiceImpl { ...@@ -484,4 +490,17 @@ public class CalculationServiceImpl {
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(calculationDiscount == null ? 0L :calculationDiscount.getDistributionFee()); shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(calculationDiscount == null ? 0L :calculationDiscount.getDistributionFee());
} }
private Long getMaterialPrice(CartGoods cartGoods){
Long materialPrice = 0L;
//单品、多规格加料
if(CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()){
materialPrice+= materialGoods.getFinalPrice() * cartGoods.getQty();
}
}
return materialPrice;
}
} }
...@@ -69,9 +69,24 @@ public class SetMealCalculation { ...@@ -69,9 +69,24 @@ public class SetMealCalculation {
long productComboAmount = cartGoods.getProductComboList().stream().mapToLong(t -> t.getFinalPrice() * t.getQty()).sum(); long productComboAmount = cartGoods.getProductComboList().stream().mapToLong(t -> t.getFinalPrice() * t.getQty()).sum();
long productComboTotalAmount = productComboAmount * cartGoods.getQty(); long productComboTotalAmount = productComboAmount * cartGoods.getQty();
cartGoods.setOriginalAmount(productGroupTotalAmount + productComboTotalAmount); long materialPrice = 0l;
//套餐固定商品加料
if(CollectionUtils.isNotEmpty(cartGoods.getProductComboList())){
for (CartGoods.ComboxGoods comboxGoods : cartGoods.getProductComboList()){
Long comboxmaterialPrice = 0L;
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods materialGoods : comboxGoods.getProductMaterialList()){
comboxmaterialPrice+= materialGoods.getFinalPrice() * cartGoods.getQty();
}
}
comboxGoods.setAmount(comboxGoods.getAmount()+comboxmaterialPrice);
materialPrice = materialPrice + comboxmaterialPrice;
}
}
cartGoods.setOriginalAmount(productGroupTotalAmount + productComboTotalAmount + materialPrice);
cartGoods.setOriginalPrice(productComboTotalAmount); cartGoods.setOriginalPrice(productComboTotalAmount);
cartGoods.setAmount(productGroupTotalAmount + productComboTotalAmount); cartGoods.setAmount(productGroupTotalAmount + productComboTotalAmount + materialPrice);
cartGoods.setFinalPrice(productComboTotalAmount); cartGoods.setFinalPrice(productComboTotalAmount);
// 套餐(固定商品)现价 // 套餐(固定商品)现价
......
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