diff --git a/server/wheelserver/api/v1/bag/bag.go b/server/wheelserver/api/v1/bag/bag.go index 27af9718..dabf0e64 100644 --- a/server/wheelserver/api/v1/bag/bag.go +++ b/server/wheelserver/api/v1/bag/bag.go @@ -41,6 +41,14 @@ func (this *BagApi) UseItem(c *gin.Context) { if s == nil { return } + reqJson := struct { + ItemUniId string `json:"item_uniid"` + ItemNum string `json:"item_num"` + }{} + if err := c.ShouldBindJSON(&reqJson); err != nil { + f5.RspErr(c, 401, "params parse error") + return + } user := new(model.User) rspObj := struct { vo.BaseVo diff --git a/server/wheelserver/model/bag.go b/server/wheelserver/model/bag.go index 5b9cb96f..11907036 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, itemId int32) (error, bool) { +func (this *Bag) FindByItemId(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) { @@ -37,6 +37,16 @@ func (this *Bag) Find(accountId string, itemId int32) (error, bool) { } } +func (this *Bag) FindByItemUniId(accountId string, itemUniId int64) (error, bool) { + if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Table(this.TableName()).Take( + this, "account_id = ? and idx = ?", accountId, itemUniId); result.Error != nil && + !errors.Is(result.Error, gorm.ErrRecordNotFound) { + return result.Error, false + } else { + return nil, result.RowsAffected > 0 + } +} + func (this *Bag) AddItemNum(itemNum int32, nowTime int32) error { this.ItemNum += itemNum this.ModifyTime = nowTime diff --git a/server/wheelserver/service/award.go b/server/wheelserver/service/award.go index 9b69f7af..a3c55000 100644 --- a/server/wheelserver/service/award.go +++ b/server/wheelserver/service/award.go @@ -33,7 +33,7 @@ func (this *award) AddItem(accountId string, itemId int32, itemNum int32, baseVo return } bagItem := new(model.Bag) - if err, found := bagItem.Find(accountId, itemId); err == nil { + if err, found := bagItem.FindByItemId(accountId, itemId); err == nil { if found { bagItem.AddItemNum(itemNum, int32(nowTime)) } else {