hxp
4 天以前 67a84dc38db8f7d0f85b03e2b06ba728d95c1e82
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCoin.py
@@ -45,23 +45,16 @@
import PlayerDailyGiftbag
import PlayerGoldGift
import PlayerActTotalRecharge
import PlayerActRechargeRebateGold
import PlayerActFamilyCTGAssist
import PlayerActManyDayRecharge
import PlayerActSingleRecharge
import PlayerActRechargePrize
import CrossActCTGBillboard
import CrossActAllRecharge
import PlayerActGrowupBuy
import PlayerWeekParty
import PlayerGoldInvest
import PlayerActTurntable
import PlayerTongTianLing
import PlayerZhanling
import PlayerGoldRush
import PlayerLLMJ
import ItemCommon
import PyGameData
import DBDataMgr
import CommFunc
import time
@@ -95,10 +88,6 @@
def OnLogin(curPlayer):
    if not DoResetCTGCountByTime(curPlayer):
        Sync_CoinToGoldCountInfo(curPlayer)
    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayFreeGoldGiftState):
        Sync_DayFreeGoldGiftState(curPlayer)
    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_OnlineRechargeTHAward):
        SyncOnlineRechargeTH(curPlayer)
    return
def DoResetCTGCountByTime(curPlayer):
@@ -205,9 +194,6 @@
    if syncRecordIDList:
        Sync_CoinToGoldCountInfo(curPlayer, syncRecordIDList)
        
    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayFreeGoldGiftState):
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayFreeGoldGiftState, 0)
        Sync_DayFreeGoldGiftState(curPlayer)
    return
def OnWeek(curPlayer):
@@ -245,11 +231,11 @@
#    tagHead        Head;
#};
def OnQueryRecharge(index, packData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    if tick - curPlayer.GetDictByKey("QRtick") < 10000:
        return
    curPlayer.SetDict("QRtick", tick)
    curPlayer.SendDBQueryRecharge()
    #curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    #if tick - curPlayer.GetDictByKey("QRtick") < 10000:
    #    return
    #curPlayer.SetDict("QRtick", tick)
    #curPlayer.SendDBQueryRecharge() 不查了,由在线轮询触发即可
    return
#// A1 23 查询充值次数 #tagCMQueryCoinToGoldCount
@@ -345,7 +331,7 @@
    PlayerControl.SendMailByKey("ExchangeToPayCoin", [playerID], addItemList, paramList)
    
    if payOrderType != PayOrderType_PayCoin:
        serverDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
        serverDay = DBDataMgr.GetEventTrigMgr().GetValue(ShareDefine.Def_ServerDay) + 1
        addDRDict.update({"coinType":ChConfig.CoinType_ExchangePayCoin, "PayCoin":[befPayCoin, aftPayCoin], 
                          "VIPLv":curPlayer.GetVIPLv(), "ServerDay":serverDay, "eventName":eventName})
        DataRecordPack.DR_CTGOK(curPlayer, addDRDict)
@@ -416,6 +402,15 @@
    cPlayerCoin.isAddBourseMoney = isAddBourseMoney
    return PlayerCoinToGold(curPlayer, cPlayerCoin, eventName)
def OnDBPushRecharge(curPlayer, orderID, orderInfo, orderAmount):
    cPlayerCoin = CPY_PlayerCoinToGold()
    cPlayerCoin.useCoin = orderAmount
    cPlayerCoin.orderID = orderID
    cPlayerCoin.orderInfo = orderInfo
    cPlayerCoin.isAddBourseMoney = True
    GameWorld.Log("OnDBPushRecharge: useCoin=%s,orderInfo=%s,orderID=%s" % (cPlayerCoin.useCoin, cPlayerCoin.orderInfo, cPlayerCoin.orderID), curPlayer.GetPlayerID())
    return PlayerCoinToGold(curPlayer, cPlayerCoin, ChConfig.Def_GiveMoney_CoinToGold)
##特别说明:充值赠送点券都要计算到各个活动中
##玩家点卷兑换元宝.
# @param curPlayer 玩家实例
@@ -429,12 +424,15 @@
    orderInfo = chargeInfo.GetOrderInfo() # 商品编号
    orderID = chargeInfo.GetOrderID() #订单号,兑换成功后清除
    isAddBourseMoney = chargeInfo.GetIsAddBourseMoney()
    if orderID:
        curPlayer.SendDBFinishRecharge(orderID)
    #if orderID:
    #    curPlayer.SendDBFinishRecharge(orderID)
    appID = chargeInfo.GetAppID()
    if not appID:
        appID = GameWorld.GetPlayerPlatform(curPlayer)
    if not appID:
        appID = GameWorld.GetAppIDByAccID(curPlayer.GetAccID())
        GameWorld.DebugLog("GetAppIDByAccID appID=%s" % appID)
    addDRDict = {"orderCoin":orderCoin, "orderInfo":orderInfo, "orderID":orderID, 
                 "isAddBourseMoney":isAddBourseMoney, "eventName":eventName, "appID":appID}
    
@@ -513,7 +511,7 @@
    recordID = ctgIpyData.GetRecordID() if ctgIpyData else 0
    Sync_CoinToGoldReport(curPlayer, orderID, orderCoin, recordID, orderInfo)
    
    curPlayer.SendDBQueryRecharge()
    #curPlayer.SendDBQueryRecharge() 不查了,由在线轮询触发即可
    return True
def __GetCTGInfoByID(curPlayer, recordID, addDRDict):
@@ -576,21 +574,8 @@
            return
        addDRDict.update({"selectItemList":selectItemList})
        
    totalBuyCountUpd = min(totalBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CTGGoodsBuyCount % recordID, totalBuyCountUpd)
    addDRDict.update({"totalBuyCountUpd":totalBuyCountUpd})
    todayBuyCountUpd = min(todayBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TodayCTGCount % recordID, todayBuyCountUpd)
    addDRDict.update({"todayBuyCountUpd":todayBuyCountUpd})
    weekBuyCountUpd = min(weekBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_WeekCTGCount % recordID, weekBuyCountUpd)
    addDRDict.update({"weekBuyCountUpd":weekBuyCountUpd})
    monthBuyCountUpd = min(monthBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MonthCTGCount % recordID, monthBuyCountUpd)
    addDRDict.update({"monthBuyCountUpd":monthBuyCountUpd})
    totalBuyCountUpd, todayBuyCountUpd, weekBuyCountUpd, monthBuyCountUpd = __addCTGIDBuyCnt(curPlayer, recordID)
    addDRDict.update({"totalBuyCountUpd":totalBuyCountUpd, "todayBuyCountUpd":todayBuyCountUpd, "weekBuyCountUpd":weekBuyCountUpd, "monthBuyCountUpd":monthBuyCountUpd})
    
    giveItemList = []
    giveItemList += GetCTGGiveItemList(ipyData)
@@ -602,16 +587,52 @@
    gainGoldPrize = ipyData.GetGainGoldPrize() # 赠送货币数,首次充值赠送仙玉时,此仙玉不给
    firstGoldPrize = ipyData.GetFirstGoldPrize() # 首次充值赠送的仙玉
    prizeGold = firstGoldPrize if (not totalBuyCount and firstGoldPrize) else gainGoldPrize
    if moneyType == IPY_GameWorld.TYPE_Price_Gold_Money:
        #if payType in [PayType_Gold, PayType_GoldPlus] and PlayerGoldInvest.GetInvestState(curPlayer, ChConfig.InvestType_Life):
        #    prizeGold = addGold # bt tqxbqy 版本,永久卡仙玉直充固定双倍
        actPrizeGold = PlayerActRechargePrize.DoAddPlayerActRechargePrizeCount(curPlayer, recordID)
        if actPrizeGold:
            prizeGold += actPrizeGold
            addDRDict.update({"actRechargePrize":1})
    syncRecordIDList = [recordID]
    # 打包购买 - 目前用于每日特惠,有需要可扩展为通用
    if recordID == IpyGameDataPY.GetFuncCfg("DailyTehui", 2):
        packItemDict = {}
        packCTGIDDict = {}
        dailyTehuiCTGIDList = IpyGameDataPY.GetFuncEvalCfg("DailyTehui", 1)
        for ctgID in dailyTehuiCTGIDList:
            ctgIpyData = IpyGameDataPY.GetIpyGameData("CTG", ctgID)
            if not ctgIpyData:
                continue
            if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TodayCTGCount % ctgID):
                continue
            syncRecordIDList.append(ctgID)
            ctgItemList = GetCTGGiveItemList(ctgIpyData)
            packCTGIDDict[ctgID] = ctgItemList
            for itemInfo in ctgItemList:
                itemID, itemCount = itemInfo[:2]
                packItemDict[itemID] = packItemDict.get(itemID, 0) + itemCount
            __addCTGIDBuyCnt(curPlayer, ctgID)
        if packCTGIDDict:
            GameWorld.Log("打包购买: recordID=%s,packCTGIDDict=%s" % (recordID, packCTGIDDict), curPlayer.GetPlayerID())
            addDRDict.update({"packCTGIDDict":packCTGIDDict})
        for itemID, itemCount in packItemDict.items():
            giveItemList.append([itemID, itemCount, 0])
            
    Sync_CoinToGoldCountInfo(curPlayer, [recordID])
    Sync_CoinToGoldCountInfo(curPlayer, syncRecordIDList)
    return moneyType, addGold, prizeGold, giveItemList, ipyData
def __addCTGIDBuyCnt(curPlayer, recordID):
    totalBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % recordID)
    totalBuyCountUpd = min(totalBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CTGGoodsBuyCount % recordID, totalBuyCountUpd)
    todayBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TodayCTGCount % recordID)
    todayBuyCountUpd = min(todayBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TodayCTGCount % recordID, todayBuyCountUpd)
    weekBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_WeekCTGCount % recordID)
    weekBuyCountUpd = min(weekBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_WeekCTGCount % recordID, weekBuyCountUpd)
    monthBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MonthCTGCount % recordID)
    monthBuyCountUpd = min(monthBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MonthCTGCount % recordID, monthBuyCountUpd)
    return totalBuyCountUpd, todayBuyCountUpd, weekBuyCountUpd, monthBuyCountUpd
def GetSelectItemListInfo(selectItemInfo, selectItemValue):
    errorInfo = ""
@@ -685,16 +706,28 @@
    
    if ctgIpyData and ctgIpyData.GetPayType() == PayType_PayCoin:
        # 代币充值,仅给代币,不触发其他内容
        ctgID = ctgIpyData.GetRecordID()
        coinType = ChConfig.CoinType_PayCoin
        orderInfo = addDRDict.get("orderInfo", "")
        orderCoin = addDRDict.get("orderCoin", 0)
        payOrderType = addDRDict.get("payOrderType", PayOrderType_Default)
        playerID = curPlayer.GetPlayerID()
        moneyInfo = {}
        befPayCoin = PlayerControl.GetPayCoin(curPlayer)
        if addGold and moneyType == ShareDefine.TYPE_Price_PayCoin:
            drDict = {ChConfig.Def_Give_Reason_SonKey:orderInfo, "payOrderType":payOrderType, "orderInfo":orderInfo}
            PlayerControl.GiveMoney(curPlayer, moneyType, addGold, eventName, drDict)
            moneyInfo[moneyType] = addGold
        aftPayCoin = PlayerControl.GetPayCoin(curPlayer)
        # 三国版本充代币支持赠送元宝
        prizeMoneyType = IPY_GameWorld.TYPE_Price_Gold_Money
        if prizeGold > 0:
            PlayerControl.GiveMoney(curPlayer, prizeMoneyType, prizeGold, eventName, addDRDict, isGiveBourseMoney=isAddBourseMoney)
            moneyInfo[prizeMoneyType] = prizeGold
        if moneyInfo:
            ItemControler.NotifyGiveAwardInfo(curPlayer, [], ChConfig.ItemGive_CTG, moneyInfo=moneyInfo,
                                              dataEx={"orderInfo":orderInfo, "ctgID":ctgID})
        
        isRealMoney = True if addDRDict.get("orderID") else False # tqxbqy 真实订单充代币算真实充值
        if isRealMoney:
@@ -703,8 +736,8 @@
        ctgRealToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGRealToday) # 当日真实货币充值Coin数 ,不含后台充值- 今日
        ctgRealTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGRealTotal) # 累计真实货币充值Coin数 ,不包后台充值 - 总计
        ctgRealFirstTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGRealFirstTime) # 首次真实货币充值时间戳
        serverDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
        addDRDict.update({"coinType":coinType, "PayCoin":[befPayCoin, aftPayCoin],
        serverDay = DBDataMgr.GetEventTrigMgr().GetValue(ShareDefine.Def_ServerDay) + 1
        addDRDict.update({"coinType":coinType, "PayCoin":[befPayCoin, aftPayCoin], "moneyInfo":moneyInfo,
                          "VIPLv":curPlayer.GetVIPLv(), "ServerDay":serverDay, "eventName":eventName, 
                          "ctgRealToday":ctgRealToday, "ctgRealTotal":ctgRealTotal, "ctgRealFirstTime":GameWorld.ChangeTimeNumToStr(ctgRealFirstTime) if ctgRealFirstTime else ""})
        DataRecordPack.DR_CTGOK(curPlayer, addDRDict)
@@ -775,33 +808,22 @@
    
    # 所有真实充值均有效的
    if coinType in [ChConfig.CoinType_Gold, ChConfig.CoinType_Buy, ChConfig.CoinType_UsePayCoin]:
        #跨服充值排行活动
        CrossActCTGBillboard.AddCTGRMB(curPlayer, orderCoin)
        #跨服全民充值
        CrossActAllRecharge.AddCTGRMB(curPlayer, orderCoin)
        PlayerActManyDayRecharge.AddManyDayRechargeValue(curPlayer, orderCoin) # 多日连充
    # 只算充仙玉的
    if coinType == ChConfig.CoinType_Gold:
        PlayerActRechargeRebateGold.AddRechargeRebateGoldRMB(curPlayer, addGold)
        
    #累积充值X元
    PlayerActTotalRecharge.AddTotalRechargeGold(curPlayer, orderCoin, coinType)
    PlayerActSingleRecharge.UpdSingleRechargeValue(curPlayer, orderCoin, coinType) # 单笔累充
    PlayerActTurntable.OnPlayerRecharge(curPlayer, orderCoin, coinType) # 转盘
    PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Recharge, addVIPExp)
    #投资
    if ctgIpyData:
        ctgID = ctgIpyData.GetRecordID()
        #PlayerActFamilyCTGAssist.OnPlayerCTG(curPlayer, ctgID)
        PlayerGoldInvest.InvestByCTG(curPlayer, ctgID)
        PlayerGoldGift.OnGiftByCTGID(curPlayer, ctgID)
        PlayerZhanling.OnActiviteByCTGID(curPlayer, ctgID)
        PlayerGoldRush.OnGoldRushByCTGID(curPlayer, ctgID)
        PlayerTongTianLing.OnActiviteTTTByCTGID(curPlayer, ctgID)
        PlayerLLMJ.OnActiviteByCTGID(curPlayer, ctgID)
        
    serverDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
    serverDay = DBDataMgr.GetEventTrigMgr().GetValue(ShareDefine.Def_ServerDay) + 1
    addDRDict.update({"gold":[goldBefore, goldAfter], "changeCoinPoint":[changeCoinPointBefore, changeCoinPointAfter], "todayCTGCoinTotal":todayCTGCoinTotal,
                      "bourseMoney":[bourseMoneyBefore, bourseMoneyAfter], "addGold":addGold, "prizeGold":prizeGold, "giveItemList":giveItemList, "coinType":coinType,
                      "coinExp":coinExp, "addVIPExp":addVIPExp, "VIPLv":curPlayer.GetVIPLv(), "ServerDay":serverDay,
@@ -909,82 +931,3 @@
    countInfoPack.RecordCount = len(countInfoPack.CTGCountInfoList)
    NetPackCommon.SendFakePack(curPlayer, countInfoPack)
    return
## ---------- 每日免费直购礼包 ----------------
def OnGetDayFreeGoldGift(curPlayer):
    ''' 领取每日免费直购礼包
    '''
    isGet = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayFreeGoldGiftState)
    if isGet:
        #GameWorld.DebugLog("已经领取过每日免费直购礼包!")
        return
    rewardItemList = IpyGameDataPY.GetFuncEvalCfg("DayFreeGoldGift", 1)
    if not rewardItemList:
        return
    needSpace = len(rewardItemList)
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
    if needSpace > packSpace:
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayFreeGoldGiftState, 1)
    # 给物品
    isAuctionItem = False
    for itemID, itemCount in rewardItemList:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])
    # 通知客户端
    Sync_DayFreeGoldGiftState(curPlayer)
    return
def Sync_DayFreeGoldGiftState(curPlayer):
    clientPack = ChPyNetSendPack.tagMCDayFreeGoldGiftState()
    clientPack.DayFreeGoldGiftState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayFreeGoldGiftState)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
## ------------------------------------------
## ---------- 创角在线充值特惠 ---------------
def OnGetOnlineRechargeTH(curPlayer):
    ## 领取创角在线充值特惠
    awardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_OnlineRechargeTHAward)
    if awardState:
        #GameWorld.DebugLog("已领取该奖励!")
        return
    # 后端只验证是否有充值其中一个即可,不验证充值时间(充值同步到游戏服务器有时间差)
    canGet = False
    needCtgIDList = IpyGameDataPY.GetFuncEvalCfg("OnlineRechargeTH", 2)
    for ctgID in needCtgIDList:
        if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % ctgID):
            canGet = True
            break
    if not canGet:
        return
    awardItemList = IpyGameDataPY.GetFuncEvalCfg("OnlineRechargeTH", 3)
    if not ItemControler.CheckPackSpaceEnough(curPlayer, awardItemList):
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_OnlineRechargeTHAward, 1)
    for itemID, itemCount, isAuctionItem in awardItemList:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem],
                                     event=["OnlineRechargeTH", False, {}])
    SyncOnlineRechargeTH(curPlayer)
    return
def SyncOnlineRechargeTH(curPlayer):
    clientPack = ChPyNetSendPack.tagMCOnlineRechargeTH()
    clientPack.AwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_OnlineRechargeTHAward)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
## ------------------------------------------