fix(quota): correct time range queries for start and expire times in quota logic

This commit is contained in:
Chang lue Tsen 2025-09-14 09:43:21 -04:00
parent 2c5efa2026
commit b0ffb15825
2 changed files with 4 additions and 4 deletions

View File

@ -43,11 +43,11 @@ func (l *CreateQuotaTaskLogic) CreateQuotaTask(req *types.CreateQuotaTaskRequest
} }
if req.StartTime != 0 { if req.StartTime != 0 {
start := time.UnixMilli(req.StartTime) start := time.UnixMilli(req.StartTime)
query = query.Where("`start_time` >= ?", start) query = query.Where("`start_time` <= ?", start)
} }
if req.EndTime != 0 { if req.EndTime != 0 {
end := time.UnixMilli(req.EndTime) end := time.UnixMilli(req.EndTime)
query = query.Where("`expire_time` <= ?", end) query = query.Where("`expire_time` >= ?", end)
} }
if err := query.Find(&subs).Error; err != nil { if err := query.Find(&subs).Error; err != nil {

View File

@ -38,11 +38,11 @@ func (l *QueryQuotaTaskPreCountLogic) QueryQuotaTaskPreCount(req *types.QueryQuo
} }
if req.StartTime != 0 { if req.StartTime != 0 {
start := time.UnixMilli(req.StartTime) start := time.UnixMilli(req.StartTime)
tx = tx.Where("`start_time` >= ?", start) tx = tx.Where("`start_time` <= ?", start)
} }
if req.EndTime != 0 { if req.EndTime != 0 {
end := time.UnixMilli(req.EndTime) end := time.UnixMilli(req.EndTime)
tx = tx.Where("`expire_time` <= ?", end) tx = tx.Where("`expire_time` >= ?", end)
} }
if err = tx.Count(&count).Error; err != nil { if err = tx.Count(&count).Error; err != nil {
l.Errorf("[QueryQuotaTaskPreCount] count error: %v", err.Error()) l.Errorf("[QueryQuotaTaskPreCount] count error: %v", err.Error())