hxp
9 小时以前 dc0b92c1e2fe9f3d24c183b325dad54d088735c1
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_CTG.py
@@ -1,83 +1,91 @@
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package GMT_CTG
# GM命令CTG
##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_CTG
#
# @author whx
# @date 2012-08-27 13:59
# @todo:GM工具命令 - CTG充值
# @author hxp
# @date 2025-06-03
# @version 1.0
#
# @note
#---------------------------------------------------------------------
"""Version = 2012-08-27 13:59"""
#---------------------------------------------------------------------
#导入
import GMCommon
from MangoDBCommon import fix_incomingText
#---------------------------------------------------------------------
#全局变量
# 详细描述: GM工具命令 - CTG充值
#
#-------------------------------------------------------------------------------
#"""Version = 2025-06-03 14:00"""
#-------------------------------------------------------------------------------
#---------------------------------------------------------------------
import GMCommon
import GameWorld
from Player import (PlayerControl, PlayerCoin)
import IpyGameDataPY
import IPY_GameWorld
import DataRecordPack
import ShareDefine
import ChConfig
## 收到gm命令执行
# @param gmCmdDict:gm命令字典
# @return None 
def OnExec(gmCmdDict):
    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
    #value = gmCmdDict.get('value', '')
    
    if queryType not in [GMCommon.Def_GMKey_PlayerAccID, GMCommon.Def_GMKey_PlayerName]:
        return GMCommon.Def_ParamErr, ''
    errorMsg = ""
    from GMToolLogicProcess import  ProjSpecialProcess
    Result, curPlayer = ProjSpecialProcess.GMCmdPlayerValidation(gmCmdDict)
    if Result != GMCommon.Def_Success:
        return Result, errorMsg
    if not curPlayer:
        return Result, "玩家不在线,上线后处理"
    
    if len(playerFind) <= 0:
        return GMCommon.Def_ParamErr, ''
    # 玩家在线,可处理
    playerID = curPlayer.GetPlayerID()
    Result = GMCommon.Def_Unknow
    GMT_Name = gmCmdDict.get(GMCommon.Def_GMKey_Type, '')
    
    return GMCommon.Def_DoQueryUserDB, ''
    value = gmCmdDict.get('value', '')
    appID = gmCmdDict.get('appID', '')
    isAddBourseMoney = GameWorld.ToIntDef(gmCmdDict.get('isAddBourseMoney', ''), 0)
    
    goldBefore = PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money)
    changeCoinPointBefore = curPlayer.GetChangeCoinPointTotal()
    bourseMoneyBefore = PlayerControl.GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney)
    
## 查询logdb返回
# @param logdb:logdb
# @param data:传入的信息
# @param gmCmdDict:gm命令字典
# @return None
def LogDBResponse(logdb, data, gmCmdDict):
    if data == "":
        return GMCommon.Def_DoQueryUserDB, ''
    # 修改为离线可用
    return GMCommon.Def_SendToGameServer, ''
#    if GMCommon.GetPlayerOnLineByAccID(logdb, data):
#        return GMCommon.Def_SendToGameServer, ''
#
#    return GMCommon.Def_PlayerOfLine, ''
## 查询userdb返回
# @param userdb:userdb
# @param data:传入的信息
# @param gmCmdDict:gm命令字典
# @return None
def UserDBResponse(userdb, data, gmCmdDict):
    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
    orderInfoIpyData = None
    if appID:
        orderInfoIpyData = IpyGameDataPY.GetIpyGameDataNotLog("OrderInfo", value, appID)
        if not orderInfoIpyData:
            Result = GMCommon.Def_ParamErr
            errorMsg = "Can not found the orderInfo(%s) and appID(%s)!" % (value, appID)
    if errorMsg:
        return Result, errorMsg
    
    playerAccID = ""
    # 玩家姓名
    if queryType == GMCommon.Def_GMKey_PlayerName:
        playerAccID = GMCommon.GetPlayerAccID(userdb, {'PlayerName':fix_incomingText(playerFind), 'IsDeleted':0})
    orderRMB = GameWorld.ToNumDef(value, None)
    if not orderInfoIpyData and orderRMB != None:
        if PlayerCoin.PlayerCoinToGoldEx(curPlayer, orderRMB, ChConfig.Def_GiveMoney_GMTCTG, isAddBourseMoney):
            Result = GMCommon.Def_Success
        else:
            errorMsg = "order error! value(%s)" % (value)
    else:
        orderInfo = value
        if PlayerCoin.DoGMCTG(curPlayer, orderInfo, appID, isAddBourseMoney, ChConfig.Def_GiveMoney_GMTCTG):
            Result = GMCommon.Def_Success
        else:
            errorMsg = "orderInfo error! appID(%s), value(%s)" % (appID, value)
    if Result != GMCommon.Def_Success:
        return Result, errorMsg
    
    elif queryType == GMCommon.Def_GMKey_PlayerAccID:
        playerAccID = GMCommon.GetPlayerAccID(userdb, {'AccID':fix_incomingText(playerFind), 'IsDeleted':0})
    goldAfter = PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money)
    changeCoinPointAfter = curPlayer.GetChangeCoinPointTotal()
    bourseMoneyAfter = PlayerControl.GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney)
    
    if playerAccID == '':
        return GMCommon.Def_NoTag, ''
    return GMCommon.Def_DoQueryLogDB, playerAccID
    resultDict = {"value":value, "appID":appID, "isAddBourseMoney":isAddBourseMoney, "Result":Result,
                  "gold":[goldBefore, goldAfter], "changeCoinPoint":[changeCoinPointBefore, changeCoinPointAfter],
                  "bourseMoney":[bourseMoneyBefore, bourseMoneyAfter]}
    #流向 增加金额记录
    DataRecordPack.DR_ToolGMOperate(playerID, curPlayer.GetPlayerName(), curPlayer.GetAccID(), GMT_Name, resultDict)
    return Result, resultDict