This commit is contained in:
aozhiwei 2024-11-20 17:38:02 +08:00
parent 87f923d42f
commit 35b8c1a72d

View File

@ -53,9 +53,8 @@ func (this *User) Find(accountId string, nowTime int64) (error, bool) {
if int32(q5.GetDaySeconds(nowTime, 0)) > this.LastPresentDiceTime { if int32(q5.GetDaySeconds(nowTime, 0)) > this.LastPresentDiceTime {
this.Dice = mt.Table.Global.GetDailyDiceNum() this.Dice = mt.Table.Global.GetDailyDiceNum()
this.LastPresentDiceTime = q5.ToInt32(nowTime) this.LastPresentDiceTime = q5.ToInt32(nowTime)
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select( if err := this.UpdateFields([]string{"dice", "last_present_dice_time"}); err != nil {
"dice", "last_present_dice_time").Updates(this); result.Error != nil { return err, false
return result.Error, false
} }
} }
} }
@ -76,19 +75,17 @@ func (this *User) DecDice(num int32) error {
} }
oldDice := this.Dice oldDice := this.Dice
this.Dice -= num this.Dice -= num
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select( if err := this.UpdateFields([]string{"dice"}); err != nil {
"dice").Updates(this); result.Error != nil {
this.Dice = oldDice this.Dice = oldDice
return result.Error return err
} }
return nil return nil
} }
func (this *User) AddSpecDice(num int32) error { func (this *User) AddSpecDice(num int32) error {
this.SpecDice += num this.SpecDice += num
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select( if err := this.UpdateFields([]string{"spec_dice"}); err != nil {
"spec_dice").Updates(this); result.Error != nil { return err
return result.Error
} }
return nil return nil
} }
@ -99,10 +96,9 @@ func (this *User) DecScore(num int32) error {
} }
oldScore := this.Score oldScore := this.Score
this.Score -= int64(num) this.Score -= int64(num)
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select( if err := this.UpdateFields([]string{"score"}); err != nil {
"score").Updates(this); result.Error != nil {
this.Score = oldScore this.Score = oldScore
return result.Error return err
} }
return nil return nil
} }
@ -113,18 +109,13 @@ func (this *User) AddScore(score int32) error {
} }
oldScore := this.Score oldScore := this.Score
this.Score += int64(score) this.Score += int64(score)
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select( if err := this.UpdateFields([]string{"score"}); err != nil {
"score").Updates(this); result.Error != nil {
this.Score = oldScore this.Score = oldScore
return result.Error return err
} }
return nil return nil
} }
func (this *User) UpdateName() error { func (this *User) UpdateName() error {
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select( return this.UpdateFields([]string{"nickname"});
"nickname").Updates(this); result.Error != nil {
return result.Error
}
return nil
} }