1
This commit is contained in:
parent
00d105d68d
commit
032e403760
@ -27,7 +27,7 @@ func (this *Bag) Create() error {
|
|||||||
return nil
|
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(
|
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Table(this.TableName()).Take(
|
||||||
this, "account_id = ? and item_id = ?", accountId, itemId); result.Error != nil &&
|
this, "account_id = ? and item_id = ?", accountId, itemId); result.Error != nil &&
|
||||||
!errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
!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
|
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
|
||||||
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"f5"
|
||||||
"main/vo"
|
"main/vo"
|
||||||
|
"main/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type award struct {
|
type award struct {
|
||||||
@ -14,4 +16,13 @@ func (this *award) unInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *award) AddItem(accountId string, itemId int32, itemNum int32, baseVo *vo.BaseVo) {
|
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 {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user