|
@@ -713,10 +713,11 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
* @param tabType 分页类型:0-全部(未使用),1-即将过期,2-已使用,3-已过期
|
|
* @param tabType 分页类型:0-全部(未使用),1-即将过期,2-已使用,3-已过期
|
|
|
* @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,可为空,传则仅返回该商铺的优惠券
|
|
|
* @return 优惠券列表
|
|
* @return 优惠券列表
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type, Integer couponType) {
|
|
|
|
|
|
|
+ public List<LifeDiscountCouponVo> getUserCouponList(UserLoginInfo userLoginInfo, int page, int size, String tabType, Integer type, Integer couponType, String storeId) {
|
|
|
// 参数校验
|
|
// 参数校验
|
|
|
if (userLoginInfo == null || StringUtils.isEmpty(userLoginInfo.getUserId())) {
|
|
if (userLoginInfo == null || StringUtils.isEmpty(userLoginInfo.getUserId())) {
|
|
|
throw new IllegalArgumentException("用户信息不能为空");
|
|
throw new IllegalArgumentException("用户信息不能为空");
|
|
@@ -781,7 +782,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);
|
|
|
|
|
|
|
+ return processVoucherCoupons(records, zoneId, localNow, storeId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// type=1 或 type=null:优惠券(或混合),查询 life_discount_coupon
|
|
// type=1 或 type=null:优惠券(或混合),查询 life_discount_coupon
|
|
@@ -797,6 +798,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)) {
|
|
|
|
|
+ couponQueryWrapper.eq(LifeDiscountCoupon::getStoreId, storeId);
|
|
|
|
|
+ }
|
|
|
List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(couponQueryWrapper);
|
|
List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(couponQueryWrapper);
|
|
|
|
|
|
|
|
// 如果type=1且没有查询到优惠券,直接返回
|
|
// 如果type=1且没有查询到优惠券,直接返回
|
|
@@ -821,8 +826,11 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
if (!voucherIdList.isEmpty()) {
|
|
if (!voucherIdList.isEmpty()) {
|
|
|
- lifeCouponsForMerge = lifeCouponMapper.selectList(
|
|
|
|
|
- new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList));
|
|
|
|
|
|
|
+ LambdaQueryWrapper<LifeCoupon> voucherWrapper = new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList);
|
|
|
|
|
+ if (!StringUtils.isEmpty(storeId)) {
|
|
|
|
|
+ voucherWrapper.eq(LifeCoupon::getStoreId, storeId);
|
|
|
|
|
+ }
|
|
|
|
|
+ lifeCouponsForMerge = lifeCouponMapper.selectList(voucherWrapper);
|
|
|
List<String> voucherStoreIds = lifeCouponsForMerge.stream()
|
|
List<String> voucherStoreIds = lifeCouponsForMerge.stream()
|
|
|
.map(LifeCoupon::getStoreId)
|
|
.map(LifeCoupon::getStoreId)
|
|
|
.filter(s -> !StringUtils.isEmpty(s))
|
|
.filter(s -> !StringUtils.isEmpty(s))
|
|
@@ -877,8 +885,8 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
/**
|
|
/**
|
|
|
* 处理代金券列表(type=4时使用)
|
|
* 处理代金券列表(type=4时使用)
|
|
|
*/
|
|
*/
|
|
|
- private List<LifeDiscountCouponVo> processVoucherCoupons(List<LifeDiscountCouponUser> records,
|
|
|
|
|
- ZoneId zoneId, LocalDate localNow) {
|
|
|
|
|
|
|
+ private List<LifeDiscountCouponVo> processVoucherCoupons(List<LifeDiscountCouponUser> records,
|
|
|
|
|
+ ZoneId zoneId, LocalDate localNow, String storeId) {
|
|
|
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)
|
|
@@ -887,9 +895,12 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
if (voucherIdList.isEmpty()) {
|
|
if (voucherIdList.isEmpty()) {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(
|
|
|
|
|
- new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<LifeCoupon> voucherWrapper = new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getId, voucherIdList);
|
|
|
|
|
+ if (!StringUtils.isEmpty(storeId)) {
|
|
|
|
|
+ voucherWrapper.eq(LifeCoupon::getStoreId, storeId);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(voucherWrapper);
|
|
|
List<String> storeIdList = lifeCoupons.stream()
|
|
List<String> storeIdList = lifeCoupons.stream()
|
|
|
.map(LifeCoupon::getStoreId)
|
|
.map(LifeCoupon::getStoreId)
|
|
|
.filter(s -> !StringUtils.isEmpty(s))
|
|
.filter(s -> !StringUtils.isEmpty(s))
|