Commit 6ee047d8 by 孙昱

Merge branch 'feature/20201112_套餐价格计算_yu.sun' into develop

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
parents 87d4b340 50068762
......@@ -62,5 +62,9 @@ public class ShoppingCartConstant {
public static final int PRODUCT_GROUP_EMPTY= 109;
public static final String CART_PRODUCT_GROUP_EMPTY_STATE = "您选择的【$spuName】商品有未选商品";
/**
* 可选商品价格校验失败
*/
public static final int PRODUCT_GROUP_PRICE_CHANGE = 113;
}
......@@ -694,7 +694,8 @@ public class ShoppingCartConvertAdapter {
}
// 若是固定商品则取商品详情的FinalPrice,若是可选商品则取MarkUpPrice
Long finalPrice = isComboxGoods ? productComboType.getFinalPrice().longValue() : groupDetailType.getMarkUpPrice().longValue();
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());
......@@ -703,16 +704,22 @@ public class ShoppingCartConvertAdapter {
comboxGoods.setSpecProductId(attributes.get(ATTRIBUTEID));
comboxGoods.setSubName(attributes.get(ATTRIBUTENAME));
comboxGoods.setPic(isComboxGoods ? productComboType.getPicture() : groupDetailType.getPicture());
comboxGoods.setOriginalPrice(isComboxGoods ? productComboType.getFinalPrice().longValue() : groupDetailType.getProductFinalPrice().longValue());
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 ? productComboType.getCustomerCode() : groupDetailType.getCustomerCode());
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 ? productComboType.getUnit() : groupDetailType.getUnit());
comboxGoods.setWeight(isComboxGoods ? productComboType.getWeight() : groupDetailType.getWeight());
comboxGoods.setTax(isComboxGoods ? productComboType.getTax() : groupDetailType.getTax());
comboxGoods.setTaxId(isComboxGoods ? productComboType.getTaxId() : groupDetailType.getTaxId());
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() : ""));
// TODO: 2020/10/22 套餐内可选商品加料,暂无
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
......@@ -1042,4 +1049,5 @@ public class ShoppingCartConvertAdapter {
);
}
}
}
}
\ No newline at end of file
......@@ -9,10 +9,7 @@ import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
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.ValiadShopProductResult;
import cn.freemud.entities.dto.product.ValidateShopProductRequest;
import cn.freemud.entities.dto.product.*;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.dto.user.GetSessionUserInfoDto;
import cn.freemud.entities.vo.*;
......@@ -340,7 +337,12 @@ public class ShoppingCartMCoffeeServiceImpl {
// checkUpdateStock(partnerId, storeId, menuType, qty, cartGoods);
// check购物车中所有商品
cartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
// cartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
List<CartGoods> temList = new ArrayList<>();
for (CartGoods goods : cartGoodsList) {
temList.addAll(checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, Arrays.asList(goods)));
}
cartGoodsList = temList;
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, sessionId, "", shoppingCartBaseService);
......@@ -400,7 +402,11 @@ public class ShoppingCartMCoffeeServiceImpl {
// 合并相同商品数据
//cartGoodsList = mergeProductList(cartGoodsList);
// check购物车中所有商品
cartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
List<CartGoods> temList = new ArrayList<>();
for (CartGoods goods : cartGoodsList) {
temList.addAll(checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, Arrays.asList(goods)));
}
cartGoodsList = temList;
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, sessionId, "", shoppingCartBaseService);
}
......@@ -813,12 +819,17 @@ public class ShoppingCartMCoffeeServiceImpl {
List<CartGoods> onlyCheckGoodsList = new ArrayList<>();
if (requestVo.getOperationType() == ShoppingCartOperationType.CHECK.getCode()){
onlyCheckGoodsList.addAll(cartGoodsList);
// 新门店check购物车中所有商品
onlyCheckGoodsList = checkCartGoods(partnerId, toStoreId, orderType, menuType, shoppingCartGoodsResponseVo, onlyCheckGoodsList);
for (CartGoods cartGoods : cartGoodsList) {
onlyCheckGoodsList.addAll(checkCartGoods(partnerId, toStoreId, orderType, menuType, shoppingCartGoodsResponseVo, Arrays.asList(cartGoods)));
}
}else{
// 新门店check购物车中所有商品
cartGoodsList = checkCartGoods(partnerId, toStoreId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
List<CartGoods> temList = new ArrayList<>();
for (CartGoods goods : cartGoodsList) {
temList.addAll(checkCartGoods(partnerId, toStoreId, orderType, menuType, shoppingCartGoodsResponseVo, Arrays.asList(goods)));
}
cartGoodsList = temList;
}
if (requestVo.getOperationType() == ShoppingCartOperationType.CHECK.getCode()) {
......@@ -830,7 +841,13 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}else {
// 新门店check购物车中所有商品
cartGoodsList = checkCartGoods(partnerId, toStoreId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
List<CartGoods> temList = new ArrayList<>();
for (CartGoods goods : cartGoodsList) {
temList.addAll(checkCartGoods(partnerId, toStoreId, orderType, menuType, shoppingCartGoodsResponseVo, Arrays.asList(goods)));
}
cartGoodsList = temList;
// 重新存储新门店购物车
assortmentSdkService.setShoppingCart(partnerId, toStoreId, userId, cartGoodsList, sessionId, "", shoppingCartBaseService);
//清空商品券商品
......@@ -917,7 +934,13 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_GETINFO_INVAILD);
}
// check购物车中所有商品
cartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
// cartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
List<CartGoods> temList = new ArrayList<>();
for (CartGoods goods : cartGoodsList) {
temList.addAll(checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, Arrays.asList(goods)));
}
cartGoodsList = temList;
// 如果购物车商品不为空, 则check购物车中所有商品
if (shoppingCartGoodsResponseVo.getChanged() && requestVo.getOperationType() == ShoppingCartOperationType.CHECK.getCode()) {
return ResponseUtil.success(shoppingCartGoodsResponseVo);
......@@ -1159,24 +1182,26 @@ public class ShoppingCartMCoffeeServiceImpl {
*/
public List<CartGoods> updateCartGoodsLegal(String partnerId, String storeId, Integer orderType, String tableNumber, String menuType, String userId,
CartGoods addCartGoods, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> oldCartGoodsList) {
oldCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType,shoppingCartGoodsResponseVo, oldCartGoodsList);
List<CartGoods> newCartGoods = new ArrayList<>();
newCartGoods.addAll(oldCartGoodsList);
newCartGoods.add(addCartGoods);
//加购商品校验
List<CartGoods> allCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, newCartGoods);
List<CartGoods> newCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType,shoppingCartGoodsResponseVo, newCartGoods);
List<CartGoods> nowCartGoodsList = new ArrayList<>();
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
allCartGoodsList.forEach(oldCartGoods -> {
int index;
if ((index = nowCartGoodsList.indexOf(oldCartGoods)) >= 0) {
nowCartGoodsList.get(index).setQty(nowCartGoodsList.get(index).getQty() + addCartGoods.getQty());
} else {
nowCartGoodsList.add(oldCartGoods);
}
});
if(CollectionUtils.isNotEmpty(oldCartGoodsList)){
nowCartGoodsList.addAll(oldCartGoodsList);
}
if(CollectionUtils.isNotEmpty(newCartGoodsList)){
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
newCartGoodsList.forEach(newCartGood -> {
int index;
if ((index = nowCartGoodsList.indexOf(newCartGood)) >= 0) {
nowCartGoodsList.get(index).setQty(nowCartGoodsList.get(index).getQty() + addCartGoods.getQty());
} else {
nowCartGoodsList.add(newCartGood);
}
});
}
// 重新set购物车信息到缓存中
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, nowCartGoodsList, null, tableNumber, this.shoppingCartBaseService);
return nowCartGoodsList;
......@@ -1698,6 +1723,11 @@ public class ShoppingCartMCoffeeServiceImpl {
validateResult.getFailureList().stream().map(ValiadShopProductResult::getProductType).collect(Collectors.toList());
shoppingCartConvertAdapter.updateCartGoodsInfoForMCoffee(cartGoods, productList);
}
if (PRODUCT_GROUP_PRICE_CHANGE == validaProduct.getCode()) {
changePriceSpu.add(spuName);
List<ProductTypeBeanDTO> productList = validateResult.getFailureList().stream().map(ValiadShopProductResult::getProductType).collect(Collectors.toList());
shoppingCartConvertAdapter.updateCartGoodsInfoForMCoffee(cartGoods, productList);
}
if (PRODUCT_GROUP_EMPTY == validaProduct.getCode()) {
cartGoodsStates.setHasInvalidGoods(true);
cartGoods.setCartGoodsUid(null);
......@@ -1736,6 +1766,9 @@ public class ShoppingCartMCoffeeServiceImpl {
for (ValiadShopProductResult valiadShopProductResult : validateResult.getSuccessList()){
ProductTypeBeanDTO productType = valiadShopProductResult.getProductType();
if(ObjectUtils.equals(productType.getPid(), cartGoods.getSpuId())){
//多规格商品更新套餐价格为商品返回
cartGoods.setFinalPrice(valiadShopProductResult.getProductType().getFinalPrice());
cartGoods.setOriginalPrice(valiadShopProductResult.getProductType().getFinalPrice());
Map<String,ProductTypeBeanDTO> subProductTypeMap = valiadShopProductResult.getSubProductTypeMap();
shoppingCartConvertAdapter.updateCartGoodsInfo(cartGoods, productType,subProductTypeMap);
break;
......@@ -1805,7 +1838,12 @@ public class ShoppingCartMCoffeeServiceImpl {
// 如果购物车商品不为空, 则check购物车中所有商品
if (CollectionUtils.isNotEmpty(cartGoodsList)) {
// check购物车中所有商品
cartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
// cartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
List<CartGoods> temList = new ArrayList<>();
for (CartGoods goods : cartGoodsList) {
temList.addAll(checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, Arrays.asList(goods)));
}
cartGoodsList = temList;
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, sessionId, "", shoppingCartBaseService);
......
......@@ -448,7 +448,7 @@ public class CalculationServiceImpl {
}
//加料
if (cartGoods != null && CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
if (null != cartGoods && CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
material.setType(1);
......@@ -456,7 +456,7 @@ public class CalculationServiceImpl {
material.setGoodsQuantity(1);
material.setOriginalPrice(null != materialGoods.getOriginalPrice() ?
materialGoods.getOriginalPrice() : 0);
material.setNowPrice(materialGoods.getFinalPrice().intValue());
material.setNowPrice(null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice().intValue():0);
materials.add(material);
}
}
......
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