From ef20829b2e86c4d703f8fef71f0a3389d03cc84f Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 2 Apr 2025 23:15:59 +0800 Subject: [PATCH] :bug: Fix did not remove user from program if they didn't pay --- pkg/internal/services/programs.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/internal/services/programs.go b/pkg/internal/services/programs.go index 8c57584..bb5db65 100644 --- a/pkg/internal/services/programs.go +++ b/pkg/internal/services/programs.go @@ -84,12 +84,14 @@ func PeriodicChargeProgramFee() { var members []models.ProgramMember // Every month paid once if err := database.C.Where("last_paid IS NULL OR last_paid < ?", time.Now().AddDate(0, 0, -30)). - Preload("Program").Find(&members).Error; err != nil { + Preload("Program").Preload("Account").Find(&members).Error; err != nil { return } for _, member := range members { if err := ChargeForProgram(member); err == nil { database.C.Model(&member).Update("last_paid", time.Now()) + } else { + LeaveProgram(member.Account, member.Program) } } }