|
|
@@ -659,229 +659,305 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取用户优惠券列表
|
|
|
+ *
|
|
|
+ * @param userLoginInfo 用户登录信息
|
|
|
+ * @param page 页码
|
|
|
+ * @param size 每页数量
|
|
|
+ * @param tabType 分页类型:0-全部(未使用),1-即将过期,2-已使用,3-已过期
|
|
|
+ * @param type 券类型:1-仅优惠券,4-仅代金券,null-全部
|
|
|
+ * @param couponType 优惠券类型:1-满减券,2-折扣券,null-全部(仅当type不为4时有效)
|
|
|
+ * @return 优惠券列表
|
|
|
+ */
|
|
|
@Override
|
|
|
public List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type, Integer couponType) {
|
|
|
+ // 参数校验
|
|
|
+ if (userLoginInfo == null || StringUtils.isEmpty(userLoginInfo.getUserId())) {
|
|
|
+ throw new IllegalArgumentException("用户信息不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(tabType)) {
|
|
|
+ throw new IllegalArgumentException("分页类型不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
|
|
|
IPage<LifeDiscountCouponUser> iPage = new Page<>(page, size);
|
|
|
LambdaQueryWrapper<LifeDiscountCouponUser> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(LifeDiscountCouponUser::getUserId, userLoginInfo.getUserId());
|
|
|
- //比较工具对象
|
|
|
- //获取七日前时间
|
|
|
+
|
|
|
+ // 计算时间边界(expirationTime是LocalDate类型,需要转换为LocalDate)
|
|
|
Date now = new Date();
|
|
|
- // 获取 7 天后的时间
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(now);
|
|
|
- calendar.add(Calendar.DAY_OF_YEAR, 7);
|
|
|
- // 获取 Calendar 实例,默认表示当前日期和时间
|
|
|
- // 将小时设置为 0
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- // 将分钟设置为 0
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
- // 将秒设置为 0
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
- // 将毫秒设置为 0
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
- Date sevenDaysLater = calendar.getTime();
|
|
|
-
|
|
|
- // 获取当前时间
|
|
|
- Calendar nowCalendar = Calendar.getInstance();
|
|
|
- nowCalendar.setTime(now);
|
|
|
- // 获取 Calendar 实例,默认表示当前日期和时间
|
|
|
- // 将小时设置为 0
|
|
|
- nowCalendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- // 将分钟设置为 0
|
|
|
- nowCalendar.set(Calendar.MINUTE, 0);
|
|
|
- // 将秒设置为 0
|
|
|
- nowCalendar.set(Calendar.SECOND, 0);
|
|
|
- // 将毫秒设置为 0
|
|
|
- nowCalendar.set(Calendar.MILLISECOND, 0);
|
|
|
- // 获取设置后的 Date 对象
|
|
|
- Date midnight = nowCalendar.getTime();
|
|
|
- //所有状态未使用且未过期的
|
|
|
- // 获取当前时间
|
|
|
- LocalDateTime localNow = LocalDateTime.now();
|
|
|
- // 计算七日前的日期
|
|
|
- LocalDateTime sevenDaysAgo = localNow.minusDays(7);
|
|
|
- // 将七日前的时间设置为凌晨 0 点 0 分 0 秒 0 纳秒
|
|
|
- LocalDateTime sevenDaysAgoMidnight = sevenDaysAgo.withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
- //判断分页类型
|
|
|
- if (tabType.equals(DiscountCouponEnum.ALL.getValue())) {
|
|
|
- //如果已过期 过期日期大于今天
|
|
|
- queryWrapper.gt(LifeDiscountCouponUser::getExpirationTime, midnight);
|
|
|
- //状态为待使用
|
|
|
- queryWrapper.eq(LifeDiscountCouponUser::getStatus, DiscountCouponEnum.WAITING_USED.getValue());
|
|
|
- } else if (tabType.equals(DiscountCouponEnum.BE_ABOUT_TO_EXPORE.getValue())) {
|
|
|
- //如果即将过期 七天之内
|
|
|
- //小于等于七日后
|
|
|
- queryWrapper.le(LifeDiscountCouponUser::getExpirationTime, sevenDaysLater);
|
|
|
- //大于等于今天
|
|
|
- queryWrapper.ge(LifeDiscountCouponUser::getExpirationTime, midnight);
|
|
|
- //并且状态为待使用
|
|
|
- queryWrapper.eq(LifeDiscountCouponUser::getStatus, DiscountCouponEnum.WAITING_USED.getValue());
|
|
|
- } else if (tabType.equals(DiscountCouponEnum.HAVE_ALREADY_APPLIED.getValue())) {
|
|
|
- //如果已使用 状态为已使用
|
|
|
+ LocalDate today = now.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); // 今天
|
|
|
+ LocalDate sevenDaysLater = today.plusDays(7); // 7天后
|
|
|
+ LocalDate sevenDaysAgo = today.minusDays(7); // 7天前
|
|
|
+
|
|
|
+ // 根据tabType添加查询条件
|
|
|
+ if (DiscountCouponEnum.ALL.getValue().equals(tabType)) {
|
|
|
+ // 全部(未使用):过期时间 >= 今天 或 过期时间为null 且 状态为待使用
|
|
|
+ // 注意:expirationTime为null的情况(可能是永久有效的券)也应该包含在"全部"中
|
|
|
+ // 使用 >= today 而不是 > today,确保包含今天过期的券(今天还没过完,券仍然有效)
|
|
|
+ queryWrapper.and(w -> w.ge(LifeDiscountCouponUser::getExpirationTime, today)
|
|
|
+ .or().isNull(LifeDiscountCouponUser::getExpirationTime))
|
|
|
+ .eq(LifeDiscountCouponUser::getStatus, DiscountCouponEnum.WAITING_USED.getValue());
|
|
|
+ } else if (DiscountCouponEnum.BE_ABOUT_TO_EXPORE.getValue().equals(tabType)) {
|
|
|
+ // 即将过期:今天 <= 过期时间 <= 7天后 且 状态为待使用
|
|
|
+ // 这是"全部(未使用)"的一个子集,只包含7天内即将过期的券
|
|
|
+ queryWrapper.ge(LifeDiscountCouponUser::getExpirationTime, today)
|
|
|
+ .le(LifeDiscountCouponUser::getExpirationTime, sevenDaysLater)
|
|
|
+ .eq(LifeDiscountCouponUser::getStatus, DiscountCouponEnum.WAITING_USED.getValue());
|
|
|
+ } else if (DiscountCouponEnum.HAVE_ALREADY_APPLIED.getValue().equals(tabType)) {
|
|
|
+ // 已使用:状态为已使用
|
|
|
queryWrapper.eq(LifeDiscountCouponUser::getStatus, DiscountCouponEnum.HAVE_BEEN_USED.getValue());
|
|
|
- } else if (tabType.equals(DiscountCouponEnum.HAVE_EXPIRED.getValue())) {
|
|
|
- //如果已过期 过期日期小于今天,并且过期时间小于七天
|
|
|
- queryWrapper.lt(LifeDiscountCouponUser::getExpirationTime, midnight);
|
|
|
- queryWrapper.gt(LifeDiscountCouponUser::getExpirationTime, sevenDaysAgoMidnight);
|
|
|
- //并且状态为待使用
|
|
|
- queryWrapper.eq(LifeDiscountCouponUser::getStatus, DiscountCouponEnum.WAITING_USED.getValue());
|
|
|
- }
|
|
|
- // type:1 仅优惠券(couponId 有值),4 仅代金券(voucherId 有值),不传则都查
|
|
|
+ } else if (DiscountCouponEnum.HAVE_EXPIRED.getValue().equals(tabType)) {
|
|
|
+ // 已过期:7天前 < 过期时间 < 今天 且 状态为待使用
|
|
|
+ queryWrapper.gt(LifeDiscountCouponUser::getExpirationTime, sevenDaysAgo)
|
|
|
+ .lt(LifeDiscountCouponUser::getExpirationTime, today)
|
|
|
+ .eq(LifeDiscountCouponUser::getStatus, DiscountCouponEnum.WAITING_USED.getValue());
|
|
|
+ }
|
|
|
+ // 根据type筛选券类型:1-仅优惠券(couponId有值),4-仅代金券(voucherId有值),null-全部
|
|
|
if (type != null && type == 1) {
|
|
|
queryWrapper.and(w -> w.isNotNull(LifeDiscountCouponUser::getCouponId));
|
|
|
} else if (type != null && type == 4) {
|
|
|
queryWrapper.and(w -> w.isNotNull(LifeDiscountCouponUser::getVoucherId));
|
|
|
}
|
|
|
queryWrapper.orderByDesc(LifeDiscountCouponUser::getCreatedTime);
|
|
|
+
|
|
|
+ // 分页查询用户优惠券记录
|
|
|
IPage<LifeDiscountCouponUser> lifeDiscountCouponUserIPage = lifeDiscountCouponUserMapper.selectPage(iPage, queryWrapper);
|
|
|
- //根据券id去查询该券的基本信息
|
|
|
- //根据优惠券列表查询该优惠券是否领取过
|
|
|
- //
|
|
|
- // 判断是否在领取时间内
|
|
|
+ List<LifeDiscountCouponUser> records = lifeDiscountCouponUserIPage.getRecords();
|
|
|
+ if (records.isEmpty()) {
|
|
|
+ return lifeDiscountCouponVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 准备时间转换
|
|
|
Instant instant = now.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
- LocalDate localNow1 = instant.atZone(zoneId).toLocalDate();
|
|
|
-
|
|
|
- List<LifeDiscountCouponUser> records = lifeDiscountCouponUserIPage.getRecords();
|
|
|
- // type=4:仅代金券,查 life_coupon 表
|
|
|
+ LocalDate localNow = instant.atZone(zoneId).toLocalDate();
|
|
|
+
|
|
|
+ // type=4:仅代金券,查询 life_coupon 表
|
|
|
if (type != null && type == 4) {
|
|
|
- List<String> voucherIdList = records.stream().map(LifeDiscountCouponUser::getVoucherId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- if (voucherIdList.isEmpty()) {
|
|
|
- return lifeDiscountCouponVos;
|
|
|
- }
|
|
|
- List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList));
|
|
|
- List<String> storeIdList = lifeCoupons.stream().map(LifeCoupon::getStoreId).filter(s -> !StringUtils.isEmpty(s)).collect(Collectors.toList());
|
|
|
- List<StoreInfo> storeInfoList = storeInfoMapper.getList(new LambdaQueryWrapper<StoreInfo>().in(!storeIdList.isEmpty(), StoreInfo::getId, storeIdList));
|
|
|
- for (LifeDiscountCouponUser lifeDiscountCouponUser : records) {
|
|
|
- LifeCoupon lc = lifeCoupons.stream().filter(c -> c.getId().equals(lifeDiscountCouponUser.getVoucherId())).findFirst().orElse(null);
|
|
|
- if (lc == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- LifeDiscountCouponVo vo = mapLifeCouponToVo(lc);
|
|
|
- vo.setUserCouponId(lifeDiscountCouponUser.getId());
|
|
|
- vo.setVoucherId(lc.getId());
|
|
|
- vo.setQuantityClaimed(records.size());
|
|
|
- vo.setExpirationTime(lifeDiscountCouponUser.getExpirationTime());
|
|
|
- vo.setReachUseTimeFlag(1);
|
|
|
- if (lc.getStartDate() != null) {
|
|
|
- LocalDate startLocal = lc.getStartDate().toInstant().atZone(zoneId).toLocalDate();
|
|
|
- if (localNow1.isBefore(startLocal)) {
|
|
|
- vo.setReachUseTimeFlag(0);
|
|
|
- }
|
|
|
- }
|
|
|
- if (lc.getEndDate() != null) {
|
|
|
- vo.setValidDate(lc.getEndDate().toInstant().atZone(zoneId).toLocalDate());
|
|
|
- }
|
|
|
- StoreInfo storeInfoOne = storeInfoList.stream().filter(s -> s.getId().toString().equals(lc.getStoreId())).findFirst().orElse(null);
|
|
|
- if (storeInfoOne != null) {
|
|
|
- vo.setBusinessSection(storeInfoOne.getBusinessSection());
|
|
|
- vo.setBusinessSectionName(storeInfoOne.getBusinessSectionName());
|
|
|
- }
|
|
|
- lifeDiscountCouponVos.add(vo);
|
|
|
- }
|
|
|
- return lifeDiscountCouponVos;
|
|
|
+ return processVoucherCoupons(records, zoneId, localNow);
|
|
|
}
|
|
|
|
|
|
- // type=1 或 type=null:优惠券(或混合),查 life_discount_coupon
|
|
|
- List<Integer> couponIdList = records.stream().map(LifeDiscountCouponUser::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ // type=1 或 type=null:优惠券(或混合),查询 life_discount_coupon
|
|
|
+ List<Integer> couponIdList = records.stream()
|
|
|
+ .map(LifeDiscountCouponUser::getCouponId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 查询优惠券信息
|
|
|
LambdaQueryWrapper<LifeDiscountCoupon> couponQueryWrapper = new LambdaQueryWrapper<LifeDiscountCoupon>()
|
|
|
.in(!couponIdList.isEmpty(), LifeDiscountCoupon::getId, couponIdList);
|
|
|
- //如果指定了优惠券类型(满减券或折扣券),添加筛选条件
|
|
|
+ // 如果指定了优惠券类型(满减券或折扣券),添加筛选条件
|
|
|
if (couponType != null) {
|
|
|
couponQueryWrapper.eq(LifeDiscountCoupon::getCouponType, couponType);
|
|
|
}
|
|
|
List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(couponQueryWrapper);
|
|
|
+
|
|
|
+ // 如果type=1且没有查询到优惠券,直接返回
|
|
|
if (type != null && type == 1 && lifeDiscountCoupons.isEmpty()) {
|
|
|
return lifeDiscountCouponVos;
|
|
|
}
|
|
|
- List<String> storeIdList = lifeDiscountCoupons.isEmpty() ? new ArrayList<>() : lifeDiscountCoupons.stream().map(LifeDiscountCoupon::getStoreId).collect(Collectors.toList());
|
|
|
- List<StoreInfo> storeInfoList = storeInfoMapper.getList(new LambdaQueryWrapper<StoreInfo>().in(!storeIdList.isEmpty(), StoreInfo::getId, storeIdList));
|
|
|
- if (type != null && type == 1 && storeInfoList.isEmpty() && records.isEmpty()) {
|
|
|
- return lifeDiscountCouponVos;
|
|
|
- }
|
|
|
+
|
|
|
+ // 查询店铺信息
|
|
|
+ List<String> storeIdList = lifeDiscountCoupons.stream()
|
|
|
+ .map(LifeDiscountCoupon::getStoreId)
|
|
|
+ .filter(s -> !StringUtils.isEmpty(s))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<StoreInfo> storeInfoList = storeInfoMapper.getList(
|
|
|
+ new LambdaQueryWrapper<StoreInfo>().in(!storeIdList.isEmpty(), StoreInfo::getId, storeIdList));
|
|
|
+
|
|
|
+ // type=null时,需要同时处理代金券
|
|
|
List<LifeCoupon> lifeCouponsForMerge = new ArrayList<>();
|
|
|
+ List<StoreInfo> voucherStoreInfoList = new ArrayList<>();
|
|
|
if (type == null) {
|
|
|
- List<String> voucherIdList = records.stream().map(LifeDiscountCouponUser::getVoucherId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ List<String> voucherIdList = records.stream()
|
|
|
+ .map(LifeDiscountCouponUser::getVoucherId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
if (!voucherIdList.isEmpty()) {
|
|
|
- lifeCouponsForMerge = lifeCouponMapper.selectList(new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList));
|
|
|
- }
|
|
|
- if (!lifeCouponsForMerge.isEmpty()) {
|
|
|
- List<String> voucherStoreIds = lifeCouponsForMerge.stream().map(LifeCoupon::getStoreId).filter(s -> !StringUtils.isEmpty(s)).collect(Collectors.toList());
|
|
|
+ lifeCouponsForMerge = lifeCouponMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList));
|
|
|
+ List<String> voucherStoreIds = lifeCouponsForMerge.stream()
|
|
|
+ .map(LifeCoupon::getStoreId)
|
|
|
+ .filter(s -> !StringUtils.isEmpty(s))
|
|
|
+ .collect(Collectors.toList());
|
|
|
if (!voucherStoreIds.isEmpty()) {
|
|
|
- List<StoreInfo> voucherStores = storeInfoMapper.getList(new LambdaQueryWrapper<StoreInfo>().in(StoreInfo::getId, voucherStoreIds));
|
|
|
- storeInfoList = new ArrayList<>(storeInfoList);
|
|
|
- storeInfoList.addAll(voucherStores);
|
|
|
+ voucherStoreInfoList = storeInfoMapper.getList(
|
|
|
+ new LambdaQueryWrapper<StoreInfo>().in(StoreInfo::getId, voucherStoreIds));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 合并店铺信息列表
|
|
|
+ List<StoreInfo> allStoreInfoList = new ArrayList<>(storeInfoList);
|
|
|
+ allStoreInfoList.addAll(voucherStoreInfoList);
|
|
|
+
|
|
|
+ // 构建Map提高查询效率
|
|
|
+ Map<Integer, LifeDiscountCoupon> couponMap = lifeDiscountCoupons.stream()
|
|
|
+ .collect(Collectors.toMap(LifeDiscountCoupon::getId, c -> c, (k1, k2) -> k1));
|
|
|
+ Map<String, LifeCoupon> voucherMap = lifeCouponsForMerge.stream()
|
|
|
+ .collect(Collectors.toMap(LifeCoupon::getId, v -> v, (k1, k2) -> k1));
|
|
|
+ Map<String, StoreInfo> storeInfoMap = allStoreInfoList.stream()
|
|
|
+ .collect(Collectors.toMap(s -> s.getId().toString(), s -> s, (k1, k2) -> k1));
|
|
|
+
|
|
|
+ // 处理每条用户优惠券记录
|
|
|
for (LifeDiscountCouponUser lifeDiscountCouponUser : records) {
|
|
|
- if (lifeDiscountCouponUser.getVoucherId() != null && !lifeCouponsForMerge.isEmpty()) {
|
|
|
- LifeCoupon lc = lifeCouponsForMerge.stream().filter(c -> c.getId().equals(lifeDiscountCouponUser.getVoucherId())).findFirst().orElse(null);
|
|
|
+ // 处理代金券(type=null时)
|
|
|
+ if (lifeDiscountCouponUser.getVoucherId() != null && !voucherMap.isEmpty()) {
|
|
|
+ LifeCoupon lc = voucherMap.get(lifeDiscountCouponUser.getVoucherId());
|
|
|
if (lc != null) {
|
|
|
- LifeDiscountCouponVo vo = mapLifeCouponToVo(lc);
|
|
|
- vo.setUserCouponId(lifeDiscountCouponUser.getId());
|
|
|
- vo.setVoucherId(lc.getId());
|
|
|
- vo.setQuantityClaimed(records.size());
|
|
|
- vo.setExpirationTime(lifeDiscountCouponUser.getExpirationTime());
|
|
|
- vo.setReachUseTimeFlag(1);
|
|
|
- if (lc.getStartDate() != null) {
|
|
|
- LocalDate startLocal = lc.getStartDate().toInstant().atZone(zoneId).toLocalDate();
|
|
|
- if (localNow1.isBefore(startLocal)) {
|
|
|
- vo.setReachUseTimeFlag(0);
|
|
|
- }
|
|
|
- }
|
|
|
- if (lc.getEndDate() != null) {
|
|
|
- vo.setValidDate(lc.getEndDate().toInstant().atZone(zoneId).toLocalDate());
|
|
|
- }
|
|
|
- StoreInfo storeInfoOne = storeInfoList.stream().filter(s -> s.getId().toString().equals(lc.getStoreId())).findFirst().orElse(null);
|
|
|
- if (storeInfoOne != null) {
|
|
|
- vo.setBusinessSection(storeInfoOne.getBusinessSection());
|
|
|
- vo.setBusinessSectionName(storeInfoOne.getBusinessSectionName());
|
|
|
- }
|
|
|
+ LifeDiscountCouponVo vo = buildVoucherVo(lc, lifeDiscountCouponUser, zoneId, localNow, storeInfoMap);
|
|
|
lifeDiscountCouponVos.add(vo);
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
- LifeDiscountCoupon lifeDiscountCouponOne = lifeDiscountCoupons.stream().filter(lifeDiscountCoupon -> lifeDiscountCoupon.getId().equals(lifeDiscountCouponUser.getCouponId())).findFirst().orElse(null);
|
|
|
- if (lifeDiscountCouponOne == null) {
|
|
|
+
|
|
|
+ // 处理优惠券
|
|
|
+ if (lifeDiscountCouponUser.getCouponId() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- StoreInfo storeInfoOne = null;
|
|
|
- if (!storeInfoList.isEmpty() && !StringUtils.isEmpty(lifeDiscountCouponOne.getStoreId())) {
|
|
|
- storeInfoOne = storeInfoList.stream().filter(storeInfo -> storeInfo.getId().toString().equals(lifeDiscountCouponOne.getStoreId())).findFirst().orElse(null);
|
|
|
+ LifeDiscountCoupon coupon = couponMap.get(lifeDiscountCouponUser.getCouponId());
|
|
|
+ if (coupon == null) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- LifeDiscountCouponVo lifeDiscountCouponVo = new LifeDiscountCouponVo();
|
|
|
- if (null != storeInfoOne) {
|
|
|
- lifeDiscountCouponVo.setBusinessSection(storeInfoOne.getBusinessSection());
|
|
|
- lifeDiscountCouponVo.setBusinessSectionName(storeInfoOne.getBusinessSectionName());
|
|
|
- }
|
|
|
- lifeDiscountCouponVo.setCouponId(lifeDiscountCouponOne.getId());
|
|
|
- lifeDiscountCouponVo.setVoucherId(lifeDiscountCouponUser.getVoucherId());
|
|
|
- BeanUtils.copyProperties(lifeDiscountCouponOne, lifeDiscountCouponVo);
|
|
|
- lifeDiscountCouponVo.setQuantityClaimed(lifeDiscountCouponUserIPage.getRecords().size());
|
|
|
- lifeDiscountCouponVo.setExpirationTime(lifeDiscountCouponUser.getExpirationTime());
|
|
|
- // 设置有效期
|
|
|
- String specifiedDay = lifeDiscountCouponOne.getSpecifiedDay();
|
|
|
- if (!StringUtils.isEmpty(specifiedDay)) {
|
|
|
+
|
|
|
+ LifeDiscountCouponVo vo = buildCouponVo(coupon, lifeDiscountCouponUser, zoneId, localNow, storeInfoMap);
|
|
|
+ lifeDiscountCouponVos.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return lifeDiscountCouponVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理代金券列表(type=4时使用)
|
|
|
+ */
|
|
|
+ private List<LifeDiscountCouponVo> processVoucherCoupons(List<LifeDiscountCouponUser> records,
|
|
|
+ ZoneId zoneId, LocalDate localNow) {
|
|
|
+ List<LifeDiscountCouponVo> result = new ArrayList<>();
|
|
|
+ List<String> voucherIdList = records.stream()
|
|
|
+ .map(LifeDiscountCouponUser::getVoucherId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (voucherIdList.isEmpty()) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList));
|
|
|
+ List<String> storeIdList = lifeCoupons.stream()
|
|
|
+ .map(LifeCoupon::getStoreId)
|
|
|
+ .filter(s -> !StringUtils.isEmpty(s))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<StoreInfo> storeInfoList = storeInfoMapper.getList(
|
|
|
+ new LambdaQueryWrapper<StoreInfo>().in(!storeIdList.isEmpty(), StoreInfo::getId, storeIdList));
|
|
|
+
|
|
|
+ Map<String, LifeCoupon> voucherMap = lifeCoupons.stream()
|
|
|
+ .collect(Collectors.toMap(LifeCoupon::getId, v -> v, (k1, k2) -> k1));
|
|
|
+ Map<String, StoreInfo> storeInfoMap = storeInfoList.stream()
|
|
|
+ .collect(Collectors.toMap(s -> s.getId().toString(), s -> s, (k1, k2) -> k1));
|
|
|
+
|
|
|
+ for (LifeDiscountCouponUser userCoupon : records) {
|
|
|
+ LifeCoupon lc = voucherMap.get(userCoupon.getVoucherId());
|
|
|
+ if (lc != null) {
|
|
|
+ LifeDiscountCouponVo vo = buildVoucherVo(lc, userCoupon, zoneId, localNow, storeInfoMap);
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建代金券VO
|
|
|
+ */
|
|
|
+ private LifeDiscountCouponVo buildVoucherVo(LifeCoupon lc, LifeDiscountCouponUser userCoupon,
|
|
|
+ ZoneId zoneId, LocalDate localNow, Map<String, StoreInfo> storeInfoMap) {
|
|
|
+ LifeDiscountCouponVo vo = mapLifeCouponToVo(lc);
|
|
|
+ vo.setUserCouponId(userCoupon.getId());
|
|
|
+ vo.setVoucherId(lc.getId());
|
|
|
+ // quantityClaimed表示该券的总领取数量,在用户券列表中不设置或设置为0
|
|
|
+ vo.setQuantityClaimed(null);
|
|
|
+ vo.setExpirationTime(userCoupon.getExpirationTime());
|
|
|
+ vo.setReachUseTimeFlag(1);
|
|
|
+
|
|
|
+ // 判断是否到了使用开始时间
|
|
|
+ if (lc.getStartDate() != null) {
|
|
|
+ LocalDate startLocal = lc.getStartDate().toInstant().atZone(zoneId).toLocalDate();
|
|
|
+ if (localNow.isBefore(startLocal)) {
|
|
|
+ vo.setReachUseTimeFlag(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置有效期
|
|
|
+ if (lc.getEndDate() != null) {
|
|
|
+ vo.setValidDate(lc.getEndDate().toInstant().atZone(zoneId).toLocalDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置店铺信息
|
|
|
+ StoreInfo storeInfo = storeInfoMap.get(lc.getStoreId());
|
|
|
+ if (storeInfo != null) {
|
|
|
+ vo.setBusinessSection(storeInfo.getBusinessSection());
|
|
|
+ vo.setBusinessSectionName(storeInfo.getBusinessSectionName());
|
|
|
+ }
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建优惠券VO
|
|
|
+ */
|
|
|
+ private LifeDiscountCouponVo buildCouponVo(LifeDiscountCoupon coupon, LifeDiscountCouponUser userCoupon,
|
|
|
+ ZoneId zoneId, LocalDate localNow, Map<String, StoreInfo> storeInfoMap) {
|
|
|
+ LifeDiscountCouponVo vo = new LifeDiscountCouponVo();
|
|
|
+ vo.setCouponId(coupon.getId());
|
|
|
+ vo.setVoucherId(userCoupon.getVoucherId());
|
|
|
+ vo.setUserCouponId(userCoupon.getId());
|
|
|
+ BeanUtils.copyProperties(coupon, vo);
|
|
|
+
|
|
|
+ // quantityClaimed表示该券的总领取数量,在用户券列表中不设置或设置为0
|
|
|
+ vo.setQuantityClaimed(null);
|
|
|
+ vo.setExpirationTime(userCoupon.getExpirationTime());
|
|
|
+
|
|
|
+ // 设置有效期(根据指定天数计算)
|
|
|
+ String specifiedDay = coupon.getSpecifiedDay();
|
|
|
+ if (!StringUtils.isEmpty(specifiedDay)) {
|
|
|
+ try {
|
|
|
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);
|
|
|
+ if (sDay > 0 && userCoupon.getReceiveTime() != null) {
|
|
|
+ Date validDate = addDaysToDateJava8(userCoupon.getReceiveTime(), sDay);
|
|
|
+ vo.setValidDate(validDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
|
|
}
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 忽略解析错误
|
|
|
}
|
|
|
-
|
|
|
- // 判断是否到了优惠券的开始时间
|
|
|
- lifeDiscountCouponVo.setReachUseTimeFlag(1);
|
|
|
- if (null != lifeDiscountCouponOne.getBeginGetDate() && localNow1.isBefore(lifeDiscountCouponOne.getBeginGetDate())) {
|
|
|
- lifeDiscountCouponVo.setReachUseTimeFlag(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否到了优惠券的开始时间
|
|
|
+ vo.setReachUseTimeFlag(1);
|
|
|
+ if (coupon.getBeginGetDate() != null && localNow.isBefore(coupon.getBeginGetDate())) {
|
|
|
+ vo.setReachUseTimeFlag(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置店铺信息
|
|
|
+ if (!StringUtils.isEmpty(coupon.getStoreId())) {
|
|
|
+ StoreInfo storeInfo = storeInfoMap.get(coupon.getStoreId());
|
|
|
+ if (storeInfo != null) {
|
|
|
+ vo.setBusinessSection(storeInfo.getBusinessSection());
|
|
|
+ vo.setBusinessSectionName(storeInfo.getBusinessSectionName());
|
|
|
}
|
|
|
- lifeDiscountCouponVos.add(lifeDiscountCouponVo);
|
|
|
}
|
|
|
- return lifeDiscountCouponVos;
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在指定日期基础上增加天数
|
|
|
+ */
|
|
|
+ private Date addDaysToDate(Date date, int days) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date);
|
|
|
+ calendar.add(Calendar.DAY_OF_YEAR, days);
|
|
|
+ return calendar.getTime();
|
|
|
}
|
|
|
|
|
|
//获取纯日期
|
|
|
@@ -892,9 +968,31 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取店铺所有优惠券列表(分页)
|
|
|
+ * 支持查询我的优惠券和好友优惠券
|
|
|
+ *
|
|
|
+ * @param storeId 店铺ID
|
|
|
+ * @param userLoginInfo 用户登录信息
|
|
|
+ * @param page 页码
|
|
|
+ * @param size 每页数量
|
|
|
+ * @param couponName 优惠券名称(模糊查询)
|
|
|
+ * @param tab 分页类型:0-全部,1-进行中,2-已结束
|
|
|
+ * @param couponsFromType 查询类型:1-我的优惠券,2-好友的优惠券
|
|
|
+ * @param couponStatus 优惠券状态:0-草稿,1-正式
|
|
|
+ * @param couponType 优惠券类型:1-满减券,2-折扣券,null-全部
|
|
|
+ * @return 分页优惠券列表
|
|
|
+ */
|
|
|
@Override
|
|
|
public IPage<LifeDiscountCouponVo> getStoreAllCouponList(String storeId, UserLoginInfo userLoginInfo, int page, int size, String couponName, String tab, int couponsFromType, int couponStatus, Integer couponType) {
|
|
|
-
|
|
|
+ // 参数校验
|
|
|
+ if (StringUtils.isEmpty(storeId)) {
|
|
|
+ throw new IllegalArgumentException("店铺ID不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(tab)) {
|
|
|
+ throw new IllegalArgumentException("分页类型不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
if (couponsFromType == 1) {
|
|
|
IPage<LifeDiscountCoupon> iPage = new Page<>(page, size);
|
|
|
List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
|
|
|
@@ -910,23 +1008,20 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
}
|
|
|
//获取当日日期
|
|
|
Date now = new Date();
|
|
|
- //如果根据类型查询
|
|
|
- if (!StringUtils.isEmpty(tab) && tab.equals("1")) {//进行中
|
|
|
- //开始时间小于当前时间
|
|
|
- lifeDiscountCouponLambdaQueryWrapper.le(LifeDiscountCoupon::getBeginGetDate, getPureDate(now));
|
|
|
- //结束时间大于当前时间
|
|
|
- lifeDiscountCouponLambdaQueryWrapper.ge(LifeDiscountCoupon::getEndGetDate, getPureDate(now));
|
|
|
- lifeDiscountCouponLambdaQueryWrapper.gt(LifeDiscountCoupon::getSingleQty, 0);
|
|
|
-
|
|
|
- //不要已暂停关闭领取的
|
|
|
- lifeDiscountCouponLambdaQueryWrapper.eq(LifeDiscountCoupon::getGetStatus, 1);
|
|
|
- } else if (!StringUtils.isEmpty(tab) && tab.equals("2")) {//已结束
|
|
|
- //结束时间小于当前时间
|
|
|
- lifeDiscountCouponLambdaQueryWrapper.lt(LifeDiscountCoupon::getEndGetDate, getPureDate(now));
|
|
|
-
|
|
|
- //不要已暂停关闭领取的
|
|
|
- lifeDiscountCouponLambdaQueryWrapper.eq(LifeDiscountCoupon::getGetStatus, 1);
|
|
|
- }
|
|
|
+ // 根据tab类型添加查询条件
|
|
|
+ Date pureDate = getPureDate(now);
|
|
|
+ if ("1".equals(tab)) {
|
|
|
+ // 进行中:开始时间 <= 当前时间 且 结束时间 >= 当前时间 且 有库存 且 开启领取
|
|
|
+ lifeDiscountCouponLambdaQueryWrapper.le(LifeDiscountCoupon::getBeginGetDate, pureDate)
|
|
|
+ .ge(LifeDiscountCoupon::getEndGetDate, pureDate)
|
|
|
+ .gt(LifeDiscountCoupon::getSingleQty, 0)
|
|
|
+ .eq(LifeDiscountCoupon::getGetStatus, 1);
|
|
|
+ } else if ("2".equals(tab)) {
|
|
|
+ // 已结束:结束时间 < 当前时间 且 开启领取
|
|
|
+ lifeDiscountCouponLambdaQueryWrapper.lt(LifeDiscountCoupon::getEndGetDate, pureDate)
|
|
|
+ .eq(LifeDiscountCoupon::getGetStatus, 1);
|
|
|
+ }
|
|
|
+ // tab=0或其他值:查询全部,不添加额外条件
|
|
|
lifeDiscountCouponLambdaQueryWrapper.eq(LifeDiscountCoupon::getStoreId, storeId);
|
|
|
lifeDiscountCouponLambdaQueryWrapper.orderByDesc(LifeDiscountCoupon::getCreatedTime);
|
|
|
//根据店铺id查询该店铺的优惠券,状态是开启领取的券
|
|
|
@@ -963,17 +1058,35 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- // 查询三个规则
|
|
|
- List<LifeDiscountCouponUnavailableRules> discountCouponId = lifeDiscountCouponUnavailableRulesMapper.selectList(new QueryWrapper<LifeDiscountCouponUnavailableRules>().eq("discount_coupon_id", lifeDiscountCoupon.getId()));
|
|
|
- Map<String, List<LifeDiscountCouponUnavailableRules>> collect = discountCouponId.stream().collect(Collectors.groupingBy(x -> x.getUnavailableRuleType()));
|
|
|
- if (collect.containsKey(DiscountCouponEnum.WEEKDAY_UNAVAILABLE.getValue())) {
|
|
|
- lifeDiscountCouponVo.setWeeklyDisabledList(collect.get(DiscountCouponEnum.WEEKDAY_UNAVAILABLE.getValue()).stream().map(x -> x.getUnavailableRuleValue()).collect(Collectors.toList()));
|
|
|
+ // 查询优惠券不可用规则(工作日、节假日、领取规则)
|
|
|
+ List<LifeDiscountCouponUnavailableRules> unavailableRules = lifeDiscountCouponUnavailableRulesMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<LifeDiscountCouponUnavailableRules>()
|
|
|
+ .eq(LifeDiscountCouponUnavailableRules::getDiscountCouponId, lifeDiscountCoupon.getId()));
|
|
|
+
|
|
|
+ // 按规则类型分组
|
|
|
+ Map<String, List<LifeDiscountCouponUnavailableRules>> rulesMap = unavailableRules.stream()
|
|
|
+ .collect(Collectors.groupingBy(LifeDiscountCouponUnavailableRules::getUnavailableRuleType));
|
|
|
+
|
|
|
+ // 设置工作日不可用列表
|
|
|
+ String weekdayKey = DiscountCouponEnum.WEEKDAY_UNAVAILABLE.getValue();
|
|
|
+ if (rulesMap.containsKey(weekdayKey)) {
|
|
|
+ lifeDiscountCouponVo.setWeeklyDisabledList(rulesMap.get(weekdayKey).stream()
|
|
|
+ .map(LifeDiscountCouponUnavailableRules::getUnavailableRuleValue)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
}
|
|
|
- if (collect.containsKey(DiscountCouponEnum.HOLIDAY_UNAVAILABLE.getValue())) {
|
|
|
- lifeDiscountCouponVo.setHolidayDisabledList(collect.get(DiscountCouponEnum.HOLIDAY_UNAVAILABLE.getValue()).stream().map(x -> x.getUnavailableRuleValue()).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // 设置节假日不可用列表
|
|
|
+ String holidayKey = DiscountCouponEnum.HOLIDAY_UNAVAILABLE.getValue();
|
|
|
+ if (rulesMap.containsKey(holidayKey)) {
|
|
|
+ lifeDiscountCouponVo.setHolidayDisabledList(rulesMap.get(holidayKey).stream()
|
|
|
+ .map(LifeDiscountCouponUnavailableRules::getUnavailableRuleValue)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
}
|
|
|
- if (collect.containsKey(DiscountCouponEnum.CLAIM_RULE.getValue())) {
|
|
|
- lifeDiscountCouponVo.setClaimRule(collect.get(DiscountCouponEnum.CLAIM_RULE.getValue()).get(0).getUnavailableRuleValue());
|
|
|
+
|
|
|
+ // 设置领取规则
|
|
|
+ String claimRuleKey = DiscountCouponEnum.CLAIM_RULE.getValue();
|
|
|
+ if (rulesMap.containsKey(claimRuleKey) && !rulesMap.get(claimRuleKey).isEmpty()) {
|
|
|
+ lifeDiscountCouponVo.setClaimRule(rulesMap.get(claimRuleKey).get(0).getUnavailableRuleValue());
|
|
|
}
|
|
|
BeanUtils.copyProperties(lifeDiscountCoupon, lifeDiscountCouponVo);
|
|
|
lifeDiscountCouponVos.add(lifeDiscountCouponVo);
|
|
|
@@ -997,21 +1110,19 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
}
|
|
|
//获取当日日期
|
|
|
Date now = new Date();
|
|
|
- //如果根据类型查询
|
|
|
- if (!StringUtils.isEmpty(tab) && tab.equals("1")) {//进行中
|
|
|
- //开始时间小于当前时间
|
|
|
- friendLifeDiscountCouponQueryWrapper.le("ldc.start_date", getPureDate(now));
|
|
|
- //结束时间大于当前时间
|
|
|
- friendLifeDiscountCouponQueryWrapper.ge("ldc.end_date", getPureDate(now));
|
|
|
- //不要已暂停关闭领取的
|
|
|
- friendLifeDiscountCouponQueryWrapper.eq("ldc.get_status", 1);
|
|
|
- } else if (!StringUtils.isEmpty(tab) && tab.equals("2")) {//已结束
|
|
|
- //结束时间小于当前时间
|
|
|
- friendLifeDiscountCouponQueryWrapper.lt("ldc.end_date", getPureDate(now));
|
|
|
-
|
|
|
- //不要已暂停关闭领取的
|
|
|
- friendLifeDiscountCouponQueryWrapper.eq("ldc.get_status", 1);
|
|
|
- }
|
|
|
+ // 根据tab类型添加查询条件(好友优惠券)
|
|
|
+ Date pureDate = getPureDate(now);
|
|
|
+ if ("1".equals(tab)) {
|
|
|
+ // 进行中:开始时间 <= 当前时间 且 结束时间 >= 当前时间 且 开启领取
|
|
|
+ friendLifeDiscountCouponQueryWrapper.le("ldc.start_date", pureDate)
|
|
|
+ .ge("ldc.end_date", pureDate)
|
|
|
+ .eq("ldc.get_status", 1);
|
|
|
+ } else if ("2".equals(tab)) {
|
|
|
+ // 已结束:结束时间 < 当前时间 且 开启领取
|
|
|
+ friendLifeDiscountCouponQueryWrapper.lt("ldc.end_date", pureDate)
|
|
|
+ .eq("ldc.get_status", 1);
|
|
|
+ }
|
|
|
+ // tab=0或其他值:查询全部,不添加额外条件
|
|
|
friendLifeDiscountCouponQueryWrapper.orderByDesc("ldc.created_time");
|
|
|
friendLifeDiscountCouponQueryWrapper.eq("ldcsf.store_user_id", storeId);
|
|
|
friendLifeDiscountCouponQueryWrapper.eq("ldcsf.delete_flag", 0);
|
|
|
@@ -1047,16 +1158,35 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- 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()));
|
|
|
- if (collect.containsKey(DiscountCouponEnum.WEEKDAY_UNAVAILABLE.getValue())) {
|
|
|
- record.setWeeklyDisabledList(collect.get(DiscountCouponEnum.WEEKDAY_UNAVAILABLE.getValue()).stream().map(x -> x.getUnavailableRuleValue()).collect(Collectors.toList()));
|
|
|
+ // 查询优惠券不可用规则(好友优惠券)
|
|
|
+ List<LifeDiscountCouponUnavailableRules> unavailableRules = lifeDiscountCouponUnavailableRulesMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<LifeDiscountCouponUnavailableRules>()
|
|
|
+ .eq(LifeDiscountCouponUnavailableRules::getDiscountCouponId, record.getCouponId()));
|
|
|
+
|
|
|
+ // 按规则类型分组
|
|
|
+ Map<String, List<LifeDiscountCouponUnavailableRules>> rulesMap = unavailableRules.stream()
|
|
|
+ .collect(Collectors.groupingBy(LifeDiscountCouponUnavailableRules::getUnavailableRuleType));
|
|
|
+
|
|
|
+ // 设置工作日不可用列表
|
|
|
+ String weekdayKey = DiscountCouponEnum.WEEKDAY_UNAVAILABLE.getValue();
|
|
|
+ if (rulesMap.containsKey(weekdayKey)) {
|
|
|
+ record.setWeeklyDisabledList(rulesMap.get(weekdayKey).stream()
|
|
|
+ .map(LifeDiscountCouponUnavailableRules::getUnavailableRuleValue)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
}
|
|
|
- if (collect.containsKey(DiscountCouponEnum.HOLIDAY_UNAVAILABLE.getValue())) {
|
|
|
- record.setHolidayDisabledList(collect.get(DiscountCouponEnum.HOLIDAY_UNAVAILABLE.getValue()).stream().map(x -> x.getUnavailableRuleValue()).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // 设置节假日不可用列表
|
|
|
+ String holidayKey = DiscountCouponEnum.HOLIDAY_UNAVAILABLE.getValue();
|
|
|
+ if (rulesMap.containsKey(holidayKey)) {
|
|
|
+ record.setHolidayDisabledList(rulesMap.get(holidayKey).stream()
|
|
|
+ .map(LifeDiscountCouponUnavailableRules::getUnavailableRuleValue)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
}
|
|
|
- if (collect.containsKey(DiscountCouponEnum.CLAIM_RULE.getValue())) {
|
|
|
- record.setClaimRule(collect.get(DiscountCouponEnum.CLAIM_RULE.getValue()).get(0).getUnavailableRuleValue());
|
|
|
+
|
|
|
+ // 设置领取规则
|
|
|
+ String claimRuleKey = DiscountCouponEnum.CLAIM_RULE.getValue();
|
|
|
+ if (rulesMap.containsKey(claimRuleKey) && !rulesMap.get(claimRuleKey).isEmpty()) {
|
|
|
+ record.setClaimRule(rulesMap.get(claimRuleKey).get(0).getUnavailableRuleValue());
|
|
|
}
|
|
|
BeanUtils.copyProperties(record, lifeDiscountcouponVo);
|
|
|
friendLifeDiscountCouponVos.add(lifeDiscountcouponVo);
|