diff --git a/call/user.go b/call/user.go index ce09c51..125919b 100644 --- a/call/user.go +++ b/call/user.go @@ -34,6 +34,34 @@ func GetUserInfo(uid int) (ret *common.PlayerDBInfo, err error) { return } +func GetUserByDeviceIp(ip, device string, withoutUid int) (uids []int) { + if ip == "" && device == "" { + log.Error("get user by device ip is nil, %d", withoutUid) + return + } + var users []common.PlayerDBInfo + db := db.Mysql().C().Model(&common.PlayerDBInfo{}).Select("id") + if ip != "" { + db = db.Where("ip = ?", ip) + } + if device != "" { + db = db.Where("deviceid = ?", device) + } + if withoutUid != 0 { + db = db.Where("id != ?", withoutUid) + } + err := db.Find(&users).Error + if err != nil { + log.Error("get user by device ip err, %s", err.Error()) + return + } + uids = make([]int, 0, len(users)) + for _, v := range users { + uids = append(uids, v.Id) + } + return +} + // 查询用户的信息 func GetUserXInfo(uid int, fields ...string) (ret *common.PlayerDBInfo, err error) { ret = new(common.PlayerDBInfo) diff --git a/modules/backend/values/gameuser.go b/modules/backend/values/gameuser.go index f6613f7..f34c2d0 100644 --- a/modules/backend/values/gameuser.go +++ b/modules/backend/values/gameuser.go @@ -166,6 +166,8 @@ type GetGameUserInfoV1Resp struct { Gpsadid string SubAccount []int Rtp int + SameIPUids []int + SameDeviceUids []int } type UserGameInfo struct { diff --git a/modules/customer/handler/guser/getGameUserInfo.go b/modules/customer/handler/guser/getGameUserInfo.go index ccb9d72..3cdb771 100644 --- a/modules/customer/handler/guser/getGameUserInfo.go +++ b/modules/customer/handler/guser/getGameUserInfo.go @@ -114,9 +114,11 @@ func GetGameUserInfo(c *gin.Context) { Status: user.Status, Birth: user.Birth, // PlayCount: util.GetGUserPlayCount(uid), - IP: user.IP, - LastLogin: user.LastLogin, - Tag: user.Tag, + IP: user.IP, + LastLogin: user.LastLogin, + Tag: user.Tag, + SameIPUids: call.GetUserByDeviceIp(user.IP, "", user.Id), + SameDeviceUids: call.GetUserByDeviceIp("", user.DeviceId, user.Id), // IsFinishNewControl: control.NewControlFin == 2, // NewControlLevel: control.NewControlLevel, // ControlLevel: control.ControlLevel,