diff --git a/logic/service/player/pack.go b/logic/service/player/pack.go index 1a90bbbf..8dbb40f6 100644 --- a/logic/service/player/pack.go +++ b/logic/service/player/pack.go @@ -124,6 +124,9 @@ func (h *ClientData) OnEvent(data common.TomeeHeader) { if cool.Config.ServerInfo.IsDebug != 0 { fmt.Println("接收数据", data.UserID, data.CMD) } + if data.UserID == 0 { + return + } cmdlister, ok := cool.CmdCache[data.CMD] if !ok { @@ -150,7 +153,7 @@ func (h *ClientData) OnEvent(data common.TomeeHeader) { cool.Logger.Error(context.Background(), data.UserID, data.CMD, "解包失败,", err, data.Data) //fmt.Println(data.UserID, data.CMD, "解包失败,", hex.EncodeToString(data.Data)) - data.Result=uint32(errorcode.ErrorCodes.ErrSystemProcessingError) + data.Result = uint32(errorcode.ErrorCodes.ErrSystemProcessingError) playerconn.SendPack(data.Pack(nil)) return } diff --git a/modules/base/controller/admin/base_sys_user.go b/modules/base/controller/admin/base_sys_user.go index 0d3815d2..2cadb10a 100644 --- a/modules/base/controller/admin/base_sys_user.go +++ b/modules/base/controller/admin/base_sys_user.go @@ -17,6 +17,7 @@ import ( "github.com/deatil/go-cryptobin/cryptobin/crypto" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" ) type BaseSysUserController struct { @@ -64,11 +65,20 @@ func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq) t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId)) res.UserID = int(t1.ID) - if blazing.NewUserService(uint32(t1.ID)).Info.IsReg() { + playerinfo := blazing.NewUserService(uint32(t1.ID)) + if playerinfo.Info.IsReg() { res.IsReg = 1 + if t1.DepartmentID == 35 { ///抢先服玩家,3天没登录衰退 + r := playerinfo.Info.Person(uint32(t1.ID)) + if r.UpdateTime.AddDate(0, 0, 3).Before(gtime.Now()) { + t1.DepartmentID = 1 + service.NewBaseSysUserService().SetdepartmentId(uint32(t1.ID), 1) + } + } } res.PetID = dict.NewDictInfoService().GetShiny() + res.Server = config.NewServerService().GetPort(t1.DepartmentID) // share.ShareManager.DeleteSession(t1) diff --git a/modules/base/service/base_sys_user.go b/modules/base/service/base_sys_user.go index 72e2e836..392e8b09 100644 --- a/modules/base/service/base_sys_user.go +++ b/modules/base/service/base_sys_user.go @@ -46,6 +46,12 @@ func (s *BaseSysUserService) GetPerson(userId uint32) (res *model.BaseSysUser) { return } +func (s *BaseSysUserService) SetdepartmentId(userId, departmentId uint32) (res *model.BaseSysUser) { + m := cool.DBM(s.Model) + m.Where("id", userId).Data("departmentId", departmentId).Update() + + return +} // 单位是分 func (s *BaseSysUserService) UpdateGold(userId uint32, gold int64) { diff --git a/modules/config/service/server.go b/modules/config/service/server.go index ab35a6ff..684c965f 100644 --- a/modules/config/service/server.go +++ b/modules/config/service/server.go @@ -74,6 +74,7 @@ func (s *ServerService) GetPort(DepartmentID uint) gdb.List { var res gdb.Result m := cool.DBM(s.Model).Where("is_open", 1).Fields("ip", "port", "online_id", "is_vip", "name") if DepartmentID != 1 { + res, _ = m.All() } else {