调整VIP检查

This commit is contained in:
Flow 2025-09-01 11:22:57 +08:00
parent ff023a2909
commit 1766bef7ca
2 changed files with 0 additions and 38 deletions

View File

@ -117,10 +117,4 @@ public interface PersonService {
* @param userid 用户编号
*/
void cancelVip(Integer userid);
/**
* 批量处理过期VIP用户
* 查询所有VIP到期时间已过的用户并将其isvip字段设置为0
*/
void processExpiredVipUsers();
}

View File

@ -191,36 +191,4 @@ public class PersonServiceImpl implements PersonService {
.set(PersonDO::getVipstarttime, null) // 清空会员开始时间
.set(PersonDO::getVipendtime, null)); // 清空会员结束时间
}
@Override
public void processExpiredVipUsers() {
// 获取当前时间
String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
log.info("开始检查VIP过期用户当前时间: {}", currentTime);
// 查询所有过期的VIP用户
List<PersonDO> expiredVipUsers = personMapper.selectList(new LambdaQueryWrapper<PersonDO>()
.eq(PersonDO::getIsvip, 1) // 当前是VIP用户
.isNotNull(PersonDO::getVipendtime) // VIP结束时间不为空
.lt(PersonDO::getVipendtime, currentTime)); // VIP结束时间小于当前时间
if (expiredVipUsers.isEmpty()) {
log.info("没有发现过期的VIP用户");
return; // 没有过期用户直接返回
}
log.info("发现 {} 个过期的VIP用户开始批量处理", expiredVipUsers.size());
// 提取所有过期用户的ID
List<Integer> expiredUserIds = expiredVipUsers.stream()
.map(PersonDO::getId)
.collect(java.util.stream.Collectors.toList());
// 批量更新过期VIP用户
personMapper.update(null, new LambdaUpdateWrapper<PersonDO>()
.in(PersonDO::getId, expiredUserIds)
.set(PersonDO::getIsvip, 0));// 设置为非会员状态
log.info("成功处理 {} 个过期VIP用户", expiredUserIds.size());
}
}