| | |
| | | import NetPackCommon
|
| | | import CommFunc
|
| | | import ChPyNetSendPack
|
| | | import PyGameDataStruct
|
| | | import CrossRealmMsg
|
| | | import DataRecordPack
|
| | | import ReadChConfig
|
| | | import PlayerDBOper
|
| | | import EventReport
|
| | | import IpyGameDataPY
|
| | | import PlayerControl
|
| | | import PyDataManager
|
| | | import PyGameData
|
| | | import datetime
|
| | | import uuid
|
| | | import math
|
| | |
| | |
|
| | | Def_RequestState = "CompensationRequestState"
|
| | |
|
| | | #==================================================================================================
|
| | | class CrossPersonalCompensationManager(object):
|
| | | ## 跨服邮件管理,注意该类只处理数据逻辑,功能相关逻辑不要写在该类,不然重读脚本不会生效
|
| | | |
| | | def __init__(self):
|
| | | self.playerMailDict = {} # 玩家补偿列表 {playerID:{GUID:tagDBCrossPersonalCompensation, ...}, ...}
|
| | | return
|
| | | |
| | | # 保存数据 存数据库和realtimebackup
|
| | | def GetSaveData(self):
|
| | | savaData = ""
|
| | | cntData = ""
|
| | | cnt = 0
|
| | | for mailDict in self.playerMailDict.values():
|
| | | for mailObj in mailDict.values():
|
| | | cnt += 1
|
| | | savaData += mailObj.getBuffer()
|
| | | |
| | | GameWorld.Log("Save DBCrossPersonalCompensation count :%s, len=%s" % (cnt, len(savaData)))
|
| | | return CommFunc.WriteDWORD(cntData, cnt) + savaData
|
| | | |
| | | # 从数据库载入数据
|
| | | def LoadPyGameData(self, datas, pos, dataslen):
|
| | | cnt, pos = CommFunc.ReadDWORD(datas, pos)
|
| | | GameWorld.Log("Load DBCrossPersonalCompensation count :%s" % cnt)
|
| | | |
| | | for _ in xrange(cnt):
|
| | | mailObj = PyGameDataStruct.tagDBCrossPersonalCompensation()
|
| | | mailObj.clear()
|
| | | pos += mailObj.readData(datas, pos, dataslen)
|
| | | |
| | | playerID = mailObj.PlayerID
|
| | | guid = mailObj.GUID
|
| | | if playerID not in self.playerMailDict:
|
| | | self.playerMailDict[playerID] = {}
|
| | | mailDict = self.playerMailDict[playerID]
|
| | | mailDict[guid] = mailObj
|
| | | |
| | | return pos
|
| | | |
| | | def Sync_CrossMailPlayerIDToClientServer(serverGroupID=0):
|
| | | ''' 同步有跨服邮件的玩家ID到子服
|
| | | @param serverGroupID: 为0时同步所有子服
|
| | | '''
|
| | | crossMailMgr = PyDataManager.GetCrossPersonalCompensationManager()
|
| | | addMailPlayerIDList = crossMailMgr.playerMailDict.keys()
|
| | | if not addMailPlayerIDList:
|
| | | return
|
| | | # 同步子服务器
|
| | | serverGroupIDList = [serverGroupID] if serverGroupID else []
|
| | | dataMsg = {"IDType":"Add", "PlayerIDList":addMailPlayerIDList}
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_MailPlayerIDList, dataMsg, serverGroupIDList)
|
| | | return
|
| | |
|
| | | def CrossServerMsg_MailPlayerIDList(dataMsg):
|
| | | ## 收到跨服服务器同步有跨服邮件的玩家ID列表
|
| | | idType = dataMsg["IDType"]
|
| | | playerIDList = dataMsg["PlayerIDList"]
|
| | | for playerID in playerIDList:
|
| | | if idType == "Del":
|
| | | if playerID in PyGameData.g_crossMailPlayerDict:
|
| | | PyGameData.g_crossMailPlayerDict.pop(playerID)
|
| | | continue
|
| | | |
| | | if idType == "Add":
|
| | | if playerID in PyGameData.g_crossMailPlayerDict:
|
| | | continue
|
| | | PyGameData.g_crossMailPlayerDict[playerID] = 0
|
| | | |
| | | player = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if not player or not player.GetInitOK():
|
| | | continue
|
| | | RequestToGetCrossMail(player)
|
| | | |
| | | return
|
| | |
|
| | | def RequestToGetCrossMail(curPlayer):
|
| | | ## 请求同步跨服邮件内容
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | if playerID not in PyGameData.g_crossMailPlayerDict:
|
| | | return
|
| | | lastTick = PyGameData.g_crossMailPlayerDict[playerID]
|
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | if tick - lastTick <= 30000:
|
| | | return
|
| | | PyGameData.g_crossMailPlayerDict[playerID] = tick
|
| | | dataMsg = {"CMD":"Get", "PlayerID":playerID}
|
| | | CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_MailContent, dataMsg)
|
| | | return
|
| | |
|
| | | def ClientServerMsg_MailContent(serverGroupID, msgData, tick):
|
| | | ## 收到子服玩家请求同步跨服邮件
|
| | | |
| | | GameWorld.Log("收到子服玩家同步个人邮件命令: serverGroupID=%s, %s" % (serverGroupID, msgData))
|
| | | |
| | | reqCMD = msgData["CMD"]
|
| | | playerID = msgData["PlayerID"]
|
| | | guidList = msgData.get("GuidList", [])
|
| | | crossMailMgr = PyDataManager.GetCrossPersonalCompensationManager()
|
| | | if playerID not in crossMailMgr.playerMailDict:
|
| | | return
|
| | | playerMailDict = crossMailMgr.playerMailDict[playerID]
|
| | | |
| | | if reqCMD == "Get":
|
| | | SyncTickAttrKey = "SyncTick"
|
| | | getMailList = []
|
| | | for guid, mailObj in playerMailDict.items():
|
| | | if hasattr(mailObj, SyncTickAttrKey):
|
| | | getTick = getattr(mailObj, SyncTickAttrKey)
|
| | | if tick - getTick <= 30000:
|
| | | GameWorld.DebugLog("短时间内重复请求领取的邮件不同步,防止重复发放! GUID=%s" % guid)
|
| | | continue
|
| | | setattr(mailObj, SyncTickAttrKey, tick)
|
| | | crossMailDict = {"PlayerID":mailObj.PlayerID, "GUID":mailObj.GUID, "LimitTime":mailObj.LimitTime,
|
| | | "Text":mailObj.Text, "ItemInfo":mailObj.ItemInfo, "Detail":mailObj.Detail,
|
| | | "Gold":mailObj.Gold, "GoldPaper":mailObj.GoldPaper, "Silver":mailObj.Silver,
|
| | | "MoneySource":mailObj.MoneySource
|
| | | }
|
| | | getMailList.append(crossMailDict)
|
| | | |
| | | if getMailList:
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_MailContent, getMailList, [serverGroupID])
|
| | | |
| | | elif reqCMD == "GetOK":
|
| | | |
| | | for guid in guidList:
|
| | | playerMailDict.pop(guid, None)
|
| | | DataRecordPack.DR_GiveCompensationSuccess(playerID, guid)
|
| | | |
| | | if not playerMailDict:
|
| | | crossMailMgr.playerMailDict.pop(playerID, None)
|
| | | dataMsg = {"IDType":"Del", "PlayerIDList":[playerID]}
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_MailPlayerIDList, dataMsg, [serverGroupID])
|
| | | |
| | | return
|
| | |
|
| | | def CrossServerMsg_MailContent(getMailList):
|
| | | ## 收到跨服服务器同步的待发送邮件内容
|
| | | |
| | | playerGetGUIDInfo = {}
|
| | | for mailDict in getMailList:
|
| | | GUID = mailDict.get("GUID", "")
|
| | | playerID = mailDict.get("PlayerID", 0)
|
| | | if not GUID or not playerID:
|
| | | continue
|
| | | |
| | | GameWorld.Log("收到跨服个人邮件内容:%s" % mailDict, playerID)
|
| | | |
| | | addItemDictList = eval(mailDict.get("ItemInfo", "[]"))
|
| | | LimitTime = mailDict.get("LimitTime", "")
|
| | | Text = mailDict.get("Text", "")
|
| | | gold = GameWorld.ToIntDef(mailDict.get("Gold"))
|
| | | goldPaper = GameWorld.ToIntDef(mailDict.get("GoldPaper"))
|
| | | silver = GameWorld.ToIntDef(mailDict.get("Silver"))
|
| | | moneySource = GameWorld.ToIntDef(mailDict.get("MoneySource"), ChConfig.Def_GiveMoney_Mail)
|
| | | detail = mailDict.get("Detail", "")
|
| | | |
| | | AddPersonalItem(GUID, addItemDictList, [playerID], LimitTime, Text, gold, goldPaper, silver, detail, moneySource)
|
| | | |
| | | if playerID not in playerGetGUIDInfo:
|
| | | playerGetGUIDInfo[playerID] = []
|
| | | guidList = playerGetGUIDInfo[playerID]
|
| | | guidList.append(GUID)
|
| | | |
| | | for playerID, guidList in playerGetGUIDInfo.items():
|
| | | dataMsg = {"CMD":"GetOK", "PlayerID":playerID, "GuidList":guidList}
|
| | | CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_MailContent, dataMsg)
|
| | | |
| | | return
|
| | |
|
| | | def __AddPlayerCrossMail(addItemDictList, PlayerIDList, LimitTime, Text, gold, goldPaper, silver, detail, moneySource):
|
| | | ## 添加跨服玩家个人补偿邮件
|
| | | |
| | | addMailPlayerIDList = []
|
| | | crossMailMgr = PyDataManager.GetCrossPersonalCompensationManager()
|
| | | for playerID in PlayerIDList:
|
| | | GUID = str(uuid.uuid1()) # 由于跨服邮件由每个玩家独自同步个人邮件,所以插入时每个人的邮件单独GUID,防止批量发送同内容邮件时重复插入奖励物品
|
| | | mailObj = PyGameDataStruct.tagDBCrossPersonalCompensation()
|
| | | mailObj.PlayerID = playerID
|
| | | mailObj.GUID = GUID
|
| | | mailObj.LimitTime = LimitTime
|
| | | mailObj.Text = Text
|
| | | mailObj.TextLen = len(mailObj.Text)
|
| | | mailObj.Gold = gold
|
| | | mailObj.GoldPaper = goldPaper
|
| | | mailObj.Silver = silver
|
| | | mailObj.ItemInfo = json.dumps(addItemDictList, ensure_ascii=False)
|
| | | mailObj.ItemLen = len(mailObj.ItemInfo)
|
| | | mailObj.Detail = detail
|
| | | mailObj.DetailLen = len(mailObj.Detail)
|
| | | mailObj.MoneySource = moneySource
|
| | | |
| | | if playerID not in crossMailMgr.playerMailDict:
|
| | | crossMailMgr.playerMailDict[playerID] = {}
|
| | | addMailPlayerIDList.append(playerID)
|
| | | playerMailDict = crossMailMgr.playerMailDict[playerID]
|
| | | playerMailDict[GUID] = mailObj
|
| | | |
| | | #添加流向
|
| | | addDict = {"LimitTime":LimitTime, "Text":Text, "Gold":gold, "GoldPaper":goldPaper, "Silver":silver, |
| | | "ItemListLen":len(addItemDictList), "Detail":detail, "MoneySource":moneySource, "CrossMail":True}
|
| | | DataRecordPack.DR_AddPersonalCompensation(PlayerIDList, GUID, addItemDictList, addDict)
|
| | | |
| | | if addMailPlayerIDList:
|
| | | dataMsg = {"IDType":"Add", "PlayerIDList":addMailPlayerIDList}
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_MailPlayerIDList, dataMsg)
|
| | | |
| | | return
|
| | |
|
| | | #==================================================================================================
|
| | | ## 根据物品信息字典,生成补偿物品实例,用于GM工具添加补偿
|
| | | # @param curItemDict
|
| | | # @return IpyCompensationItem
|
| | |
| | | # @param addItemList [(itemID, itemCnt, 是否拍品), {或物品信息字典}, ...]
|
| | | # @return GUID
|
| | | def SendPersonalItemMailEx(title, content, getDays, playerIDList, addItemList, gold = 0, goldPaper = 0, silver = 0,
|
| | | detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
|
| | | detail="", moneySource=ChConfig.Def_GiveMoney_Mail, crossMail=False):
|
| | | limitTime = str(GameWorld.GetDatetimeByDiffDays(getDays))
|
| | | limitTime = limitTime.split(".")[0]
|
| | | return SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource)
|
| | | return SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource, crossMail)
|
| | |
|
| | | def SendPersonalItemMailBatch(batchMailInfoList):
|
| | | ## 批量发送邮件
|
| | |
| | | limitTime = limitTime.split(".")[0]
|
| | |
|
| | | for i, playerIDList in enumerate(batchPlayerIDList):
|
| | | if not playerIDList:
|
| | | continue
|
| | | addItemList = batchAddItemList[i] if lenItem == lenPlayerID else []
|
| | | paramList = batchParamList[i] if lenParam == lenPlayerID else []
|
| | | gold = batchGold[i] if lenGold == lenPlayerID else 0
|
| | |
| | | return
|
| | |
|
| | | def SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList=[], gold=0, goldPaper=0, silver=0,
|
| | | detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
|
| | | detail="", moneySource=ChConfig.Def_GiveMoney_Mail, crossMail=False):
|
| | | if not mailTypeKey:
|
| | | mailTypeKey = ShareDefine.DefaultLackSpaceMailType
|
| | | GameWorld.DebugLog("SendMailByKey %s, playerIDList=%s, addItemList=%s, paramList=%s, gold=%s, goldPaper=%s, silver=%s, moneySource=%s"
|
| | | % (mailTypeKey, playerIDList, addItemList, paramList, gold, goldPaper, silver, moneySource))
|
| | | title = ""
|
| | | content = "<MailTemplate>%s</MailTemplate>%s" % (mailTypeKey, json.dumps(paramList, ensure_ascii=False))
|
| | | return SendPersonalItemMailEx(title, content, 30, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource)
|
| | | return SendPersonalItemMailEx(title, content, 30, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource, crossMail)
|
| | |
|
| | | def CrossServerMsg_SendMail(msgData):
|
| | | ## 收到跨服服务器同步的发送邮件
|
| | | mailTypeKey = msgData["MailTypeKey"]
|
| | | playerIDList = msgData["Player"]
|
| | | addItemList = msgData.get("Item", [])
|
| | | paramList = msgData.get("Param", [])
|
| | | SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList)
|
| | | return
|
| | |
|
| | | # 此处货币playerIDList发放统一,如根据玩家不同而变,则应需修改
|
| | | ## 功能发放物品补偿/奖励邮件
|
| | |
| | | # @return GUID
|
| | | # @remarks addItemList支持append字典
|
| | | def SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold = 0, goldPaper = 0, silver = 0,
|
| | | detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
|
| | | detail="", moneySource=ChConfig.Def_GiveMoney_Mail, crossMail=False):
|
| | | if not playerIDList:
|
| | | return ""
|
| | |
|
| | |
| | | perMailItemCnt = IpyGameDataPY.GetFuncCfg("MailMaxItemCnt")
|
| | | mailCnt = max(1, int(math.ceil(len(addItemDictList)/float(perMailItemCnt)))) # 一封邮件最多5个物品
|
| | | for i in xrange(mailCnt):
|
| | | if i != 0:
|
| | | gold, goldPaper, silver = 0, 0, 0 # 拆分后非第一封的邮件货币归零,防止重复给货币奖励
|
| | | startIndex = i*perMailItemCnt
|
| | | GUID = str(uuid.uuid1())
|
| | | AddPersonalItem(GUID, addItemDictList[startIndex:startIndex + perMailItemCnt], playerIDList,
|
| | | limitTime, "%s<$_$>%s<$_$>%s" % (ChConfig.Def_Mail_SenderSys, title, content),
|
| | | gold, goldPaper, silver, detail, moneySource)
|
| | | gold, goldPaper, silver, detail, moneySource, crossMail)
|
| | | return GUID
|
| | |
|
| | | ## 发送纯文字个人补偿
|
| | |
| | | limitLVType = (mailInfo - checkState * 1000000) / 100000
|
| | | return checkState, limitLVType, limitLV
|
| | |
|
| | | def QueryCompensationPersonalInfo(playerID):
|
| | | '''个人补偿邮件查询
|
| | | '''
|
| | | |
| | | retList = []
|
| | | compensationMgr = GameWorld.GetCompensationMgr()
|
| | | |
| | | tempSign = "<MailTemplate>"
|
| | | tempSignEnd = "</MailTemplate>"
|
| | | curPersonalCount = compensationMgr.GetPersonalCompensationCount(playerID)
|
| | | GameWorld.DebugLog("QueryCompensationPersonalInfo %s" % curPersonalCount)
|
| | | for i in xrange(curPersonalCount):
|
| | | compensation = compensationMgr.PersonalCompensationAt(playerID, i)
|
| | | |
| | | contentList = compensation.Text.split("<$_$>")
|
| | | if len(contentList) != 3:
|
| | | continue
|
| | | sender, title, content = contentList
|
| | | |
| | | if tempSign in content and tempSignEnd in content:
|
| | | title = content[content.index(tempSign) + len(tempSign):content.index(tempSignEnd)]
|
| | | content = ""
|
| | | |
| | | GUID = compensation.GUID
|
| | | itemList = []
|
| | | curGUIDItemCount = compensationMgr.FindItemCount(GUID)
|
| | | for i in xrange(curGUIDItemCount):
|
| | | curItem = compensationMgr.FindItemAt(GUID, i)
|
| | | itemID = curItem.ItemID
|
| | | if not itemID:
|
| | | continue
|
| | | itemList.append([itemID, curItem.Count, curItem.IsBind, curItem.UserData])
|
| | | |
| | | recState = compensationMgr.FindPlayerRecState(playerID, GUID)
|
| | | |
| | | infoDict = {"GUID":GUID, "Gold":compensation.Gold, "GoldPaper":compensation.GoldPaper, "Silver":compensation.Silver,
|
| | | "Sender":sender, "Title":title, "Content":content, "RecState":recState,
|
| | | "CreateTime":compensation.CreateTime, "LimitTime":compensation.LimitTime, "ItemList":itemList}
|
| | | |
| | | retList.append(infoDict)
|
| | | |
| | | return retList
|
| | |
|
| | | def QueryCompensationInfo(fromDate, toDate, guid, searchTitle, searchContent, searchState=None, maxCount=10):
|
| | | '''补偿邮件查询
|
| | | '''全服补偿邮件查询
|
| | | '''
|
| | |
|
| | | compensationMgr = GameWorld.GetCompensationMgr()
|
| | |
| | |
|
| | | compensationDict = {"GUID":GUID, "CheckState":checkState, "LimitLVType":limitLVType, "LimitLV":limitLV,
|
| | | "Gold":compensation.Gold, "GoldPaper":compensation.GoldPaper, "Silver":compensation.Silver,
|
| | | "PlayerJob":compensation.PlayerJob, "Sender":sender, "Title":title, "Content":content,
|
| | | "PlayerJob":compensation.PlayerJob, "Sender":sender, "Title":title, "Content":content, "OnlyServerID":compensation.ServerID,
|
| | | "CreateTime":compensation.CreateTime, "LimitTime":compensation.LimitTime, "ItemList":itemList}
|
| | | return compensationDict
|
| | |
|
| | |
| | | SyncQueryCompensationResult(player, notifyList)
|
| | |
|
| | | return successGUIDList
|
| | |
|
| | | def SendEntireMail(mailTypeKey, getDays, limitLV, limitLVType, addItemList=[], paramList=[], \
|
| | | gold=0, goldPaper=0, silver=0, detail="", moneySource=ChConfig.Def_GiveMoney_Mail, GUID=""):
|
| | | ''' 发送全服邮件
|
| | | @param mailTypeKey: 邮件模板key
|
| | | @param getDays: 有效天数
|
| | | @param limitLV: 领取最低等级限制
|
| | | @param limitLVType: 等级不足的升级后是否可领 0-不可,1-可以
|
| | | '''
|
| | | |
| | | if not mailTypeKey or getDays <= 0:
|
| | | return
|
| | | |
| | | addItemDictList = []
|
| | | for itemInfo in addItemList:
|
| | | if isinstance(itemInfo, dict):
|
| | | addItemDictList.append(itemInfo)
|
| | | continue
|
| | | |
| | | if len(itemInfo) == 3:
|
| | | itemID, itemCnt, isAuctionItem = itemInfo
|
| | | else:
|
| | | continue
|
| | | |
| | | addItemDict = {}
|
| | | addItemDict['ItemID'] = itemID
|
| | | addItemDict['Count'] = itemCnt
|
| | | addItemDict['IsAuctionItem'] = isAuctionItem
|
| | | addItemDictList.append(addItemDict)
|
| | | |
| | | if not GUID:
|
| | | GUID = str(uuid.uuid1())
|
| | | |
| | | limitTime = str(GameWorld.GetDatetimeByDiffDays(getDays))
|
| | | limitTime = limitTime.split(".")[0]
|
| | | |
| | | sender = ChConfig.Def_Mail_SenderSys
|
| | | title = ""
|
| | | content = "<MailTemplate>%s</MailTemplate>%s" % (mailTypeKey, json.dumps(paramList, ensure_ascii=False))
|
| | | |
| | | checkState = 0 # 邮件审核状态,为兼容老邮件,默认0-已审核,1-未审核
|
| | | mailInfo = GetEntireCompensationInfo(checkState, limitLVType, limitLV)
|
| | | PlayerJob = 127 # 默认全职业可领
|
| | | serverID = 0 # 默认所有服务器ID
|
| | | |
| | | AddEntireItem(GUID, addItemDictList, limitTime, mailInfo, PlayerJob, "%s<$_$>%s<$_$>%s" % (sender, title, content), |
| | | gold, goldPaper, silver, detail, serverID)
|
| | | return
|
| | |
|
| | | ## 添加全服补偿
|
| | | # @param addItemDictList, LimitTime, mailInfo, PlayerJob, Text
|
| | |
| | | ## 添加个人补偿
|
| | | # @param addItemDict, PlayerIDList, LimitTime, Text
|
| | | # @return None
|
| | | def AddPersonalItem(GUID, addItemDictList, PlayerIDList, LimitTime, Text, gold = 0, goldPaper = 0, silver = 0, detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
|
| | | def AddPersonalItem(GUID, addItemDictList, PlayerIDList, LimitTime, Text, gold = 0, goldPaper = 0, silver = 0, |
| | | detail="", moneySource=ChConfig.Def_GiveMoney_Mail, crossMail=False):
|
| | | if GameWorld.IsCrossServer():
|
| | | if crossMail:
|
| | | __AddPlayerCrossMail(addItemDictList, PlayerIDList, LimitTime, Text, gold, goldPaper, silver, detail, moneySource)
|
| | | return
|
| | | GameWorld.DebugLog("Compensation### AddPersonalItem GUID:%s ItemDict:\n%s "%(GUID, addItemDictList))
|
| | |
|
| | |
| | |
|
| | | # 提取接收邮件下发
|
| | | def NotifyPlayerCompensation(curPlayer):
|
| | | RequestToGetCrossMail(curPlayer)
|
| | | notifyList = SeekPlayerCompensation(curPlayer)
|
| | | SyncQueryCompensationResult(curPlayer, notifyList)
|
| | | return
|
| | |
| | | SetPrizeState(curPlayerID, curRequire.GUID, Disable_State, readState)
|
| | | continue
|
| | |
|
| | | if curRequire.ServerID and curRequire.ServerID != GameWorld.GetPlayerServerID(curPlayer):
|
| | | # 指定服务器邮件
|
| | | SetPrizeState(curPlayerID, curRequire.GUID, Disable_State, readState)
|
| | | continue
|
| | | |
| | | #可以用的奖励
|
| | | if Enable_State != curState:
|
| | | SetPrizeState(curPlayerID, curRequire.GUID, Enable_State, readState)
|
| | |
| | | # @return None
|
| | | def SendGMRequestCompensationResult(routeIndex, mapID, curPlayer, GUID, compensationType, curEntireRequire):
|
| | |
|
| | | Text, gold, goldPaper, silver, moneySource, createTime = curEntireRequire.Text, curEntireRequire.Gold, \
|
| | | curEntireRequire.GoldPaper, curEntireRequire.Silver, curEntireRequire.Type, curEntireRequire.CreateTime
|
| | | Text, gold, goldPaper, silver, createTime = curEntireRequire.Text, curEntireRequire.Gold, \
|
| | | curEntireRequire.GoldPaper, curEntireRequire.Silver, curEntireRequire.CreateTime
|
| | | # 全服邮件没有 Type 字段
|
| | | moneySource = curEntireRequire.Type if compensationType == Personal_CompensationType else 0
|
| | | |
| | | sendPack = ChGameToMapPyPack.tagGMRequestCompensationResult()
|
| | | sendPack.PlayerID = curPlayer.GetID()
|
| | | sendPack.CompensationType = compensationType
|
| | |
| | | return
|
| | |
|
| | |
|
| | | ##清理超时30天的个人邮件, 否则流失玩家在不断合服情况下数据会累积
|
| | | # 个人邮件暂无过期时间设定,只有30天清理逻辑,以创建时间为准
|
| | | # @param None
|
| | | # @return None
|
| | | def ClearUpPersonalCompensation():
|
| | | #校验过期补偿
|
| | | tempSign = "<MailTemplate>"
|
| | | tempSignEnd = "</MailTemplate>"
|
| | | curTime = datetime.datetime.today()
|
| | | needClearGUIDList = []
|
| | | allCnt = GameWorld.GetCompensationMgr().GetAllPersonalCompensationCount()
|
| | | for i in xrange(allCnt):
|
| | | curMail = GameWorld.GetCompensationMgr().AtAllPersonalCompensation(i)
|
| | | |
| | | mailText = curMail.Text
|
| | | # 通知类模板邮件,过天可直接删除
|
| | | if tempSign in mailText and tempSignEnd in mailText and CheckCanDelCompensation(curMail, curMail.GUID):
|
| | | #tempKey = mailText[mailText.index(tempSign) + len(tempSign):mailText.index(tempSignEnd)]
|
| | | #GameWorld.DebugLog("过天删除无附件通知类邮件模板! tempKey=%s %s, %s" % (tempKey, curMail.PlayerID, curMail.GUID))
|
| | | needClearGUIDList.append([curMail.PlayerID, curMail.GUID])
|
| | | player = GameWorld.GetPlayerManager().FindPlayerByID(curMail.PlayerID)
|
| | | if player and player.GetInitOK():
|
| | | NotifyCompensationResult(player, curMail.GUID, 1)
|
| | | continue
|
| | | |
| | | # 超过接收邮件30天则完全删除此邮件
|
| | | limitTime = datetime.datetime.strptime(curMail.CreateTime, ChConfig.TYPE_Time_Format) + datetime.timedelta(days = 30)
|
| | | if limitTime < curTime:
|
| | | needClearGUIDList.append([curMail.PlayerID, curMail.GUID])
|
| | | |
| | | GameWorld.Log("ClearUpPersonalCompensation count=%s"%len(needClearGUIDList))
|
| | | |
| | | #删除过期补偿信息, 没有主动通知在线玩家
|
| | | for playerID, GUID in needClearGUIDList:
|
| | | ClearPersonalCompensation(playerID, GUID)
|
| | | return
|
| | |
|
| | | ## 清理超时补偿, 个人邮件在超过上限后才会自动删除
|
| | | # @param None
|
| | | # @return None
|
| | | def ClearUpTimeOutCompensation():
|
| | |
|
| | | ClearUpPersonalCompensation()
|
| | | ClearUpEntireCompensation()
|
| | | return
|
| | |
|