huangjiajun 2 settimane fa
parent
commit
eb239ca19c
1 ha cambiato i file con 22 aggiunte e 18 eliminazioni
  1. +22
    -18
      rule/user_upgrade.go

+ 22
- 18
rule/user_upgrade.go Vedi File

@@ -14,26 +14,30 @@ import (
func UserUpgradeInsert(uid, level int) error {
userDb := implement.NewUserDb(db.Db)
user, _ := userDb.GetUser(int64(uid))
if level == user.Level {
return errors.New("等级相同")
}
task, err := UserUpgradeTask(db.Db, int(user.Id), level)
if err == nil {
//升级
oldLevel := user.Level
user.Level = level
_, err = db.Db.Where("id=?", user.Id).Cols("level").Update(user)
if err != nil {
return err
}
var tmp = model.UserUpgradeLevel{
Uid: int(user.Id),
Level: level,
OldLv: oldLevel,
CreateTime: time.Now(),
Task: utils.SerializeStr(task),
}
db.Db.Insert(&tmp)
return nil
if err != nil {
return err
}
return err
//升级
oldLevel := user.Level
user.Level = level
_, err = db.Db.Where("id=?", user.Id).Cols("level").Update(user)
if err != nil {
return err
}
var tmp = model.UserUpgradeLevel{
Uid: int(user.Id),
Level: level,
OldLv: oldLevel,
CreateTime: time.Now(),
Task: utils.SerializeStr(task),
}
db.Db.Insert(&tmp)
return nil

}

/*


Caricamento…
Annulla
Salva