From ba876e7e57df7e24f15a65c246d3f0dcf34ca33a Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 13 二月 2026 16:18:11 +0800
Subject: [PATCH] 66 【公会】基础主体-服务端(后台查询公会、转让会长、解散公会支持跨服;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetFamilyInfo.py  |  134 +++++++++++++++++++++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyDismiss.py  |   61 +++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyTransfer.py |   34 ++++++--
 3 files changed, 220 insertions(+), 9 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyDismiss.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyDismiss.py
new file mode 100644
index 0000000..e44f207
--- /dev/null
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyDismiss.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+# -*- coding: GBK -*-
+#-------------------------------------------------------------------------------
+#
+##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_FamilyDismiss
+#
+# @todo:GM工具命令 - 解散公会
+# @author hxp
+# @date 2026-02-13
+# @version 1.0
+#
+# 详细描述: GM工具命令 - 解散公会
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2026-02-13 16:30"""
+#-------------------------------------------------------------------------------
+
+import GMCommon
+import GameWorld
+import DBDataMgr
+
+## 收到gm命令执行
+# @param gmCmdDict:gm命令字典
+# @return None 
+def OnExec(gmCmdDict):
+    
+    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')      
+    familyName = gmCmdDict.get(GMCommon.Def_GMKey_FamilyName, '')
+    
+    if familyName == '':
+        return GMCommon.Def_ParamErr
+    
+    if GameWorld.IsMainServer():
+        crossServerID = DBDataMgr.GetFamilyMgr().GetCurCrossServerID()
+        if crossServerID:
+            return GMCommon.Def_ParamErr, "公会已经跨服了,跨服ID=%s" % crossServerID
+        
+    familyMgr = DBDataMgr.GetFamilyMgr()
+    if queryType == "FamilyID":
+        familyID = GameWorld.ToIntDef(familyName)
+        if not familyID:
+            return GMCommon.Def_ParamErr
+        curFamily = familyMgr.FindFamily(familyID)
+    else:
+        curFamily = None
+        for zoneID in familyMgr.GetZoneIDListThisServer():
+            zoneMgr = familyMgr.GetZoneFamilyMgr(zoneID)
+            curFamily = zoneMgr.FindFamilyByName(familyName)
+            if curFamily:
+                break
+            
+    if not curFamily:
+        GameWorld.DebugLogEx("目标工会不存在")
+        return GMCommon.Def_NoTag, "no tag family"
+    
+    familyID = curFamily.GetID()
+    zoneMgr = familyMgr.GetZoneFamilyMgrByFamilyID(familyID)
+    familyMgr.DelFamily(familyID)
+    zoneMgr.Sort()
+    
+    return GMCommon.Def_Success
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyTransfer.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyTransfer.py
index bc8c11f..8269b70 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyTransfer.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_FamilyTransfer.py
@@ -18,6 +18,7 @@
 import GMCommon
 import GameWorld
 import PlayerFamily
+import CrossPlayer
 import PlayerMail
 import DBDataMgr
 
@@ -32,6 +33,11 @@
     if familyName == '':
         return GMCommon.Def_ParamErr
     
+    if GameWorld.IsMainServer():
+        crossServerID = DBDataMgr.GetFamilyMgr().GetCurCrossServerID()
+        if crossServerID:
+            return GMCommon.Def_ParamErr, "公会已经跨服了,跨服ID=%s" % crossServerID
+        
     familyMgr = DBDataMgr.GetFamilyMgr()
     if queryType == "FamilyID":
         familyID = GameWorld.ToIntDef(familyName)
@@ -39,34 +45,44 @@
             return GMCommon.Def_ParamErr
         curFamily = familyMgr.FindFamily(familyID)
     else:
-        curFamily = familyMgr.FindFamilyByName(familyName)
-        
+        curFamily = None
+        for zoneID in familyMgr.GetZoneIDListThisServer():
+            zoneMgr = familyMgr.GetZoneFamilyMgr(zoneID)
+            curFamily = zoneMgr.FindFamilyByName(familyName)
+            if curFamily:
+                break
+            
     if not curFamily:
         GameWorld.DebugLogEx("目标工会不存在")
         return GMCommon.Def_NoTag, "no tag family"
     
     familyID = curFamily.GetID()
-    tagPlayer = None
+    tagCrossPlayer = None
     queryTagType = gmCmdDict.get("queryTagType", '')  
     queryTag = gmCmdDict.get("queryTag", '')
     if queryTagType == "PlayerName":
-        tagPlayer = GameWorld.GetPlayerManager().FindPlayerByName(queryTag)
+        tagCrossPlayer = None #GameWorld.GetPlayerManager().FindPlayerByName(queryTag)
     else:
-        tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(GameWorld.ToIntDef(queryTag))
+        tagCrossPlayer = CrossPlayer.GetCrossPlayerMgr().FindCrossPlayer(GameWorld.ToIntDef(queryTag))
         
-    if not tagPlayer:
+    if not tagCrossPlayer:
         GameWorld.DebugLogEx("目标玩家不在线")
         return GMCommon.Def_NoTag, "tagPlayer is offLine"
     
-    tagPlayerID = tagPlayer.GetPlayerID()
+    leaderID = curFamily.GetLeaderID()
+    tagPlayerID = tagCrossPlayer.GetPlayerID()
     toMember = curFamily.FindMember(tagPlayerID)
     if not toMember:
         GameWorld.DebugLogEx("目标玩家非该工会成员: tagPlayerID=%s", tagPlayerID)
         return GMCommon.Def_NoTag, "tagPlayer is not this family member"
     
     PlayerFamily.ChangeFamilyLeader(curFamily, toMember)
-    PlayerFamily.Broadcast_FamilyChange(familyID, PlayerFamily.FamilyChangeType_LeaderChange)
+    PlayerFamily.Broadcast_FamilyInfo(familyID, changeMemIDList=[leaderID, tagPlayerID])
     
     # 邮件通知
-    PlayerMail.SendMailByKey("FamilyLeaderAutoChange", tagPlayerID, [], [curFamily.GetName()])
+    toServerID = 0
+    if GameWorld.IsCrossServer():
+        toServerID = toMember.GetServerID()
+    PlayerMail.SendMailByKey("FamilyLeaderAutoChange", tagPlayerID, [], [curFamily.GetName()], toServerID=toServerID)
+    
     return GMCommon.Def_Success
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetFamilyInfo.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetFamilyInfo.py
new file mode 100644
index 0000000..2795746
--- /dev/null
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetFamilyInfo.py
@@ -0,0 +1,134 @@
+#!/usr/bin/python
+# -*- coding: GBK -*-
+#-------------------------------------------------------------------------------
+#
+##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_GetFamilyInfo
+#
+# @todo:GM工具命令 - 查询公会
+# @author hxp
+# @date 2026-02-13
+# @version 1.0
+#
+# 详细描述: GM工具命令 - 查询公会
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2026-02-13 16:30"""
+#-------------------------------------------------------------------------------
+
+import GMCommon
+import GameWorld
+import DBDataMgr
+
+## 收到gm命令执行
+# @param gmCmdDict:gm命令字典
+# @return None 
+def OnExec(gmCmdDict):
+    
+    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')      
+    familyName = gmCmdDict.get(GMCommon.Def_GMKey_FamilyName, '')
+    
+    if queryType != 'all' and familyName == '':
+        return GMCommon.Def_ParamErr
+    
+    if GameWorld.IsMainServer():
+        crossServerID = DBDataMgr.GetFamilyMgr().GetCurCrossServerID()
+        if crossServerID:
+            return GMCommon.Def_ParamErr, "公会已经跨服了,跨服ID=%s" % crossServerID
+        
+    familyInfo = []
+    familyMgr = DBDataMgr.GetFamilyMgr()
+    
+    # 全名查询
+    if queryType == 'normal':
+        curFamily = None
+        for zoneID in familyMgr.GetZoneIDListThisServer():
+            zoneMgr = familyMgr.GetZoneFamilyMgr(zoneID)
+            curFamily = zoneMgr.FindFamilyByName(familyName)
+            if curFamily:
+                break
+        familyInfo.append(GetQueryFamilyInfo(curFamily, True))
+        
+    # 模糊查询
+    elif queryType == 'faintness':
+        for familyID in familyMgr.GetFamilyIDList():
+            curFamily = familyMgr.FindFamily(familyID)
+            if not curFamily:
+                continue
+            if familyName not in curFamily.GetName():
+                continue
+            familyInfo.append(GetQueryFamilyInfo(curFamily, False))
+            
+    # 全部
+    elif queryType == 'all':
+        for zoneID in familyMgr.GetZoneIDListThisServer():
+            zoneMgr = familyMgr.GetZoneFamilyMgr(zoneID)
+            for index in range(zoneMgr.GetCount()):
+                curFamily = zoneMgr.GetAt(index)
+                if not curFamily:
+                    continue
+                familyInfo.append(GetQueryFamilyInfo(curFamily, False))
+                
+    return GMCommon.Def_Success, familyInfo
+
+def GetQueryFamilyInfo(curFamily, memberDetail):
+    if curFamily == None:
+        return {}
+    
+    familyID = curFamily.GetID()
+    familyMgr = DBDataMgr.GetFamilyMgr()
+    zoneMgr = familyMgr.GetZoneFamilyMgrByFamilyID(familyID)
+    
+    memberCnt = curFamily.GetCount()
+    memberInfo = []
+    onlineCnt = 0
+    
+    # 遍历说有成员
+    for index in range(memberCnt):
+        curMember = curFamily.GetAt(index)
+        offLineTime = curMember.GetOffTime()
+        # 是否在线
+        if not offLineTime:
+            onlineCnt += 1
+            
+        if not memberDetail:
+            continue
+        
+        offLineSeconds = GameWorld.GetPastSeconds(GameWorld.ChangeTimeNumToStr(offLineTime)) if offLineTime > 1 else offLineTime
+        
+        # 成员信息
+        member = {
+                  'Name':curMember.GetPlayerName(),
+                  'PlayerID':curMember.GetPlayerID(),
+                  'LV':curMember.GetLV(),
+                  'FmLV':curMember.GetFmLV(),
+                  'ContribTotal':curMember.GetContribTotal(),
+                  'FightPowerTotal':curMember.GetFightPowerTotal(),
+                  'OffLineSeconds':offLineSeconds, 
+                  }
+        memberInfo.append(member)
+        
+    if memberInfo:
+        memberInfo.sort(key=lambda m: (m['FmLV'], m['FightPowerTotal']), reverse=True)
+        
+    leaderName = ""
+    leaderMember = curFamily.FindMember(curFamily.GetLeaderID())
+    if leaderMember:
+        leaderName = leaderMember.GetPlayerName()
+        
+    familyInfo = {
+                  'ZoneID':zoneMgr.GetZoneID(),
+                  'Rank':zoneMgr.GetFamilyRank(familyID), # 排名
+                  #'WarRank':PlayerFamily.GetFamilyWarRank(curFamily), # 联赛排名
+                  'FightPower':curFamily.GetFightPowerTotal(), # 总战力
+                  'FamilyName':curFamily.GetName(),
+                  'LeaderName':leaderName,
+                  'LV':curFamily.GetLV(),
+                  'Broadcast':curFamily.GetBroadcast(),
+                  'MemberCnt':memberCnt,
+                  'OnLineCnt':onlineCnt,
+                  'ServerID':curFamily.GetServerID(),
+                  }
+    if memberInfo:
+        familyInfo['MemberInfo'] = memberInfo
+        
+    return familyInfo

--
Gitblit v1.8.0