From 58720a24355af4e07b2b70a470cc5b9c6951f82b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 11 Nov 2024 13:58:36 +0800 Subject: [PATCH] 1 --- server/wheelserver/model/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/wheelserver/model/user.go b/server/wheelserver/model/user.go index 7c037e9e..70572a05 100644 --- a/server/wheelserver/model/user.go +++ b/server/wheelserver/model/user.go @@ -56,7 +56,13 @@ func (this *User) DecDice(num int32) error { if this.Score < int64(num) { return errors.New("") } + oldScore := this.Score this.Score -= int64(num) + if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select( + "dice").Updates(this); result.Error != nil { + this.Score = oldScore + return result.Error + } return nil }