#!/usr/bin/python
|
# -*- coding: utf-8 -*-
|
# @todo: 玩家列表
|
|
import CommFunc
|
import DBOperate
|
import ConfigParser
|
|
import json
|
import mylog
|
import logging
|
|
cfg = ConfigParser.ConfigParser()
|
cfg.read("../../InterfaceConfig.php")
|
ServerPath = cfg.get("ServerInfo", "ServerPath")
|
|
|
def queryPlayerList(argvDict):
|
|
dboper = DBOperate.DBOper(ServerPath)
|
col = dboper.db["tagDBPlayer"]
|
TotalCount = col.count()
|
spec = {}
|
fields = {'_id':0, "AccID":1, "PlayerName":1, "PlayerID":1, "LV":1, "CreateRoleTime":1, "ChangeCoinPointTotal":1, "VIPLv":1}
|
Ret = col.find(spec, fields).sort([("LV", -1)]).limit(1000)
|
|
retData = []
|
accIDList = []
|
for dataInfo in Ret:
|
retData.append(dataInfo)
|
accIDList.append(dataInfo["AccID"])
|
|
col = dboper.db["tagDSAccount"]
|
spec = {"ACCID":{"$in":accIDList}}
|
fields = {'_id':0, "ACCID":1, "ClientVersion":1}
|
accRet = col.find(spec, fields)
|
# 关闭
|
dboper.close()
|
|
accountInfo = {} # 账号表的关联信息
|
for ad in accRet:
|
accID = ad.pop("ACCID", "")
|
if accID:
|
accountInfo[accID] = ad
|
|
# 合并数据
|
for dataInfo in retData:
|
accID = dataInfo["AccID"]
|
dataInfo.update(accountInfo.get(accID, {}))
|
|
ret = {"OK":1, "Data":retData, "TotalCount":TotalCount}
|
logging.info("ret:%s" % ret)
|
print json.dumps(ret, ensure_ascii=False, default=lambda obj: obj.__dict__)
|
return
|
|
def main():
|
CommFunc.setdefaultencoding()
|
argvDict = CommFunc.parse_args()
|
mylog.InitMyLog(argvDict.get("eventType", ""))
|
queryPlayerList(argvDict)
|
return
|
|
if __name__ == "__main__":
|
try:
|
main()
|
except:
|
CommFunc.printExceptionError()
|