🎨 新增清理机器人和定时设置免费定时任务

This commit is contained in:
2025-10-11 16:15:02 +08:00
parent 481635d333
commit 91ec3a2601
4 changed files with 79 additions and 0 deletions

24
task/checkTeacherVip.go Normal file
View File

@@ -0,0 +1,24 @@
package task
import (
"git.echol.cn/loser/lckt/global"
"git.echol.cn/loser/lckt/model/app"
"gorm.io/gorm"
)
// CheckTeacherVip 检查讲师VIP是否过期
func CheckTeacherVip(db *gorm.DB) error {
global.GVA_LOG.Info("开始检查用户讲师包月是否过期...")
var userTeacherVips []app.UserTeacherVip
// 根据当前时间和expire_at对比 查看是否到过期时间
db.Where("expire_at < ? AND is_expire = 1", gorm.Expr("NOW()")).Find(&userTeacherVips)
for _, u := range userTeacherVips {
u.IsExpire = 2
err := db.Save(&u).Error
if err != nil {
return err
}
}
global.GVA_LOG.Info("检查用户讲师包月是否过期完成...")
return nil
}