From 1171f06cfe6681de17ffd3bcb2ce7c807a1de60a Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Wed, 23 Oct 2024 10:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E9=A6=86=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=BF=85=E4=B8=AD=E7=8E=A9=E5=AE=B6=E5=BC=80?= =?UTF-8?q?=E5=A5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/gameparam.go | 13 +++++++++++-- worldsrv/etcd.go | 2 ++ worldsrv/lotterymgr.go | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/model/gameparam.go b/model/gameparam.go index 965ba2d..85b9f46 100644 --- a/model/gameparam.go +++ b/model/gameparam.go @@ -3,6 +3,7 @@ package model import ( "encoding/json" "os" + "time" "github.com/globalsign/mgo" "mongo.games.com/goserver/core/logger" @@ -84,14 +85,14 @@ type GameParam struct { PermitInitScore int64 // 赛季通行证初始积分 GuideStepMaxNum int32 // 新手引导步骤最大值 GuideTs int64 // 新手引导时间戳,小于这个时间的玩家不显示新手引导 - CustomAwardUpdateTime int // 竞技馆奖励更新时间,单位秒 + CustomAwardUpdateTime int // 竞技馆奖励更新时间,单位秒 CustomAwardMinAddTime int // 竞技馆假奖励方法周期,单位秒 CustomAwardMaxAddTime int // 竞技馆假奖励方法周期,单位秒 AdminPassword string // 管理员密码 UseAdminPassword bool // 是否使用管理员密码 CloseCustomRoomCreate bool // 关闭自定义房间创建 ClientVersion int32 // 客户端版本号 - ClientVersionChannel []string // 客户端版本号包渠道 + ClientVersionChannel []string // 客户端版本号包渠道 } var GameParamPath = "../data/gameparam.json" @@ -238,3 +239,11 @@ func InitGameParam() { GameParamData.AdminPassword = "fjslowopcserg" } } + +// BackTimeUnixToLocalTimeUnix 后台时间戳转本地时间戳 +func BackTimeUnixToLocalTimeUnix(ts int64) int64 { + _, offset := time.Now().Zone() + backOffset := GameParamData.BackendTimeLocal * 3600 + ts += int64(backOffset - offset) + return ts +} diff --git a/worldsrv/etcd.go b/worldsrv/etcd.go index d776736..603fff9 100644 --- a/worldsrv/etcd.go +++ b/worldsrv/etcd.go @@ -560,6 +560,7 @@ func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *c return } config := data.(*webapi.UserLottery) + config.Time = model.BackTimeUnixToLocalTimeUnix(config.Time) PlatformMgrSingleton.GetConfig(config.GetPlatform()).LotteryUser[config.GetId()] = config case clientv3.EventTypeDelete: if plt == "" || len(param) == 0 { @@ -575,6 +576,7 @@ func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *c return } config := data.(*webapi.ShowLottery) + config.Time = model.BackTimeUnixToLocalTimeUnix(config.Time) PlatformMgrSingleton.GetConfig(config.GetPlatform()).LotteryShows[config.GetId()] = config case clientv3.EventTypeDelete: if plt == "" || len(param) == 0 { diff --git a/worldsrv/lotterymgr.go b/worldsrv/lotterymgr.go index 7100b39..521981c 100644 --- a/worldsrv/lotterymgr.go +++ b/worldsrv/lotterymgr.go @@ -252,6 +252,12 @@ func (l *LotteryData) Done() { break } + if awardPlayer == nil { + awardPlayer = &Player{ + PlayerData: &model.PlayerData{}, + } + } + // 是否必中 for _, v := range PlatformMgrSingleton.GetConfig(l.Platform).LotteryUser { if v.GetOn() != common.On { @@ -331,6 +337,15 @@ func (l *LotteryData) Done() { } return nil }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { + if code == nil && isMust { + code = &model.LotteryCode{ + Platform: l.Platform, + SnId: awardPlayer.SnId, + CId: l.CId, + StartTs: l.StartTs, + Code: fmt.Sprintf("%d", l.TotalCode), + } + } if code == nil { return }