From d5460d0cd1c0f573c190b899ff72bf5cdd15c697 Mon Sep 17 00:00:00 2001 From: Chang lue Tsen Date: Sat, 23 Aug 2025 09:07:56 -0400 Subject: [PATCH] fix(subscribe): ensure active status and reset timestamps during traffic resets --- queue/logic/traffic/resetTrafficLogic.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/queue/logic/traffic/resetTrafficLogic.go b/queue/logic/traffic/resetTrafficLogic.go index 10bc9fa..db33be7 100644 --- a/queue/logic/traffic/resetTrafficLogic.go +++ b/queue/logic/traffic/resetTrafficLogic.go @@ -238,8 +238,10 @@ func (l *ResetTrafficLogic) resetMonth(ctx context.Context) error { err = db.Model(&user.Subscribe{}).Where("`id` IN ?", monthlyResetUsers). Updates(map[string]interface{}{ - "upload": 0, - "download": 0, + "upload": 0, + "download": 0, + "status": 1, // Ensure status is active + "finished_at": nil, }).Error if err != nil { logger.Errorw("[ResetTraffic] Failed to update monthly reset users", logger.Field("error", err.Error())) @@ -321,8 +323,10 @@ func (l *ResetTrafficLogic) reset1st(ctx context.Context, cache resetTrafficCach // Reset upload and download traffic to zero err = db.Model(&user.Subscribe{}).Where("`id` IN ?", users1stReset). Updates(map[string]interface{}{ - "upload": 0, - "download": 0, + "upload": 0, + "download": 0, + "status": 1, // Ensure status is active + "finished_at": nil, }).Error if err != nil { logger.Errorw("[ResetTraffic] Failed to update 1st reset users", logger.Field("error", err.Error())) @@ -405,8 +409,10 @@ func (l *ResetTrafficLogic) resetYear(ctx context.Context) error { // Reset upload and download traffic to zero err = db.Model(&user.Subscribe{}).Where("`id` IN ?", usersYearReset). Updates(map[string]interface{}{ - "upload": 0, - "download": 0, + "upload": 0, + "download": 0, + "status": 1, // Ensure status is active + "finished_at": nil, }).Error if err != nil { logger.Errorw("[ResetTraffic] Failed to update yearly reset users", logger.Field("error", err.Error()))