赛季通行证排行榜奖励发放
This commit is contained in:
parent
aaf15d2b3d
commit
83cfbe6381
|
|
@ -698,13 +698,12 @@ func CSPermitAward(s *netlib.Session, packetid int, data interface{}, sid int64)
|
|||
}
|
||||
startTs := PlatformMgrSingleton.GetConfig(p.Platform).PermitStartTs
|
||||
endTs := PlatformMgrSingleton.GetConfig(p.Platform).PermitEndTs
|
||||
if startTs == 0 || endTs == 0 {
|
||||
now := time.Now()
|
||||
if startTs == 0 || endTs == 0 || now.Unix() < startTs || now.Unix() >= endTs {
|
||||
logger.Logger.Errorf("CSPermitAward not startTs %v", p.SnId)
|
||||
return nil
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
pack := &welfare.SCPermitAward{
|
||||
OpRetCode: welfare.OpResultCode_OPRC_Sucess,
|
||||
Tp: msg.GetTp(),
|
||||
|
|
@ -978,13 +977,12 @@ func CSPermitExchange(s *netlib.Session, packetid int, data interface{}, sid int
|
|||
}
|
||||
startTs := PlatformMgrSingleton.GetConfig(p.Platform).PermitStartTs
|
||||
endTs := PlatformMgrSingleton.GetConfig(p.Platform).PermitEndTs
|
||||
if startTs == 0 || endTs == 0 {
|
||||
now := time.Now()
|
||||
if startTs == 0 || endTs == 0 || now.Unix() < startTs || now.Unix() >= endTs {
|
||||
logger.Logger.Errorf("CSPermitExchange not startTs %v", p.SnId)
|
||||
return nil
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
isExchange, code := GetPermitCanExchange(p, msg.GetId())
|
||||
pack := &welfare.SCPermitExchange{
|
||||
OpRetCode: welfare.OpResultCode_OPRC_Sucess,
|
||||
|
|
|
|||
211
worldsrv/etcd.go
211
worldsrv/etcd.go
|
|
@ -207,6 +207,112 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e
|
|||
case *webapi.ActInviteConfig:
|
||||
PlatformMgrSingleton.GetConfig(config.Platform).ActInviteConfig = config
|
||||
case *webapi.ActPermitConfig:
|
||||
// test
|
||||
actConfig := &webapi.ActPermitConfig{
|
||||
Platform: "1",
|
||||
StartTs: 1719646575,
|
||||
Days: 7,
|
||||
}
|
||||
channelConfig := webapi.PermitChannelConfig{
|
||||
Channel: "Official",
|
||||
}
|
||||
for i := 0; i < 100; i++ {
|
||||
channelConfig.LevelConfig = append(channelConfig.LevelConfig, &webapi.PermitLevelConfig{
|
||||
Rank: int32(i + 1),
|
||||
Score: int64((i + 1) * 100),
|
||||
Award1: []*webapi.ItemInfo{
|
||||
{
|
||||
ItemId: common.ItemIDCoin,
|
||||
ItemNum: 100,
|
||||
},
|
||||
},
|
||||
Award2: []*webapi.ItemInfo{
|
||||
{
|
||||
ItemId: common.ItemIDLong,
|
||||
ItemNum: 100,
|
||||
},
|
||||
{
|
||||
ItemId: common.ItemIDDiamond,
|
||||
ItemNum: 100,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
itemId := []int32{100001, 100002, 10001, 20001, 20002, 20003}
|
||||
for i := 0; i < 10; i++ {
|
||||
level := 0
|
||||
if common.RandInt(0, 3) == 0 {
|
||||
level = common.RandInt(1, 101)
|
||||
}
|
||||
channelConfig.ExchangeConfig = append(channelConfig.ExchangeConfig, &webapi.PermitExchangeConfig{
|
||||
Id: int32(i + 1),
|
||||
SortId: int32(100 - i),
|
||||
Gain: []*webapi.ItemInfo{
|
||||
{
|
||||
ItemId: itemId[common.RandInt(len(itemId))],
|
||||
ItemNum: 1,
|
||||
},
|
||||
},
|
||||
Cost: []*webapi.ItemInfo{{
|
||||
ItemId: common.ItemIDLong,
|
||||
ItemNum: int64(common.RandInt(50, 101)),
|
||||
}},
|
||||
IsPermit: common.RandInt(0, 3) == 0,
|
||||
Level: int64(level),
|
||||
Times: int64(common.RandInt(0, 5)),
|
||||
IsShow: common.RandInt(0, 4) != 0,
|
||||
})
|
||||
}
|
||||
rankN := 1
|
||||
for i := 0; i < 3; i++ {
|
||||
sub := common.RandInt(0, 3)
|
||||
items := []*webapi.ItemInfo{
|
||||
{
|
||||
ItemId: common.ItemIDCoin,
|
||||
ItemNum: 100,
|
||||
},
|
||||
}
|
||||
if common.RandInt(2) == 0 {
|
||||
items = append(items, &webapi.ItemInfo{
|
||||
ItemId: common.ItemIDDiamond,
|
||||
ItemNum: 100,
|
||||
})
|
||||
}
|
||||
channelConfig.RankConfig = append(channelConfig.RankConfig, &webapi.PermitRankConfig{
|
||||
Start: int32(rankN),
|
||||
End: int32(rankN + sub),
|
||||
ItemId: items,
|
||||
})
|
||||
rankN = rankN + sub + 1
|
||||
}
|
||||
|
||||
actConfig.Configs = append(actConfig.Configs, &channelConfig)
|
||||
webConfig := channelConfig
|
||||
webConfig.Channel = "Web"
|
||||
actConfig.Configs = append(actConfig.Configs, &webConfig)
|
||||
googleConfig := channelConfig
|
||||
googleConfig.Channel = "GooglePlay"
|
||||
actConfig.Configs = append(actConfig.Configs, &googleConfig)
|
||||
PlatformMgrSingleton.GetConfig("1").ActPermitConfig = actConfig
|
||||
PlatformMgrSingleton.GetConfig("1").PermitStartTs = common.GetDayStartTs(1719646575)
|
||||
PlatformMgrSingleton.GetConfig("1").PermitEndTs = common.GetDayStartTs(1719646575) + int64(actConfig.GetDays()*24*3600)
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
b, err := json.Marshal(&model.PermitStartTs{
|
||||
StartTs: common.GetDayStartTs(1719646575),
|
||||
EndTs: common.GetDayStartTs(1719646575) + int64(actConfig.GetDays()*24*3600),
|
||||
})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("permit startts save error: %v", err)
|
||||
} else {
|
||||
err := model.UptStrKVGameData(common.PermitStartTsKey+"1", string(b))
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("permit startts update error:%v", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}), nil).StartByExecutor("permit_start_ts")
|
||||
logger.Logger.Tracef("==> PermitConfig: %v ", actConfig)
|
||||
// test
|
||||
break
|
||||
PlatformMgrSingleton.GetConfig(config.Platform).ActPermitConfig = config
|
||||
st := new(model.PermitStartTs)
|
||||
|
|
@ -251,112 +357,7 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e
|
|||
default:
|
||||
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
||||
}
|
||||
// test
|
||||
actConfig := &webapi.ActPermitConfig{
|
||||
Platform: "1",
|
||||
StartTs: 1719646575,
|
||||
Days: 7,
|
||||
}
|
||||
channelConfig := webapi.PermitChannelConfig{
|
||||
Channel: "Official",
|
||||
}
|
||||
for i := 0; i < 100; i++ {
|
||||
channelConfig.LevelConfig = append(channelConfig.LevelConfig, &webapi.PermitLevelConfig{
|
||||
Rank: int32(i + 1),
|
||||
Score: int64((i + 1) * 100),
|
||||
Award1: []*webapi.ItemInfo{
|
||||
{
|
||||
ItemId: common.ItemIDCoin,
|
||||
ItemNum: 100,
|
||||
},
|
||||
},
|
||||
Award2: []*webapi.ItemInfo{
|
||||
{
|
||||
ItemId: common.ItemIDLong,
|
||||
ItemNum: 100,
|
||||
},
|
||||
{
|
||||
ItemId: common.ItemIDDiamond,
|
||||
ItemNum: 100,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
itemId := []int32{100001, 100002, 10001, 20001, 20002, 20003}
|
||||
for i := 0; i < 10; i++ {
|
||||
level := 0
|
||||
if common.RandInt(0, 3) == 0 {
|
||||
level = common.RandInt(1, 101)
|
||||
}
|
||||
channelConfig.ExchangeConfig = append(channelConfig.ExchangeConfig, &webapi.PermitExchangeConfig{
|
||||
Id: int32(i + 1),
|
||||
SortId: int32(100 - i),
|
||||
Gain: []*webapi.ItemInfo{
|
||||
{
|
||||
ItemId: itemId[common.RandInt(len(itemId))],
|
||||
ItemNum: 1,
|
||||
},
|
||||
},
|
||||
Cost: []*webapi.ItemInfo{{
|
||||
ItemId: common.ItemIDLong,
|
||||
ItemNum: int64(common.RandInt(50, 101)),
|
||||
}},
|
||||
IsPermit: common.RandInt(0, 3) == 0,
|
||||
Level: int64(level),
|
||||
Times: int64(common.RandInt(0, 5)),
|
||||
IsShow: common.RandInt(0, 4) != 0,
|
||||
})
|
||||
}
|
||||
rankN := 1
|
||||
for i := 0; i < 3; i++ {
|
||||
sub := common.RandInt(0, 3)
|
||||
items := []*webapi.ItemInfo{
|
||||
{
|
||||
ItemId: common.ItemIDCoin,
|
||||
ItemNum: 100,
|
||||
},
|
||||
}
|
||||
if common.RandInt(2) == 0 {
|
||||
items = append(items, &webapi.ItemInfo{
|
||||
ItemId: common.ItemIDDiamond,
|
||||
ItemNum: 100,
|
||||
})
|
||||
}
|
||||
channelConfig.RankConfig = append(channelConfig.RankConfig, &webapi.PermitRankConfig{
|
||||
Start: int32(rankN),
|
||||
End: int32(rankN + sub),
|
||||
ItemId: items,
|
||||
})
|
||||
rankN = rankN + sub + 1
|
||||
}
|
||||
|
||||
actConfig.Configs = append(actConfig.Configs, &channelConfig)
|
||||
webConfig := channelConfig
|
||||
webConfig.Channel = "Web"
|
||||
actConfig.Configs = append(actConfig.Configs, &webConfig)
|
||||
googleConfig := channelConfig
|
||||
googleConfig.Channel = "GooglePlay"
|
||||
actConfig.Configs = append(actConfig.Configs, &googleConfig)
|
||||
PlatformMgrSingleton.GetConfig("1").ActPermitConfig = actConfig
|
||||
PlatformMgrSingleton.GetConfig("1").PermitStartTs = common.GetDayStartTs(1719646575)
|
||||
PlatformMgrSingleton.GetConfig("1").PermitEndTs = common.GetDayStartTs(1719646575) + int64(actConfig.GetDays()*24*3600)
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
b, err := json.Marshal(&model.PermitStartTs{
|
||||
StartTs: common.GetDayStartTs(1719646575),
|
||||
EndTs: common.GetDayStartTs(1719646575) + int64(actConfig.GetDays()*24*3600),
|
||||
})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("permit startts save error: %v", err)
|
||||
} else {
|
||||
err := model.UptStrKVGameData(common.PermitStartTsKey+"1", string(b))
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("permit startts update error:%v", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}), nil).StartByExecutor("permit_start_ts")
|
||||
logger.Logger.Tracef("==> PermitConfig: %v ", actConfig)
|
||||
// test
|
||||
}
|
||||
|
||||
func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||
|
|
|
|||
|
|
@ -27,11 +27,12 @@ func (r *PermitMgr) OnDayTimer() {
|
|||
logger.Logger.Info("(this *PermitMgr) OnDayTimer")
|
||||
now := time.Now()
|
||||
for _, v := range PlatformMgrSingleton.GetPlatforms() {
|
||||
pl := PlatformMgrSingleton.GetConfig(v.IdStr).ActPermitConfig
|
||||
platform := v.IdStr
|
||||
pl := PlatformMgrSingleton.GetConfig(platform).ActPermitConfig
|
||||
if pl == nil {
|
||||
continue
|
||||
}
|
||||
b := model.GetStrKVGameData(common.PermitStartTsKey + v.IdStr)
|
||||
b := model.GetStrKVGameData(common.PermitStartTsKey + platform)
|
||||
if b == "" {
|
||||
logger.Logger.Errorf("(this *PermitMgr) OnDayTimer GetStrKVGameData not found")
|
||||
continue
|
||||
|
|
@ -41,6 +42,7 @@ func (r *PermitMgr) OnDayTimer() {
|
|||
logger.Logger.Errorf("(this *PermitMgr) OnDayTimer json.Unmarshal err:%v", err)
|
||||
continue
|
||||
}
|
||||
logger.Logger.Tracef("(this *PermitMgr) OnDayTimer se:%+v now:%v", *se, now)
|
||||
if se.StartTs <= now.Unix() && now.Unix() < se.EndTs {
|
||||
// 在活动内
|
||||
continue
|
||||
|
|
@ -57,18 +59,18 @@ func (r *PermitMgr) OnDayTimer() {
|
|||
var players []*model.PlayerBaseInfo
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
list, err = model.FindPlayerPermitList(&model.FindPlayerPermitListArgs{
|
||||
Platform: v.IdStr,
|
||||
Platform: platform,
|
||||
StartTs: startTs,
|
||||
})
|
||||
for _, vv := range list.List {
|
||||
player := PlayerMgrSington.GetPlayerBySnId(vv.SnId)
|
||||
if player != nil {
|
||||
players = append(players, &model.PlayerBaseInfo{
|
||||
SnId: 0,
|
||||
SnId: player.SnId,
|
||||
LastChannel: player.LastChannel,
|
||||
})
|
||||
} else {
|
||||
baseInfo := model.GetPlayerBaseInfo(v.IdStr, vv.SnId)
|
||||
baseInfo := model.GetPlayerBaseInfo(platform, vv.SnId)
|
||||
players = append(players, baseInfo)
|
||||
}
|
||||
}
|
||||
|
|
@ -83,8 +85,9 @@ func (r *PermitMgr) OnDayTimer() {
|
|||
logger.Logger.Errorf("PermitMgr OnDayTimer FindPlayerPermitList player is nil %v", list.List[k].SnId)
|
||||
continue
|
||||
}
|
||||
curPlayer := player
|
||||
// 发送奖励
|
||||
cfg := PlatformMgrSingleton.GetPermitConfig(v.IdStr, player.LastChannel).GetRankConfig()
|
||||
cfg := PlatformMgrSingleton.GetPermitConfig(platform, player.LastChannel).GetRankConfig()
|
||||
rank := k + 1
|
||||
for _, rankInfo := range cfg {
|
||||
var has bool
|
||||
|
|
@ -105,16 +108,16 @@ func (r *PermitMgr) OnDayTimer() {
|
|||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
title := i18n.Tr("languages", "PermitAwardTitle")
|
||||
content := i18n.Tr("languages", "PermitAward", []int{rank, rank, rank, rank})
|
||||
newMsg = model.NewMessage("", 0, "", player.SnId, model.MSGTYPE_RANK_REWARD,
|
||||
title, content, 0, 0, model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", items, v.IdStr, model.HallTienlen, nil)
|
||||
err := model.InsertMessage(v.IdStr, newMsg)
|
||||
newMsg = model.NewMessage("", 0, "", curPlayer.SnId, model.MSGTYPE_RANK_REWARD,
|
||||
title, content, 0, 0, model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", items, platform, model.HallTienlen, nil)
|
||||
err := model.InsertMessage(platform, newMsg)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("发送邮件失败 snid:%v err:%v", player.SnId, err)
|
||||
logger.Logger.Errorf("发送邮件失败 snid:%v err:%v", curPlayer.SnId, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||
p := PlayerMgrSington.GetPlayerBySnId(player.SnId)
|
||||
p := PlayerMgrSington.GetPlayerBySnId(curPlayer.SnId)
|
||||
if p != nil {
|
||||
p.AddMessage(newMsg)
|
||||
}
|
||||
|
|
@ -136,15 +139,15 @@ func (r *PermitMgr) OnDayTimer() {
|
|||
se.StartTs = common.GetDayStartTs(now.Unix())
|
||||
se.EndTs = se.StartTs + int64(pl.Days*24*3600)
|
||||
}
|
||||
PlatformMgrSingleton.GetConfig(v.IdStr).PermitStartTs = se.StartTs
|
||||
PlatformMgrSingleton.GetConfig(v.IdStr).PermitEndTs = se.EndTs
|
||||
PlatformMgrSingleton.GetConfig(platform).PermitStartTs = se.StartTs
|
||||
PlatformMgrSingleton.GetConfig(platform).PermitEndTs = se.EndTs
|
||||
b, err := json.Marshal(se)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("(this *PermitMgr) OnDayTimer json.Marshal err:%v", err)
|
||||
continue
|
||||
}
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
model.UptStrKVGameData(common.PermitStartTsKey+v.IdStr, string(b))
|
||||
model.UptStrKVGameData(common.PermitStartTsKey+platform, string(b))
|
||||
return nil
|
||||
}), nil).StartByExecutor("permit_start_ts")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue