|
@@ -865,7 +865,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
&& !DiscountCouponEnum.BE_ABOUT_TO_EXPORE.getValue().equals(tabType)
|
|
&& !DiscountCouponEnum.BE_ABOUT_TO_EXPORE.getValue().equals(tabType)
|
|
|
&& !DiscountCouponEnum.HAVE_ALREADY_APPLIED.getValue().equals(tabType)
|
|
&& !DiscountCouponEnum.HAVE_ALREADY_APPLIED.getValue().equals(tabType)
|
|
|
&& !DiscountCouponEnum.HAVE_EXPIRED.getValue().equals(tabType)) {
|
|
&& !DiscountCouponEnum.HAVE_EXPIRED.getValue().equals(tabType)) {
|
|
|
- throw new IllegalArgumentException("分页类型参数错误,必须为0(未使用)、1(即将过期)、2(已使用)、3(已过期)");
|
|
|
|
|
|
|
+ throw new IllegalArgumentException("分页类型参数错误,必须为0(未使用)、1(即将过期)、2(已使用)、3(已过期/已失效)");
|
|
|
}
|
|
}
|
|
|
if (legacyTypeParam != null && legacyTypeParam == 4) {
|
|
if (legacyTypeParam != null && legacyTypeParam == 4) {
|
|
|
throw new IllegalArgumentException("不再支持代金券(type=4)");
|
|
throw new IllegalArgumentException("不再支持代金券(type=4)");
|
|
@@ -906,6 +906,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
vo.setCouponId(coupon.getId());
|
|
vo.setCouponId(coupon.getId());
|
|
|
vo.setVoucherId(userCoupon.getVoucherId());
|
|
vo.setVoucherId(userCoupon.getVoucherId());
|
|
|
vo.setUserCouponId(userCoupon.getId());
|
|
vo.setUserCouponId(userCoupon.getId());
|
|
|
|
|
+ vo.setStatus(userCoupon.getStatus());
|
|
|
BeanUtils.copyProperties(coupon, vo);
|
|
BeanUtils.copyProperties(coupon, vo);
|
|
|
|
|
|
|
|
// quantityClaimed表示该券的总领取数量,在用户券列表中不设置或设置为0
|
|
// quantityClaimed表示该券的总领取数量,在用户券列表中不设置或设置为0
|
|
@@ -971,6 +972,9 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
/** 未配置领取起止日时,列表仍按草稿/库存/领取开关推断展示状态,避免整条记录被丢弃 */
|
|
/** 未配置领取起止日时,列表仍按草稿/库存/领取开关推断展示状态,避免整条记录被丢弃 */
|
|
|
private Integer resolveListStatusWhenGetWindowMissing(Integer couponStatus, Integer getStatus,
|
|
private Integer resolveListStatusWhenGetWindowMissing(Integer couponStatus, Integer getStatus,
|
|
|
Integer unlimitedQty, Integer singleQty) {
|
|
Integer unlimitedQty, Integer singleQty) {
|
|
|
|
|
+ if (couponStatus != null && couponStatus == LifeDiscountCoupon.COUPON_STATUS_INVALID) {
|
|
|
|
|
+ return Integer.parseInt(DiscountCouponEnum.INVALID.getValue());
|
|
|
|
|
+ }
|
|
|
if (couponStatus != null && couponStatus == 0) {
|
|
if (couponStatus != null && couponStatus == 0) {
|
|
|
return Integer.parseInt(DiscountCouponEnum.HAVE_NOT_STARTED.getValue());
|
|
return Integer.parseInt(DiscountCouponEnum.HAVE_NOT_STARTED.getValue());
|
|
|
}
|
|
}
|
|
@@ -983,6 +987,13 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
return Integer.parseInt(DiscountCouponEnum.UNDER_WAY.getValue());
|
|
return Integer.parseInt(DiscountCouponEnum.UNDER_WAY.getValue());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private Integer resolveInvalidStatusIfNeeded(Integer couponStatus) {
|
|
|
|
|
+ if (couponStatus != null && couponStatus == LifeDiscountCoupon.COUPON_STATUS_INVALID) {
|
|
|
|
|
+ return Integer.parseInt(DiscountCouponEnum.INVALID.getValue());
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取店铺所有优惠券列表(分页)
|
|
* 获取店铺所有优惠券列表(分页)
|
|
|
* 支持查询我的优惠券和好友优惠券
|
|
* 支持查询我的优惠券和好友优惠券
|
|
@@ -1078,8 +1089,8 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
|
|
|
|
|
// 计算优惠券状态
|
|
// 计算优惠券状态
|
|
|
- Integer calculatedStatus = null;
|
|
|
|
|
- if (!StringUtils.isEmpty(lifeDiscountCoupon.getBeginGetDate()) && !StringUtils.isEmpty(lifeDiscountCoupon.getEndGetDate())) {
|
|
|
|
|
|
|
+ Integer calculatedStatus = resolveInvalidStatusIfNeeded(lifeDiscountCoupon.getCouponStatus());
|
|
|
|
|
+ if (calculatedStatus == null && !StringUtils.isEmpty(lifeDiscountCoupon.getBeginGetDate()) && !StringUtils.isEmpty(lifeDiscountCoupon.getEndGetDate())) {
|
|
|
int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
//如果当前时间小于开始时间
|
|
//如果当前时间小于开始时间
|
|
@@ -1233,8 +1244,8 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
|
|
|
|
|
// 计算优惠券状态
|
|
// 计算优惠券状态
|
|
|
- Integer calculatedStatus = null;
|
|
|
|
|
- if (!StringUtils.isEmpty(record.getBeginGetDate()) && !StringUtils.isEmpty(record.getEndGetDate())) {
|
|
|
|
|
|
|
+ Integer calculatedStatus = resolveInvalidStatusIfNeeded(record.getCouponStatus());
|
|
|
|
|
+ if (calculatedStatus == null && !StringUtils.isEmpty(record.getBeginGetDate()) && !StringUtils.isEmpty(record.getEndGetDate())) {
|
|
|
int startResult = localNow.compareTo(record.getBeginGetDate());
|
|
int startResult = localNow.compareTo(record.getBeginGetDate());
|
|
|
int endResult = localNow.compareTo(record.getEndGetDate());
|
|
int endResult = localNow.compareTo(record.getEndGetDate());
|
|
|
//如果当前时间小于开始时间
|
|
//如果当前时间小于开始时间
|
|
@@ -1357,7 +1368,10 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
Instant instant = now.toInstant();
|
|
Instant instant = now.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
- if (!StringUtils.isEmpty(lifeDiscountCoupon.getBeginGetDate()) && !StringUtils.isEmpty(lifeDiscountCoupon.getEndGetDate())) {
|
|
|
|
|
|
|
+ Integer invalidStatus = resolveInvalidStatusIfNeeded(lifeDiscountCoupon.getCouponStatus());
|
|
|
|
|
+ if (invalidStatus != null) {
|
|
|
|
|
+ lifeDiscountCouponVo.setStatus(invalidStatus);
|
|
|
|
|
+ } else if (!StringUtils.isEmpty(lifeDiscountCoupon.getBeginGetDate()) && !StringUtils.isEmpty(lifeDiscountCoupon.getEndGetDate())) {
|
|
|
int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
if (!LifeDiscountCouponStock.hasTemplateStockRemaining(
|
|
if (!LifeDiscountCouponStock.hasTemplateStockRemaining(
|