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 }