hxp
2025-05-30 efc705c4fb10577ff83e09273c90a6ead41164bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package GMT_CTG
# GMÃüÁîCTG
#
# @author whx
# @date 2012-08-27 13:59
# @version 1.0
#
# @note
#---------------------------------------------------------------------
"""Version = 2012-08-27 13:59"""
#---------------------------------------------------------------------
#µ¼Èë
import GMCommon
from MangoDBCommon import fix_incomingText
import GameWorld
from Player import (PlayerControl, PlayerCoin)
import IpyGameDataPY
import IPY_GameWorld
import ShareDefine
import DataRecordPack
import ChConfig
from PyMongoDB.GMToolLogicProcess import GMToolPyInterface
import json
#---------------------------------------------------------------------
#È«¾Ö±äÁ¿
 
#---------------------------------------------------------------------
 
## ÊÕµ½gmÃüÁîÖ´ÐÐ
# @param gmCmdDict:gmÃüÁî×Öµä
# @return None 
def OnExec(gmCmdDict):
    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
    Result = GMCommon.Def_ParamErr
    errorMsg = ""
    
    if queryType not in [GMCommon.Def_GMKey_PlayerAccID, GMCommon.Def_GMKey_PlayerName]:
        return Result, errorMsg
    
    if len(playerFind) <= 0:
        return Result, errorMsg
    
    curPlayer = None
    if queryType == GMCommon.Def_GMKey_PlayerName:
        curPlayer = GameWorld.GetPlayerManager().FindPlayerByName(playerFind)
    else:
        curPlayer = GameWorld.GetPlayerManager().FindPlayerByAccID(playerFind)
    
    if not curPlayer or curPlayer.IsEmpty():
        Result = GMCommon.Def_Success
        # ²»ÔÚÏß
        return Result, errorMsg
 
    playerID = curPlayer.GetPlayerID()
    
    Result = GMCommon.Def_Unknow
 
    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)
    
 
    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
    
    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
    
    goldAfter = PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money)
    changeCoinPointAfter = curPlayer.GetChangeCoinPointTotal()
    bourseMoneyAfter = PlayerControl.GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney)
    
    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_CTG', resultDict)
    
    return Result, resultDict