From cf4d8099e4740ad77ed7a38a7c1a9bf4dc1ba93b Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 14 Dec 2024 11:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/user_upgrade.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rule/user_upgrade.go b/rule/user_upgrade.go index 6a7d161..4709830 100644 --- a/rule/user_upgrade.go +++ b/rule/user_upgrade.go @@ -11,9 +11,22 @@ import ( "xorm.io/xorm" ) -func UserUpgradeInsert(eg *xorm.Engine, uid, level int) error { +func UserUpgradeInsert(eg *xorm.Engine, uid int) error { userDb := implement.NewUserDb(eg) user, _ := userDb.GetUser(int64(uid)) + level := user.Level + isNext := 0 + levelDb := implement.NewUserLevelDb(db.Db) + levels, _ := levelDb.UserLevelAllByAsc() + for _, v1 := range levels { + if isNext == 1 { + level = v1.Id + isNext = 0 + } + if v1.Id == level { + isNext = 1 + } + } if level == user.Level { return errors.New("等级相同") }