From afa61267844723f906a632e4ac8b30f91cf4a3c0 Mon Sep 17 00:00:00 2001
From: 刘帅 <rr.iii@qq.com>
Date: 星期一, 21 九月 2026 11:56:04 +0800
Subject: [PATCH] bug:获取优惠券接口问题

---
 cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java |    6 +++---
 1 files changed, 3 insertions(+), 3 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 3515c38..a01492b 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
@@ -848,7 +848,7 @@
                 if (userCoupon != null && coupon.getType() == 2) {//代金券
                     JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                     Double num1 = jsonObject.getDouble("conditionalAmount");
-                    if (money.compareTo(new BigDecimal(num1)) <= 0) {
+                    if (num1 == null || num1 <= 0) {
                         return ResultUtil.error("该优惠券无法使用");
                     }
                     money = money.subtract(new BigDecimal(num1)).max(BigDecimal.ZERO).setScale(2, RoundingMode.HALF_EVEN);
@@ -1280,7 +1280,7 @@
             if (coupon.getType() == 2) {//代金券
                 JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                 Double num1 = jsonObject.getDouble("conditionalAmount");
-                money = money.subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN);
+                money = money.subtract(new BigDecimal(num1)).max(BigDecimal.ZERO).setScale(2, RoundingMode.HALF_EVEN);
             }
             userCoupon.setStatus(2);
             userCouponClient.updateUserCoupon(userCoupon);
@@ -1368,7 +1368,7 @@
             if (coupon.getType() == 2) {//代金券
                 JSONObject jsonObject = JSON.parseObject(coupon.getContent());
                 Double num1 = jsonObject.getDouble("conditionalAmount");
-                money = money.subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN);
+                money = money.subtract(new BigDecimal(num1)).max(BigDecimal.ZERO).setScale(2, RoundingMode.HALF_EVEN);
             }
         }
         switch (siteBooking.getPayType()) {

--
Gitblit v1.7.1