|
|
@@ -456,7 +456,11 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
//查询该优惠券属于哪个店铺
|
|
|
LifeDiscountCoupon lifeDiscountCoupon = lifeDiscountCouponMapper.selectById(lifeDiscountCouponUser.getCouponId());
|
|
|
String couponStoreId = lifeDiscountCoupon.getStoreId();
|
|
|
- if (couponStoreId.equals(storeId)) {
|
|
|
+ if (null != couponStoreId && couponStoreId.equals(storeId)) {
|
|
|
+ lifeDiscountCouponUsers.add(lifeDiscountCouponUser);
|
|
|
+ }
|
|
|
+ //平台优惠券
|
|
|
+ if (3 == lifeDiscountCoupon.getType()) {
|
|
|
lifeDiscountCouponUsers.add(lifeDiscountCouponUser);
|
|
|
}
|
|
|
}
|
|
|
@@ -665,14 +669,19 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
//优惠券的所有门店
|
|
|
List<String> storeIdList = lifeDiscountCoupons.stream().map(LifeDiscountCoupon::getStoreId).collect(Collectors.toList());
|
|
|
List<StoreInfo> storeInfoList = storeInfoMapper.getList(new LambdaQueryWrapper<StoreInfo>().in(!storeIdList.isEmpty(), StoreInfo::getId, storeIdList));
|
|
|
- if (storeInfoList.isEmpty()) {
|
|
|
+ if (storeInfoList.isEmpty() && lifeDiscountCouponUserIPage.getRecords().isEmpty()) {
|
|
|
return lifeDiscountCouponVos;
|
|
|
}
|
|
|
for (LifeDiscountCouponUser lifeDiscountCouponUser : lifeDiscountCouponUserIPage.getRecords()) {
|
|
|
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);
|
|
|
+ StoreInfo storeInfoOne = null;
|
|
|
+ if (!storeInfoList.isEmpty()) {
|
|
|
+ storeInfoOne = storeInfoList.stream().filter(storeInfo -> storeInfo.getId().toString().equals(lifeDiscountCouponOne.getStoreId())).collect(Collectors.toList()).get(0);
|
|
|
+ }
|
|
|
LifeDiscountCouponVo lifeDiscountCouponVo = new LifeDiscountCouponVo();
|
|
|
- lifeDiscountCouponVo.setBusinessSection(storeInfoOne.getBusinessSection());
|
|
|
+ if (null != storeInfoOne) {
|
|
|
+ lifeDiscountCouponVo.setBusinessSection(storeInfoOne.getBusinessSection());
|
|
|
+ }
|
|
|
lifeDiscountCouponVo.setCouponId(lifeDiscountCouponOne.getId());
|
|
|
BeanUtils.copyProperties(lifeDiscountCouponOne, lifeDiscountCouponVo);
|
|
|
lifeDiscountCouponVo.setQuantityClaimed(lifeDiscountCouponUserIPage.getRecords().size());
|
|
|
@@ -691,7 +700,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
|
|
|
// 判断是否到了优惠券的开始时间
|
|
|
lifeDiscountCouponVo.setReachUseTimeFlag(1);
|
|
|
- if (localNow1.isBefore(lifeDiscountCouponOne.getBeginGetDate())) {
|
|
|
+ if (null != lifeDiscountCouponOne.getBeginGetDate() && localNow1.isBefore(lifeDiscountCouponOne.getBeginGetDate())) {
|
|
|
lifeDiscountCouponVo.setReachUseTimeFlag(0);
|
|
|
}
|
|
|
lifeDiscountCouponVos.add(lifeDiscountCouponVo);
|
|
|
@@ -1084,8 +1093,14 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean addPlatformCoupon(LifeDiscountCoupon lifeDiscountCoupon) {
|
|
|
+ lifeDiscountCoupon.setStartDate(LocalDate.now());
|
|
|
+ if (null == lifeDiscountCoupon.getExpirationDate()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ lifeDiscountCoupon.setEndDate(LocalDate.now().plusDays(lifeDiscountCoupon.getExpirationDate()));
|
|
|
lifeDiscountCoupon.setType(3);
|
|
|
lifeDiscountCoupon.setGetStatus(1);
|
|
|
+ lifeDiscountCoupon.setMinimumSpendingAmount(BigDecimal.ZERO);
|
|
|
return this.save(lifeDiscountCoupon);
|
|
|
}
|
|
|
|
|
|
@@ -1116,7 +1131,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
lifeDiscountCouponUser.setUserId(userId);
|
|
|
lifeDiscountCouponUser.setCouponId(couponId);
|
|
|
lifeDiscountCouponUser.setReceiveTime(new Date());
|
|
|
- lifeDiscountCouponUser.setExpirationTime(lifeDiscountCoupon.getEndDate());
|
|
|
+ lifeDiscountCouponUser.setExpirationTime(LocalDate.now().plusDays(lifeDiscountCoupon.getExpirationDate()));
|
|
|
lifeDiscountCouponUser.setStatus(0);
|
|
|
lifeDiscountCouponUser.setDeleteFlag(0);
|
|
|
lifeDiscountCouponUser.setCreatedTime(new Date());
|
|
|
@@ -1133,7 +1148,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean recoverPlatformCoupon(Integer couponId) {
|
|
|
- return lifeDiscountCouponUserService.remove(new LambdaQueryWrapper<LifeDiscountCouponUser>().eq(LifeDiscountCouponUser::getCouponId, couponId)) && this.updateById(new LifeDiscountCoupon().setId(couponId).setGetStatus(0));
|
|
|
+ return lifeDiscountCouponUserService.remove(new LambdaQueryWrapper<LifeDiscountCouponUser>().eq(LifeDiscountCouponUser::getCouponId, couponId));
|
|
|
}
|
|
|
|
|
|
/**
|