From 4bb385b76610be43afd848c4b2dd5ff64749131e Mon Sep 17 00:00:00 2001 From: Echo <1711788888@qq.com> Date: Tue, 2 Apr 2024 15:02:46 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BF=AE=E6=94=B9=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=94=99=E8=AF=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task/user.go | 4 ++-- task/wxMsg.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/task/user.go b/task/user.go index e6a1d58..9a356ce 100644 --- a/task/user.go +++ b/task/user.go @@ -27,7 +27,7 @@ func CheckUserSurgeryDate() { func SendMsg2User() { go func() { - global.GVA_LOG.Info("执行发送消息定时任务") + global.GVA_LOG.Info("创建发送消息定时任务") var ut []common.UserTodo err := global.GVA_DB.Model(&common.UserTodo{}).Find(&ut).Error if err != nil { @@ -47,7 +47,7 @@ func SendMsg2User() { } // 根据用户手术信息 发送提醒消息 - if todo.RemindPeriod == 0 && todo.IsFinish == 0 { + if todo.RemindPeriod == user.IsSurgery && todo.IsFinish == 0 { // 根据年月日时发送消息 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))) diff --git a/task/wxMsg.go b/task/wxMsg.go index 7494560..9b1258b 100644 --- a/task/wxMsg.go +++ b/task/wxMsg.go @@ -1,7 +1,6 @@ package task import ( - "fmt" "github.com/medivhzhan/weapp/v3" msg "github.com/medivhzhan/weapp/v3/subscribemessage" "go.uber.org/zap" @@ -67,6 +66,7 @@ func MiniappSendMsg(userId string, utId string) { err = global.GVA_DB.Model(&common.UserTodo{}).Where("id = ?", utId).First(&ut).Error if err != nil { global.GVA_LOG.Error("定时任务获取用户Todo列表失败:", zap.Error(err)) + return } var msgDatas []msg.SendRequest @@ -111,7 +111,7 @@ func MiniappSendMsg(userId string, utId string) { err = send.GetResponseError() if err != nil { - fmt.Printf("微信返回错误: %#v", err) + global.GVA_LOG.Error("发送失败: %#v", zap.Any("返回结果: %#v", send)) return } global.GVA_LOG.Info("发送成功: %#v", zap.Any("返回结果: %#v", send)) @@ -125,7 +125,7 @@ func MiniappSendMsg(userId string, utId string) { err = send.GetResponseError() if err != nil { - fmt.Printf("微信返回错误: %#v", err) + global.GVA_LOG.Error("发送失败: %#v", zap.Any("返回结果: %#v", send)) return } global.GVA_LOG.Info("发送成功: %#v", zap.Any("返回结果: %#v", send))