| | |
| | | @Autowired |
| | | private TBackRecordService backRecordService; |
| | | |
| | | @Autowired |
| | | private ISiteBookingService iSiteBookingService; |
| | | |
| | | @Autowired |
| | | private ISiteService siteService; |
| | | |
| | | |
| | | /** |
| | | * 获取场地列表 |
| | |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private ISiteBookingService iSiteBookingService; |
| | | @Autowired |
| | | private ISiteService siteService; |
| | | |
| | | |
| | | /** |
| | | * 获取场地预约日期数据 |
| | |
| | | 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).ne("status", 5).eq("nextName", siteName).like("times", day)); |
| | | |
| | | |
| | | if (siteName == null || siteName.equals("")) { |
| | | siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).ne("status", 5).like("times", day)); |
| | |
| | | */ |
| | | @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(";"); |
| | |
| | | payMoney = new BigDecimal(site.getPlayPaiCoinOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | 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(); |
| | | } else { |
| | | payMoney = new BigDecimal(site.getCashPriceOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | |
| | | } |
| | | } |
| | | |
| | | //校验优惠券 |
| | | Long couponId = reservationSite.getCouponId(); |
| | | 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("优惠券已被核销"); |
| | | } |
| | |
| | | return ResultUtil.error("优惠券已过期"); |
| | | } |
| | | if (userCoupon != null && coupon.getType() == 1) {//满减 |
| | | // {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | Double num2 = jsonObject.getDouble("deductionAmount"); |
| | |
| | | siteBooking.setState(1); |
| | | siteBooking.setInsertTime(new Date()); |
| | | |
| | | // 2.0 |
| | | siteBooking.setNextName(reservationSite.getNextName()); |
| | | siteBooking.setIsHalf(reservationSite.getIsHalf()); |
| | | siteBooking.setHalfName(reservationSite.getHalfName()); |
| | |
| | | |
| | | if (reservationSite.getPayType() == 1) {//微信支付 |
| | | ResultUtil resultUtil = weChatPaymentSite(payMoney, siteBooking); |
| | | |
| | | return resultUtil; |
| | | } |
| | | if (reservationSite.getPayType() == 2) {//支付宝支付 |
| | |
| | | public ResultUtil weChatPaymentSite(Double paymentPrice, SiteBooking siteBooking) throws Exception { |
| | | String code = siteBooking.getOrderNo(); |
| | | Integer id = siteBooking.getId(); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("预约场地", id.toString(), 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 |
| | |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("trade_state"); |
| | | String transaction_id = data1.get("transaction_id"); |
| | | if ("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10) { |
| | | if ("REFUND".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10) { |
| | | break; |
| | | } |
| | | if ("SUCCESS".equals(s)) { |
| | |
| | | siteBookingService.updateById(siteBooking); |
| | | break; |
| | | } |
| | | if ("USERPAYING".equals(s)) { |
| | | if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | |
| | | return weixinpay; |
| | | } |
| | | |
| | | |
| | | private String smid = "2088330203191220";//平台支付宝商户号 |
| | | /** |
| | | * 课程支付宝支付 |
| | | * |
| | |
| | | public ResultUtil aliPaymentSite(Double paymentPrice, SiteBooking siteBooking) throws Exception { |
| | | String code = siteBooking.getOrderNo(); |
| | | Integer id = siteBooking.getId(); |
| | | ResultUtil alipay = payMoneyUtil.alipay("预约场地", "预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback"); |
| | | // 判断预约的门店 属于哪个运营商 |
| | | Integer storeId = siteBooking.getStoreId(); |
| | | Store byId = storeService.getById(storeId); |
| | | Integer operatorId = byId.getOperatorId(); |
| | | String smid1 = ""; |
| | | if (operatorId == null ){ |
| | | // 平台的门店 |
| | | smid1 = smid; |
| | | }else if (operatorId == 0){ |
| | | smid1 = smid; |
| | | }else{ |
| | | smid1 = siteService.getSMIDByOperatorId(operatorId); |
| | | |
| | | } |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1,"预约场地", "预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback"); |
| | | System.out.println("预约场地----" + alipay.getCode()); |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | |
| | | siteBooking.setPayOrderNo(tradeNo); |
| | | siteBookingService.updateById(siteBooking); |
| | | System.err.println("======完成支付"); |
| | | // 判断预约的门店 属于哪个运营商 |
| | | Integer storeId = siteBooking.getStoreId(); |
| | | Store byId = storeService.getById(storeId); |
| | | Integer operatorId = byId.getOperatorId(); |
| | | String smid1 = ""; |
| | | if (operatorId == null ){ |
| | | // 平台的门店 |
| | | }else if (operatorId == 0){ |
| | | smid1 = smid; |
| | | }else{ |
| | | smid1 = siteService.getSMIDByOperatorId(operatorId); |
| | | |
| | | } |
| | | payMoneyUtil.confirm(smid1,code,tradeNo,paymentPrice.toString()); |
| | | break; |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | |
| | | } |
| | | |
| | | if (siteBooking.getStatus() == 0) { |
| | | // return ResultUtil.error("请先进行支付"); |
| | | siteBooking.setStatus(5); |
| | | siteBookingService.updateById(siteBooking); |
| | | AppUser appUser = appUserClient.queryAppUser(siteBooking.getAppUserId()); |
| | |
| | | return ResultUtil.error("不能进行取消操作"); |
| | | } |
| | | if (siteBooking.getPayType() == 1) {//微信支付 |
| | | Map<String, String> map = payMoneyUtil.wxRefund(siteBooking.getPayOrderNo(), siteBooking.getOrderNo(), siteBooking.getPayMoney().toString(), siteBooking.getPayMoney().toString(), "/base/site/cancelMySiteCallback"); |
| | | Map<String, String> map = payMoneyUtil.wxRefund(siteBooking.getPayOrderNo(), siteBooking.getOrderNo(), siteBooking.getPayMoney().toString(), |
| | | siteBooking.getPayMoney().toString(), "/base/site/cancelMySiteCallback"); |
| | | if (null == map) { |
| | | return ResultUtil.error("取消退款异常"); |
| | | } |
| | | String result_code = map.get("result_code"); |
| | | if (!"SUCCESS".equals(result_code)) { |
| | | String return_code = map.get("return_code"); |
| | | if (!"SUCCESS".equals(return_code)) { |
| | | return ResultUtil.error(map.get("return_msg")); |
| | | } |
| | | siteBooking.setCancelUserId(uid); |
| | |
| | | return siteMapper.changeState(siteIds, type); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public String getSMIDByOperatorId(Integer id) { |
| | | return siteMapper.getSMIDByOperatorId(id); |
| | | } |
| | | } |