🎨 修改定时任务错误逻辑

This commit is contained in:
loser 2024-04-02 15:02:46 +08:00
parent 0d688ccae5
commit 4bb385b766
2 changed files with 5 additions and 5 deletions

View File

@ -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)))

View File

@ -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))