|
|
@@ -94,8 +94,9 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
String specifiedDay = lifeDiscountCoupon.getSpecifiedDay();
|
|
|
if(!StringUtils.isEmpty(specifiedDay)){
|
|
|
int sDay = Integer.parseInt(specifiedDay);
|
|
|
- if(sDay > 0){
|
|
|
- Date validDate = addDaysToDateJava8(new Date(), sDay);
|
|
|
+ if(sDay > 0 && lifeDiscountCouponDto.getBeginGetDate() != null){
|
|
|
+ Date beginGetDate = Date.from(lifeDiscountCouponDto.getBeginGetDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
+ Date validDate = addDaysToDateJava8(beginGetDate, sDay);
|
|
|
LocalDate validDateLocalDate = validDate.toInstant()
|
|
|
.atZone(ZoneId.systemDefault())
|
|
|
.toLocalDate();
|
|
|
@@ -188,8 +189,9 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
String specifiedDay = lifeDiscountCouponDto.getSpecifiedDay();
|
|
|
if(!StringUtils.isEmpty(specifiedDay)){
|
|
|
int sDay = Integer.parseInt(specifiedDay);
|
|
|
- if(sDay > 0){
|
|
|
- Date validDate = addDaysToDateJava8(new Date(), sDay);
|
|
|
+ if(sDay > 0 && lifeDiscountCouponDto.getBeginGetDate() != null) {
|
|
|
+ Date beginGetDate = Date.from(lifeDiscountCouponDto.getBeginGetDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
+ Date validDate = addDaysToDateJava8(beginGetDate, sDay);
|
|
|
LocalDate validDateLocalDate = validDate.toInstant()
|
|
|
.atZone(ZoneId.systemDefault())
|
|
|
.toLocalDate();
|
|
|
@@ -367,8 +369,13 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
queryWrapper.eq(LifeDiscountCouponUser::getUserId, userLoginInfo.getUserId());
|
|
|
queryWrapper.orderByDesc(LifeDiscountCouponUser::getReceiveTime);
|
|
|
List<LifeDiscountCouponUser> lifeDiscountCouponUsers = lifeDiscountCouponUserMapper.selectList(queryWrapper);
|
|
|
+ String specifiedDay = lifeDiscountCoupon.getSpecifiedDay();
|
|
|
+ Date receiveDay = null;
|
|
|
+
|
|
|
//判断是否已经全部领取
|
|
|
if (lifeDiscountCoupon.getRestrictedQuantity() != 0 && lifeDiscountCouponUsers.size() >= lifeDiscountCoupon.getRestrictedQuantity()) {
|
|
|
+ receiveDay = lifeDiscountCouponUsers.get(0).getReceiveTime();
|
|
|
+ lifeDiscountCouponVo.setExpirationTime(lifeDiscountCouponUsers.get(0).getExpirationTime());
|
|
|
lifeDiscountCouponVo.setCanReceived(false);
|
|
|
} else {
|
|
|
//判断一下领取规则
|
|
|
@@ -382,6 +389,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
} else {
|
|
|
LifeDiscountCouponUser lifeDiscountCouponUser = lifeDiscountCouponUsers.get(0);
|
|
|
Date receiveTime = lifeDiscountCouponUser.getReceiveTime();
|
|
|
+ receiveDay = lifeDiscountCouponUser.getReceiveTime();
|
|
|
|
|
|
// 将 Date 转换为 Instant
|
|
|
Instant instant = receiveTime.toInstant();
|
|
|
@@ -404,6 +412,19 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
}
|
|
|
//如果在规则范围内,则不允许领取,范围外,则可以领取
|
|
|
lifeDiscountCouponVo.setCanReceived(confineTo >= 1);
|
|
|
+ lifeDiscountCouponVo.setExpirationTime(lifeDiscountCouponUser.getExpirationTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(specifiedDay)){
|
|
|
+ int sDay = Integer.parseInt(specifiedDay);
|
|
|
+ if(sDay > 0 && receiveDay != null){
|
|
|
+ Date validDate = addDaysToDateJava8(receiveDay, sDay);
|
|
|
+ LocalDate validDateLocalDate = validDate.toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDate();
|
|
|
+ lifeDiscountCouponVo.setValidDate(validDateLocalDate);
|
|
|
+ } else {
|
|
|
+ lifeDiscountCouponVo.setValidDate(null);
|
|
|
}
|
|
|
}
|
|
|
lifeDiscountCouponVo.setQuantityClaimed(lifeDiscountCouponUsers.size());
|
|
|
@@ -667,13 +688,29 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
return lifeDiscountCouponVos;
|
|
|
}
|
|
|
for (LifeDiscountCouponUser lifeDiscountCouponUser : lifeDiscountCouponUserIPage.getRecords()) {
|
|
|
- LifeDiscountCoupon lifeDiscountCouponOne = lifeDiscountCoupons.stream().filter(lifeDiscountCoupon -> lifeDiscountCoupon.getId().equals(lifeDiscountCouponUser.getCouponId())).collect(Collectors.toList()).get(0);
|
|
|
+ LifeDiscountCoupon lifeDiscountCouponOne = lifeDiscountCoupons.stream().filter(lifeDiscountCoupon ->
|
|
|
+ lifeDiscountCoupon.getId().equals(lifeDiscountCouponUser.getCouponId())).collect(Collectors.toList()).get(0);
|
|
|
StoreInfo storeInfoOne = storeInfoList.stream().filter(storeInfo -> storeInfo.getId().toString().equals(lifeDiscountCouponOne.getStoreId())).collect(Collectors.toList()).get(0);
|
|
|
LifeDiscountCouponVo lifeDiscountCouponVo = new LifeDiscountCouponVo();
|
|
|
lifeDiscountCouponVo.setBusinessSection(storeInfoOne.getBusinessSection());
|
|
|
lifeDiscountCouponVo.setCouponId(lifeDiscountCouponOne.getId());
|
|
|
BeanUtils.copyProperties(lifeDiscountCouponOne, lifeDiscountCouponVo);
|
|
|
lifeDiscountCouponVo.setQuantityClaimed(lifeDiscountCouponUserIPage.getRecords().size());
|
|
|
+ lifeDiscountCouponVo.setExpirationTime(lifeDiscountCouponUser.getExpirationTime());
|
|
|
+ // 设置有效期
|
|
|
+ String specifiedDay = lifeDiscountCouponOne.getSpecifiedDay();
|
|
|
+ if(!StringUtils.isEmpty(specifiedDay)){
|
|
|
+ int sDay = Integer.parseInt(specifiedDay);
|
|
|
+ if(sDay > 0){
|
|
|
+ Date receiveDay = lifeDiscountCouponUser.getReceiveTime();
|
|
|
+ Date validDate = addDaysToDateJava8(receiveDay, sDay);
|
|
|
+ LocalDate validDateLocalDate = validDate.toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDate();
|
|
|
+ lifeDiscountCouponVo.setValidDate(validDateLocalDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 判断是否到了优惠券的开始时间
|
|
|
lifeDiscountCouponVo.setReachUseTimeFlag(1);
|
|
|
if (localNow1.isBefore(lifeDiscountCouponOne.getBeginGetDate())) {
|