2025-08-27 20:52:15 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/cool"
|
2026-01-19 18:51:56 +08:00
|
|
|
"blazing/modules/player/model"
|
2025-08-28 17:13:54 +00:00
|
|
|
"time"
|
2025-12-07 19:23:44 +08:00
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/os/gtime"
|
2025-08-27 20:52:15 +00:00
|
|
|
)
|
|
|
|
|
|
2025-08-31 08:42:53 +00:00
|
|
|
// 获取任务信息
|
2026-02-14 03:05:51 +08:00
|
|
|
func (s *TaskService) Exec(id uint32, t func(*model.Task) bool) {
|
|
|
|
|
var gg model.Task
|
2026-02-05 23:44:07 +08:00
|
|
|
|
2026-02-13 22:57:05 +08:00
|
|
|
m1 := s.dbm(s.Model).Where("task_id", id)
|
2026-02-14 03:05:51 +08:00
|
|
|
|
2025-11-16 20:30:17 +00:00
|
|
|
m1.Scan(&gg)
|
2026-02-14 03:05:51 +08:00
|
|
|
if gg.Data == nil {
|
|
|
|
|
gg.Data = make([]uint32, 0)
|
|
|
|
|
}
|
2025-09-23 15:01:52 +00:00
|
|
|
tre := t(&gg)
|
2026-02-05 23:44:07 +08:00
|
|
|
|
2025-09-23 15:01:52 +00:00
|
|
|
if !tre { //不需要更新
|
|
|
|
|
return
|
2025-08-30 21:59:52 +08:00
|
|
|
}
|
2026-02-05 23:44:07 +08:00
|
|
|
if cool.Config.ServerInfo.IsVip != 0 {
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-10-10 01:10:13 +08:00
|
|
|
gg.PlayerID = uint64(s.userid)
|
|
|
|
|
gg.TaskID = id
|
2025-11-29 19:26:56 +08:00
|
|
|
_, err := m1.Save(gg)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
2025-08-30 21:59:52 +08:00
|
|
|
|
|
|
|
|
}
|
2025-08-28 17:13:54 +00:00
|
|
|
|
|
|
|
|
// IsToday 判断给定时间是否是今天
|
2025-12-07 19:23:44 +08:00
|
|
|
func IsToday(t1 *gtime.Time) bool {
|
|
|
|
|
if t1 == nil {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2025-12-14 23:28:28 +08:00
|
|
|
t := t1.Time
|
2025-12-07 19:23:44 +08:00
|
|
|
|
2025-12-14 23:28:28 +08:00
|
|
|
// 获取当前时间
|
|
|
|
|
now := time.Now()
|
2025-08-28 17:13:54 +00:00
|
|
|
|
2025-12-14 23:28:28 +08:00
|
|
|
// 比较年、月、日是否相同
|
|
|
|
|
return t.Year() == now.Year() &&
|
|
|
|
|
t.Month() == now.Month() &&
|
|
|
|
|
t.Day() == now.Day()
|
2025-08-28 17:13:54 +00:00
|
|
|
}
|
2026-03-05 14:56:28 +08:00
|
|
|
func IsWEEK(t1 *gtime.Time) bool {
|
|
|
|
|
if t1 == nil {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
t := t1.Time
|
|
|
|
|
|
|
|
|
|
// 获取当前时间
|
|
|
|
|
now := time.Now()
|
|
|
|
|
_, nweek := now.ISOWeek()
|
|
|
|
|
_, tweek := now.ISOWeek()
|
|
|
|
|
// 比较年、月、日是否相同
|
|
|
|
|
return t.Year() == now.Year() &&
|
|
|
|
|
tweek == nweek
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-16 20:30:17 +00:00
|
|
|
|
|
|
|
|
type TaskService struct {
|
|
|
|
|
BaseService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewTaskService(id uint32) *TaskService {
|
|
|
|
|
return &TaskService{
|
|
|
|
|
|
|
|
|
|
BaseService: BaseService{userid: id,
|
|
|
|
|
|
|
|
|
|
Service: &cool.Service{Model: model.NewTask()},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|