From e030255c23c7ba3e2cbad1036a810d6d72fa864f Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期四, 26 十月 2023 18:04:58 +0800
Subject: [PATCH] 修改bug

---
 cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java |   41 ++++++++++++++++++++++++++++++-----------
 1 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java b/cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java
index 3efad9a..041bb6b 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java
@@ -177,9 +177,12 @@
 
 //        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));
         }
+
 
         System.out.println("=======siteBookings======"+siteBookings);
         for (SiteBooking siteBooking : siteBookings) {
@@ -193,6 +196,12 @@
                     strings.add(convertedValue);
                 }
             }else {
+                if (halfName==null){
+                    for (String s : split) {
+                        String convertedValue = s.substring(11);
+                        strings.add(convertedValue);
+                    }
+                }
 
                 if (siteBooking.getHalfName().equals(halfName)){
                     for (String s : split) {
@@ -313,17 +322,18 @@
      */
     @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 + "】" +
+                            "时间段已被使用");
                 }
             }
         }
@@ -343,7 +353,8 @@
                 payMoney = new BigDecimal(site.getPlayPaiCoinOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
             }
             if(appUser.getPlayPaiCoins().compareTo(payMoney.intValue()) < 0){
-                return ResultUtil.error("玩湃币不足");
+
+                return new ResultUtil(3,"玩湃币不足");
             }
         }else{
             payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
@@ -357,7 +368,7 @@
             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());
@@ -365,7 +376,7 @@
             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");
@@ -376,7 +387,7 @@
 
                 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){
@@ -418,7 +429,9 @@
         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);
@@ -443,7 +456,7 @@
     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
@@ -507,7 +520,7 @@
     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
@@ -573,7 +586,9 @@
         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);
     }
 
 
@@ -715,7 +730,11 @@
                 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();
+            }
         }
 
         //校验优惠券

--
Gitblit v1.7.1