23 lines
520 B
Go
23 lines
520 B
Go
package task
|
|
|
|
import (
|
|
"github.com/go-co-op/gocron"
|
|
"go.uber.org/zap"
|
|
"miniapp/global"
|
|
"time"
|
|
)
|
|
|
|
var WxTask *gocron.Scheduler
|
|
|
|
func InitTask() {
|
|
WxTask = gocron.NewScheduler(time.Local)
|
|
|
|
// 每天凌晨1点执行
|
|
_, _ = WxTask.Every(1).Day().At("01:00").Do(CheckUserSurgeryDate) // 检查用户是否已到手术日期
|
|
_, _ = WxTask.Every(1).Day().At("01:00").Do(SendMsg2User)
|
|
|
|
// 开启定时任务
|
|
WxTask.StartAsync()
|
|
global.GVA_LOG.Info("定时任务已开启", zap.Any("任务数量:", WxTask.Len()))
|
|
}
|