| | |
| | | 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; |
| | |
| | | |
| | | // List<SiteBooking> siteBookings = siteClient.listBooks(id); |
| | | List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("nextName",siteName).like("times",day)); |
| | | |
| | | |
| | | if (siteName==null|| siteName.equals("")){ |
| | | siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).like("times",day)); |
| | | } |
| | |
| | | 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(); |
| | | payMoney = new BigDecimal(site.getPlayPaiCoinOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue() /2; |
| | | } |
| | | if(appUser.getPlayPaiCoins().compareTo(payMoney.intValue()) < 0){ |
| | | |
| | | 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.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue() / 2; |
| | | |
| | | } |
| | | } |
| | | |
| | | //校验优惠券 |
| | |
| | | siteBooking.setHalfName(reservationSite.getHalfName()); |
| | | siteBookingService.save(siteBooking); |
| | | |
| | | |
| | | |
| | | |
| | | if(reservationSite.getPayType() == 1){//微信支付 |
| | | return weChatPaymentSite(payMoney, siteBooking); |
| | | ResultUtil resultUtil = weChatPaymentSite(payMoney, siteBooking); |
| | | |
| | | return resultUtil; |
| | | } |
| | | if(reservationSite.getPayType() == 2){//支付宝支付 |
| | | return aliPaymentSite(payMoney, siteBooking); |
| | |
| | | public ResultUtil weChatPaymentSite(Double paymentPrice, SiteBooking siteBooking) throws Exception{ |
| | | String code = siteBooking.getOrderNo(); |
| | | Integer id = siteBooking.getId(); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("预约场地", "", code, paymentPrice.toString(), "/base/site/weChatPaymentSiteCallback", "APP", ""); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/weChatPaymentSiteCallback", "APP", ""); |
| | | if(weixinpay.getCode() == 200){ |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | public ResultUtil aliPaymentSite(Double paymentPrice, SiteBooking siteBooking) throws Exception{ |
| | | String code = siteBooking.getOrderNo(); |
| | | Integer id = siteBooking.getId(); |
| | | ResultUtil alipay = payMoneyUtil.alipay("预约场地", "预约场地", "", code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback"); |
| | | ResultUtil alipay = payMoneyUtil.alipay("预约场地", "预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback"); |
| | | 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(); |
| | | 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)){ |
| | |
| | | siteBooking.setPayTime(new Date()); |
| | | siteBooking.setStatus(1); |
| | | siteBookingService.updateById(siteBooking); |
| | | return ResultUtil.success(); |
| | | HashMap<String, String> map = new HashMap<>(); |
| | | map.put("siteBooking",siteBooking.getId().toString()); |
| | | return ResultUtil.success(map); |
| | | } |
| | | |
| | | |