VIP改版

This commit is contained in:
wuchunlei
2025-02-21 15:47:50 +08:00
parent 0e8b4d2e0e
commit 6908c092a5
38 changed files with 973 additions and 1797 deletions

View File

@@ -1,46 +1,13 @@
package com.peanut.modules.book.task;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.modules.common.entity.MyUserEntity;
import com.peanut.modules.book.service.MyUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Component
@EnableScheduling
//@Async
public class SysTask {
@Autowired
private MyUserService userService;
//
@Scheduled(cron = "0 0 2 ? * * ")
public void run() throws InterruptedException {
List<MyUserEntity> users = userService.getBaseMapper().selectList(new QueryWrapper<>());
for (MyUserEntity user : users) {
Date vipValidtime = user.getVipValidtime();
Date date = new Date();
long times = date.getTime() - vipValidtime.getTime();
if (times <= 0) {
String vip = user.getVip();
if (vip.equals("1")) {
user.setVip("0");
userService.save(user);
}
}
}
// System.out.println(Thread.currentThread().getName()+"=====>>>>>使用cron {}"+(System.currentTimeMillis()/1000));
}
}