| | |
| | | if (couponId != null && couponId != 0) { |
| | | if (null != couponId && reservationSite.getPayType() != 3) { |
| | | UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(reservationSite.getCouponId(), uid)); |
| | | if (userCoupon != null && userCoupon.getStatus() == 2) { |
| | | return ResultUtil.error("优惠券已被核销"); |
| | | if (userCoupon == null || userCoupon.getStatus() == null || userCoupon.getStatus() != 1) { |
| | | return ResultUtil.error("优惠券不可用"); |
| | | } |
| | | Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId()); |
| | | long time = coupon.getEndTime().getTime(); |
| | |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | | |
| | | money = money.subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN); |
| | | money = money.subtract(new BigDecimal(num2)).max(BigDecimal.ZERO).setScale(2, RoundingMode.HALF_EVEN); |
| | | } |
| | | if (userCoupon != null && coupon.getType() == 2) {//代金券 |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | |
| | | if (money.compareTo(new BigDecimal(num1)) <= 0) { |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | | money = money.subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN); |
| | | money = money.subtract(new BigDecimal(num1)).max(BigDecimal.ZERO).setScale(2, RoundingMode.HALF_EVEN); |
| | | } |
| | | userCoupon.setStatus(2); |
| | | userCouponClient.updateUserCoupon(userCoupon); |