fix(email): convert RegisterStartTime and RegisterEndTime to time.Time for accurate query filtering

This commit is contained in:
Chang lue Tsen 2025-08-20 08:22:48 -04:00
parent bc1e6315a8
commit 4f32d67113
2 changed files with 9 additions and 4 deletions

View File

@ -45,10 +45,10 @@ func (l *CreateBatchSendEmailTaskLogic) CreateBatchSendEmailTask(req *types.Crea
Where("auth_type = ?", "email")
if req.RegisterStartTime != 0 {
query = query.Where("user.created_at >= ?", req.RegisterStartTime)
query = query.Where("user.created_at >= ?", time.UnixMilli(req.RegisterStartTime))
}
if req.RegisterEndTime != 0 {
query = query.Where("user.created_at <= ?", req.RegisterEndTime)
query = query.Where("user.created_at <= ?", time.UnixMilli(req.RegisterEndTime))
}
return query
}

View File

@ -2,6 +2,7 @@ package marketing
import (
"context"
"time"
"github.com/perfect-panel/server/internal/model/user"
"github.com/perfect-panel/server/internal/svc"
@ -37,10 +38,14 @@ func (l *GetPreSendEmailCountLogic) GetPreSendEmailCount(req *types.GetPreSendEm
Where("auth_type = ?", "email")
if req.RegisterStartTime != 0 {
query = query.Where("user.created_at >= ?", req.RegisterStartTime)
registerStartTime := time.UnixMilli(req.RegisterStartTime)
query = query.Where("user.created_at >= ?", registerStartTime)
}
if req.RegisterEndTime != 0 {
query = query.Where("user.created_at <= ?", req.RegisterEndTime)
registerEndTime := time.UnixMilli(req.RegisterEndTime)
query = query.Where("user.created_at <= ?", registerEndTime)
}
return query
}