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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @todo: VIP等级信息
 
import CommFunc
import DBOperate
import ConfigParser
 
import time
import mylog
import logging
 
cfg = ConfigParser.ConfigParser()
cfg.read("../../InterfaceConfig.php")
ServerPath = cfg.get("ServerInfo", "ServerPath")
 
class CrossPlayer():
    
    def __init__(self):
        self.playerLV = 0
        self.fightPower = 0
        return
 
def getVIPLVInfo(argvDict):
    
    gteVIPLV = CommFunc.toInt(argvDict.get("gteVIPLV"), 1)
    topLimitCount = CommFunc.toInt(argvDict.get("topLimitCount"), 3)
    dboper = DBOperate.DBOper(ServerPath)
    col = dboper.db["tagDBPlayer"]
    spec = {"VIPLv":{"$gte":1}}
    fields = {'_id':0, "AccID":1, "PlayerName":1, "ExAttr9":1, "VIPLv":1}
    findRet = col.find(spec, fields).sort([("VIPLv", -1), ("ExAttr9", 1)])
    
    vipPlayerCountTotal = 0
    drList = []
    vipLVCountDict = {}
    for docInfo in findRet:
        #AccID = docInfo["AccID"]
        #PlayerName = docInfo["PlayerName"]
        VIPLv = docInfo["VIPLv"]
        ExAttr9 = docInfo["ExAttr9"]
        vipLVCountDict[VIPLv] = vipLVCountDict.get(VIPLv, 0) + 1
        vipPlayerCountTotal += 1
        
        if VIPLv < gteVIPLV:
            continue
        
        if topLimitCount <= 0:
            continue
        
        docInfo["ExAttr9"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ExAttr9)) if ExAttr9 else ""
        drList.append(docInfo)
        topLimitCount -= 1
        
    # 关闭
    dboper.close()
    
    printStr = ""
    
    vipLVList = vipLVCountDict.keys()
    vipLVList.sort(reverse=True)
    printStr += "%s: %s人<br/>" % (_(u"VIP等级人数汇总"), vipPlayerCountTotal)
    for vipLV in vipLVList:
        printStr += "VIP%s - %s人 , " % (vipLV, vipLVCountDict[vipLV])
    printStr += "<br/>"
    
    # 表格输出
    printStr += CommFunc.editTableHtml(drList, ["AccID", "PlayerName", "VIPLv", "ExAttr9"], _(u"编号"),
                                       styleInfo={"AccID":{"align":"right", "title":_(u"账号")},
                                                  "PlayerName":{"align":"right", "title":_(u"玩家名")},
                                                  "ExAttr9":{"align":"right", "title":_(u"提升VIP等级时间")},
                                                  })
    
    # 只会返回最后一个print的内容
    print printStr
    return
 
def main():
    CommFunc.setdefaultencoding()
    argvDict = CommFunc.parse_args()
    mylog.InitMyLog(argvDict.get("eventType", ""))
    CommFunc.gettextInstall(argvDict.get("lang", ""))
    getVIPLVInfo(argvDict)
    return
 
if __name__ == "__main__":
    try:
        main()
    except:
        CommFunc.printExceptionError()