Files
bl/modules/player/service/task.go
昔念 06b77d598e
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
1
2026-02-14 03:05:51 +08:00

69 lines
1.0 KiB
Go

package service
import (
"blazing/cool"
"blazing/modules/player/model"
"time"
"github.com/gogf/gf/v2/os/gtime"
)
// 获取任务信息
func (s *TaskService) Exec(id uint32, t func(*model.Task) bool) {
var gg model.Task
m1 := s.dbm(s.Model).Where("task_id", id)
m1.Scan(&gg)
if gg.Data == nil {
gg.Data = make([]uint32, 0)
}
tre := t(&gg)
if !tre { //不需要更新
return
}
if cool.Config.ServerInfo.IsVip != 0 {
return
}
gg.PlayerID = uint64(s.userid)
gg.TaskID = id
_, err := m1.Save(gg)
if err != nil {
panic(err)
}
}
// IsToday 判断给定时间是否是今天
func IsToday(t1 *gtime.Time) bool {
if t1 == nil {
return false
}
t := t1.Time
// 获取当前时间
now := time.Now()
// 比较年、月、日是否相同
return t.Year() == now.Year() &&
t.Month() == now.Month() &&
t.Day() == now.Day()
}
type TaskService struct {
BaseService
}
func NewTaskService(id uint32) *TaskService {
return &TaskService{
BaseService: BaseService{userid: id,
Service: &cool.Service{Model: model.NewTask()},
},
}
}