Compare commits

..

No commits in common. "8aa2b355d981535327cfe02ce0c21baabbcb189f" and "0d688ccae5375475e06aba208f778e71d52972c4" have entirely different histories.

3 changed files with 7 additions and 6 deletions

View File

@ -55,7 +55,8 @@ func Routers() *gin.Engine {
r.OkWithData(len(jobs), c) r.OkWithData(len(jobs), c)
}) })
PublicGroup.GET("/task/send", func(c *gin.Context) { PublicGroup.GET("/task/send", func(c *gin.Context) {
task.SendMsg2User() tag, _ := task.WxTask.FindJobsByTag("sendMsg")
r.OkWithData(tag[0].NextRun(), c)
}) })
} }

View File

@ -27,7 +27,7 @@ func CheckUserSurgeryDate() {
func SendMsg2User() { func SendMsg2User() {
go func() { go func() {
global.GVA_LOG.Info("创建发送消息定时任务") global.GVA_LOG.Info("执行发送消息定时任务")
var ut []common.UserTodo var ut []common.UserTodo
err := global.GVA_DB.Model(&common.UserTodo{}).Find(&ut).Error err := global.GVA_DB.Model(&common.UserTodo{}).Find(&ut).Error
if err != nil { if err != nil {
@ -47,7 +47,7 @@ func SendMsg2User() {
} }
// 根据用户手术信息 发送提醒消息 // 根据用户手术信息 发送提醒消息
if todo.RemindPeriod == user.IsSurgery && todo.IsFinish == 0 { if todo.RemindPeriod == 0 && 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.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.Cron("0 30 23 30 3 2024").Do(MiniappSendMsg, strconv.Itoa(int(user.ID)), strconv.Itoa(int(todo.ID)))

View File

@ -1,6 +1,7 @@
package task package task
import ( import (
"fmt"
"github.com/medivhzhan/weapp/v3" "github.com/medivhzhan/weapp/v3"
msg "github.com/medivhzhan/weapp/v3/subscribemessage" msg "github.com/medivhzhan/weapp/v3/subscribemessage"
"go.uber.org/zap" "go.uber.org/zap"
@ -66,7 +67,6 @@ func MiniappSendMsg(userId string, utId string) {
err = global.GVA_DB.Model(&common.UserTodo{}).Where("id = ?", utId).First(&ut).Error err = global.GVA_DB.Model(&common.UserTodo{}).Where("id = ?", utId).First(&ut).Error
if err != nil { if err != nil {
global.GVA_LOG.Error("定时任务获取用户Todo列表失败", zap.Error(err)) global.GVA_LOG.Error("定时任务获取用户Todo列表失败", zap.Error(err))
return
} }
var msgDatas []msg.SendRequest var msgDatas []msg.SendRequest
@ -111,7 +111,7 @@ func MiniappSendMsg(userId string, utId string) {
err = send.GetResponseError() err = send.GetResponseError()
if err != nil { if err != nil {
global.GVA_LOG.Error("发送失败: %#v", zap.Any("返回结果: %#v", send)) fmt.Printf("微信返回错误: %#v", err)
return return
} }
global.GVA_LOG.Info("发送成功: %#v", zap.Any("返回结果: %#v", send)) global.GVA_LOG.Info("发送成功: %#v", zap.Any("返回结果: %#v", send))
@ -125,7 +125,7 @@ func MiniappSendMsg(userId string, utId string) {
err = send.GetResponseError() err = send.GetResponseError()
if err != nil { if err != nil {
global.GVA_LOG.Error("发送失败: %#v", zap.Any("返回结果: %#v", send)) fmt.Printf("微信返回错误: %#v", err)
return return
} }
global.GVA_LOG.Info("发送成功: %#v", zap.Any("返回结果: %#v", send)) global.GVA_LOG.Info("发送成功: %#v", zap.Any("返回结果: %#v", send))