From 7034bb7b2fb2a4f4999160d0fb78034f0e793ca0 Mon Sep 17 00:00:00 2001 From: Echo <1711788888@qq.com> Date: Sat, 30 Mar 2024 23:51:35 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E5=8F=91=E9=80=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task/task.go | 4 ---- task/user.go | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/task/task.go b/task/task.go index 0410c25..2f6fb4e 100644 --- a/task/task.go +++ b/task/task.go @@ -22,11 +22,7 @@ func InitTask() { global.GVA_LOG.Error("发送消息定时任务创建失败", zap.Error(err)) } - //_, err = WxTask.Every("1m").Do(MiniappSendMsg, "o9Fq_6_cYKvOWnyUM3McC11hWsTI", "测试", "测试", "测试") _, err = WxTask.Every("1m").Do(SendMsg2User) - if err != nil { - global.GVA_LOG.Error("检查用户是否已到手术日期定时任务创建失败", zap.Error(err)) - } // 开启定时任务 WxTask.StartAsync() diff --git a/task/user.go b/task/user.go index 977a2db..ccfcc67 100644 --- a/task/user.go +++ b/task/user.go @@ -49,13 +49,14 @@ func SendMsg2User() { // 根据用户手术信息 发送提醒消息 if user.IsSurgery == 0 && todo.RemindPeriod == 0 && todo.IsFinish == 0 { // 根据年月日时发送消息 - //job, err := WxTask.Every(1).Day().At(todo.RemindTime).Do(MiniappSendMsg, *user.WechatOpenId, todo.Content, todo.RemindPeriod, todo.RemindTime) - job, err := WxTask.Every(1).Day().At(todo.RemindTime).Do(MiniappSendMsg, strconv.Itoa(int(user.ID)), strconv.Itoa(int(todo.ID))) - global.GVA_LOG.Info("定时任务创建成功", zap.Any("job", job)) + job, err := WxTask.Every(1).Day().At(todo.RemindTime).LimitRunsTo(1).Do(MiniappSendMsg, strconv.Itoa(int(user.ID)), strconv.Itoa(int(todo.ID))) + //job, err := WxTask.Cron("0 30 23 30 3 2024").Do(MiniappSendMsg, strconv.Itoa(int(user.ID)), strconv.Itoa(int(todo.ID))) + //job, err := WxTask.Every(1).Day().At("23:51").LimitRunsTo(1).Do(MiniappSendMsg, strconv.Itoa(int(user.ID)), strconv.Itoa(int(todo.ID))) if err != nil { global.GVA_LOG.Error("定时任务创建失败:%s", zap.Error(err)) return } + global.GVA_LOG.Info("定时任务创建成功", zap.Any("job", job.LastRun())) } } }