Commit f3e5195a by weijiguang

test

parent 9925d2fb
......@@ -22,6 +22,7 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -214,6 +215,20 @@ public class CouponUserServiceImpl implements ICouponUserService {
return;
}
couponVo.setCouponAmount(couponVo.getPriceDiscount().min(orderTotalOrigDiscount));
AtomicReference<Integer> nums = new AtomicReference<>(0);
orderDetails.forEach(x -> nums.updateAndGet(v -> v + x.getNum()));
if (nums.get() <= 1) {
OrderDetail orderDetail = orderDetails.get(0);
orderDetail.setCouponAmount(couponVo.getCouponAmount());
orderDetail.setRealAmount(orderDetail.getAmountShould().add(orderDetail.getCouponAmount()));
} else {
orderDetails.forEach(orderDetail -> {
BigDecimal rate = orderDetail.getAmountShould().divide(orderTotalOrigDiscount);
orderDetail.setCouponAmount(couponVo.getCouponAmount().multiply(rate));
orderDetail.setRealAmount(orderDetail.getAmountShould().add(orderDetail.getCouponAmount()));
});
}
} else {
List<OrderDetail> fitOrderDetails = orderDetails.stream().filter(orderDetail -> fitCouponGoodsIdList.contains(orderDetail.getGoodsId())).collect(Collectors.toList());
BigDecimal fitGoodsAmount = fitOrderDetails.stream().map(x -> x.getAmountShould().multiply(new BigDecimal(x.getNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
......
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