获奖记录修改

This commit is contained in:
by 2024-07-31 11:15:08 +08:00
parent 4d2a136eca
commit 36cce9df01
4 changed files with 53 additions and 26 deletions

View File

@ -23,6 +23,7 @@ type FetchAwardLogArgs struct {
} }
type AwardLogRes struct { type AwardLogRes struct {
Data *AwardLog Data *AwardLog
Ts int64
} }
func FetchAwardLog(plt string) (recs AwardLog, err error) { func FetchAwardLog(plt string) (recs AwardLog, err error) {

View File

@ -5,7 +5,6 @@ import (
"mongo.games.com/game/protocol/shop" "mongo.games.com/game/protocol/shop"
"mongo.games.com/game/protocol/webapi" "mongo.games.com/game/protocol/webapi"
"strconv" "strconv"
"time"
) )
/* /*
@ -134,8 +133,6 @@ type AllConfig struct {
*webapi.RankTypeConfig *webapi.RankTypeConfig
//获奖记录配置 //获奖记录配置
*webapi.AwardLogConfig *webapi.AwardLogConfig
// 获得道具总数
AwardItem AwardLog
} }
type GlobalConfig struct { type GlobalConfig struct {
@ -357,12 +354,3 @@ func (cm *ConfigMgr) GetSkinSkillMaxLevel(plt string, skinId int32) int32 {
} }
return level 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()
}

View File

@ -2896,6 +2896,30 @@ func CSAwardLog(s *netlib.Session, packetId int, data interface{}, sid int64) er
if p == nil { if p == nil {
return 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) msg, ok := data.(*player_proto.CS_AwardLog)
if !ok { if !ok {
return nil return nil

View File

@ -14,6 +14,7 @@ import (
type AwardLogManager struct { type AwardLogManager struct {
BaseClockSinker 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实物 AnnouncerLog map[string]map[int32][]model.AnnouncerLog //key:1话费 2实物
} }
@ -28,10 +29,9 @@ func (this *AwardLogManager) ModuleName() string {
// GetAwardLog 获取总数量 // GetAwardLog 获取总数量
// typeId 1 话费 2实物 // typeId 1 话费 2实物
func (this *AwardLogManager) GetAwardLog(plt string, typeId int32) map[int32]int64 { func (this *AwardLogManager) GetAwardLog(plt string, typeId int32) map[int32]int64 {
d := PlatformMgrSingleton.GetConfig(plt).AwardItem
ret := make(map[int32]int64) ret := make(map[int32]int64)
if d.AwardMap != nil && d.AwardMap[typeId] != nil { if this.AwardMap[plt] != nil && this.AwardMap[plt][typeId] != nil {
ret = d.AwardMap[typeId] ret = this.AwardMap[plt][typeId]
} }
return ret 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 || if srvdata.GameItemMgr.Get(plt, itemId).Type == common.ItemTypeObjective ||
srvdata.GameItemMgr.Get(plt, itemId).Type == common.ItemTypeChange { srvdata.GameItemMgr.Get(plt, itemId).Type == common.ItemTypeChange {
typeId := int32(1) 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 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() { func (this *AwardLogManager) Init() {
this.AwardMap = make(map[string]map[int32]map[int32]int64)
for _, v := range PlatformMgrSingleton.platforms { for _, v := range PlatformMgrSingleton.platforms {
if v != nil { if v != nil {
// 获取道具获得总数 // 获取道具获得总数
@ -95,21 +105,21 @@ func (this *AwardLogManager) Init() {
if err != nil { if err != nil {
logger.Logger.Errorf("fetch award log error: %v", err) logger.Logger.Errorf("fetch award log error: %v", err)
} else { } else {
PlatformMgrSingleton.GetConfig(v.IdStr).AwardItem = res this.AwardMap[v.IdStr] = res.AwardMap
} }
// 获取实时播报数据 // 获取实时播报数据
arr, err := model.FetchAnnouncerLog(v.IdStr) arr, err := model.FetchAnnouncerLog(v.IdStr)
if err != nil { if err != nil {
logger.Logger.Errorf("fetch announcer log error: %v", err) logger.Logger.Errorf("fetch announcer log error: %v", err)
} else { } else {
for _, v := range arr { for _, data := range arr {
if this.AnnouncerLog[v.Platform] == nil { if this.AnnouncerLog[data.Platform] == nil {
this.AnnouncerLog[v.Platform] = make(map[int32][]model.AnnouncerLog) this.AnnouncerLog[data.Platform] = make(map[int32][]model.AnnouncerLog)
} }
if this.AnnouncerLog[v.Platform][v.TypeId] == nil { if this.AnnouncerLog[data.Platform][data.TypeId] == nil {
this.AnnouncerLog[v.Platform][v.TypeId] = make([]model.AnnouncerLog, 0) 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() { func (this *AwardLogManager) Save() {
for _, v := range PlatformMgrSingleton.platforms { for plt, v := range this.AwardMap {
if v != nil { 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)
} }
} }
} }