Commit e7652b77 by weijiguang

test

parent 46ea78e6
...@@ -187,8 +187,8 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -187,8 +187,8 @@ public class CouponUserServiceImpl implements ICouponUserService {
List<Goods> goods = goodsMapper.selectGoodsByIds(goodsIds); List<Goods> goods = goodsMapper.selectGoodsByIds(goodsIds);
Assert.notEmpty(goods, "未查询到匹配的商品信息[id=" + goodsIds + "]"); Assert.notEmpty(goods, "未查询到匹配的商品信息[id=" + goodsIds + "]");
// 订单总额 // 订单总额
BigDecimal orderTotalAmount = orderDetails.stream().map(OrderDetail::getAmountShould).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal orderTotalAmount = orderDetails.stream().map(x -> x.getAmountShould().multiply(new BigDecimal(x.getNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal orderTotalOrigDiscount = orderDetails.stream().map(OrderDetail::getOrigDiscount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal orderTotalOrigDiscount = orderDetails.stream().map(x -> x.getOrigDiscount().multiply(new BigDecimal(x.getNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
log.info("orderTotalAmount:{}, orderTotalOrigDiscount:{}", orderTotalAmount, orderTotalOrigDiscount); log.info("orderTotalAmount:{}, orderTotalOrigDiscount:{}", orderTotalAmount, orderTotalOrigDiscount);
couponVos.stream().filter(couponVo -> StringUtils.isEmpty(couponVo.getNotFitableDesc())).forEach(couponVo -> { couponVos.stream().filter(couponVo -> StringUtils.isEmpty(couponVo.getNotFitableDesc())).forEach(couponVo -> {
/** 可用饮品范围的判断 */ /** 可用饮品范围的判断 */
...@@ -213,8 +213,8 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -213,8 +213,8 @@ public class CouponUserServiceImpl implements ICouponUserService {
couponVo.setCouponAmount(couponVo.getPriceDiscount().min(orderTotalOrigDiscount)); couponVo.setCouponAmount(couponVo.getPriceDiscount().min(orderTotalOrigDiscount));
} else { } else {
List<OrderDetail> fitOrderDetails = orderDetails.stream().filter(orderDetail -> fitCouponGoodsIdList.contains(orderDetail.getGoodsId())).collect(Collectors.toList()); 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 fitGoodsAmount = fitOrderDetails.stream().map(x -> x.getAmountShould().multiply(new BigDecimal(x.getNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal fitGoodsOrigDiscount = fitOrderDetails.stream().map(OrderDetail::getOrigDiscount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal fitGoodsOrigDiscount = fitOrderDetails.stream().map(x -> x.getOrigDiscount().multiply(new BigDecimal(x.getNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
log.info("fitGoodsOrigDiscount:{}, fitGoodsAmount:{}", fitGoodsOrigDiscount, fitGoodsAmount); log.info("fitGoodsOrigDiscount:{}, fitGoodsAmount:{}", fitGoodsOrigDiscount, fitGoodsAmount);
if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(fitGoodsAmount) > 0) { if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(fitGoodsAmount) > 0) {
if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣 if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣
...@@ -231,19 +231,11 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -231,19 +231,11 @@ public class CouponUserServiceImpl implements ICouponUserService {
orderDetails.forEach(orderDetail -> { orderDetails.forEach(orderDetail -> {
BigDecimal couponAmount = couponAmountMap.get(orderDetail.getSkuId()); BigDecimal couponAmount = couponAmountMap.get(orderDetail.getSkuId());
orderDetail.setCouponAmount(couponAmount == null ? BigDecimal.ZERO : couponAmount.negate()); orderDetail.setCouponAmount(couponAmount == null ? BigDecimal.ZERO : couponAmount.negate());
if (couponAmount.compareTo(BigDecimal.ZERO) > 0) {
if (orderDetail.getOriAmount().add(orderDetail.getCouponAmount()).compareTo(BigDecimal.ZERO) < 0) {
orderDetail.setRealAmount(BigDecimal.ZERO);
} else {
orderDetail.setRealAmount(orderDetail.getOriAmount().add(orderDetail.getCouponAmount()));
}
} else {
if (orderDetail.getAmountShould().add(orderDetail.getCouponAmount()).compareTo(BigDecimal.ZERO) < 0) { if (orderDetail.getAmountShould().add(orderDetail.getCouponAmount()).compareTo(BigDecimal.ZERO) < 0) {
orderDetail.setRealAmount(BigDecimal.ZERO); orderDetail.setRealAmount(BigDecimal.ZERO);
} else { } else {
orderDetail.setRealAmount(orderDetail.getAmountShould().add(orderDetail.getCouponAmount())); orderDetail.setRealAmount(orderDetail.getAmountShould().add(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