|
|
@@ -75,34 +75,55 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
BeanUtils.copyProperties(lifeDiscountCouponDto, lifeDiscountCoupon);
|
|
|
// 根据开始领取时间判断可领取状态
|
|
|
// 判断是否在领取时间内
|
|
|
+
|
|
|
Date now = new Date();
|
|
|
Instant instant = now.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
- int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
- int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
- if ((lifeDiscountCouponDto.getCouponStatus() != null && lifeDiscountCouponDto.getCouponStatus() == 0) || (startResult < 0 || endResult > 0)) {
|
|
|
- lifeDiscountCoupon.setGetStatus(0);
|
|
|
- } else {
|
|
|
- lifeDiscountCoupon.setGetStatus(1);
|
|
|
+ if (lifeDiscountCouponDto.getCouponStatus() == 1 && !StringUtils.isEmpty(lifeDiscountCoupon.getBeginGetDate()) || !StringUtils.isEmpty(lifeDiscountCoupon.getEndGetDate())) {
|
|
|
+ int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
+ int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
+ if ((lifeDiscountCouponDto.getCouponStatus() != null && lifeDiscountCouponDto.getCouponStatus() == 0) || (startResult < 0 || endResult > 0)) {
|
|
|
+ lifeDiscountCoupon.setGetStatus(0);
|
|
|
+ } else {
|
|
|
+ lifeDiscountCoupon.setGetStatus(1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // 设置有效期
|
|
|
+ String specifiedDay = lifeDiscountCoupon.getSpecifiedDay();
|
|
|
+ if(!StringUtils.isEmpty(specifiedDay)){
|
|
|
+ int sDay = Integer.parseInt(specifiedDay);
|
|
|
+ if(sDay > 0){
|
|
|
+ Date validDate = addDaysToDateJava8(new Date(), sDay);
|
|
|
+ LocalDate validDateLocalDate = validDate.toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDate();
|
|
|
+ lifeDiscountCoupon.setValidDate(validDateLocalDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
lifeDiscountCouponMapper.insert(lifeDiscountCoupon);
|
|
|
//发布优惠券规则信息
|
|
|
//周中规则保存
|
|
|
LifeDiscountCouponUnavailableRules lifeDiscountCouponUnavailableRules = new LifeDiscountCouponUnavailableRules();
|
|
|
lifeDiscountCouponUnavailableRules.setDiscountCouponId(lifeDiscountCoupon.getId());
|
|
|
lifeDiscountCouponUnavailableRules.setUnavailableRuleType(DiscountCouponEnum.WEEKDAY_UNAVAILABLE.getValue());
|
|
|
- lifeDiscountCouponDto.getWeeklyDisabledList().forEach(weeklyDisabled -> {
|
|
|
- lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(weeklyDisabled);
|
|
|
- lifeDiscountCouponUnavailableRulesMapper.insert(lifeDiscountCouponUnavailableRules);
|
|
|
- });
|
|
|
+ if(CollectionUtils.isNotEmpty(lifeDiscountCouponDto.getWeeklyDisabledList())) {
|
|
|
+ lifeDiscountCouponDto.getWeeklyDisabledList().forEach(weeklyDisabled -> {
|
|
|
+ lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(weeklyDisabled);
|
|
|
+ lifeDiscountCouponUnavailableRulesMapper.insert(lifeDiscountCouponUnavailableRules);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
//节假日规则保存
|
|
|
lifeDiscountCouponUnavailableRules.setUnavailableRuleType(DiscountCouponEnum.HOLIDAY_UNAVAILABLE.getValue());
|
|
|
- lifeDiscountCouponDto.getHolidayDisabledList().forEach(holidayDisabled -> {
|
|
|
- lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(holidayDisabled);
|
|
|
- lifeDiscountCouponUnavailableRulesMapper.insert(lifeDiscountCouponUnavailableRules);
|
|
|
- });
|
|
|
+ if(CollectionUtils.isNotEmpty(lifeDiscountCouponDto.getHolidayDisabledList())){
|
|
|
+ lifeDiscountCouponDto.getHolidayDisabledList().forEach(holidayDisabled -> {
|
|
|
+ lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(holidayDisabled);
|
|
|
+ lifeDiscountCouponUnavailableRulesMapper.insert(lifeDiscountCouponUnavailableRules);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
//领取规则
|
|
|
lifeDiscountCouponUnavailableRules.setUnavailableRuleType(DiscountCouponEnum.CLAIM_RULE.getValue());
|
|
|
String claimRule = lifeDiscountCouponDto.getClaimRule();
|
|
|
@@ -151,12 +172,29 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
Instant instant = now.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
- int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
- int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
- if ((lifeDiscountCouponDto.getCouponStatus() != null && lifeDiscountCouponDto.getCouponStatus() == 0) || (startResult < 0 || endResult > 0)) {
|
|
|
+ if (lifeDiscountCouponDto.getCouponStatus() == 1 && !StringUtils.isEmpty(lifeDiscountCoupon.getBeginGetDate()) || !StringUtils.isEmpty(lifeDiscountCoupon.getEndGetDate())) {
|
|
|
+ int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
+ int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
+ if ((lifeDiscountCouponDto.getCouponStatus() != null && lifeDiscountCouponDto.getCouponStatus() == 0) || (startResult < 0 || endResult > 0)) {
|
|
|
+ lifeDiscountCoupon.setGetStatus(0);
|
|
|
+ } else {
|
|
|
+ lifeDiscountCoupon.setGetStatus(1);
|
|
|
+ }
|
|
|
+ } else if (lifeDiscountCouponDto.getCouponStatus() == 0) {
|
|
|
lifeDiscountCoupon.setGetStatus(0);
|
|
|
- } else {
|
|
|
- lifeDiscountCoupon.setGetStatus(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置有效期
|
|
|
+ String specifiedDay = lifeDiscountCouponDto.getSpecifiedDay();
|
|
|
+ if(!StringUtils.isEmpty(specifiedDay)){
|
|
|
+ int sDay = Integer.parseInt(specifiedDay);
|
|
|
+ if(sDay > 0){
|
|
|
+ Date validDate = addDaysToDateJava8(new Date(), sDay);
|
|
|
+ LocalDate validDateLocalDate = validDate.toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDate();
|
|
|
+ lifeDiscountCoupon.setValidDate(validDateLocalDate);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
lifeDiscountCouponMapper.updateById(lifeDiscountCoupon);
|
|
|
@@ -170,16 +208,22 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
LifeDiscountCouponUnavailableRules lifeDiscountCouponUnavailableRules = new LifeDiscountCouponUnavailableRules();
|
|
|
lifeDiscountCouponUnavailableRules.setDiscountCouponId(lifeDiscountCoupon.getId());
|
|
|
lifeDiscountCouponUnavailableRules.setUnavailableRuleType(DiscountCouponEnum.WEEKDAY_UNAVAILABLE.getValue());
|
|
|
- lifeDiscountCouponDto.getWeeklyDisabledList().forEach(weeklyDisabled -> {
|
|
|
- lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(weeklyDisabled);
|
|
|
- lifeDiscountCouponUnavailableRulesMapper.insert(lifeDiscountCouponUnavailableRules);
|
|
|
- });
|
|
|
+ if(CollectionUtils.isNotEmpty(lifeDiscountCouponDto.getWeeklyDisabledList())) {
|
|
|
+ lifeDiscountCouponDto.getWeeklyDisabledList().forEach(weeklyDisabled -> {
|
|
|
+ lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(weeklyDisabled);
|
|
|
+ lifeDiscountCouponUnavailableRulesMapper.insert(lifeDiscountCouponUnavailableRules);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
//节假日规则保存
|
|
|
lifeDiscountCouponUnavailableRules.setUnavailableRuleType(DiscountCouponEnum.HOLIDAY_UNAVAILABLE.getValue());
|
|
|
- lifeDiscountCouponDto.getHolidayDisabledList().forEach(holidayDisabled -> {
|
|
|
- lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(holidayDisabled);
|
|
|
- lifeDiscountCouponUnavailableRulesMapper.insert(lifeDiscountCouponUnavailableRules);
|
|
|
- });
|
|
|
+ if(CollectionUtils.isNotEmpty(lifeDiscountCouponDto.getHolidayDisabledList())){
|
|
|
+ lifeDiscountCouponDto.getHolidayDisabledList().forEach(holidayDisabled -> {
|
|
|
+ lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(holidayDisabled);
|
|
|
+ lifeDiscountCouponUnavailableRulesMapper.insert(lifeDiscountCouponUnavailableRules);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
//领取规则
|
|
|
lifeDiscountCouponUnavailableRules.setUnavailableRuleType(DiscountCouponEnum.CLAIM_RULE.getValue());
|
|
|
lifeDiscountCouponUnavailableRules.setUnavailableRuleValue(lifeDiscountCouponDto.getClaimRule());
|
|
|
@@ -229,14 +273,14 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
LifeDiscountCoupon lifeDiscountCoupon = lifeDiscountCouponMapper.selectById(counponId);
|
|
|
lifeDiscountCoupon.setGetStatus(lifeDiscountCoupon.getGetStatus() == Integer.parseInt(DiscountCouponEnum.NO_GET.getValue())
|
|
|
? Integer.parseInt(DiscountCouponEnum.CAN_GET.getValue()) : Integer.parseInt(DiscountCouponEnum.NO_GET.getValue()));
|
|
|
- Date now = new Date();
|
|
|
- Instant instant = now.toInstant();
|
|
|
- ZoneId zoneId = ZoneId.systemDefault();
|
|
|
- LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
- if (localNow.compareTo(lifeDiscountCoupon.getStartDate()) < 0) {
|
|
|
- lifeDiscountCoupon.setStartDate(localNow);
|
|
|
- lifeDiscountCoupon.setGetStatus(Integer.parseInt(DiscountCouponEnum.CAN_GET.getValue()));
|
|
|
- }
|
|
|
+// Date now = new Date();
|
|
|
+// Instant instant = now.toInstant();
|
|
|
+// ZoneId zoneId = ZoneId.systemDefault();
|
|
|
+// LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
+// if (localNow.compareTo(lifeDiscountCoupon.getStartDate()) < 0) {
|
|
|
+// lifeDiscountCoupon.setStartDate(localNow);
|
|
|
+// lifeDiscountCoupon.setGetStatus(Integer.parseInt(DiscountCouponEnum.CAN_GET.getValue()));
|
|
|
+// }
|
|
|
lifeDiscountCouponMapper.updateById(lifeDiscountCoupon);
|
|
|
return true;
|
|
|
}
|
|
|
@@ -289,6 +333,18 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
return lifeDiscountCouponVo;
|
|
|
}
|
|
|
|
|
|
+ public static Date addDaysToDateJava8(Date date, int days) {
|
|
|
+ // 将Date转换为Instant
|
|
|
+ Instant instant = date.toInstant();
|
|
|
+
|
|
|
+ // 转换为LocalDate并加天数
|
|
|
+ LocalDate localDate = instant.atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ LocalDate newLocalDate = localDate.plusDays(days);
|
|
|
+
|
|
|
+ // 转换回Date
|
|
|
+ return Date.from(newLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<LifeDiscountCouponVo> getStoreUserCouponList(String storeId, UserLoginInfo userLoginInfo) {
|
|
|
List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
|
|
|
@@ -298,7 +354,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
.eq(LifeDiscountCoupon::getStoreId, storeId)
|
|
|
.eq(LifeDiscountCoupon::getGetStatus, "1")
|
|
|
.gt(LifeDiscountCoupon::getSingleQty, 0) //还有库存
|
|
|
- .ge(LifeDiscountCoupon::getEndDate, new Date())
|
|
|
+ .ge(LifeDiscountCoupon::getEndGetDate, new Date())
|
|
|
.orderByDesc(LifeDiscountCoupon::getCreatedTime));
|
|
|
//根据优惠券列表查询该优惠券是否领取过
|
|
|
for (LifeDiscountCoupon lifeDiscountCoupon : lifeDiscountCoupons) {
|
|
|
@@ -347,11 +403,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
confineTo = ChronoUnit.YEARS.between(localDateTime, now);
|
|
|
}
|
|
|
//如果在规则范围内,则不允许领取,范围外,则可以领取
|
|
|
- if (confineTo < 1) {
|
|
|
- lifeDiscountCouponVo.setCanReceived(false);
|
|
|
- } else {
|
|
|
- lifeDiscountCouponVo.setCanReceived(true);
|
|
|
- }
|
|
|
+ lifeDiscountCouponVo.setCanReceived(confineTo >= 1);
|
|
|
}
|
|
|
}
|
|
|
lifeDiscountCouponVo.setQuantityClaimed(lifeDiscountCouponUsers.size());
|
|
|
@@ -641,12 +693,13 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, String tab, int couponsFromType) {
|
|
|
+ public IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, String tab, int couponsFromType, int couponStatus) {
|
|
|
|
|
|
if (couponsFromType == 1) {
|
|
|
IPage<LifeDiscountCoupon> iPage = new Page<>(page, size);
|
|
|
List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
|
|
|
LambdaQueryWrapper<LifeDiscountCoupon> lifeDiscountCouponLambdaQueryWrapper = new LambdaQueryWrapper<LifeDiscountCoupon>();
|
|
|
+ lifeDiscountCouponLambdaQueryWrapper.eq(LifeDiscountCoupon::getCouponStatus, couponStatus);
|
|
|
//如果couponName不为空,则模糊查询
|
|
|
if (!StringUtils.isEmpty(couponName)) {
|
|
|
lifeDiscountCouponLambdaQueryWrapper.like(LifeDiscountCoupon::getName, couponName);
|
|
|
@@ -681,19 +734,21 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
Instant instant = now.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
- int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
- int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
- //如果当前时间小于开始时间
|
|
|
- if (lifeDiscountCoupon.getSingleQty() == 0) {//无库存则已售罄
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_SOLD_OUT.getValue()));
|
|
|
- } else if (lifeDiscountCoupon.getGetStatus().toString().equals(DiscountCouponEnum.NO_GET.getValue())) {
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.SUSPEND_GET.getValue()));
|
|
|
- } else if (startResult < 0) {
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_NOT_STARTED.getValue()));
|
|
|
- } else if (endResult > 0) {
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.FINISHED.getValue()));
|
|
|
- } else if (startResult >= 0 && endResult <= 0) {
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.UNDER_WAY.getValue()));
|
|
|
+ if(!StringUtils.isEmpty(lifeDiscountCoupon.getBeginGetDate()) && !StringUtils.isEmpty(lifeDiscountCoupon.getEndGetDate())) {
|
|
|
+ int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
+ int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
+ //如果当前时间小于开始时间
|
|
|
+ if (lifeDiscountCoupon.getSingleQty() == 0) {//无库存则已售罄
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_SOLD_OUT.getValue()));
|
|
|
+ } else if (lifeDiscountCoupon.getGetStatus().toString().equals(DiscountCouponEnum.NO_GET.getValue())) {
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.SUSPEND_GET.getValue()));
|
|
|
+ } else if (startResult < 0) {
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_NOT_STARTED.getValue()));
|
|
|
+ } else if (endResult > 0) {
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.FINISHED.getValue()));
|
|
|
+ } else if (startResult >= 0 && endResult <= 0) {
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.UNDER_WAY.getValue()));
|
|
|
+ }
|
|
|
}
|
|
|
// 查询三个规则
|
|
|
List<LifeDiscountCouponUnavailableRules> discountCouponId = lifeDiscountCouponUnavailableRulesMapper.selectList(new QueryWrapper<LifeDiscountCouponUnavailableRules>().eq("discount_coupon_id", lifeDiscountCoupon.getId()));
|
|
|
@@ -751,19 +806,21 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
Instant instant = now.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
- int startResult = localNow.compareTo(record.getStartDate());
|
|
|
- int endResult = localNow.compareTo(record.getEndDate());
|
|
|
- //如果当前时间小于开始时间
|
|
|
- if (record.getSingleQty() == 0) {//无库存则已售罄
|
|
|
- record.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_SOLD_OUT.getValue()));
|
|
|
- } else if (record.getGetStatus().toString().equals(DiscountCouponEnum.NO_GET.getValue())) {
|
|
|
- record.setStatus(Integer.parseInt(DiscountCouponEnum.SUSPEND_GET.getValue()));
|
|
|
- } else if (startResult < 0) {
|
|
|
- record.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_NOT_STARTED.getValue()));
|
|
|
- } else if (endResult > 0) {
|
|
|
- record.setStatus(Integer.parseInt(DiscountCouponEnum.FINISHED.getValue()));
|
|
|
- } else if (startResult >= 0 && endResult <= 0) {
|
|
|
- record.setStatus(Integer.parseInt(DiscountCouponEnum.UNDER_WAY.getValue()));
|
|
|
+ if(!StringUtils.isEmpty(record.getBeginGetDate()) && !StringUtils.isEmpty(record.getEndGetDate())) {
|
|
|
+ int startResult = localNow.compareTo(record.getBeginGetDate());
|
|
|
+ int endResult = localNow.compareTo(record.getEndGetDate());
|
|
|
+ //如果当前时间小于开始时间
|
|
|
+ if (record.getSingleQty() == 0) {//无库存则已售罄
|
|
|
+ record.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_SOLD_OUT.getValue()));
|
|
|
+ } else if (record.getGetStatus().toString().equals(DiscountCouponEnum.NO_GET.getValue())) {
|
|
|
+ record.setStatus(Integer.parseInt(DiscountCouponEnum.SUSPEND_GET.getValue()));
|
|
|
+ } else if (startResult < 0) {
|
|
|
+ record.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_NOT_STARTED.getValue()));
|
|
|
+ } else if (endResult > 0) {
|
|
|
+ record.setStatus(Integer.parseInt(DiscountCouponEnum.FINISHED.getValue()));
|
|
|
+ } else if (startResult >= 0 && endResult <= 0) {
|
|
|
+ record.setStatus(Integer.parseInt(DiscountCouponEnum.UNDER_WAY.getValue()));
|
|
|
+ }
|
|
|
}
|
|
|
List<LifeDiscountCouponUnavailableRules> discountCouponId = lifeDiscountCouponUnavailableRulesMapper.selectList(new QueryWrapper<LifeDiscountCouponUnavailableRules>().eq("discount_coupon_id", record.getCouponId()));
|
|
|
Map<String, List<LifeDiscountCouponUnavailableRules>> collect = discountCouponId.stream().collect(Collectors.groupingBy(x -> x.getUnavailableRuleType()));
|
|
|
@@ -787,12 +844,13 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<LifeDiscountCouponVo> getStoreAllCouponListPaginateNot(String status, String storeId, UserLoginInfo userLoginInfo) {
|
|
|
+ public List<LifeDiscountCouponVo> getStoreAllCouponListPaginateNot(String status, String storeId, UserLoginInfo userLoginInfo, int couponStatus) {
|
|
|
List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
|
|
|
//根据店铺id查询该店铺的优惠券,状态是开启领取的券
|
|
|
List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(
|
|
|
new LambdaQueryWrapper<LifeDiscountCoupon>()
|
|
|
.eq(LifeDiscountCoupon::getStoreId, storeId)
|
|
|
+ .eq(LifeDiscountCoupon::getCouponStatus, couponStatus)
|
|
|
.ne(LifeDiscountCoupon::getSingleQty, 0)
|
|
|
.orderByDesc(LifeDiscountCoupon::getCreatedTime)
|
|
|
);
|
|
|
@@ -806,17 +864,19 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
Instant instant = now.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
- int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
- int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
- //如果当前时间小于开始时间
|
|
|
- if (lifeDiscountCoupon.getGetStatus().toString().equals(DiscountCouponEnum.NO_GET.getValue())) {
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.SUSPEND_GET.getValue()));
|
|
|
- } else if (startResult < 0) {
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_NOT_STARTED.getValue()));
|
|
|
- } else if (endResult > 0) {
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.FINISHED.getValue()));
|
|
|
- } else if (startResult >= 0 && endResult <= 0) {
|
|
|
- lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.UNDER_WAY.getValue()));
|
|
|
+ if(!StringUtils.isEmpty(lifeDiscountCoupon.getBeginGetDate()) && !StringUtils.isEmpty(lifeDiscountCoupon.getEndGetDate())) {
|
|
|
+ int startResult = localNow.compareTo(lifeDiscountCoupon.getBeginGetDate());
|
|
|
+ int endResult = localNow.compareTo(lifeDiscountCoupon.getEndGetDate());
|
|
|
+ //如果当前时间小于开始时间
|
|
|
+ if (lifeDiscountCoupon.getGetStatus().toString().equals(DiscountCouponEnum.NO_GET.getValue())) {
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.SUSPEND_GET.getValue()));
|
|
|
+ } else if (startResult < 0) {
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.HAVE_NOT_STARTED.getValue()));
|
|
|
+ } else if (endResult > 0) {
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.FINISHED.getValue()));
|
|
|
+ } else if (startResult >= 0 && endResult <= 0) {
|
|
|
+ lifeDiscountCouponVo.setStatus(Integer.parseInt(DiscountCouponEnum.UNDER_WAY.getValue()));
|
|
|
+ }
|
|
|
}
|
|
|
BeanUtils.copyProperties(lifeDiscountCoupon, lifeDiscountCouponVo);
|
|
|
//如果按照状态查询了
|