JM-WechatMini/task/user.go
2024-03-21 21:08:45 +08:00

20 lines
467 B
Go

package task
import (
"miniapp/global"
"miniapp/model/app"
"time"
)
// CheckUserSurgeryDate 检查用户是否已到手术日期
func CheckUserSurgeryDate() {
var users []app.User
global.GVA_DB.Model(&app.User{}).Find(&users)
for _, user := range users {
parse, _ := time.Parse("2006-01-02", user.SurgeryTime)
if time.Now().Sub(parse).Hours()/24 == 0 {
global.GVA_DB.Model(&app.User{}).Where("id = ?", user.ID).Updates(app.User{IsSurgery: 1})
}
}
}