|
@@ -714,10 +714,11 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
* @param type 券类型:1-仅优惠券,4-仅代金券,null-全部
|
|
* @param type 券类型:1-仅优惠券,4-仅代金券,null-全部
|
|
|
* @param couponType 优惠券类型:1-满减券,2-折扣券,null-全部(仅当type不为4时有效)
|
|
* @param couponType 优惠券类型:1-满减券,2-折扣券,null-全部(仅当type不为4时有效)
|
|
|
* @param storeId 商铺ID,可为空,传则仅返回该商铺的优惠券
|
|
* @param storeId 商铺ID,可为空,传则仅返回该商铺的优惠券
|
|
|
|
|
+ * @param storeName 商铺名称模糊查询,可为空;与 storeId 同时传时 storeId 须属于名称匹配的门店
|
|
|
* @return 优惠券列表
|
|
* @return 优惠券列表
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type, Integer couponType, String storeId) {
|
|
|
|
|
|
|
+ public List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type, Integer couponType, String storeId, String storeName) {
|
|
|
// 参数校验
|
|
// 参数校验
|
|
|
if (userLoginInfo == null || StringUtils.isEmpty(userLoginInfo.getUserId())) {
|
|
if (userLoginInfo == null || StringUtils.isEmpty(userLoginInfo.getUserId())) {
|
|
|
throw new IllegalArgumentException("用户信息不能为空");
|
|
throw new IllegalArgumentException("用户信息不能为空");
|
|
@@ -732,6 +733,17 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
&& !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(已过期)");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ List<String> storeIdsByName = null;
|
|
|
|
|
+ if (!StringUtils.isEmpty(storeName)) {
|
|
|
|
|
+ String kw = storeName.trim();
|
|
|
|
|
+ if (!StringUtils.isEmpty(kw)) {
|
|
|
|
|
+ storeIdsByName = resolveStoreIdsByStoreNameLike(kw);
|
|
|
|
|
+ if (storeIdsByName.isEmpty()) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
|
|
List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
|
|
|
IPage<LifeDiscountCouponUser> iPage = new Page<>(page, size);
|
|
IPage<LifeDiscountCouponUser> iPage = new Page<>(page, size);
|
|
@@ -781,7 +793,10 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
if (records.isEmpty()) {
|
|
if (records.isEmpty()) {
|
|
|
return lifeDiscountCouponVos;
|
|
return lifeDiscountCouponVos;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(storeId) && storeIdsByName != null && !storeIdsByName.contains(storeId)) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 准备时间转换
|
|
// 准备时间转换
|
|
|
Instant instant = now.toInstant();
|
|
Instant instant = now.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
@@ -789,7 +804,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
|
|
|
|
|
// type=4:仅代金券,查询 life_coupon 表
|
|
// type=4:仅代金券,查询 life_coupon 表
|
|
|
if (type != null && type == 4) {
|
|
if (type != null && type == 4) {
|
|
|
- return processVoucherCoupons(records, zoneId, localNow, storeId);
|
|
|
|
|
|
|
+ return processVoucherCoupons(records, zoneId, localNow, storeId, storeIdsByName);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// type=1 或 type=null:优惠券(或混合),查询 life_discount_coupon
|
|
// type=1 或 type=null:优惠券(或混合),查询 life_discount_coupon
|
|
@@ -805,9 +820,10 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
if (couponType != null) {
|
|
if (couponType != null) {
|
|
|
couponQueryWrapper.eq(LifeDiscountCoupon::getCouponType, couponType);
|
|
couponQueryWrapper.eq(LifeDiscountCoupon::getCouponType, couponType);
|
|
|
}
|
|
}
|
|
|
- // 商铺ID检索:传则仅返回该商铺的优惠券
|
|
|
|
|
if (!StringUtils.isEmpty(storeId)) {
|
|
if (!StringUtils.isEmpty(storeId)) {
|
|
|
couponQueryWrapper.eq(LifeDiscountCoupon::getStoreId, storeId);
|
|
couponQueryWrapper.eq(LifeDiscountCoupon::getStoreId, storeId);
|
|
|
|
|
+ } else if (storeIdsByName != null) {
|
|
|
|
|
+ couponQueryWrapper.in(LifeDiscountCoupon::getStoreId, storeIdsByName);
|
|
|
}
|
|
}
|
|
|
List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(couponQueryWrapper);
|
|
List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(couponQueryWrapper);
|
|
|
|
|
|
|
@@ -836,6 +852,8 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
LambdaQueryWrapper<LifeCoupon> voucherWrapper = new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList);
|
|
LambdaQueryWrapper<LifeCoupon> voucherWrapper = new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList);
|
|
|
if (!StringUtils.isEmpty(storeId)) {
|
|
if (!StringUtils.isEmpty(storeId)) {
|
|
|
voucherWrapper.eq(LifeCoupon::getStoreId, storeId);
|
|
voucherWrapper.eq(LifeCoupon::getStoreId, storeId);
|
|
|
|
|
+ } else if (storeIdsByName != null) {
|
|
|
|
|
+ voucherWrapper.in(LifeCoupon::getStoreId, storeIdsByName);
|
|
|
}
|
|
}
|
|
|
lifeCouponsForMerge = lifeCouponMapper.selectList(voucherWrapper);
|
|
lifeCouponsForMerge = lifeCouponMapper.selectList(voucherWrapper);
|
|
|
List<String> voucherStoreIds = lifeCouponsForMerge.stream()
|
|
List<String> voucherStoreIds = lifeCouponsForMerge.stream()
|
|
@@ -890,10 +908,24 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 按门店名称模糊匹配,返回门店 id 列表(字符串,与优惠券/代金券 store_id 一致)
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<String> resolveStoreIdsByStoreNameLike(String storeNameKeyword) {
|
|
|
|
|
+ LambdaQueryWrapper<StoreInfo> w = new LambdaQueryWrapper<>();
|
|
|
|
|
+ w.like(StoreInfo::getStoreName, storeNameKeyword);
|
|
|
|
|
+ List<StoreInfo> list = storeInfoMapper.getList(w);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ return list.stream().map(s -> String.valueOf(s.getId())).distinct().collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 处理代金券列表(type=4时使用)
|
|
* 处理代金券列表(type=4时使用)
|
|
|
*/
|
|
*/
|
|
|
private List<LifeDiscountCouponVo> processVoucherCoupons(List<LifeDiscountCouponUser> records,
|
|
private List<LifeDiscountCouponVo> processVoucherCoupons(List<LifeDiscountCouponUser> records,
|
|
|
- ZoneId zoneId, LocalDate localNow, String storeId) {
|
|
|
|
|
|
|
+ ZoneId zoneId, LocalDate localNow, String storeId,
|
|
|
|
|
+ List<String> storeIdsByName) {
|
|
|
List<LifeDiscountCouponVo> result = new ArrayList<>();
|
|
List<LifeDiscountCouponVo> result = new ArrayList<>();
|
|
|
List<String> voucherIdList = records.stream()
|
|
List<String> voucherIdList = records.stream()
|
|
|
.map(LifeDiscountCouponUser::getVoucherId)
|
|
.map(LifeDiscountCouponUser::getVoucherId)
|
|
@@ -902,10 +934,15 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
if (voucherIdList.isEmpty()) {
|
|
if (voucherIdList.isEmpty()) {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!StringUtils.isEmpty(storeId) && storeIdsByName != null && !storeIdsByName.contains(storeId)) {
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
LambdaQueryWrapper<LifeCoupon> voucherWrapper = new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList);
|
|
LambdaQueryWrapper<LifeCoupon> voucherWrapper = new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList);
|
|
|
if (!StringUtils.isEmpty(storeId)) {
|
|
if (!StringUtils.isEmpty(storeId)) {
|
|
|
voucherWrapper.eq(LifeCoupon::getStoreId, storeId);
|
|
voucherWrapper.eq(LifeCoupon::getStoreId, storeId);
|
|
|
|
|
+ } else if (storeIdsByName != null) {
|
|
|
|
|
+ voucherWrapper.in(LifeCoupon::getStoreId, storeIdsByName);
|
|
|
}
|
|
}
|
|
|
List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(voucherWrapper);
|
|
List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(voucherWrapper);
|
|
|
List<String> storeIdList = lifeCoupons.stream()
|
|
List<String> storeIdList = lifeCoupons.stream()
|