🐛 Fix did not remove user from program if they didn't pay
This commit is contained in:
parent
e716f5700c
commit
ef20829b2e
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user