| | |
| | | } |
| | | } |
| | | |
| | | if (request.getRank() == null && goods.size() > 0) { |
| | | goods = goods.stream() |
| | | .sorted(Comparator.comparing(Goods::getGoodId, Comparator.reverseOrder())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | //当前第几页 |
| | | int pageNo = request.getPageNum(); |
| | | //一页五条 |
| | |
| | | @Override |
| | | @Transactional |
| | | public synchronized ResultUtil productRedemptionOperation(Integer userIdFormRedis, GoodsExchangeVo exchangeType) { |
| | | // 兼容前端历史参数 chooseCouponId,内部统一使用 couponId。 |
| | | if (exchangeType.getCouponId() == null && exchangeType.getChooseCouponId() != null) { |
| | | exchangeType.setCouponId(exchangeType.getChooseCouponId()); |
| | | } |
| | | ReturnModel returnModel = new ReturnModel(); |
| | | Long returnId = null; |
| | | //如果是兑换优惠卷 |
| | |
| | | .divide(BigDecimal.valueOf(exchangeType.getNums() == null ? 1 : exchangeType.getNums()), 2, java.math.RoundingMode.HALF_UP); |
| | | } else if (Integer.valueOf(2).equals(coupon.getType())) { |
| | | BigDecimal deduction = rule.getBigDecimal("conditionalAmount"); |
| | | if (deduction == null || orderCash.compareTo(deduction) < 0) { |
| | | if (deduction == null || deduction.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | | // 代金券可覆盖全部订单金额,超出订单金额的部分不找零。 |
| | | ticketPayableCashAmount = orderCash.subtract(deduction).max(BigDecimal.ZERO); |
| | | cashAmount = ticketPayableCashAmount |
| | | .divide(BigDecimal.valueOf(exchangeType.getNums() == null ? 1 : exchangeType.getNums()), 2, java.math.RoundingMode.HALF_UP); |