fix: send_stats task_id type

This commit is contained in:
Your Name
2026-01-06 16:47:40 +08:00
parent 558edc864b
commit 29ad95ac98
3 changed files with 6 additions and 24 deletions
+1 -13
View File
@@ -347,18 +347,6 @@ func (sm *SendMessageService) UpdateSendStats() {
// 获取当前日期
currentDay := sm.getCurrentDay()
// 解析任务ID(如果是数字ID
var taskID *uint
if sm.TaskID != "" {
// 尝试将字符串ID转换为uint(如果是数字ID)
var id uint64
_, err := fmt.Sscanf(sm.TaskID, "%d", &id)
if err == nil {
taskIDValue := uint(id)
taskID = &taskIDValue
}
}
// 确定任务类型
taskType := "task"
if sm.SendMode == SendModeTemplate {
@@ -374,7 +362,7 @@ func (sm *SendMessageService) UpdateSendStats() {
}
// 更新统计:每次任务执行记录为1次
err := models.IncrementSendStats(taskID, taskType, currentDay, status, 1)
err := models.IncrementSendStats(sm.TaskID, taskType, currentDay, status, 1)
if err != nil {
logrus.Errorf("更新发送统计失败:%s", err)
}
+2 -8
View File
@@ -2,7 +2,6 @@ package statistic_service
import (
"message-nest/models"
"strconv"
)
type StatisticService struct {
@@ -44,11 +43,6 @@ func (sw *StatisticService) GetSendStatsByTask() (models.SendStatsData, error) {
if days <= 0 {
days = 30 // 默认30天
}
taskID, err := strconv.ParseUint(sw.TaskID, 10, 64)
if err != nil {
return models.SendStatsData{}, err
}
return models.GetSendStatsByTask(uint(taskID), days)
return models.GetSendStatsByTask(sw.TaskID, days)
}