From 79a23de6692781dfe4b18fdb57bc4b3e69f34014 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 05 三月 2019 16:44:26 +0800
Subject: [PATCH] 6250 【后端】【2.0】拍卖行开发单(邮件记录货币来源)

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py |   83 +++++++++++++++++++----------------------
 1 files changed, 38 insertions(+), 45 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
index 7f5901b..280bae4 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
@@ -84,16 +84,15 @@
 ## 功能发放物品补偿/奖励邮件
 #  @param addItemList [(itemID, itemCnt, isBind), {或物品信息字典}, ...]
 #  @return GUID
-def SendPersonalItemMailEx(title, content, getDays, playerIDList, addItemList, 
-                           gold = 0, goldPaper = 0, silver = 0, sourceType = ChConfig.Mail_Type_Default, detail=""):
+def SendPersonalItemMailEx(title, content, getDays, playerIDList, addItemList, gold = 0, goldPaper = 0, silver = 0, 
+                           detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
     limitTime = str(GameWorld.GetDatetimeByDiffDays(getDays))
     limitTime = limitTime.split(".")[0]
-    return SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, 
-                                gold, goldPaper, silver, sourceType, detail=detail)
+    return SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource)
     
 def SendPersonalItemMailBatch(batchMailInfoList):
     ## 批量发送邮件
-    mailTypeKey, batchPlayerIDList, batchAddItemList, batchParamList, batchGold, batchGoldPaper, batchSilver, batchDetail = batchMailInfoList
+    mailTypeKey, batchPlayerIDList, batchAddItemList, batchParamList, batchGold, batchGoldPaper, batchSilver, batchDetail, moneySource = batchMailInfoList
     
     lenPlayerID = len(batchPlayerIDList)
     lenItem = len(batchAddItemList)
@@ -116,26 +115,27 @@
         silver = batchSilver[i] if lenSilver == lenPlayerID else 0
         detail = batchDetail[i] if lenDetail == lenPlayerID else ""
         content = "<MailTemplate>%s</MailTemplate>%s" % (mailTypeKey, str(paramList))
-        SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold, goldPaper, silver, detail=detail)
+        SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold, goldPaper, silver, detail=detail, moneySource=moneySource)
         
     return
 
-def SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList=[], gold=0, goldPaper=0, silver=0, detail=""):
+def SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList=[], gold=0, goldPaper=0, silver=0, 
+                  detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
     if not mailTypeKey:
         mailTypeKey = ShareDefine.DefaultLackSpaceMailType
-    GameWorld.DebugLog("SendMailByKey %s, playerIDList=%s, addItemList=%s, paramList=%s, gold=%s, goldPaper=%s, silver=%s" 
-                       % (mailTypeKey, playerIDList, addItemList, paramList, gold, goldPaper, silver))
+    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=detail)
+    return SendPersonalItemMailEx(title, content, 30, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource)
 
 #  此处货币playerIDList发放统一,如根据玩家不同而变,则应需修改
 ## 功能发放物品补偿/奖励邮件
 #  @param addItemList [(itemID, itemCnt, isBind), {或物品信息字典}, ...]
 #  @return GUID
 #  @remarks addItemList支持append字典
-def SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList,
-                         gold = 0, goldPaper = 0, silver = 0, sourceType = ChConfig.Mail_Type_Default, detail=""):
+def SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold = 0, goldPaper = 0, silver = 0, 
+                         detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
     if not playerIDList:
         return ""
     
@@ -173,19 +173,18 @@
         GUID = str(uuid.uuid1())
         AddPersonalItem(GUID, addItemDictList[startIndex:startIndex + perMailItemCnt], playerIDList, 
                                            limitTime, "%s<$_$>%s<$_$>%s" % (ChConfig.Def_Mail_SenderSys, title, content),
-                                           gold, goldPaper, silver, sourceType, detail)
+                                           gold, goldPaper, silver, detail, moneySource)
     return GUID
 
 ## 发送纯文字个人补偿
 #  @param limitTime 可以传空
-#  @param sourceType 查看 Mail_Type_Default 相关定义
 #  @return None
-def SendPersonalAsTextMail(PlayerID, title, content, limitTime, sourceType = ChConfig.Mail_Type_Default):
+def SendPersonalAsTextMail(PlayerID, title, content, limitTime):
     if GameWorld.IsCrossServer():
         return
     GUID = str(uuid.uuid1())
     PyAddPersonalCompensation(GUID, PlayerID, GameWorld.GetCurrentDataTimeStr(), limitTime, 
-                              "%s<$_$>%s<$_$>%s" % (ChConfig.Def_Mail_SenderSys,title, content), sourceType)
+                              "%s<$_$>%s<$_$>%s" % (ChConfig.Def_Mail_SenderSys,title, content))
     return
 
 def GetEntireCompensationInfo(checkState, limitLVType, limitLV):
@@ -378,38 +377,33 @@
 
 # 检查邮件是否已达到保存上限,如超过则先删除旧邮件
 # @param LimitTime 参数可传空,个人邮件不限制领取期限,只限制保存数量, 
-def PyAddPersonalCompensation(GUID, PlayerID, CreateTime, LimitTime, Text, sourceType, 
-                              gold = 0, goldPaper = 0, silver = 0):
+def PyAddPersonalCompensation(GUID, PlayerID, CreateTime, LimitTime, Text, gold = 0, goldPaper = 0, silver = 0, moneySource=ChConfig.Def_GiveMoney_Mail):
     curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(PlayerID)
-    cnt = GameWorld.GetCompensationMgr().GetPersonalCompensationCountByType(PlayerID, sourceType)
+    totalCount = GameWorld.GetCompensationMgr().GetPersonalCompensationCount(PlayerID)
     #待支持py读表
-    tmpDict = {ChConfig.Mail_Type_Default:IpyGameDataPY.GetFuncCfg("MailDefaultCount"), 
-               ChConfig.Mail_Type_Market:IpyGameDataPY.GetFuncCfg("MailMarketCount")}
-    
-    delcnt = cnt - tmpDict[sourceType] + 1
-    #GameWorld.DebugLog("PyAddPersonalCompensation typecnt = %s-%s"%(cnt, delcnt))
-    if delcnt > 0:
+    maxMailCount = IpyGameDataPY.GetFuncCfg("MailDefaultCount")
+    delCount = totalCount - maxMailCount + 1
+    GameWorld.DebugLog("新增个人邮件: totalCount=%s,maxMailCount=%s" % (totalCount, maxMailCount), PlayerID)
+    if delCount > 0:
+        GameWorld.Log("个人邮件达到上限,需要删除!delCount=%s" % (delCount), PlayerID)
         #先取得要删除的GUID
         delGUIDs = []
-        for i in xrange(delcnt):
-            tmpGuid = GameWorld.GetCompensationMgr().AtGUIDInPersonalTypesByType(PlayerID, sourceType, i)
-            if not tmpGuid:
-                #GameWorld.DebugLog("PyAddPersonalCompensation not GUID = %s"%tmpGuid)
-                continue
-            delGUIDs.append(tmpGuid)
-        
-        for guid in delGUIDs:    
+        for i in xrange(delCount):
+            curIpyPersonalData = GameWorld.GetCompensationMgr().PersonalCompensationAt(PlayerID, i)
+            delGUIDs.append(curIpyPersonalData.GUID)
+            
+        for guid in delGUIDs:
             ClearPersonalCompensation(PlayerID, guid)
-            #GameWorld.DebugLog("PyAddPersonalCompensation DeletePersonalCompensation GUID = %s"%guid)
+            GameWorld.Log("    DeletePersonalCompensation GUID = %s" % guid, PlayerID)
             
             if curPlayer:
                 NotifyCompensationResult(curPlayer, guid, 1)
             #未补流向
-    
-    #GameWorld.DebugLog("PyAddPersonalCompensation CreateTime %s"%CreateTime)
+            
     #此处没有下发通知
+    mailType = moneySource - ChConfig.Def_GiveMoney_Unknown # type类型为byte,存值时需要处理下
     GameWorld.GetCompensationMgr().AddPersonalCompensation(GUID, PlayerID, CreateTime,
-                                                           LimitTime, Text, sourceType, gold, goldPaper, silver)
+                                                           LimitTime, Text, mailType, gold, goldPaper, silver)
     return
 
 
@@ -417,8 +411,7 @@
 ## 添加个人补偿
 #  @param addItemDict, PlayerIDList, LimitTime, Text 
 #  @return None
-def AddPersonalItem(GUID, addItemDictList, PlayerIDList, LimitTime, Text, 
-                    gold = 0, goldPaper = 0, silver = 0, sourceType = ChConfig.Mail_Type_Default, detail=""):
+def AddPersonalItem(GUID, addItemDictList, PlayerIDList, LimitTime, Text, gold = 0, goldPaper = 0, silver = 0, detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
     if GameWorld.IsCrossServer():
         return
     GameWorld.DebugLog("Compensation### AddPersonalItem GUID:%s ItemDict:\n%s "%(GUID, addItemDictList))
@@ -433,8 +426,7 @@
     #批量添加玩家个人补偿领取表
     createTime = GameWorld.GetCurrentDataTimeStr()
     for PlayerID in PlayerIDList:
-        PyAddPersonalCompensation(GUID, PlayerID, createTime, LimitTime, 
-                                  Text, sourceType, gold, goldPaper, silver)
+        PyAddPersonalCompensation(GUID, PlayerID, createTime, LimitTime, Text, gold, goldPaper, silver, moneySource)
         # 针对个人补偿,如果是在线玩家,则立即推送给客户端
         curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(PlayerID)
         if curPlayer:
@@ -454,7 +446,7 @@
     
     #添加流向
     addDict = {"LimitTime":LimitTime, "Text":Text, "Gold":gold, "GoldPaper":goldPaper, "Silver":silver, 
-               "ItemListLen":len(addItemDictList), "Detail":detail}
+               "ItemListLen":len(addItemDictList), "Detail":detail, "MoneySource":moneySource}
     DataRecordPack.DR_AddPersonalCompensation(PlayerIDList, GUID, addItemDictList, addDict)
     return
 
@@ -680,7 +672,7 @@
         curPlayer.SetDict(Def_RequestState, 0)#解锁
         GameWorld.DebugLog("Compensation### OnMGRequestCompensation no found")
         return
-    Text, gold, goldPaper, silver = curEntireRequire.Text, curEntireRequire.Gold, curEntireRequire.GoldPaper, curEntireRequire.Silver
+    Text, gold, goldPaper, silver, moneySource = curEntireRequire.Text, curEntireRequire.Gold, curEntireRequire.GoldPaper, curEntireRequire.Silver, curEntireRequire.Type
     #校验背包剩余空间是否足够
     #===========================================================================
     # curCUIDItemCount = GameWorld.GetCompensationMgr().FindItemCount(GUID)
@@ -690,7 +682,7 @@
     #    return
     #===========================================================================
     #发送到MapServer给予奖励
-    SendGMRequestCompensationResult(routeIndex, mapID, curPlayer, GUID, compensationType, Text, gold, goldPaper, silver)
+    SendGMRequestCompensationResult(routeIndex, mapID, curPlayer, GUID, compensationType, Text, gold, goldPaper, silver, moneySource)
     GameWorld.DebugLog("Compensation### OnMGRequestCompensation out")
     
 ##请求领取物品
@@ -767,7 +759,7 @@
 #  @param routeIndex, mapID, curPlayer, curItem
 #  @return None
 def SendGMRequestCompensationResult(routeIndex, mapID, curPlayer, GUID, compensationType, Text,
-                                    gold, goldPaper, silver):
+                                    gold, goldPaper, silver, moneySource):
     sendPack = ChGameToMapPyPack.tagGMRequestCompensationResult() 
     sendPack.PlayerID = curPlayer.GetID()
     sendPack.CompensationType = compensationType
@@ -777,6 +769,7 @@
     sendPack.Gold = gold
     sendPack.GoldPaper = goldPaper
     sendPack.Silver = silver
+    sendPack.MoneySource = moneySource
     curGUIDItemCount = GameWorld.GetCompensationMgr().FindItemCount(GUID)
     
     for i in xrange(curGUIDItemCount):

--
Gitblit v1.8.0