Commit f19ff496 by weijiguang

.

parent a93b860c
......@@ -83,6 +83,12 @@ public class OrderDetail {
private BigDecimal realAmount;
/**
* 原优惠价
*/
@Excel(name = "原优惠价")
private BigDecimal origDiscount;
/**
* 规格选项详情
*/
@Excel(name = "规格选项详情")
......
......@@ -212,6 +212,7 @@ public class CouponUserServiceImpl implements ICouponUserService {
} else {
List<OrderDetail> fitOrderDetails = orderDetails.stream().filter(orderDetail -> fitCouponGoodsIdList.contains(orderDetail.getGoodsId())).collect(Collectors.toList());
BigDecimal fitGoodsAmount = fitOrderDetails.stream().map(OrderDetail::getAmountShould).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal fitGoodsOrigDiscount = fitOrderDetails.stream().map(OrderDetail::getOrigDiscount).reduce(BigDecimal.ZERO, BigDecimal::add);
if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(fitGoodsAmount) > 0) {
if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣
couponVo.setNotFitableDesc("未达到满减要求");
......@@ -221,7 +222,7 @@ public class CouponUserServiceImpl implements ICouponUserService {
return;
}
this.wrapperCouponAmount(couponVo, fitOrderDetails, fitGoodsAmount);
this.wrapperCouponAmount(couponVo, fitOrderDetails, fitGoodsAmount, fitGoodsOrigDiscount);
Map<Long, BigDecimal> couponAmountMap = couponVo.getCouponAmountMap();
orderDetails.forEach(orderDetail -> {
......@@ -257,19 +258,20 @@ public class CouponUserServiceImpl implements ICouponUserService {
return goodsSkus;
}
private void wrapperCouponAmount(CouponVo couponVo, List<OrderDetail> fitOrderDetails, BigDecimal fitGoodsAmount) {
private void wrapperCouponAmount(CouponVo couponVo, List<OrderDetail> fitOrderDetails, BigDecimal fitGoodsAmount, BigDecimal fitGoodsOrigDiscount) {
Map<Long, BigDecimal> couponAmountMap = new HashMap<>();
if (couponVo.getOrderLimit() != null && couponVo.getOrderLimit()) { // 单杯
OrderDetail orderDetail = fitOrderDetails.stream().max(Comparator.comparing(OrderDetail::getUnitPrice)).get();
BigDecimal discountAmount = orderDetail.getUnitPrice();
if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣
discountAmount = orderDetail.getOrigDiscount(); // 折扣使用折扣价(非特惠价格)
discountAmount = this.getDiscountAmount(discountAmount, couponVo.getPriceDiscount()).min(BigDecimal.valueOf(50));
}
couponVo.setCouponAmount(discountAmount);
couponAmountMap.put(orderDetail.getSkuId(), couponVo.getCouponAmount());
} else { // 整单
if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣
BigDecimal couponAmount = this.getDiscountAmount(fitGoodsAmount, couponVo.getPriceDiscount());
BigDecimal couponAmount = this.getDiscountAmount(fitGoodsOrigDiscount, couponVo.getPriceDiscount());
couponAmount = couponAmount.min(BigDecimal.valueOf(50)); // 折扣类整单最高抵扣50元
couponVo.setCouponAmount(couponAmount);
fitOrderDetails.forEach(orderDetail -> orderDetail.setCouponAmount(this.getDiscountAmount(orderDetail.getAmountShould(), couponVo.getPriceDiscount())));
......@@ -281,7 +283,7 @@ public class CouponUserServiceImpl implements ICouponUserService {
orderDetail.setCouponAmount(orderDetail.getCouponAmount().add(couponVo.getCouponAmount().subtract(detailCouponSum)));
}
} else { // 免单
couponVo.setCouponAmount(fitGoodsAmount);
couponVo.setCouponAmount(fitGoodsOrigDiscount);
}
fitOrderDetails.forEach(orderDetail -> couponAmountMap.put(orderDetail.getSkuId(), orderDetail.getCouponAmount()));
}
......
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