From 4bc77e3c629f8fa7b40629d2822a14fd8e5d7e90 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 19 一月 2021 20:01:11 +0800
Subject: [PATCH] 8701 【主干】【后端】活动相关的充值界面显示优化(永久累充、每日礼包、限时礼包、累计充值);

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py |   11 +++--
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDailyGiftbag.py     |    3 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py                 |   16 ++++----
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCoin.py             |   24 ++++++-----
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/CommFunc.py                      |    7 +++
 PySysDB/PySysDBPY.h                                                                                  |    8 ++--
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFlashGiftbag.py     |    7 ++-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py         |   14 ++++---
 8 files changed, 52 insertions(+), 38 deletions(-)

diff --git a/PySysDB/PySysDBPY.h b/PySysDB/PySysDBPY.h
index 41ecc05..920f616 100644
--- a/PySysDB/PySysDBPY.h
+++ b/PySysDB/PySysDBPY.h
@@ -1342,7 +1342,7 @@
 {
 	DWORD		_GiftbagID;	//礼包编号
 	WORD		GiftbagType;	//礼包类型
-	DWORD		OriginalRMB;	//原价(RMB)
+	float		OriginalRMB;	//原价(RMB)
 	WORD		BuyCountLimit;		//限购次数,0不限购
 	list		GiftItemList;	//礼包物品信息列表 [(物品ID,个数,是否绑定),...]
 	DWORD		MainItemID;	//标的物品ID
@@ -1639,7 +1639,7 @@
 struct tagTotalRechargeTemplate
 {
 	DWORD		_TemplateID;	//模板ID
-	DWORD		NeedGold;	//需要充值仙玉数
+	float		NeedGold;	//需要充值RMB,元
 	BYTE		AwardIndex;		//返利奖励索引0~31,同个模板中不重复
 	dict		AwardItem;	//返利物品信息列表 {职业:[(物品ID,个数,是否绑定),...]}
 	char		NotifyKey;		//全服广播key,默认两个参数(玩家名, 档位额度)
@@ -2170,6 +2170,6 @@
 struct tagHistoryRechargeAward
 {
 	BYTE		_ID;	//id
-	DWORD		Recharge;	//所需充值元
+	float		NeedRMB;	//所需充值元
 	dict		Reward;	//职业对应的奖励内容,每个职业4组数据,物品ID和物品数量(1.枪豪2.道师3.剑修)
-};
\ No newline at end of file
+};
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/CommFunc.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/CommFunc.py
index ce16469..9781308 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/CommFunc.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/CommFunc.py
@@ -592,3 +592,10 @@
         
     return ""
 
+def RMBToCoin(floatRMB):
+    ''' 元转为分,统一函数,方便修改及搜索
+    @param floatRMB: 单位元,float 类型,支持 RMB 或 美元
+    @return: 转化为分数值
+    '''
+    # 由于float会有不精确的现象出现xxx.9999999的问题,所以这里计算出的结果向上取整
+    return int(math.ceil(floatRMB * 100))
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
index 0d51728..3677297 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -1074,7 +1074,7 @@
                 "FlashGiftbag":(
                         ("DWORD", "GiftbagID", 1),
                         ("WORD", "GiftbagType", 0),
-                        ("DWORD", "OriginalRMB", 0),
+                        ("float", "OriginalRMB", 0),
                         ("WORD", "BuyCountLimit", 0),
                         ("list", "GiftItemList", 0),
                         ("DWORD", "MainItemID", 0),
@@ -1293,7 +1293,7 @@
 
                 "TotalRechargeTemplate":(
                         ("DWORD", "TemplateID", 1),
-                        ("DWORD", "NeedGold", 0),
+                        ("float", "NeedGold", 0),
                         ("BYTE", "AwardIndex", 0),
                         ("dict", "AwardItem", 0),
                         ("char", "NotifyKey", 0),
@@ -1679,7 +1679,7 @@
 
                 "HistoryRechargeAward":(
                         ("BYTE", "ID", 1),
-                        ("DWORD", "Recharge", 0),
+                        ("float", "NeedRMB", 0),
                         ("dict", "Reward", 0),
                         ),
                 }
@@ -3864,7 +3864,7 @@
     def __init__(self):
         self.GiftbagID = 0
         self.GiftbagType = 0
-        self.OriginalRMB = 0
+        self.OriginalRMB = 0.0
         self.BuyCountLimit = 0
         self.GiftItemList = []
         self.MainItemID = 0
@@ -4329,14 +4329,14 @@
     
     def __init__(self):
         self.TemplateID = 0
-        self.NeedGold = 0
+        self.NeedGold = 0.0
         self.AwardIndex = 0
         self.AwardItem = {}
         self.NotifyKey = ""
         return
         
     def GetTemplateID(self): return self.TemplateID # 模板ID
-    def GetNeedGold(self): return self.NeedGold # 需要充值仙玉数
+    def GetNeedGold(self): return self.NeedGold # 需要充值RMB,元
     def GetAwardIndex(self): return self.AwardIndex # 返利奖励索引0~31,同个模板中不重复
     def GetAwardItem(self): return self.AwardItem # 返利物品信息列表 {职业:[(物品ID,个数,是否绑定),...]}
     def GetNotifyKey(self): return self.NotifyKey # 全服广播key,默认两个参数(玩家名, 档位额度)
@@ -5149,12 +5149,12 @@
     
     def __init__(self):
         self.ID = 0
-        self.Recharge = 0
+        self.NeedRMB = 0.0
         self.Reward = {}
         return
         
     def GetID(self): return self.ID # id
-    def GetRecharge(self): return self.Recharge # 所需充值元
+    def GetNeedRMB(self): return self.NeedRMB # 所需充值元
     def GetReward(self): return self.Reward # 职业对应的奖励内容,每个职业4组数据,物品ID和物品数量(1.枪豪2.道师3.剑修)
 
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py
index 5ea1147..e99d5fa 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py
@@ -27,6 +27,7 @@
 import ItemCommon
 import GameWorld
 import ChConfig
+import CommFunc
 
 def GetTemplateID(cfgID, dayIndex, actNum):
     if cfgID == None or dayIndex == None:
@@ -135,7 +136,7 @@
         if awardRecord & pow(2, awardIndex):
             continue
         
-        needGold = ipyData.GetNeedGold()
+        needGold = CommFunc.RMBToCoin(ipyData.GetNeedGold())
         if curRechargeGold < needGold:
             continue
         awardRecord |= pow(2, awardIndex) 
@@ -143,7 +144,7 @@
         awardItemList = __GetItemList(ipyData.GetAwardItem(), job, playerWorldLV)
         batchPlayerIDList.append([playerID])
         batchAddItemList.append(awardItemList)
-        batchParamList.append([needGold])
+        batchParamList.append([str(ipyData.GetNeedGold())]) # 钱支持小数,显示参数传字符串
         
     if batchPlayerIDList:
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeAwardRecord % actNum, awardRecord)
@@ -236,7 +237,7 @@
         GameWorld.DebugLog("找不到该返利活动档位索引奖励!actNum=%s,templateID=%s,awardIndex=%s" % (actNum, templateID, awardIndex), playerID)
         return
     
-    needGold = awardIpyData.GetNeedGold()
+    needGold = CommFunc.RMBToCoin(awardIpyData.GetNeedGold())
     actWorldLV = actTotalRechargeInfo.get(ShareDefine.ActKey_WorldLV, 0)
     awardItemList = __GetItemList(ipyData.GetAwardItem(), curPlayer.GetJob(), actWorldLV)
     
@@ -257,7 +258,7 @@
     
     notifyKey = awardIpyData.GetNotifyKey()
     if notifyKey:
-        PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), needGold])
+        PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), str(awardIpyData.GetNeedGold())]) # 钱支持小数,显示参数传字符串
         
     for itemID, itemCount, _ in awardItemList:
         ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
@@ -320,7 +321,7 @@
         for ipyData in ipyDataList:
             awardInfo = ChPyNetSendPack.tagMCTotalRechargeAward()
             awardInfo.AwardIndex = ipyData.GetAwardIndex()
-            awardInfo.NeedGold = ipyData.GetNeedGold()
+            awardInfo.NeedGold = CommFunc.RMBToCoin(ipyData.GetNeedGold())
             awardInfo.AwardItem = []
             awardItemList = __GetItemList(ipyData.GetAwardItem(), job, actWorldLV)
             for awardItemInfo in awardItemList:
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCoin.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCoin.py
index 65088fb..345a2ac 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCoin.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCoin.py
@@ -55,6 +55,7 @@
 import PlayerWeekParty
 import PlayerGoldInvest
 import ItemCommon
+import CommFunc
 
 import time
 
@@ -171,7 +172,7 @@
     ## 直接充值自定义金额
     prizeGold = 0
     giveItemList = []
-    orderCoin = orderRMB * 100
+    orderCoin = CommFunc.RMBToCoin(orderRMB)
     addGold = orderRMB * GetCoinRate()
     addDRDict = {"orderCoin":orderCoin, "isAddBourseMoney":isAddBourseMoney, "eventName":eventName}
     DoCTGLogic(curPlayer, CoinType_Gold, orderCoin, addGold, prizeGold, giveItemList, isAddBourseMoney, eventName, addDRDict)
@@ -181,7 +182,7 @@
     ## 使用赠送的物品兑换点券,一般用于bt版
     prizeGold = 0
     giveItemList = []
-    orderCoin = orderRMB * 100 # 单位,分
+    orderCoin = CommFunc.RMBToCoin(orderRMB) # 单位,分
     addGold = orderRMB * GetCoinRate()
     addDRDict = {"orderCoin":orderCoin, "eventName":eventName}
     DoCTGLogic(curPlayer, CoinType_Item, orderCoin, addGold, prizeGold, giveItemList, isAddBourseMoney, eventName, addDRDict)
@@ -194,7 +195,7 @@
         return
     
     cPlayerCoin = CPY_PlayerCoinToGold()
-    cPlayerCoin.useCoin = int(ipyData.GetPayRMBNum() * 100)
+    cPlayerCoin.useCoin = CommFunc.RMBToCoin(ipyData.GetPayRMBNum())
     cPlayerCoin.orderInfo = orderInfo
     cPlayerCoin.appID = appID
     cPlayerCoin.isAddBourseMoney = isAddBourseMoney
@@ -232,7 +233,7 @@
         return
     
     payRMBNum = ipyData.GetPayRMBNum() # 单位,元
-    if orderCoin != int(payRMBNum * 100):
+    if orderCoin != CommFunc.RMBToCoin(payRMBNum):
         DataRecordPack.DR_CTGError(curPlayer, "The orderCoin is not equal to the ipyData's RMB(%s)!" % payRMBNum, addDRDict)
         return
     
@@ -358,21 +359,22 @@
     DataRecordPack.DR_CTGOK(curPlayer, addDRDict)
     
     #---充值成功后逻辑---
-    orderRMB = orderCoin / 100
+    # 功能统一以分存储记录,玩家字典不支持存小数
+    
     # 所有真实充值均有效的
     if coinType in [CoinType_Gold, CoinType_Buy]:
         #跨服充值排行活动
-        CrossActCTGBillboard.AddCTGRMB(curPlayer, orderRMB)
+        CrossActCTGBillboard.AddCTGRMB(curPlayer, orderCoin)
         
     #仙界盛典-充值大礼
     PlayerFairyCeremony.OnFCRecharge(curPlayer)
     PlayerNewFairyCeremony.OnFCRecharge(curPlayer)
-    PlayerGoldGift.OnPlayerChargeGold(curPlayer, addGold)
+    PlayerGoldGift.OnPlayerChargeGold(curPlayer)
     #累积充值X元
-    PlayerActTotalRecharge.AddTotalRechargeGold(curPlayer, orderCoin/100, 1)
-    PlayerActTotalRecharge.AddTotalRechargeGold(curPlayer, orderCoin/100, 2)
-    PlayerFairyCeremony.AddFCCTGRMB(curPlayer, orderCoin/100)
-    PlayerNewFairyCeremony.AddFCCostGold(curPlayer, orderCoin/100)
+    PlayerActTotalRecharge.AddTotalRechargeGold(curPlayer, orderCoin, 1)
+    PlayerActTotalRecharge.AddTotalRechargeGold(curPlayer, orderCoin, 2)
+    PlayerFairyCeremony.AddFCCTGRMB(curPlayer, orderCoin)
+    PlayerNewFairyCeremony.AddFCCostGold(curPlayer, orderCoin)
     #开服活动
     #OpenServerCampaign.AddOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_Recharge, orderCoin)
     PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Recharge, addVIPExp)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDailyGiftbag.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDailyGiftbag.py
index 1a81ade..e5c0d30 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDailyGiftbag.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDailyGiftbag.py
@@ -27,6 +27,7 @@
 import ItemCommon
 import GameWorld
 import ChConfig
+import CommFunc
 
 def OnPlayerLogin(curPlayer):
     __CheckPlayerDailyGiftbagAction(curPlayer)
@@ -207,7 +208,7 @@
         giftBag.OrderInfo = "" if not orderIpyData else orderIpyData.GetOrderInfo()
         giftBag.OrderInfoLen = len(giftBag.OrderInfo)
         giftBag.BuyCountLimit = giftIpyData.GetBuyCountLimit()
-        giftBag.RMB = 0 if not orderIpyData else int(orderIpyData.GetPayRMBNum())
+        giftBag.RMB = 0 if not orderIpyData else CommFunc.RMBToCoin(orderIpyData.GetPayRMBNum())
         giftBag.ItemInfo = []
         for itemID, itemCount, isBind in __GetJobItemList(giftIpyData.GetGiftItemList(), curPlayer.GetJob()):
             item = ChPyNetSendPack.tagMCDailyGiftbagItem()
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFlashGiftbag.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFlashGiftbag.py
index d86ac36..40f701b 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFlashGiftbag.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFlashGiftbag.py
@@ -28,6 +28,7 @@
 import ItemCommon
 import GameWorld
 import ChConfig
+import CommFunc
 
 
 def GetGiftbagTypeList(cfgID, dayIndex, woldLV):
@@ -163,7 +164,7 @@
     notifyKey = giftbagIpyData.GetNotifyKey()
     if notifyKey:
         orderIpyData = GetFlashGiftbagIDOrderInfoIpyData(giftbagID, appID)
-        rmb = 0 if not orderIpyData else int(orderIpyData.GetPayRMBNum())
+        rmb = "0" if not orderIpyData else str(orderIpyData.GetPayRMBNum()) # RMB支持小数,这里直接转str广播
         PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), rmb, giftbagIpyData.GetMainItemID()])
     
     SyncFlashGiftbagBuyCount(curPlayer, [giftbagID])
@@ -273,8 +274,8 @@
             giftBag.OrderInfo = "" if not orderIpyData else orderIpyData.GetOrderInfo()
             giftBag.OrderInfoLen = len(giftBag.OrderInfo)
             giftBag.BuyCountLimit = giftIpyData.GetBuyCountLimit()
-            giftBag.RMB = 0 if not orderIpyData else int(orderIpyData.GetPayRMBNum())
-            giftBag.RMBOriginal = giftIpyData.GetOriginalRMB()
+            giftBag.RMB = 0 if not orderIpyData else CommFunc.RMBToCoin(orderIpyData.GetPayRMBNum())
+            giftBag.RMBOriginal = CommFunc.RMBToCoin(giftIpyData.GetOriginalRMB())
             giftBag.ItemInfo = []
             for itemID, itemCount, isBind in __GetJobItemList(giftIpyData.GetGiftItemList(), curPlayer.GetJob()):
                 item = ChPyNetSendPack.tagMCFlashGiftbagItem()
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 3abf18b..a35f7d7 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
@@ -194,7 +195,7 @@
 #  @param curPlayer: 玩家
 #  @param addGold: 充元宝数
 #  @return: None
-def OnPlayerChargeGold(curPlayer, addGold):
+def OnPlayerChargeGold(curPlayer):
     DayChargeRedPackAward(curPlayer)
     
     firstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
@@ -303,18 +304,19 @@
     if not ipyData:
         return
     
-    getRecharge = ipyData.GetRecharge()
+    needCoin = CommFunc.RMBToCoin(ipyData.GetNeedRMB())
     # 检查可否领取
     
     # 玩家充值小于领取充值
-    if curPlayer.GetChangeCoinPointTotal()/100 < getRecharge:
-        GameWorld.ErrLog("OnGetHistoryRechargeAward error:getRecharge=%s greater than ChangeCoinPointTotal=%s" % (getRecharge, curPlayer.GetChangeCoinPointTotal()))
+    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,getRecharge=%s" % (awardID, getRecharge))
+        GameWorld.DebugLog("已领取历史充值奖励!awardID=%s,needCoin=%s" % (awardID, needCoin))
         return
 
     job = curPlayer.GetJob()
@@ -345,7 +347,7 @@
     Sync_HistoryChargeAwardGetRecordInfo(curPlayer)
     
     # 记录领取事件
-    DataRecordPack.SendEventPack("HistoryRechargeAward", {'awardID':awardID, 'getRecharge':getRecharge}, curPlayer)
+    DataRecordPack.SendEventPack("HistoryRechargeAward", {'awardID':awardID, 'needCoin':needCoin}, curPlayer)
     return
 
 

--
Gitblit v1.8.0