From 032e4037606293727fa240a84426e7b1619964b7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 20 Nov 2024 15:35:23 +0800 Subject: [PATCH] 1 --- server/wheelserver/model/bag.go | 12 +++++++++++- server/wheelserver/service/award.go | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/server/wheelserver/model/bag.go b/server/wheelserver/model/bag.go index 3410773d..fe3c7ff3 100644 --- a/server/wheelserver/model/bag.go +++ b/server/wheelserver/model/bag.go @@ -27,7 +27,7 @@ func (this *Bag) Create() error { return nil } -func (this *Bag) Find(accountId string, nowTime int64, itemId int32) (error, bool) { +func (this *Bag) Find(accountId string, itemId int32) (error, bool) { if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Table(this.TableName()).Take( this, "account_id = ? and item_id = ?", accountId, itemId); result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) { @@ -36,3 +36,13 @@ func (this *Bag) Find(accountId string, nowTime int64, itemId int32) (error, boo return nil, result.RowsAffected > 0 } } + +func (this *Bag) AddItemNum(itemNum int32, nowTime int32) error { + this.ItemNum += itemNum + this.ModifyTime = nowTime + if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select( + "item_num", "modifytime").Updates(this); result.Error != nil { + return result.Error + } + return nil +} diff --git a/server/wheelserver/service/award.go b/server/wheelserver/service/award.go index 0cbc437c..3e81b9ab 100644 --- a/server/wheelserver/service/award.go +++ b/server/wheelserver/service/award.go @@ -1,7 +1,9 @@ package service import ( + "f5" "main/vo" + "main/model" ) type award struct { @@ -14,4 +16,13 @@ func (this *award) unInit() { } func (this *award) AddItem(accountId string, itemId int32, itemNum int32, baseVo *vo.BaseVo) { + nowTime := int32(f5.GetApp().GetRealSeconds()) + bagItem := new(model.Bag) + if err, found := bagItem.Find(accountId, itemId); err == nil { + if found { + bagItem.AddItemNum(itemNum, nowTime) + } else { + + } + } }