<?php
|
include_once "/Common/Logging.php";
|
include_once "/Account/User.php";
|
include_once "/db/DBOper.php";
|
include_once "/language/lang.php";
|
|
function logweb($msg, $showWeb = True)
|
{
|
\Logging\LogInfo($msg);
|
if ($showWeb) {
|
echo date('Y-m-d H:i:s'), $msg, "<br/>";
|
}
|
}
|
|
function ImportServerRoles()
|
{
|
set_time_limit(1800); //暂时设置本脚本执行时间x秒,0不限制
|
ini_set('memory_limit', '2048M'); // 将内存限制设置为256MB
|
header("Content-type: text/html; charset=utf-8");
|
logweb("开始导入区服角色");
|
\DBOper\Find("GameRoles", array(), $findDataList);
|
$batchInsRoles = array();
|
$totalRoleCount = 0;
|
logweb("总账号数:" . count($findDataList));
|
foreach ($findDataList as $findData) {
|
$Channel = $findData["Channel"];
|
$AccountID = $findData["AccountID"];
|
// 计算滚服次数
|
$rollInfo = array();
|
foreach ($findData as $field => $value) {
|
$ServerID = \CommFunc\GetServerIDBySid($field);
|
if ($ServerID <= 0) {
|
continue;
|
}
|
$rollInfo[$field] = array("CreateRoleTime" => $value["CreateRoleTime"]);
|
}
|
//排序 根据 CreateRoleTime 升序排序 SORT_ASC 和 SORT_DESC
|
array_multisort(array_column($rollInfo, 'CreateRoleTime'), SORT_ASC, $rollInfo);
|
$rollCount = 0;
|
foreach ($rollInfo as $field => $info) {
|
$info["RollCount"] = $rollCount;
|
$rollInfo[$field] = $info;
|
$rollCount += 1;
|
}
|
// \Logging\LogInfo("AccountID:" . $AccountID . " rollInfo:" . print_r($rollInfo, true));
|
foreach ($findData as $field => $value) {
|
$ServerID = \CommFunc\GetServerIDBySid($field);
|
if ($ServerID <= 0) {
|
continue;
|
}
|
$roleInfo = array("Channel" => $Channel, "AccountID" => $AccountID, "ServerID" => $ServerID);
|
if ($value["CreateRoleTime"]) {
|
$roleInfo["CreateYMD"] = substr($value["CreateRoleTime"], 0, 10);
|
}
|
if ($rollInfo[$field]) {
|
$roleInfo["RollCount"] = $rollInfo[$field]["RollCount"];
|
} else {
|
$roleInfo["RollCount"] = 0;
|
}
|
$roleInfo = array_merge($roleInfo, $value);
|
|
$key = $Channel . "_s" . $ServerID;
|
if (!array_key_exists($key, $batchInsRoles)) {
|
$batchInsRoles[$key] = array();
|
}
|
$insArray = $batchInsRoles[$key];
|
array_push($insArray, $roleInfo);
|
$batchInsRoles[$key] = $insArray;
|
$totalRoleCount += 1;
|
if ($totalRoleCount % 1000 == 0) {
|
logweb("totalRoleCount:" . $totalRoleCount);
|
}
|
}
|
}
|
logweb("总角色数 totalRoleCount:" . $totalRoleCount);
|
|
if (count($batchInsRoles)) {
|
ksort($batchInsRoles);
|
\DBOper\Remove("ServerRoles", array(), false);
|
$succCount = 0;
|
foreach ($batchInsRoles as $key => $insArray) {
|
if (DBOper\BatchInsert("ServerRoles", $insArray)) {
|
logweb("批量导入区服角色数: " . $key . " count:" . count($insArray));
|
$succCount += count($insArray);
|
} else {
|
logweb("###批量导入区服角色数: " . $key . " count:" . count($insArray));
|
}
|
}
|
logweb("批量导入角色总数: " . $succCount);
|
}
|
logweb("导入区服角色完毕");
|
}
|
|
\Logging\CreateLogging("serverview.php");
|
$Permission = \User\Permission::P_Serverview;
|
|
$spid = $_SESSION['spid'];
|
$UserAccount = $_SESSION['UserAccount'];
|
$user = new \User\User($UserAccount);
|
if (!$user->HavePermission($Permission)) {
|
exit;
|
}
|
|
// 从GameRoles表导入
|
if ($_GET["import"] == 1) {
|
ImportServerRoles();
|
exit;
|
};
|
|
$serverID = $_SESSION['serverID'];
|
$startDate = array_key_exists("startDate", $_POST) ? $_POST["startDate"] : \CommFunc\CalcToStrDateTime("-7 days", "Y-m-d");
|
$endDate = array_key_exists("endDate", $_POST) ? $_POST["endDate"] : date("Y-m-d");
|
|
\DBOper\Find("ServerRoles", array(
|
"Channel" => $spid, "ServerID" => $serverID,
|
"CreateYMD" => array('$lte' => $endDate)
|
), $roleList, array("AccountID" => 1, "CreateYMD" => 1, "RollCount" => 1));
|
|
$roleTotal = count($roleList); // 截止日期总角色数
|
$roleCountInYMD = 0; // 日期内总角色数
|
$rollCountTotal = 0; // 截止日期总滚服数
|
$rollCountInYMD = 0; // 日期内总滚服数
|
$rollAccountIDInfo = array(); // 滚服账号信息 {accountID:滚服次数, ...}
|
$rollCountInfo = array(); // 滚服次数信息 {滚服次数:滚服角色数, ...}
|
foreach ($roleList as $roleInfo) {
|
$AccountID = $roleInfo["AccountID"];
|
$CreateYMD = $roleInfo["CreateYMD"];
|
$RollCount = $roleInfo["RollCount"];
|
|
if ($CreateYMD >= $startDate) {
|
$roleCountInYMD += 1;
|
}
|
if ($RollCount > 0) {
|
$rollCountTotal += 1;
|
if ($CreateYMD >= $startDate) {
|
$rollCountInYMD += 1;
|
}
|
$rollAccountIDInfo[$AccountID] = $RollCount;
|
|
$rollCountInfo["" . $RollCount] = $rollCountInfo["" . $RollCount] ? ($rollCountInfo["" . $RollCount] + 1) : 1;
|
}
|
}
|
|
// 只显示成功的订单; 1-成功;2-失败
|
$match = array(
|
"Channel" => $spid, "ServerID" => $serverID, "State" => 1,
|
"PayTime" => array('$gte' => $startDate . " 00:00:00", '$lte' => $endDate . " 23:59:59")
|
);
|
$ret = \DBOper\Aggregate("PayOrder", array(
|
array(
|
'$match' => $match,
|
),
|
array(
|
'$group' => array(
|
'_id' => array('AccountID' => '$AccountID'),
|
'total' => array('$sum' => '$OrderAmount'),
|
),
|
),
|
), $retInfo);
|
|
$payCount = 0; // 总充值条数
|
$payTotal = 0; // 充值总额
|
$payUserCount = 0; // 充值人数
|
$payTotalRoll = 0; // 滚服充值总额
|
$payUserCountRoll = 0; // 滚服充值人数
|
$ARPPU = 0;
|
if (isset($retInfo)) {
|
$payUserCount = count($retInfo);
|
foreach ($retInfo as $info) {
|
$AccountID = $info["_id"]["AccountID"];
|
$payTotal += floatval($info["total"]);
|
if ($rollAccountIDInfo[$AccountID]) {
|
$payTotalRoll += floatval($info["total"]);
|
$payUserCountRoll += 1;
|
}
|
}
|
if ($payTotal > 0 && $payUserCount > 0) {
|
$ARPPU = round($payTotal / $payUserCount, 2);
|
}
|
}
|
|
$payCount = \DBOper\Count("PayOrder", $match);
|
?>
|
|
<html>
|
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<title><?php echo \Lang\gettext("本服总览"); ?></title>
|
<link rel="stylesheet" type="text/css" href="/css/table.css">
|
<link rel="stylesheet" type="text/css" href="/css/button.css">
|
</head>
|
|
<body>
|
<center>
|
<p><b><?php echo \Lang\gettext("本服总览"); ?></b></P>
|
</center>
|
<hr />
|
<form action="" method="post">
|
<?php echo \Lang\gettext("查询时间"); ?>:
|
<input type="text" name="startDate" id="startDate" onclick="new Calendar().show(this);" readonly value="<?php echo $startDate; ?>" size="8" />
|
~
|
<input type="text" name="endDate" id="endDate" onclick="new Calendar().show(this);" readonly value="<?php echo $endDate; ?>" size="8" />
|
<input type="submit" name="submit" value="<?php echo \Lang\gettext("查询"); ?>" class="button green medium" />
|
</form>
|
<hr />
|
<table width="50%">
|
<caption>【总数据】</caption>
|
<thead>
|
<tr>
|
<th align='center' width='200'></th>
|
<th align='center' width='300'></th>
|
<th align='center' width='100'></th>
|
</tr>
|
</thead>
|
<tr class='trc'>
|
<td align='center'>本服总创角</td>
|
<td align='center'><?php echo $roleTotal ?></td>
|
<td align='center'></td>
|
<tr>
|
<tr class='trc'>
|
<td align='center'>本服总滚服</td>
|
<td align='center'><?php echo $rollCountTotal ?></td>
|
<td align='center'><?php echo $roleTotal ? round($rollCountTotal / $roleTotal * 100, 2) . "%" : "" ?></td>
|
<tr>
|
<tr class='trc'>
|
<td align='center'>滚服次数对应账号数</td>
|
<td align='center'><?php echo json_encode($rollCountInfo) ?></td>
|
<td align='center'></td>
|
<tr>
|
</table>
|
<hr />
|
<table width="50%">
|
<caption>【统计日期内数据】</caption>
|
<thead>
|
<tr>
|
<th align='center' width='200'></th>
|
<th align='center' width='300'></th>
|
<th align='center' width='100'></th>
|
</tr>
|
</thead>
|
<tr class='trc'>
|
<td align='center'>总创角</td>
|
<td align='center'><?php echo $roleCountInYMD ?></td>
|
<td align='center'></td>
|
<tr>
|
<tr class='trc'>
|
<td align='center'>总滚服</td>
|
<td align='center'><?php echo $rollCountInYMD ?></td>
|
<td align='center'><?php echo $roleCountInYMD ? round($rollCountInYMD / $roleCountInYMD * 100, 2) . "%" : "" ?></td>
|
<tr>
|
<tr class='trc'>
|
<td align='center'>充值总额</td>
|
<td align='center'><?php echo $payTotal ?></td>
|
<td align='center'></td>
|
<tr>
|
<tr class='trc'>
|
<td align='center'>滚服充值总额</td>
|
<td align='center'><?php echo $payTotalRoll ?></td>
|
<td align='center'><?php echo $payTotal ? round($payTotalRoll / $payTotal * 100, 2) . "%" : "" ?></td>
|
<tr>
|
<tr class='trc'>
|
<td align='center'>充值人数</td>
|
<td align='center'><?php echo $payUserCount ?></td>
|
<td align='center'></td>
|
<tr>
|
<tr class='trc'>
|
<td align='center'>滚服充值人数</td>
|
<td align='center'><?php echo $payUserCountRoll ?></td>
|
<td align='center'><?php echo $payUserCount ? round($payUserCountRoll / $payUserCount * 100, 2) . "%" : "" ?></td>
|
<tr>
|
</table>
|
</body>
|
|
<script type='text/javascript' src='/language/gettext.js'></script>
|
<script type='text/javascript' src="/js/calendar.js"></script>
|
<script type='text/javascript' src="/js/common.js"></script>
|
<script type="text/javascript">
|
</script>
|
|
</html>
|