| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | |
| | | public List<QuerySiteTimes> querySiteTimes(Integer id, String day,String halfName,String siteName) throws Exception { |
| | | |
| | | System.out.println("=======date======"+day); |
| | | |
| | | List<String> strings = new ArrayList<>(); |
| | | |
| | | // List<SiteBooking> siteBookings = siteClient.listBooks(id); |
| | | List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("nextName",siteName).like("times",day)); |
| | | List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).ne("status",5).eq("nextName",siteName).like("times",day)); |
| | | |
| | | |
| | | if (siteName==null|| siteName.equals("")){ |
| | | siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).like("times",day)); |
| | | siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).ne("status",5).like("times",day)); |
| | | } |
| | | |
| | | |
| | |
| | | if(stringDateBetween){ |
| | | orderDto.setSelectable(0); |
| | | } |
| | | if (DateComparisonExample.isStringWithinTimeRange(stime, siteLock.getStartTime(), siteLock.getEndTime())){ |
| | | orderDto.setSelectable(0); |
| | | } |
| | | if (DateComparisonExample.isStringWithinTimeRange(etime, siteLock.getStartTime(), siteLock.getEndTime())){ |
| | | orderDto.setSelectable(0); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public static String getNextTime(String currentTime) { |
| | |
| | | Double payMoney = 0D; |
| | | if(reservationSite.getPayType() == 3){ |
| | | if(reservationSite.getIsHalf()==2){ |
| | | payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue() ; |
| | | }else { |
| | | payMoney = new BigDecimal(site.getPlayPaiCoinOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | |
| | | return new ResultUtil(3,"玩湃币不足"); |
| | | } |
| | | }else{ |
| | | payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | if(reservationSite.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(); |
| | | |
| | | } |
| | | } |
| | | |
| | | //校验优惠券 |
| | |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | Double num2 = jsonObject.getDouble("deductionAmount"); |
| | | if(payMoney.compareTo(num1) <= 0){ |
| | | if(payMoney.compareTo(num1) < 0){ |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | | |
| | |
| | | siteBooking.setIsHalf(reservationSite.getIsHalf()); |
| | | siteBooking.setHalfName(reservationSite.getHalfName()); |
| | | siteBookingService.save(siteBooking); |
| | | |
| | | |
| | | |
| | | |
| | | if(reservationSite.getPayType() == 1){//微信支付 |
| | | ResultUtil resultUtil = weChatPaymentSite(payMoney, siteBooking); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 课程支付宝支付 |
| | | * @param paymentPrice |
| | |
| | | String code = siteBooking.getOrderNo(); |
| | | Integer id = siteBooking.getId(); |
| | | ResultUtil alipay = payMoneyUtil.alipay("预约场地", "预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback"); |
| | | System.out.println("预约场地----"+alipay.getCode()); |
| | | if(alipay.getCode() == 200){ |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | if(siteBooking.getStatus() != 0){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode() == 200 && siteBooking.getStatus() == 0){ |
| | | AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode().equals("10000") && siteBooking.getStatus() == 0){ |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("tradeStatus"); |
| | | String tradeNo = data1.get("tradeNo"); |
| | | // Map<String, String> data1 = resultUtil.getData(); |
| | | // String s = data1.get("tradeStatus"); |
| | | String tradeNo = resultUtil.getTradeNo(); |
| | | String s = resultUtil.getTradeStatus(); |
| | | System.out.println("ssssss"+s); |
| | | if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){ |
| | | break; |
| | | } |
| | |
| | | siteBooking.setStatus(1); |
| | | siteBooking.setPayOrderNo(tradeNo); |
| | | siteBookingService.updateById(siteBooking); |
| | | System.err.println("======完成支付"); |
| | | break; |
| | | } |
| | | if("WAIT_BUYER_PAY".equals(s)){ |
| | |
| | | Site site = this.getById(siteBooking.getSiteId()); |
| | | String[] split = siteBooking.getTimes().split(";"); |
| | | if(site!=null){ |
| | | |
| | | queryMySiteVo.setPlayPaiCoin(site.getPlayPaiCoin() * split.length); |
| | | if (queryMySiteVo.getIsHalf()==1) { |
| | | queryMySiteVo.setPlayPaiCoin(site.getPlayPaiCoin() * split.length); |
| | | }else { |
| | | queryMySiteVo.setPlayPaiCoin((int) (site.getPlayPaiCoinOne() * split.length)); |
| | | } |
| | | } |
| | | } |
| | | return queryMySiteVos; |
| | |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | Date startTime = siteBooking.getStartTime(); |
| | | if(format.format(new Date()).equals(format.format(startTime))){ |
| | | if(format.format(new Date()).equals(format.format(startTime))&&siteBooking.getStatus() != 0){ |
| | | return ResultUtil.error("预约当天,不能取消"); |
| | | } |
| | | |
| | | if(siteBooking.getStatus() == 0){ |
| | | return ResultUtil.error("请先进行支付"); |
| | | // return ResultUtil.error("请先进行支付"); |
| | | siteBooking.setStatus(5); |
| | | siteBookingService.updateById(siteBooking); |
| | | AppUser appUser = appUserClient.queryAppUser(siteBooking.getAppUserId()); |
| | | |
| | | if(null != siteBooking.getUserCouponId()&&siteBooking.getUserCouponId()!=0){ |
| | | UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),appUser.getId())); |
| | | userCoupon.setStatus(1); |
| | | userCouponClient.updateUserCoupon(userCoupon); |
| | | } |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | if(siteBooking.getStatus() != 1 && siteBooking.getStatus() != 2){ |
| | | return ResultUtil.error("不能进行取消操作"); |
| | |
| | | siteBooking.setCancelTime(new Date()); |
| | | siteBooking.setRefundOrderNo(trade_no); |
| | | siteBookingService.updateById(siteBooking); |
| | | if(null != siteBooking.getUserCouponId()){ |
| | | if(null != siteBooking.getUserCouponId()&&siteBooking.getUserCouponId()!=0){ |
| | | UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),siteBooking.getAppUserId())); |
| | | userCoupon.setStatus(1); |
| | | userCouponClient.updateUserCoupon(userCoupon); |
| | |
| | | siteBooking.setCancelUserId(uid); |
| | | siteBooking.setCancelTime(new Date()); |
| | | siteBookingService.updateById(siteBooking); |
| | | if(null != siteBooking.getUserCouponId()){ |
| | | if(null != siteBooking.getUserCouponId()&&siteBooking.getUserCouponId()!=0){ |
| | | UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),appUser.getId())); |
| | | userCoupon.setStatus(1); |
| | | userCouponClient.updateUserCoupon(userCoupon); |
| | |
| | | String[] split = siteBooking.getTimes().split(";"); |
| | | Double payMoney = 0D; |
| | | if(payType == 3){ |
| | | payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | // payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | if(appUser.getPlayPaiCoins().compareTo(payMoney.intValue()) < 0){ |
| | | return ResultUtil.error("玩湃币不足"); |
| | | } |
| | | |
| | | if(siteBooking.getIsHalf()==2){ |
| | | payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | }else { |
| | | payMoney = new BigDecimal(site.getPlayPaiCoinOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | }else{ |
| | | if(siteBooking.getIsHalf()==2){ |
| | |
| | | String[] split = siteBooking.getTimes().split(";"); |
| | | Map<String, Double> map = new HashMap<>(); |
| | | Double payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | |
| | | |
| | | if(siteBooking.getIsHalf()==2){ |
| | | payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | }else { |
| | | payMoney = new BigDecimal(site.getPlayPaiCoinOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | |
| | | map.put("playPaiCoin", payMoney); |
| | | 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(); |
| | | } |
| | | |
| | | //校验优惠券 |
| | | Long couponId = siteBooking.getUserCouponId(); |
| | | if(null != couponId){ |
| | | if(null != couponId&&couponId!=0){ |
| | | UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),siteBooking.getAppUserId())); |
| | | Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId()); |
| | | if(coupon.getType() == 1){//满减 |