fix(quota): update time handling in quota logic and correct subscriber ID query

This commit is contained in:
Chang lue Tsen
2025-09-13 14:02:49 -04:00
parent 9b0e1b1e0f
commit cf4792cdc8
3 changed files with 7 additions and 6 deletions
@@ -42,12 +42,12 @@ func (l *CreateQuotaTaskLogic) CreateQuotaTask(req *types.CreateQuotaTaskRequest
query = query.Where("`status` IN ?", []int64{0, 1, 2}) // 0: Pending 1: Active 2: Finished
}
if req.StartTime != 0 {
start := time.UnixMilli(req.StartTime)
start := time.Unix(req.StartTime, 0)
query = query.Where("`start_time` >= ?", start)
}
if req.EndTime != 0 {
end := time.UnixMilli(req.EndTime)
query = query.Where("`start_time` <= ?", end)
query = query.Where("`expire_time` <= ?", end)
}
if err := query.Find(&subs).Error; err != nil {
@@ -67,6 +67,7 @@ func (l *CreateQuotaTaskLogic) CreateQuotaTask(req *types.CreateQuotaTaskRequest
IsActive: req.IsActive,
StartTime: req.StartTime,
EndTime: req.EndTime,
Objects: subIds,
}
scopeBytes, _ := scopeInfo.Marshal()
contentInfo := task.QuotaContent{
@@ -37,12 +37,12 @@ func (l *QueryQuotaTaskPreCountLogic) QueryQuotaTaskPreCount(req *types.QueryQuo
tx = tx.Where("`status` IN ?", []int64{0, 1, 2}) // 0: Pending 1: Active 2: Finished
}
if req.StartTime != 0 {
start := time.UnixMilli(req.StartTime)
start := time.Unix(req.StartTime, 0)
tx = tx.Where("`start_time` >= ?", start)
}
if req.EndTime != 0 {
end := time.UnixMilli(req.EndTime)
tx = tx.Where("`start_time` <= ?", end)
tx = tx.Where("`expire_time` <= ?", end)
}
if err = tx.Count(&count).Error; err != nil {
l.Errorf("[QueryQuotaTaskPreCount] count error: %v", err.Error())