Commit a7f655e8 by xiaoer.li@freemud.com

Merge remote-tracking branch 'remotes/origin/feature/促销算价基于最新master的分支' into qa

parents 49de40b0 5801b83d
package cn.freemud.enums;
public enum CalculationGoodsType {
TYPE_0(0, "原来的购物车商品"),
TYPE_1(1, "赠品"),
TYPE_2(2, "加购商品");
Integer type;
String desc;
CalculationGoodsType(Integer type, String desc) {
this.type = type;
this.desc = desc;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
...@@ -6,6 +6,7 @@ import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto; ...@@ -6,6 +6,7 @@ import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
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;
import cn.freemud.enums.CalculationGoodsType;
import cn.freemud.enums.ResponseResult; import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException; import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.ItemService; import cn.freemud.service.ItemService;
...@@ -232,14 +233,17 @@ public class AdditionSharingService { ...@@ -232,14 +233,17 @@ public class AdditionSharingService {
, CalculationSharingDiscountResponseDto.CalculationDiscountResult discountResult , CalculationSharingDiscountResponseDto.CalculationDiscountResult discountResult
, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity) { , CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity) {
if (premiumExchangeActivity == null || CollectionUtils.isEmpty(premiumExchangeActivity.getProducts())) { if (discountResult == null || CollectionUtils.isEmpty(discountResult.getGoods()) || premiumExchangeActivity == null || CollectionUtils.isEmpty(premiumExchangeActivity.getProducts())) {
return; return;
} }
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods hgGood = discountResult.getGoods()
.stream()
.filter(d -> CalculationGoodsType.TYPE_2.getType().equals(d.getCartGoodType()))
.findFirst()
.orElse(null);
//检查是否有加价购商品 if (hgGood == null) {
ResponseResult checkResult = checkAdditionalGoods(premiumExchangeActivity.getProducts(), discountResult.getSendGoods()); throw new ServiceException(ResponseResult.PREMIUM_EXCHANGE_ACTIVITY_NOT_EXIST);
if (!ObjectUtils.equals(ResponseResult.SUCCESS, checkResult)) {
throw new ServiceException(checkResult);
} }
//检查是否有加价购商品 //检查是否有加价购商品
...@@ -256,7 +260,9 @@ public class AdditionSharingService { ...@@ -256,7 +260,9 @@ public class AdditionSharingService {
//添加商品行 //添加商品行
List<String> productIds = premiumExchangeActivity.getProducts().stream().map(p -> StringUtils.isEmpty(p.getSkuId()) ? p.getSpuId() : p.getSkuId()).collect(Collectors.toList()); List<String> productIds = premiumExchangeActivity.getProducts().stream().map(p -> StringUtils.isEmpty(p.getSkuId()) ? p.getSpuId() : p.getSkuId()).collect(Collectors.toList());
Map<String, GetProductsVo> getProductsVoMap = itemService.getProducts(productIds, shoppingCartInfoRequestVo.getPartnerId(), shoppingCartInfoRequestVo.getShopId(), BusinessTypeEnum.getByType(shoppingCartInfoRequestVo.getMenuType()).getCode()); Map<String, GetProductsVo> getProductsVoMap = itemService.getProducts(productIds, shoppingCartInfoRequestVo.getPartnerId(), shoppingCartInfoRequestVo.getShopId(), BusinessTypeEnum.getByType(shoppingCartInfoRequestVo.getMenuType()).getCode());
if (getProductsVoMap.isEmpty()) {
throw new ServiceException(ResponseResult.PREMIUM_EXCHANGE_ACTIVITY_NOT_EXIST);
}
// 获取计算返回的价格 // 获取计算返回的价格
Long originalTotalAmount = shoppingCartGoodsDto.getOriginalTotalAmount(); Long originalTotalAmount = shoppingCartGoodsDto.getOriginalTotalAmount();
Long totalAmount = shoppingCartGoodsDto.getTotalAmount(); Long totalAmount = shoppingCartGoodsDto.getTotalAmount();
...@@ -271,7 +277,7 @@ public class AdditionSharingService { ...@@ -271,7 +277,7 @@ public class AdditionSharingService {
continue; continue;
} }
CalculationSharingDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods send = sendGoodsMap.get(goodsId); CalculationSharingDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods send = sendGoodsMap.get(goodsId);
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = this.getCartGoodsDetailDto(product, getProductsVo, goodsId, send); ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = this.getCartGoodsDetailDto(product, getProductsVo, goodsId, hgGood);
shoppingCartGoodsDto.getProducts().add(cartGoodsDetailDto); shoppingCartGoodsDto.getProducts().add(cartGoodsDetailDto);
//2.计算优惠价格 //2.计算优惠价格
originalTotalAmount += getProductsVo.getFinalPrice(); originalTotalAmount += getProductsVo.getFinalPrice();
...@@ -293,12 +299,11 @@ public class AdditionSharingService { ...@@ -293,12 +299,11 @@ public class AdditionSharingService {
public ShoppingCartGoodsDto.CartGoodsDetailDto getCartGoodsDetailDto(CreateOrderVo.PremiumExchangeActivity.Product product public ShoppingCartGoodsDto.CartGoodsDetailDto getCartGoodsDetailDto(CreateOrderVo.PremiumExchangeActivity.Product product
, GetProductsVo getProductsVo , GetProductsVo getProductsVo
, String goodsId , String goodsId
, CalculationSharingDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods sendGoods) { , CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods hgGood) {
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = new ShoppingCartGoodsDto.CartGoodsDetailDto(); ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = new ShoppingCartGoodsDto.CartGoodsDetailDto();
cartGoodsDetailDto.setOriginalPrice(getProductsVo.getFinalPrice()); cartGoodsDetailDto.setOriginalPrice(hgGood.getOriginalPrice());
int totalDiscountAmount = product.getQty() * (getProductsVo.getFinalPrice().intValue() - sendGoods.getNowPrice().intValue()); cartGoodsDetailDto.setTotalDiscountAmount(hgGood.getDiscountAmount().intValue());
cartGoodsDetailDto.setTotalDiscountAmount(totalDiscountAmount);
cartGoodsDetailDto.setSpuId(product.getSpuId()); cartGoodsDetailDto.setSpuId(product.getSpuId());
cartGoodsDetailDto.setSkuId(goodsId); cartGoodsDetailDto.setSkuId(goodsId);
cartGoodsDetailDto.setQty(product.getQty()); cartGoodsDetailDto.setQty(product.getQty());
......
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