This commit is contained in:
aozhiwei 2024-11-20 16:04:00 +08:00
parent 2bd2a7a99a
commit 13cc4bf78b
2 changed files with 20 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"f5" "f5"
"main/vo" "main/vo"
"main/model" "main/model"
"main/mt"
) )
type award struct { type award struct {
@ -16,6 +17,10 @@ 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) {
itemMeta := mt.Table.Item.GetById(int64(itemId))
if itemMeta == nil {
return
}
nowTime := int32(f5.GetApp().GetRealSeconds()) nowTime := int32(f5.GetApp().GetRealSeconds())
bagItem := new(model.Bag) bagItem := new(model.Bag)
if err, found := bagItem.Find(accountId, itemId); err == nil { if err, found := bagItem.Find(accountId, itemId); err == nil {
@ -29,5 +34,6 @@ func (this *award) AddItem(accountId string, itemId int32, itemNum int32, baseVo
bagItem.ModifyTime = nowTime bagItem.ModifyTime = nowTime
bagItem.Create() bagItem.Create()
} }
baseVo.GetOrCreateAward().AddItem(itemId, itemNum)
} }
} }

View File

@ -29,3 +29,17 @@ func (this *Award) AddItem(itemId int32, itemNum int32) {
p := new(AwardItem) p := new(AwardItem)
q5.AppendSlice(&this.Items, p) q5.AppendSlice(&this.Items, p)
} }
func (this *BaseVo) GetOrCreateAward() *Award {
if this.Award == nil {
this.Award = new(Award)
}
return this.Award
}
func (this *BaseVo) GetOrCreateSideEffect() *SideEffect {
if this.SideEffect == nil {
this.SideEffect = new(SideEffect)
}
return this.SideEffect
}