| | |
| | | */ |
| | | @Override |
| | | public ResultUtil reservationSite(Integer uid, ReservationSite reservationSite) throws Exception { |
| | | |
| | | Site site = this.getById(reservationSite.getId()); |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | String[] split = reservationSite.getTimes().split(";"); |
| | | |
| | | for (String s : split) { |
| | | String day = s.split(" ")[0]; |
| | | String time = s.split(" ")[1]; |
| | | List<QuerySiteTimes> querySiteTimes = querySiteTimes(reservationSite.getId(), day,reservationSite.getHalfName(),reservationSite.getNextName()); |
| | | for (QuerySiteTimes querySiteTime : querySiteTimes) { |
| | | if(querySiteTime.getTime().equals(time) && querySiteTime.getSelectable() == 0){ |
| | | return ResultUtil.error("【" + s + "】时间段已被使用"); |
| | | return ResultUtil.error("【" + s + "】" + |
| | | "时间段已被使用"); |
| | | } |
| | | } |
| | | } |
| | |
| | | UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(reservationSite.getCouponId(),uid)); |
| | | |
| | | |
| | | if(userCoupon.getStatus() == 2){ |
| | | if(userCoupon!=null && userCoupon.getStatus() == 2){ |
| | | return ResultUtil.error("优惠券已被核销"); |
| | | } |
| | | Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId()); |
| | |
| | | if(System.currentTimeMillis() >= time){ |
| | | return ResultUtil.error("优惠券已过期"); |
| | | } |
| | | if(coupon.getType() == 1){//满减 |
| | | if(userCoupon!=null && coupon.getType() == 1){//满减 |
| | | // {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | |
| | | |
| | | payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | if(coupon.getType() == 2){//代金券 |
| | | if(userCoupon!=null && coupon.getType() == 2){//代金券 |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | if(payMoney.compareTo(num1) <= 0){ |
| | |
| | | return ResultUtil.error("玩湃币不足"); |
| | | } |
| | | }else{ |
| | | payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | if(siteBooking.getIsHalf()==2){ |
| | | payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | }else { |
| | | payMoney = new BigDecimal(site.getCashPriceOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | } |
| | | |
| | | //校验优惠券 |