|
@@ -4516,7 +4516,7 @@ public class OrderServiceImpl implements OrderService {
|
|
Integer score = memberInfoDTO.getScore();
|
|
Integer score = memberInfoDTO.getScore();
|
|
if (Objects.nonNull(score) && score > 0) {
|
|
if (Objects.nonNull(score) && score > 0) {
|
|
// 有积分
|
|
// 有积分
|
|
- afterDiscountPrice = calculatePreferentialPrice(orderTotalPrice, score, memberCode, storeId, calculateOrderDiscountPriceResponseVO, goodsDetailsDtos, promotionSkuList, mkActivitiesEntityList);
|
|
|
|
|
|
+ afterDiscountPrice = calculatePreferentialPrice(orderTotalPrice, score, memberCode, calculateOrderDiscountPriceResponseVO, goodsDetailsDtos, promotionSkuList, mkActivitiesEntityList);
|
|
LOGGER.info("会员【{}】,当前积分:{},积分抵扣后的订单金额:{},积分抵扣前的订单金额:{}", memberCode, score, afterDiscountPrice, orderTotalPrice);
|
|
LOGGER.info("会员【{}】,当前积分:{},积分抵扣后的订单金额:{},积分抵扣前的订单金额:{}", memberCode, score, afterDiscountPrice, orderTotalPrice);
|
|
calculateOrderDiscountPriceResponseVO.setOrderTotalPrice(afterDiscountPrice);
|
|
calculateOrderDiscountPriceResponseVO.setOrderTotalPrice(afterDiscountPrice);
|
|
calculateOrderDiscountPriceResponseVO.setGoodsDetailsDtos(goodsDetailsDtos);
|
|
calculateOrderDiscountPriceResponseVO.setGoodsDetailsDtos(goodsDetailsDtos);
|
|
@@ -4549,7 +4549,6 @@ public class OrderServiceImpl implements OrderService {
|
|
* @param score 积分
|
|
* @param score 积分
|
|
* @param memberCode 会员码
|
|
* @param memberCode 会员码
|
|
* @param goodsDetailsDtos 订单商品详情
|
|
* @param goodsDetailsDtos 订单商品详情
|
|
- * @param activityFlag 是否参加过活动
|
|
|
|
* @param calculateOrderDiscountPriceResponseVO 响应数据
|
|
* @param calculateOrderDiscountPriceResponseVO 响应数据
|
|
* @param promotionSkuList 参与了限时特价活动并且与积分抵扣互斥的sku集合
|
|
* @param promotionSkuList 参与了限时特价活动并且与积分抵扣互斥的sku集合
|
|
*
|
|
*
|
|
@@ -4558,7 +4557,6 @@ public class OrderServiceImpl implements OrderService {
|
|
private BigDecimal calculatePreferentialPrice(BigDecimal orderTotalPrice,
|
|
private BigDecimal calculatePreferentialPrice(BigDecimal orderTotalPrice,
|
|
Integer score,
|
|
Integer score,
|
|
String memberCode,
|
|
String memberCode,
|
|
- String storeId,
|
|
|
|
CalculateOrderDiscountPriceResponseVO calculateOrderDiscountPriceResponseVO,
|
|
CalculateOrderDiscountPriceResponseVO calculateOrderDiscountPriceResponseVO,
|
|
List<GoodsDetailsDto> goodsDetailsDtos,
|
|
List<GoodsDetailsDto> goodsDetailsDtos,
|
|
List<String> promotionSkuList,
|
|
List<String> promotionSkuList,
|
|
@@ -4590,8 +4588,8 @@ public class OrderServiceImpl implements OrderService {
|
|
.collect(Collectors.toMap(MkActivitiesScoreEntity::getSku, mkActivitiesScoreEntity -> {
|
|
.collect(Collectors.toMap(MkActivitiesScoreEntity::getSku, mkActivitiesScoreEntity -> {
|
|
BigDecimal scoreLimit = mkActivitiesScoreEntity.getScoreLimit();
|
|
BigDecimal scoreLimit = mkActivitiesScoreEntity.getScoreLimit();
|
|
if (Objects.isNull(scoreLimit)) {
|
|
if (Objects.isNull(scoreLimit)) {
|
|
- LOGGER.error("商品:【{}】,未设置最大抵扣比例!请设置后在计算优惠价!", mkActivitiesScoreEntity.getSku());
|
|
|
|
- throw new ServiceException(String.format("商品:【%s】,未设置最大抵扣比例!请设置后在计算优惠价!", mkActivitiesScoreEntity.getSku()));
|
|
|
|
|
|
+ LOGGER.error("商品:【{}】,未设置最大抵扣比例!请设置后再计算优惠价!", mkActivitiesScoreEntity.getSku());
|
|
|
|
+ throw new ServiceException(String.format("商品:【%s】,未设置最大抵扣比例!请设置后再计算优惠价!", mkActivitiesScoreEntity.getSku()));
|
|
}
|
|
}
|
|
return scoreLimit;
|
|
return scoreLimit;
|
|
}, (k1, k2) -> k2));
|
|
}, (k1, k2) -> k2));
|
|
@@ -4635,7 +4633,8 @@ public class OrderServiceImpl implements OrderService {
|
|
GoodsDetailsDto goodsDetailsDto = goodsDetailsDtos.get(i);
|
|
GoodsDetailsDto goodsDetailsDto = goodsDetailsDtos.get(i);
|
|
// 抵扣积分分摊
|
|
// 抵扣积分分摊
|
|
int index = size - 1;
|
|
int index = size - 1;
|
|
- goodsDetailsDto.setActivity(org.springframework.util.StringUtils.isEmpty(goodsDetailsDto.getActivity()) ? "积分抵扣" : goodsDetailsDto.getActivity() + ",积分抵扣");
|
|
|
|
|
|
+ String activity = goodsDetailsDto.getActivity();
|
|
|
|
+ goodsDetailsDto.setActivity(org.springframework.util.StringUtils.isEmpty(activity) ? "积分抵扣" : activity.contains("积分抵扣") ? activity : activity + ",积分抵扣");
|
|
String sku = goodsDetailsDto.getGoodsSn();
|
|
String sku = goodsDetailsDto.getGoodsSn();
|
|
// 系统设置的最大抵扣比例(最多能抵扣订单金额的比例),导入积分抵扣活动时设置
|
|
// 系统设置的最大抵扣比例(最多能抵扣订单金额的比例),导入积分抵扣活动时设置
|
|
BigDecimal scoreLimitDecimal = skuScoreLimitMap.get(sku);
|
|
BigDecimal scoreLimitDecimal = skuScoreLimitMap.get(sku);
|
|
@@ -4654,7 +4653,7 @@ public class OrderServiceImpl implements OrderService {
|
|
BigDecimal discountedPrice = BigDecimal.ZERO;
|
|
BigDecimal discountedPrice = BigDecimal.ZERO;
|
|
// 计算抵扣,当商品不是最后一个商品
|
|
// 计算抵扣,当商品不是最后一个商品
|
|
if (i < index) {
|
|
if (i < index) {
|
|
- shareScoreItem = actualPaymentAmount.divide(skuTotalPrice, 2, BigDecimal.ROUND_HALF_UP).multiply(scoreIntegerDecimal);
|
|
|
|
|
|
+ shareScoreItem = actualPaymentAmount.divide(skuTotalPrice, 10, BigDecimal.ROUND_HALF_UP).multiply(scoreIntegerDecimal).setScale(0, BigDecimal.ROUND_FLOOR);
|
|
discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
|
|
discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
|
|
}
|
|
}
|
|
// 订单商品详情最后一个商品并且详情不止一个商品
|
|
// 订单商品详情最后一个商品并且详情不止一个商品
|