hxp
2018-08-10 bf6eb250654cbb2b11284ef7642f7ca1f1826b20
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
113
114
115
116
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package GMT_SendGMMail
# ·¢ËÍGMÓʼþ
#
# @author whx
# @date 2012-07-16
# @version 1.1
#
# @note
# @change: "2012-07-30 11:30" wdb GM»Ø¸´Ï¸»¯£¬´úÂëÓÅ»¯
#---------------------------------------------------------------------
"""Version = 2012-07-30 11:30"""
#---------------------------------------------------------------------
#µ¼Èë
import GMCommon
from MangoDBCommon import (fix_incomingText, fix_outgoingText)
from Collections import DataServerPlayerData
from Common import(mylog, CommFuncEx)
from Collections.CollectionDefine import *
import uuid
#---------------------------------------------------------------------
#È«¾Ö±äÁ¿
 
#---------------------------------------------------------------------
 
## ÊÕµ½gmÃüÁîÖ´ÐÐ
# @param gmCmdDict:gmÃüÁî×Öµä
# @return None 
def OnExec(gmCmdDict):
    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, "")  #Õ˺Żò½ÇÉ«Ãû
    
    if playerFind == "":
        return GMCommon.Def_ParamErr, ''               
 
    # »Ø¸´gm²ÎÊý´íÎó
    return GMCommon.Def_DoQueryUserDB, ''
 
    
## ²éѯlogdb·µ»Ø
# @param logdb:logdb
# @param data:´«ÈëµÄÐÅÏ¢
# @param gmCmdDict:gmÃüÁî×Öµä
# @return None 
def LogDBResponse(logdb, data, gmCmdDict):       
    return GMCommon.Def_DoQueryUserDB, ''
 
 
## ²éѯuserdb·µ»Ø
# @param userdb:userdb
# @param data:´«ÈëµÄÐÅÏ¢
# @param gmCmdDict:gmÃüÁî×Öµä
# @return None 
def UserDBResponse(userdb, data, gmCmdDict):
    sendType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, "")  #Õ˺Żò½ÇÉ«Ãû
    mailTitle = gmCmdDict.get("mailTitle", "")  #±êÌâ
    mailContent = gmCmdDict.get("content", "")   #ÄÚÈÝ
    
    #³¤¶È¹ý³¤
    if len(mailTitle) > 15 or len(mailContent) > 402:
        return GMCommon.Def_MsgMaxLenLimit, ''
    
    playerID = 0
    dbCollect = userdb[UCN_DBPlayer]
    
    if sendType == "accID":
        queryName = "AccID"
    
    elif sendType == "playerName":
        queryName = "PlayerName"
        
    else:
        return GMCommon.Def_NoTag, ''
    
    coll = dbCollect.find({queryName:fix_incomingText(playerFind)})
    
    if coll.count() <= 0:
        # »Ø¸´£¬Î´ÕÒµ½Íæ¼Ò
        return GMCommon.Def_NoTag, ''
    
    playerID = coll[0].get('PlayerID', 0)
    playerAccID = fix_outgoingText(coll[0].get('AccID', ''))
    
    if playerID <= 0 or len(playerAccID) <= 0:
        return GMCommon.Def_NoTag, ''
    
    con = userdb[UCN_DBMailList]
    doc = DataServerPlayerData.tagDBMailList()
    doc.SenderID = 0   #gm·¢¼þÕßΪ0
    doc.ReceverID = playerID
    doc.MailID = str(uuid.uuid1())
    doc.MailType = 3   #gmÓʼþÀàÐÍΪ3
    doc.SenderName = ''
    doc.Title = mailTitle
    doc.LetterType = 0
    doc.Money = 0
    doc.ExistTime = 0
    doc.ContentLen = len(mailContent)
    doc.Content = mailContent
    doc.TitleUseSysMessage = 1
    doc.ContentUseSysMessage = 1
    
    if not doc.adoInsert(con):
        return GMCommon.Def_InsertFail, ''
    
    # ¼Ç¼Á÷Ïò
    dataDic = {"PlayerID":playerID, 'AccID':playerAccID}
    
    GMCommon.SendEventPack(gmCmdDict.get(GMCommon.Def_GMKey_Type, ''), dataDic, str(gmCmdDict)) 
    return GMCommon.Def_SendToGameServer, ''