#!/usr/bin/python # -*- coding: utf-8 -*- # @todo: 区服汇总 import CommFunc import ConfigParser import CTGOKSort import mylog import logging #==================== 配置 ==================== cfg = ConfigParser.ConfigParser() cfg.read("../../InterfaceConfig.php") ServerPath = cfg.get("ServerInfo", "ServerPath") # 需要处理的流向名及顺序列表 DRNameList = ["FirstLogin", "CTGOK"] #==================== 配置 ==================== class ValueObj(): def __init__(self): return def getServerSum(argvDict): ## 统计所有玩家充值累加 logging.info("getServerSum %s" % str(argvDict)) startDate = argvDict.get("startDate", "") endDate = argvDict.get("endDate", CommFunc.getCurrentDateStr()) serverSumInfo = {} # 查询中心备份的 if CommFunc.isQueryCenterbak(argvDict): queryCenterBak(startDate, endDate, argvDict) return needQueryCenterbak = CommFunc.loopMainServerDR(cfg, startDate, endDate, argvDict, checkDrFileNeedParseFunc, parseLineFunc, serverSumInfo, drNameList=DRNameList) logging.info("needQueryCenterbak %s" % needQueryCenterbak) if needQueryCenterbak: bakDataInfo = CommFunc.queryBackupCenterDR(cfg, argvDict) logging.info("queryBackupCenterDR OK") if bakDataInfo == None: return serverSumInfoBak = bakDataInfo # 合并数据 for serverIDStr, serverInfoBak in serverSumInfoBak.items(): serverID = int(serverIDStr) if serverID not in serverSumInfo: serverSumInfo[serverID] = serverInfoBak else: serverInfo = serverSumInfo[serverID] serverInfo["FirstLoginTotal"] = serverInfo.get("FirstLoginTotal", 0) + serverInfoBak.get("FirstLoginTotal", 0) CTGOKTotalInfo = serverInfo.get("CTGOKTotal", {}) for payOrderType, orderValue in serverInfoBak.get("CTGOKTotal", {}).items(): CTGOKTotalInfo[str(payOrderType)] = CTGOKTotalInfo.get(str(payOrderType), 0) + orderValue serverInfo["CTGOKTotal"] = CTGOKTotalInfo logging.info("query all data OK") serverIDList = serverSumInfo.keys() serverIDList.sort() logging.info("serverIDList %s" % serverIDList) PayOrderTypeList = eval(CommFunc.getSPConfig(argvDict, "Config", "PayOrderType", "[]")) ctgOKTotalTDNameList, tdStyleInfo = [], {} for payOrderType in PayOrderTypeList: tdName = "CTGOKTotal%s" % payOrderType orderTypeName = CommFunc.getPayOrderTypeName(payOrderType) ctgOKTotalTDNameList.append(tdName) tdStyleInfo[tdName] = {"align":"right", "title":orderTypeName} dataList = [] for serverID in serverIDList: serverInfo = serverSumInfo[serverID] serverInfo["ServerID"] = serverID CTGOKTotalInfo = serverInfo.get("CTGOKTotal", {}) for payOrderType in PayOrderTypeList: tdName = "CTGOKTotal%s" % payOrderType ctgOKTotal = CTGOKTotalInfo.get(str(payOrderType), 0) if payOrderType not in CTGOKSort.PayByMoneyOrderTypeList: ctgOKTotal = CommFunc.coinToY(ctgOKTotal, CommFunc.getPayOrderCoinRate(payOrderType)) serverInfo[tdName] = ctgOKTotal dataList.append(serverInfo) printStr = "" #printStr = "
%s