From a5d4f5da140e15781f1b39a49876104ce398b178 Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期三, 18 九月 2024 14:33:42 +0800
Subject: [PATCH] 1.优惠券-活动优惠券-增加领取时间的结束时间小于当前时间则不可以发布
---
src/main/java/com/mzl/flower/web/v2/coupon/CouponTemplateActivyController.java | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/mzl/flower/web/v2/coupon/CouponTemplateActivyController.java b/src/main/java/com/mzl/flower/web/v2/coupon/CouponTemplateActivyController.java
index 09721fe..7905c5f 100644
--- a/src/main/java/com/mzl/flower/web/v2/coupon/CouponTemplateActivyController.java
+++ b/src/main/java/com/mzl/flower/web/v2/coupon/CouponTemplateActivyController.java
@@ -24,6 +24,7 @@
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
+import java.time.LocalDateTime;
/**
@@ -133,6 +134,27 @@
throw new ValidationException("优惠券不存在");
}
+ // 判断当前时间是否在优惠券的领取时间范围内
+ LocalDateTime now = LocalDateTime.now();
+// if (couponTemplateDO.getGetStartDate() != null && couponTemplateDO.getGetEndDate() != null) {
+// if (now.isBefore(couponTemplateDO.getGetStartDate()) || now.isAfter(couponTemplateDO.getGetEndDate())) {
+// throw new ValidationException("当前时间不在优惠券领取时间范围内,不能发布优惠券。");
+// }
+// } else {
+// throw new ValidationException("优惠券的领取时间未设置。");
+// }
+
+ // 检查结束时间是否存在
+ if (couponTemplateDO.getGetEndDate() != null) {
+ // 如果当前时间小于结束时间,允许发布
+ if (now.isAfter(couponTemplateDO.getGetEndDate())) {
+ throw new ValidationException("当前时间已超过优惠券领取结束时间,不能发布优惠券。");
+ }
+ } else {
+ throw new ValidationException("优惠券的领取结束时间未设置。");
+ }
+
+
couponTemplateService.activeCouponTemplate(id);
return returnData(R.SUCCESS.getCode(), null);
--
Gitblit v1.9.3