Browse Source

升级

master
huangjiajun 2 weeks ago
parent
commit
99d48e1816
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      rule/user_upgrade.go

+ 5
- 5
rule/user_upgrade.go View File

@@ -11,20 +11,20 @@ import (
"xorm.io/xorm" "xorm.io/xorm"
) )


func UserUpgradeInsert(uid, level int) error {
userDb := implement.NewUserDb(db.Db)
func UserUpgradeInsert(eg *xorm.Engine, uid, level int) error {
userDb := implement.NewUserDb(eg)
user, _ := userDb.GetUser(int64(uid)) user, _ := userDb.GetUser(int64(uid))
if level == user.Level { if level == user.Level {
return errors.New("等级相同") return errors.New("等级相同")
} }
task, err := UserUpgradeTask(db.Db, int(user.Id), level)
task, err := UserUpgradeTask(eg, int(user.Id), level)
if err != nil { if err != nil {
return err return err
} }
//升级 //升级
oldLevel := user.Level oldLevel := user.Level
user.Level = level user.Level = level
_, err = db.Db.Where("id=?", user.Id).Cols("level").Update(user)
_, err = eg.Where("id=?", user.Id).Cols("level").Update(user)
if err != nil { if err != nil {
return err return err
} }
@@ -35,7 +35,7 @@ func UserUpgradeInsert(uid, level int) error {
CreateTime: time.Now(), CreateTime: time.Now(),
Task: utils.SerializeStr(task), Task: utils.SerializeStr(task),
} }
db.Db.Insert(&tmp)
eg.Insert(&tmp)
return nil return nil


} }


Loading…
Cancel
Save