|
@@ -88,6 +88,8 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
.eq(MercCoupon::getMercId, param.getInt("mercId"))
|
|
|
.in(MercCoupon::getId, param.getList("couponIdList"));
|
|
|
List<MercCoupon> couponList = list(lqw);
|
|
|
+ //过滤超过使用时间的券
|
|
|
+ couponList = filterCouponValidEndDate(couponList);
|
|
|
if (!Emptys.check(couponList)) {
|
|
|
throw new BusinessException("没有可以赠送的优惠券!");
|
|
|
}
|
|
@@ -120,6 +122,8 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
.or()
|
|
|
.ge(MercCoupon::getSendEndDate, today));
|
|
|
List<MercCoupon> list = list(lqw);
|
|
|
+ //过滤超过使用时间的券
|
|
|
+ list = filterCouponValidEndDate(list);
|
|
|
if (!Emptys.check(list)) {
|
|
|
throw new BusinessException("没有可赠送的优惠券!");
|
|
|
}
|
|
@@ -165,6 +169,8 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
.or()
|
|
|
.ge(MercCoupon::getSendEndDate, orderCreateTime));
|
|
|
List<MercCoupon> list = list(lqw);
|
|
|
+ //过滤超过使用时间的券
|
|
|
+ list = filterCouponValidEndDate(list);
|
|
|
if (!Emptys.check(list)) {
|
|
|
throw new BusinessException("没有可赠送的优惠券!");
|
|
|
}
|
|
@@ -200,6 +206,8 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
.or()
|
|
|
.ge(MercCoupon::getSendEndDate, today));
|
|
|
List<MercCoupon> list = list(lqw);
|
|
|
+ //过滤超过使用时间的券
|
|
|
+ list = filterCouponValidEndDate(list);
|
|
|
List<MercCoupon> sendList = new ArrayList<>();
|
|
|
if (Emptys.check(list)) {
|
|
|
list.forEach(mercCoupon -> {
|
|
@@ -242,6 +250,26 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 返回不超过过期时间的券
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<MercCoupon> filterCouponValidEndDate(List<MercCoupon> list) {
|
|
|
+ List<MercCoupon> resultList = new ArrayList<>();
|
|
|
+ if (!Emptys.check(list)) {
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+ list.forEach(mercCoupon -> {
|
|
|
+ boolean isDays = Objects.equals(mercCoupon.getValidType(), CouponValidTypeEnum.T_1.getCode());
|
|
|
+ if (isDays || !mercCoupon.getValidEndDate().isBefore(LocalDate.now())) {
|
|
|
+ resultList.add(mercCoupon);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public JMap<String, Object> modelSave(MercCoupon mercCoupon, String memberId, String remark, String createOrderId) {
|
|
|
LocalDate today = LocalDate.now();
|