53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package service
|
|
|
|
import (
|
|
"f5"
|
|
"main/constant"
|
|
"main/model"
|
|
"main/mt"
|
|
"main/vo"
|
|
)
|
|
|
|
type award struct {
|
|
}
|
|
|
|
func (this *award) init() {
|
|
}
|
|
|
|
func (this *award) unInit() {
|
|
}
|
|
|
|
func (this *award) AddItem(accountId string, itemId int32, itemNum int32, baseVo *vo.BaseVo) {
|
|
nowTime := f5.GetApp().GetRealSeconds()
|
|
itemMeta := mt.Table.Item.GetById(int64(itemId))
|
|
if itemMeta == nil {
|
|
return
|
|
}
|
|
if itemMeta.GetItemType() == constant.ITEM_TYPE_SPEC_DICE {
|
|
user := new(model.User)
|
|
if err, found := user.Find(accountId, nowTime); err == nil && found {
|
|
user.AddSpecDice(itemNum)
|
|
baseVo.GetOrCreateSideEffect().User = new(vo.User)
|
|
baseVo.GetOrCreateSideEffect().User.FromModel(user)
|
|
baseVo.GetOrCreateSideEffect().User.HourlyEarnings = Chip.GetHourEarning(user.AccountId)
|
|
}
|
|
return
|
|
}
|
|
bagItem := new(model.Bag)
|
|
if err, found := bagItem.FindByItemId(accountId, itemId); err == nil {
|
|
if found {
|
|
bagItem.AddItemNum(itemNum, int32(nowTime))
|
|
} else {
|
|
bagItem.AccountId = accountId
|
|
bagItem.ItemId = itemId
|
|
bagItem.ItemNum = itemNum
|
|
bagItem.CreateTime = int32(nowTime)
|
|
bagItem.ModifyTime = int32(nowTime)
|
|
bagItem.Create()
|
|
}
|
|
if baseVo != nil {
|
|
baseVo.GetOrCreateAward().AddItem(itemId, itemNum)
|
|
}
|
|
}
|
|
}
|