From 7302e3c9e686ab0d404e936e7e324b314deca1b3 Mon Sep 17 00:00:00 2001
From: gongzuming <gongzuming>
Date: 星期日, 22 九月 2024 19:50:44 +0800
Subject: [PATCH] 查询条件
---
src/main/java/com/mzl/flower/web/v2/coupon/CouponTemplateActivyController.java | 39 ++++++++++++++++++++++++++++++++++-----
1 files changed, 34 insertions(+), 5 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 9ce4203..f06fbf6 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
@@ -11,10 +11,7 @@
import com.mzl.flower.dto.response.coupon.CouponTemplatePointVO;
import com.mzl.flower.dto.response.coupon.CouponTemplateVO;
import com.mzl.flower.entity.coupon.CouponTemplateDO;
-import com.mzl.flower.enums.CouponCategoryEnum;
-import com.mzl.flower.enums.CouponGetUserTypeEnum;
-import com.mzl.flower.enums.CouponTypeEnum;
-import com.mzl.flower.enums.CouponUsageTypeEnum;
+import com.mzl.flower.enums.*;
import com.mzl.flower.service.coupon.CouponTemplateService2;
import com.mzl.flower.utils.ConverterUtil;
import io.swagger.annotations.Api;
@@ -27,6 +24,7 @@
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
+import java.time.LocalDateTime;
/**
@@ -136,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);
@@ -161,7 +180,7 @@
if (StringUtils.isNotBlank(dto.getCouponDiscountType())
&& dto.getCouponDiscountType().equals(CouponTypeEnum.DISCOUNT.getType())
&& dto.getMinOrderAmount().compareTo(dto.getCouponDiscountValue()) < 0) {
- throw new ValidationException("订单金额不能小于折扣金额");
+ throw new ValidationException("优惠券使用条件不能小于面值金额");
}
if (StringUtils.isNotBlank(dto.getCouponDiscountType())
&& dto.getCouponDiscountType().equals(CouponTypeEnum.DISCOUNT.getType())
@@ -200,6 +219,16 @@
throw new ValidationException("领取后有效时间整数需要大于0");
}
}
+
+ // 用户获取的类型是首页领取的话
+ if(StringUtils.isNotBlank(dto.getGetType()) && dto.getGetType().equals(dto.getGetType().equals(CouponGetTypeEnum.HOME.getType()))
+ ){
+ // 优惠券图片校验
+ if(StringUtils.isBlank(dto.getImageUrl())){
+ throw new ValidationException("优惠券图片不能为空");
+ }
+ }
+
}
}
--
Gitblit v1.9.3