chore: refacto

This commit is contained in:
2026-04-20 19:41:52 +02:00
parent 5fc52c72ee
commit 2e9827af98
46 changed files with 497 additions and 648 deletions
+4 -1
View File
@@ -2,6 +2,7 @@ package db
import (
"fmt"
"gestion/models"
"gorm.io/gorm"
)
@@ -19,7 +20,9 @@ func (d *Database) CreditClientReferral(username string, amount float64) error {
if amount <= 0 {
return fmt.Errorf("le montant doit être positif")
}
result := d.GDB.Exec(`UPDATE clients SET referral_balance = referral_balance + ? WHERE username = ?`, amount, username)
result := d.GDB.Model(&models.Client{}).Where("username = ?", username).Updates(map[string]any{
"referral_balance": gorm.Expr("referral_balance + ?", amount),
})
if result.Error != nil {
return result.Error
}