feat: 添加抢先服玩家3天未登录自动降级功能
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
修复数据包处理中UserID为0的问题 优化解包失败时的错误处理格式 添加设置用户部门ID的服务方法
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user