hxp
2025-06-04 f4a514d5ac952110da846636ecbb9de951eaf3d2
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
#!/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()