#!/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, ''
|
|
|