|
|
@@ -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 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|