|  |  | 
 |  |  |     GameWorld.DebugLog("新增个人邮件: totalCount=%s,maxMailCount=%s" % (totalCount, maxMailCount), PlayerID)
 | 
 |  |  |     if delCount > 0:
 | 
 |  |  |         GameWorld.Log("个人邮件达到上限,需要删除!delCount=%s" % (delCount), PlayerID)
 | 
 |  |  |         delGUIDList = GetPlayerDelMailGUIDList(PlayerID)
 | 
 |  |  |         #先取得要删除的GUID
 | 
 |  |  |         delGUIDs = []
 | 
 |  |  |         for i in xrange(delCount):
 | 
 |  |  |             curIpyPersonalData = GameWorld.GetCompensationMgr().PersonalCompensationAt(PlayerID, i)
 | 
 |  |  |             delGUIDs.append(curIpyPersonalData.GUID)
 | 
 |  |  |         for _ in xrange(delCount):
 | 
 |  |  |             if not delGUIDList:
 | 
 |  |  |                 break
 | 
 |  |  |             delGUID = delGUIDList.pop(0)
 | 
 |  |  |             curIpyPersonalData = GameWorld.GetCompensationMgr().FindPersonalCompensation(PlayerID, delGUID)
 | 
 |  |  |             if curIpyPersonalData.GUID == delGUID:
 | 
 |  |  |                 delGUIDs.append(curIpyPersonalData.GUID)
 | 
 |  |  |             
 | 
 |  |  |         for guid in delGUIDs:
 | 
 |  |  |             ClearPersonalCompensation(PlayerID, guid)
 | 
 |  |  |             ClearPersonalCompensation(PlayerID, guid, "MaxCountLimiit")
 | 
 |  |  |             GameWorld.Log("    DeletePersonalCompensation GUID = %s" % guid, PlayerID)
 | 
 |  |  |             
 | 
 |  |  |             if curPlayer:
 | 
 |  |  | 
 |  |  |     mailType = moneySource - ChConfig.Def_GiveMoney_Unknown # type类型为byte,存值时需要处理下
 | 
 |  |  |     GameWorld.GetCompensationMgr().AddPersonalCompensation(GUID, PlayerID, CreateTime,
 | 
 |  |  |                                                            LimitTime, Text, mailType, gold, goldPaper, silver)
 | 
 |  |  |     if PlayerID in PyGameData.g_playerDelMailGUIDDict:
 | 
 |  |  |         guidList = PyGameData.g_playerDelMailGUIDDict[PlayerID]
 | 
 |  |  |         guidList.append(GUID)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def GetPlayerDelMailGUIDList(playerID):
 | 
 |  |  |     ## 获取待删除的个人邮件GUID列表
 | 
 |  |  |     if playerID not in PyGameData.g_playerDelMailGUIDDict:
 | 
 |  |  |          | 
 |  |  |         timeGUIDList = []
 | 
 |  |  |         curPersonalCount = GameWorld.GetCompensationMgr().GetPersonalCompensationCount(playerID)
 | 
 |  |  |         for i in xrange(curPersonalCount):
 | 
 |  |  |             curMail = GameWorld.GetCompensationMgr().PersonalCompensationAt(playerID, i)
 | 
 |  |  |             timeGUIDList.append([curMail.CreateTime, curMail.GUID])
 | 
 |  |  |              | 
 |  |  |         timeGUIDList.sort() # 按创建时间升序排序
 | 
 |  |  |         delGUIDList = []
 | 
 |  |  |         for _, guid in timeGUIDList:
 | 
 |  |  |             if guid not in delGUIDList:
 | 
 |  |  |                 delGUIDList.append(guid)
 | 
 |  |  |         PyGameData.g_playerDelMailGUIDDict[playerID] = delGUIDList
 | 
 |  |  |          | 
 |  |  |     return PyGameData.g_playerDelMailGUIDDict[playerID]
 | 
 |  |  | 
 | 
 |  |  | #  此处货币playerIDList发放统一,如根据玩家不同而变,则应需修改
 | 
 |  |  | ## 添加个人补偿
 | 
 |  |  | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | # 删除个人邮件表 状态表,同一个GUID 可以多人领取,不能同时删除物品
 | 
 |  |  | def ClearPersonalCompensation(curPlayerID, curGUID):
 | 
 |  |  | def ClearPersonalCompensation(curPlayerID, curGUID, eventName=""):
 | 
 |  |  |     GameWorld.GetCompensationMgr().DeletePersonalCompensation(curPlayerID, curGUID)
 | 
 |  |  |     GameWorld.GetCompensationMgr().DeletePlayerCompensationRec(curPlayerID, curGUID)
 | 
 |  |  |     
 | 
 |  |  |     #存在多人邮件的情况,故删除物品需检查是否最后一个领取者才可删除
 | 
 |  |  |     if GameWorld.GetCompensationMgr().GetPersonalCountByGUID(curGUID) == 0:
 | 
 |  |  |         GameWorld.GetCompensationMgr().DeleteCompensationItem(curGUID)
 | 
 |  |  |          | 
 |  |  |     if curPlayerID in PyGameData.g_playerDelMailGUIDDict:
 | 
 |  |  |         guidList = PyGameData.g_playerDelMailGUIDDict[curPlayerID]
 | 
 |  |  |         if curGUID in guidList:
 | 
 |  |  |             guidList.remove(curGUID)
 | 
 |  |  |     if eventName:
 | 
 |  |  |         # 有特殊操作删除的才记录,常规领取删除的默认无eventName,不记录
 | 
 |  |  |         DataRecordPack.DR_DelPersonalCompensation(curPlayerID, curGUID, eventName)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | # 设置领取状态
 | 
 |  |  | 
 |  |  |         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
 | 
 |  |  |             tempKey = mailText[mailText.index(tempSign) + len(tempSign):mailText.index(tempSignEnd)]
 | 
 |  |  |             notClearMailKeyList = IpyGameDataPY.GetFuncEvalCfg("MailSet", 1)
 | 
 |  |  |             if tempKey not in notClearMailKeyList:
 | 
 |  |  |                 #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)
 | 
 |  |  | 
 |  |  |         
 | 
 |  |  |     #删除过期补偿信息, 没有主动通知在线玩家
 | 
 |  |  |     for playerID, GUID in needClearGUIDList:
 | 
 |  |  |         ClearPersonalCompensation(playerID, GUID)
 | 
 |  |  |         ClearPersonalCompensation(playerID, GUID, "Timeout")
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | ## 清理超时补偿, 个人邮件在超过上限后才会自动删除
 | 
 |  |  | 
 |  |  |             NotifyCompensationResult(curPlayer, GUID, 0)
 | 
 |  |  |             return
 | 
 |  |  |         
 | 
 |  |  |         ClearPersonalCompensation(curPlayerID, GUID)
 | 
 |  |  |         ClearPersonalCompensation(curPlayerID, GUID, "ClientDel")
 | 
 |  |  |         NotifyCompensationResult(curPlayer, GUID, 1)
 | 
 |  |  |         #GameWorld.DebugLog("个人补偿中OnDelCompensation:%s"%GUID)
 | 
 |  |  |         return
 |