feat: add free charge price mode for product buy page (#3015)

* feat: add free charge price mode for product buy page

* fix: improve code format
This commit is contained in:
DacongDA
2024-06-22 14:05:53 +08:00
committed by GitHub
parent 4cc2120fed
commit 793a7d6cda
36 changed files with 332 additions and 34 deletions

View File

@ -687,7 +687,7 @@ func UpdateUser(id string, user *User, columns []string, isAdmin bool) (bool, er
}
}
if isAdmin {
columns = append(columns, "name", "id", "email", "phone", "country_code", "type")
columns = append(columns, "name", "id", "email", "phone", "country_code", "type", "balance")
}
columns = append(columns, "updated_time")
@ -1157,3 +1157,13 @@ func GenerateIdForNewUser(application *Application) (string, error) {
res := strconv.Itoa(lastUserId + 1)
return res, nil
}
func updateUserBalance(owner string, name string, balance float64) error {
user, err := getUser(owner, name)
if err != nil {
return err
}
user.Balance += balance
_, err = UpdateUser(user.GetId(), user, []string{"balance"}, true)
return err
}