liujie
2023-08-08 5592de9cf80aa78486775a72a6224973c93146da
cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java
@@ -11,6 +11,7 @@
import com.dsh.other.feignclient.activity.CouponClient;
import com.dsh.other.feignclient.activity.UserCouponClient;
import com.dsh.other.feignclient.activity.model.Coupon;
import com.dsh.other.feignclient.activity.model.QueryUserCouponByIdAndUserId;
import com.dsh.other.feignclient.activity.model.UserCoupon;
import com.dsh.other.mapper.SiteMapper;
import com.dsh.other.model.*;
@@ -210,7 +211,7 @@
        //校验优惠券
        Long couponId = reservationSite.getCouponId();
        if(null != couponId && reservationSite.getPayType() != 3){
            UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId);
            UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(reservationSite.getCouponId(),uid));
            if(userCoupon.getStatus() == 2){
                return ResultUtil.error("优惠券已被核销");
            }
@@ -220,9 +221,10 @@
                return ResultUtil.error("优惠券已过期");
            }
            if(coupon.getType() == 1){//满减
//                {"conditionalAmount":50,"deductionAmount":10,"experienceName":""}
                JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                Double num1 = jsonObject.getDouble("num1");
                Double num2 = jsonObject.getDouble("num2");
                Double num1 = jsonObject.getDouble("conditionalAmount");
                Double num2 = jsonObject.getDouble("deductionAmount");
                if(payMoney.compareTo(num1) <= 0){
                    return ResultUtil.error("该优惠券无法使用");
                }
@@ -231,7 +233,7 @@
            }
            if(coupon.getType() == 2){//代金券
                JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                Double num1 = jsonObject.getDouble("num1");
                Double num1 = jsonObject.getDouble("conditionalAmount");
                if(payMoney.compareTo(num1) <= 0){
                    return ResultUtil.error("该优惠券无法使用");
                }
@@ -276,11 +278,7 @@
        return ResultUtil.success();
    }
    public static void main(String[] args) {
        String a ="2023-07-28 10:30-15:30";
        String substring = a.substring(0,a.lastIndexOf("-"));
        System.out.println(substring);
    }
    /**
     * 课程微信支付
     * @param paymentPrice
@@ -490,7 +488,7 @@
            siteBooking.setRefundOrderNo(trade_no);
            siteBookingService.updateById(siteBooking);
            if(null != siteBooking.getUserCouponId()){
                UserCoupon userCoupon = userCouponClient.queryUserCouponById(siteBooking.getUserCouponId());
                UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),siteBooking.getAppUserId()));
                userCoupon.setStatus(1);
                userCouponClient.updateUserCoupon(userCoupon);
            }
@@ -506,7 +504,7 @@
            siteBooking.setCancelTime(new Date());
            siteBookingService.updateById(siteBooking);
            if(null != siteBooking.getUserCouponId()){
                UserCoupon userCoupon = userCouponClient.queryUserCouponById(siteBooking.getUserCouponId());
                UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),appUser.getId()));
                userCoupon.setStatus(1);
                userCouponClient.updateUserCoupon(userCoupon);
            }
@@ -545,24 +543,25 @@
        //校验优惠券
        Long couponId = siteBooking.getUserCouponId();
        if(null != couponId && payType != 3){
            UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId);
            UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),appUser.getId()));
            Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId());
            if(coupon.getType() == 1){//满减
//                {"conditionalAmount":50,"deductionAmount":10,"experienceName":""}
                JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                Double num1 = jsonObject.getDouble("num1");
                Double num2 = jsonObject.getDouble("num2");
                Double num1 = jsonObject.getDouble("conditionalAmount");
                Double num2 = jsonObject.getDouble("deductionAmount");
                payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
            }
            if(coupon.getType() == 2){//代金券
                JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                Double num1 = jsonObject.getDouble("num1");
                Double num1 = jsonObject.getDouble("conditionalAmount");
                payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
            }
            userCoupon.setStatus(2);
            userCouponClient.updateUserCoupon(userCoupon);
        }
        if(null != couponId && payType == 3){
            UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId);
            UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),appUser.getId()));
            userCoupon.setStatus(1);
            userCouponClient.updateUserCoupon(userCoupon);
        }
@@ -610,17 +609,18 @@
        //校验优惠券
        Long couponId = siteBooking.getUserCouponId();
        if(null != couponId){
            UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId);
            UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),siteBooking.getAppUserId()));
            Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId());
            if(coupon.getType() == 1){//满减
//                {"conditionalAmount":50,"deductionAmount":10,"experienceName":""}
                JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                Double num1 = jsonObject.getDouble("num1");
                Double num2 = jsonObject.getDouble("num2");
                Double num1 = jsonObject.getDouble("conditionalAmount");
                Double num2 = jsonObject.getDouble("deductionAmount");
                payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
            }
            if(coupon.getType() == 2){//代金券
                JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                Double num1 = jsonObject.getDouble("num1");
                Double num1 = jsonObject.getDouble("conditionalAmount");
                payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
            }
        }