From c2acfe7cf4641bc560a8454a985af16cf349f3ad Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 25 六月 2021 17:42:38 +0800
Subject: [PATCH] 5090 【主干】【BT2】【BT3】【bt2_1.100.1】【gt_1.100.7】循环活动优化-日期活动结束后周循环开启异常(修复活动日期时间头尾衔接导致的活动开启异常问题)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py |  140 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 113 insertions(+), 27 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
index ae637da..fbdaa0f 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
@@ -47,6 +47,7 @@
 import NetPackCommon
 import IpyGameDataPY
 import PlayerTJG
+import CommFunc
 import ChEquip
 
 import time
@@ -96,25 +97,46 @@
     return
 
 
-def GetPlayerGoldGiftFirst(curPlayer):
+def GetPlayerGoldGiftFirst(curPlayer, giftDay):
     '''领取玩家首充奖励
+    @param dayIndex: 首充第几天奖励
     '''
     
-    isGet = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)
-    if isGet:
-        GameWorld.DebugLog("已经领取过首充奖励!", curPlayer.GetPlayerID())
+    if not giftDay:
+        return
+    
+    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
+    firstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
+    if not firstGoldServerDay:
+        GameWorld.DebugLog("还未充值过!firstGoldServerDay=%s" % firstGoldServerDay)
+        return
+    canGetMaxDay = openServerDay - firstGoldServerDay + 1
+    if giftDay > canGetMaxDay:
+        GameWorld.DebugLog("还未到可领取的首充天,无法领取!openServerDay=%s,firstGoldServerDay=%s,canGetMaxDay=%s < giftDay=%s" 
+                           % (openServerDay, firstGoldServerDay, canGetMaxDay, giftDay))
+        return
+    dayIndex = giftDay - 1
+    getRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)
+    if getRecord & pow(2, dayIndex):
+        GameWorld.DebugLog("已经领取过首充奖励!giftDay=%s" % giftDay, curPlayer.GetPlayerID())
         return
     
     if not curPlayer.GetChangeCoinPointTotal():
         GameWorld.DebugLog("没有充值过,无法领取首充奖励!", curPlayer.GetPlayerID())
         return
     
-    firstGoldRewardDict = IpyGameDataPY.GetFuncEvalCfg("FirstGold", 1)
+    ipyData = IpyGameDataPY.GetIpyGameData("FirstGold", giftDay)
+    if not ipyData:
+        return    
+    jobItemInfoDict = ipyData.GetJobItemInfo()
+    commItemList = ipyData.GetCommItemList()
+    
+    rewardItemList = []
     jobStr = str(curPlayer.GetJob())
-    if jobStr not in firstGoldRewardDict:
-        GameWorld.ErrLog("没有配置该职业对应的首充奖励!job=%s" % jobStr, curPlayer.GetPlayerID())
-        return
-    rewardItemList = firstGoldRewardDict[jobStr]
+    if jobStr in jobItemInfoDict:
+        rewardItemList += jobItemInfoDict[jobStr]
+    rewardItemList += commItemList
+    
     if not rewardItemList:
         return
     needSpace = len(rewardItemList)
@@ -126,17 +148,22 @@
         return
     
     # 更新已领取成功标记
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldGiftFirstRecord, 1)
+    updGetRecord = getRecord | pow(2, dayIndex)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldGiftFirstRecord, updGetRecord)
+    GameWorld.DebugLog("领取首充奖励: giftDay=%s,getRecord=%s,updGetRecord=%s, %s" % (giftDay, getRecord, updGetRecord, rewardItemList))
     
     # 给物品
-    for itemID, itemCount, isBind in rewardItemList:        
-        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
+    isAuctionItem = False
+    for itemID, itemCount in rewardItemList:        
+        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])
         
     # 全服提示
     if len(rewardItemList) >= 2:
-        PlayerControl.WorldNotify(0, "FirstPayReward1", [curPlayer.GetPlayerName(), rewardItemList[0][0], rewardItemList[1][0]])
+        PlayerControl.WorldNotify(0, "FirstPayReward1", [curPlayer.GetPlayerName(), rewardItemList[0][0], rewardItemList[1][0], giftDay])
+        
     # 记录领取事件
-    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "FirstGoldGift")
+    infoDict = {"GiftDay":giftDay, "ItemList":rewardItemList}
+    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "FirstGoldGift", infoDict)
     
     # 通知客户端
     Sync_FirstGoldInfo(curPlayer)
@@ -148,7 +175,6 @@
 #  @param curPlayer: 玩家
 #  @return: None
 def OnDay(curPlayer):
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyChargeState, 0)
     return
 
 ## 充值豪礼OnLogin
@@ -158,6 +184,7 @@
     Sync_FirstGoldInfo(curPlayer)
     
     Sync_FirstGoldTime(curPlayer)
+    Sync_HistoryChargeAwardGetRecordInfo(curPlayer)
     #更新首充提示开始计时时间
     if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime):
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, int(time.time()))
@@ -167,14 +194,15 @@
 #  @param curPlayer: 玩家
 #  @param addGold: 充元宝数
 #  @return: None
-def OnPlayerChargeGold(curPlayer, addGold):
+def OnPlayerChargeGold(curPlayer):
     
-    # 更新今日已充值数
-    dailyGoldCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyGoldChargeCnt)
-    updDailyGoldCnt = dailyGoldCnt + addGold
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyGoldChargeCnt, updDailyGoldCnt)
-    #PlayerControl.NotifyPlayerDictValue(curPlayer, ChConfig.Def_PDict_DailyGoldChargeCnt)
-    
+    firstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
+    if not firstGoldServerDay:
+        recordServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldServerDay, recordServerDay)
+        GameWorld.DebugLog("记录首充开服天: recordServerDay=%s" % recordServerDay)
+        Sync_FirstGoldInfo(curPlayer)
+        
     return
 
 def Sync_FirstGoldInfo(curPlayer):
@@ -183,6 +211,7 @@
     sendPack.Clear()
     sendPack.FirstGoldRewardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)
     sendPack.FirstGoldTry = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldTry)
+    sendPack.FirstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
     NetPackCommon.SendFakePack(curPlayer, sendPack)
     return
 
@@ -257,10 +286,67 @@
             GameWorld.DebugLog('首充试用物品过期了 背包仓库没武器则送一把 没给成功!!giveItemID=%s'%giveItemID, curPlayer.GetID())
             
     return
-#每日充值任意金额红包奖励
-def DayChargeRedPackAward(curPlayer):
-    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyChargeState) == 1:
+
+def OnGetHistoryRechargeAward(curPlayer, awardID):
+    # 领取历史充值奖励
+    
+    ipyData = IpyGameDataPY.GetIpyGameData('HistoryRechargeAward', awardID)
+    if not ipyData:
         return
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyChargeState, 1)
-    PlayerFamilyRedPacket.CreatRedPacketByID(curPlayer, 2)
+    
+    needCoin = CommFunc.RMBToCoin(ipyData.GetNeedRMB())
+    # 检查可否领取
+    
+    # 玩家充值小于领取充值
+    if curPlayer.GetChangeCoinPointTotal() < needCoin:
+        GameWorld.ErrLog("OnGetHistoryRechargeAward error:needCoin=%s greater than ChangeCoinPointTotal=%s" 
+                         % (needCoin, curPlayer.GetChangeCoinPointTotal()))
+        return
+    awardInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HistoryChargeAwardGetRecord, 0)
+    awardMark = pow(2, awardID)
+    if awardInfo & awardMark:
+        #已领取
+        GameWorld.DebugLog("已领取历史充值奖励!awardID=%s,needCoin=%s" % (awardID, needCoin))
+        return
+
+    job = curPlayer.GetJob()
+    awardDict = ipyData.GetReward()
+    if str(job) not in awardDict:
+        return
+    itemList = awardDict[str(job)]
+    
+    if not itemList:
+        return
+    # 检查背包
+    needSpace = len(itemList)
+    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
+    if needSpace > packSpace:
+        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
+        return
+    
+    # 给物品
+    for itemInfo in itemList:
+        itemID, itemCount = itemInfo[:2]
+        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
+    
+    # 更新已领取成功标记
+    awardMark = pow(2, awardID)
+
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HistoryChargeAwardGetRecord, awardInfo | awardMark)
+    # 通知客户端
+    Sync_HistoryChargeAwardGetRecordInfo(curPlayer)
+    
+    # 记录领取事件
+    DataRecordPack.SendEventPack("HistoryRechargeAward", {'awardID':awardID, 'needCoin':needCoin}, curPlayer)
+    return
+
+
+## 通知等级奖励领取记录信息
+#  @param None
+#  @return None
+def Sync_HistoryChargeAwardGetRecordInfo(curPlayer):
+    sendPack = ChPyNetSendPack.tagMCHistoryReChargeAwardRecord()
+    sendPack.Clear()
+    sendPack.AwardGetRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HistoryChargeAwardGetRecord, 0)
+    NetPackCommon.SendFakePack(curPlayer, sendPack)
     return
\ No newline at end of file

--
Gitblit v1.8.0