获奖记录修改
This commit is contained in:
parent
4d2a136eca
commit
36cce9df01
|
@ -23,6 +23,7 @@ type FetchAwardLogArgs struct {
|
|||
}
|
||||
type AwardLogRes struct {
|
||||
Data *AwardLog
|
||||
Ts int64
|
||||
}
|
||||
|
||||
func FetchAwardLog(plt string) (recs AwardLog, err error) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"mongo.games.com/game/protocol/shop"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -134,8 +133,6 @@ type AllConfig struct {
|
|||
*webapi.RankTypeConfig
|
||||
//获奖记录配置
|
||||
*webapi.AwardLogConfig
|
||||
// 获得道具总数
|
||||
AwardItem AwardLog
|
||||
}
|
||||
|
||||
type GlobalConfig struct {
|
||||
|
@ -357,12 +354,3 @@ func (cm *ConfigMgr) GetSkinSkillMaxLevel(plt string, skinId int32) int32 {
|
|||
}
|
||||
return level
|
||||
}
|
||||
|
||||
func (cm *ConfigMgr) AddAwardItem(plt string, id int32, num int64) {
|
||||
cfg := cm.GetConfig(plt).AwardItem
|
||||
if cfg.AwardMap == nil {
|
||||
cfg.AwardMap = make(map[int32]int64)
|
||||
}
|
||||
cfg.AwardMap[id] += num
|
||||
cfg.Ts = time.Now().Unix()
|
||||
}
|
||||
|
|
|
@ -2896,6 +2896,30 @@ func CSAwardLog(s *netlib.Session, packetId int, data interface{}, sid int64) er
|
|||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
var items []*Item
|
||||
item := &Item{
|
||||
ItemId: 30011,
|
||||
ItemNum: 1,
|
||||
}
|
||||
var cost []*model.ItemInfo
|
||||
items = append(items, item)
|
||||
item = &Item{
|
||||
ItemId: 77006,
|
||||
ItemNum: 1,
|
||||
}
|
||||
items = append(items, item)
|
||||
BagMgrSingleton.AddItemsV2(&ItemParam{
|
||||
P: p,
|
||||
Change: items,
|
||||
Cost: cost,
|
||||
Add: 0,
|
||||
GainWay: common.GainWaySign7Add,
|
||||
Operator: "system",
|
||||
Remark: "累计签到进阶奖励获得",
|
||||
gameId: 0,
|
||||
gameFreeId: 0,
|
||||
noLog: false,
|
||||
})
|
||||
msg, ok := data.(*player_proto.CS_AwardLog)
|
||||
if !ok {
|
||||
return nil
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
type AwardLogManager struct {
|
||||
BaseClockSinker
|
||||
AwardMap map[string]map[int32]map[int32]int64 //key1:plt key2:1话费 2实物 key3 itemId value:数量
|
||||
AnnouncerLog map[string]map[int32][]model.AnnouncerLog //key:1话费 2实物
|
||||
}
|
||||
|
||||
|
@ -28,10 +29,9 @@ func (this *AwardLogManager) ModuleName() string {
|
|||
// GetAwardLog 获取总数量
|
||||
// typeId 1 话费 2实物
|
||||
func (this *AwardLogManager) GetAwardLog(plt string, typeId int32) map[int32]int64 {
|
||||
d := PlatformMgrSingleton.GetConfig(plt).AwardItem
|
||||
ret := make(map[int32]int64)
|
||||
if d.AwardMap != nil && d.AwardMap[typeId] != nil {
|
||||
ret = d.AwardMap[typeId]
|
||||
if this.AwardMap[plt] != nil && this.AwardMap[plt][typeId] != nil {
|
||||
ret = this.AwardMap[plt][typeId]
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
@ -54,10 +54,19 @@ func (this *AwardLogManager) UpdateAwardLog(plt string, itemId int32, num int64)
|
|||
if srvdata.GameItemMgr.Get(plt, itemId).Type == common.ItemTypeObjective ||
|
||||
srvdata.GameItemMgr.Get(plt, itemId).Type == common.ItemTypeChange {
|
||||
typeId := int32(1)
|
||||
if srvdata.GameItemMgr.Get(plt, itemId).Type == common.ItemTypeChange {
|
||||
aaa := srvdata.GameItemMgr.Get(plt, itemId).Type
|
||||
logger.Logger.Trace("--------------------", aaa)
|
||||
if srvdata.GameItemMgr.Get(plt, itemId).Type == common.ItemTypeObjective {
|
||||
typeId = 2
|
||||
}
|
||||
PlatformMgrSingleton.AddAwardItem(plt, itemId, num, typeId)
|
||||
if this.AwardMap[plt] == nil {
|
||||
this.AwardMap[plt] = make(map[int32]map[int32]int64)
|
||||
}
|
||||
if this.AwardMap[plt][typeId] == nil {
|
||||
this.AwardMap[plt][typeId] = make(map[int32]int64)
|
||||
}
|
||||
this.AwardMap[plt][typeId][itemId] += num
|
||||
this.Save()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,6 +97,7 @@ func (this *AwardLogManager) UpdateAnnouncerLog(data model.AnnouncerLog) {
|
|||
}
|
||||
|
||||
func (this *AwardLogManager) Init() {
|
||||
this.AwardMap = make(map[string]map[int32]map[int32]int64)
|
||||
for _, v := range PlatformMgrSingleton.platforms {
|
||||
if v != nil {
|
||||
// 获取道具获得总数
|
||||
|
@ -95,21 +105,21 @@ func (this *AwardLogManager) Init() {
|
|||
if err != nil {
|
||||
logger.Logger.Errorf("fetch award log error: %v", err)
|
||||
} else {
|
||||
PlatformMgrSingleton.GetConfig(v.IdStr).AwardItem = res
|
||||
this.AwardMap[v.IdStr] = res.AwardMap
|
||||
}
|
||||
// 获取实时播报数据
|
||||
arr, err := model.FetchAnnouncerLog(v.IdStr)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("fetch announcer log error: %v", err)
|
||||
} else {
|
||||
for _, v := range arr {
|
||||
if this.AnnouncerLog[v.Platform] == nil {
|
||||
this.AnnouncerLog[v.Platform] = make(map[int32][]model.AnnouncerLog)
|
||||
for _, data := range arr {
|
||||
if this.AnnouncerLog[data.Platform] == nil {
|
||||
this.AnnouncerLog[data.Platform] = make(map[int32][]model.AnnouncerLog)
|
||||
}
|
||||
if this.AnnouncerLog[v.Platform][v.TypeId] == nil {
|
||||
this.AnnouncerLog[v.Platform][v.TypeId] = make([]model.AnnouncerLog, 0)
|
||||
if this.AnnouncerLog[data.Platform][data.TypeId] == nil {
|
||||
this.AnnouncerLog[data.Platform][data.TypeId] = make([]model.AnnouncerLog, 0)
|
||||
}
|
||||
this.AnnouncerLog[v.Platform][v.TypeId] = append(this.AnnouncerLog[v.Platform][v.TypeId], v)
|
||||
this.AnnouncerLog[data.Platform][data.TypeId] = append(this.AnnouncerLog[data.Platform][data.TypeId], data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,9 +142,13 @@ func (this *AwardLogManager) OnHourTimer() {
|
|||
}
|
||||
|
||||
func (this *AwardLogManager) Save() {
|
||||
for _, v := range PlatformMgrSingleton.platforms {
|
||||
for plt, v := range this.AwardMap {
|
||||
if v != nil {
|
||||
model.UpsertAwardLog(v.IdStr, &PlatformMgrSingleton.GetConfig(v.IdStr).AwardItem)
|
||||
data := &model.AwardLog{
|
||||
Ts: time.Now().Unix(),
|
||||
AwardMap: v,
|
||||
}
|
||||
model.UpsertAwardLog(plt, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue