"; } } 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; }; $server_id = \CommFunc\GetServerIDBySid($_SESSION['server_id']); $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" => $server_id, "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" => $server_id, "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); ?>
本服总创角 | ||
本服总滚服 | ||
滚服次数对应账号数 | ||
总创角 | ||
总滚服 | ||
充值总额 | ||
滚服充值总额 | ||
充值人数 | ||
滚服充值人数 | ||