hxp
2026-01-12 c01b1a3fef2d672873754103d4dabbdd1ba39ee3
1111 【后台】增加全服主线任务、全服主线关卡;
2个文件已添加
2个文件已修改
342 ■■■■■ 已修改文件
Account/User.php 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
index.php 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverrep/allplayerMainpass.php 168 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverrep/allplayerTask.php 168 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Account/User.php
@@ -29,6 +29,8 @@
                    Permission::P_REP_FirstLoginFirstPayCnt => array("Name" => \Lang\gettext("首登首充人数")),
                    Permission::P_REP_XPayPaycnt => array("Name" => \Lang\gettext("购买X礼包再次付费人数")),
                    Permission::P_All_PlayerLV => array("Name" => \Lang\gettext("全服等级分布")),
                    Permission::P_All_PlayerTask => array("Name" => \Lang\gettext("全服主线任务")),
                    Permission::P_All_PlayerMainPass => array("Name" => \Lang\gettext("全服主线关卡")),
                )
            ),
            array(
@@ -225,6 +227,8 @@
    const P_REP_FirstLoginFirstPayCnt = "P_REP_FirstLoginFirstPayCnt";
    const P_REP_XPayPaycnt = "P_REP_XPayPaycnt";
    const P_All_PlayerLV = "P_All_PlayerLV";
    const P_All_PlayerTask = "P_All_PlayerTask";
    const P_All_PlayerMainPass = "P_All_PlayerMainPass";
    //服务器
    const P_Online = "P_Online";
index.php
@@ -46,6 +46,8 @@
        array(\User\Permission::P_REP_FirstLoginFirstPayCnt, "serverrep/firstLoginFirstPayCnt.php", \Lang\gettext("首登首充人数")),
        array(\User\Permission::P_REP_FirstLoginFirstPayCnt, "serverrep/xpaypaycnt.php", \Lang\gettext("购买X礼包再次付费人数")),
        array(\User\Permission::P_All_PlayerLV, "serverrep/allplayerlv.php", \Lang\gettext("全服等级分布")),
        array(\User\Permission::P_All_PlayerTask, "serverrep/allplayerTask.php", \Lang\gettext("全服主线任务")),
        array(\User\Permission::P_All_PlayerMainPass, "serverrep/allplayerMainpass.php", \Lang\gettext("全服主线关卡")),
    ),
    \Lang\gettext("服务器") => array(
serverrep/allplayerMainpass.php
New file
@@ -0,0 +1,168 @@
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
include_once "/serverrep/report.php";
\Logging\CreateLogging("rep.allplayerMainpass.php");
$Permission = \User\Permission::P_All_PlayerMainPass;
$alertMsg = "";
$channel = $_SESSION['spid'];
$UserAccount = $_SESSION['UserAccount'];
$user = new \User\User($UserAccount);
if (!$user->HavePermission($Permission)) {
    exit;
}
// $startDate = array_key_exists("startDate", $_POST) ? $_POST["startDate"] : date("Y-m-d", strtotime("-7 days"));
// $endDate = array_key_exists("endDate", $_POST) ? $_POST["endDate"] : date("Y-m-d");
$match = array("Channel" => $channel);
\CommFunc\MatchServerIDCond($match, $serverIDCondArray);
\Logging\LogInfo("match:" . print_r($match, true));
$showByServerID = $_POST["showByServerID"];
$_id = array('MainPassLVID' => '$MainPassLVID');
if ($showByServerID) {
    $_id = array('ServerID' => '$ServerID', 'MainPassLVID' => '$MainPassLVID');
}
$ret = \DBOper\Aggregate("ServerRoles", array(
    array(
        '$match' => $match,
    ),
    array(
        '$group' => array(
            '_id' => $_id,
            'count' => array('$sum' => 1),
        )
    )
), $retInfo);
// \Logging\LogInfo("retInfo:" . print_r($retInfo, true));
$serverDataCountInfo = array();
foreach ($retInfo as $info) {
    $_idInfo = $info["_id"];
    $key = $showByServerID ? $_idInfo["ServerID"] . "" : "0";
    $MainPassLVID = $_idInfo["MainPassLVID"];
    $count = $info["count"];
    if (!$serverDataCountInfo[$key]) {
        $serverDataCountInfo[$key] = array();
    }
    $lvCountInfo = $serverDataCountInfo[$key];
    $lvCountInfo[$MainPassLVID . ""] = $count;
    $serverDataCountInfo[$key] = $lvCountInfo;
}
// \Logging\LogInfo("serverDataCountInfo:" . print_r($serverDataCountInfo, true));
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo \Lang\gettext("全服主线关卡"); ?></title>
    <link rel="gettext" type="application/x-po" href="../language/<?php echo \Lang\getLang(); ?>/LC_MESSAGES/<?php echo \Lang\getjspodomain(); ?>.po" />
</head>
<body>
    <center>
        <p><b><?php echo \Lang\gettext("全服主线关卡"); ?></b></P>
    </center>
    <form method="post">
        &nbsp;&nbsp;<input type="button" value="添加服务器ID条件" onclick="AddServerIDCondition('', '', '')" />
        &nbsp;&nbsp;<input type="button" value="重置条件" onclick="ResetServerIDCondition()" />
        &nbsp;&nbsp;
        <input type="checkbox" name="showByServerID" id="showByServerID" <?php echo $showByServerID == "on" ? "checked" : ""; ?> />区服独立显示
        &nbsp;&nbsp;<input type="submit" value="<?php echo \Lang\gettext("查询"); ?>" />
        &nbsp;&nbsp;<input type="button" value="<?php echo \Lang\gettext("复制数据"); ?>" onclick="onCopyData()" />
        <div id="ServerIDCondition"></div>
        <hr />
        <div id="MyChart"></div>
    </form>
</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' src="/js/chart.min.js"></script>
<script type="text/javascript">
    var copydata = "";
    window.onload = function() {
        LoadServerIDCondition('<?php echo json_encode($serverIDCondArray); ?>');
        var showByServerID = <?php echo json_encode($showByServerID); ?>;
        var serverDataCountInfo = JSON.parse('<?php echo json_encode($serverDataCountInfo); ?>');
        // console.log("showByServerID", showByServerID);
        // console.log("serverDataCountInfo", serverDataCountInfo);
        var serverIDList = [];
        for (const serverID in serverDataCountInfo) {
            serverIDList.push(parseInt(serverID));
        }
        serverIDList.sort((a, b) => a - b); // 按区服顺序展示
        // console.log("serverIDList", serverIDList);
        copydata += "<table><tr>";
        for (let index = 0; index < serverIDList.length; index++) {
            const serverID = serverIDList[index];
            const lvCountInfo = serverDataCountInfo[serverID + ""];
            // console.log("serverID", serverID, lvCountInfo);
            let xLabels = [];
            let yDatas = [];
            let totalCnt = 0;
            for (const lv in lvCountInfo) {
                const lvCnt = lvCountInfo[lv];
                xLabels.push(lv);
                yDatas.push(lvCnt);
                totalCnt += lvCnt;
            }
            let datas = {
                "人数": yDatas
            };
            let chartID = "myChart" + serverID; // 图表ID,关联html中的元素ID
            let insHtml = "";
            insHtml += "<canvas id=\"" + chartID + "\" ></canvas>"; // 插入画布
            insHtml += "<hr />";
            document.getElementById("MyChart").insertAdjacentHTML("beforeEnd", insHtml);
            let chartText = serverID == 0 ? "全服" : "s" + serverID; // 图表总标题
            chartText += " 总人数: " + totalCnt;
            let xText = "关卡ID"; // x轴文本, 如等级
            let yText = "人数"; // y轴文本, 如人数
            // (图标ID, 图标标题, x轴文本, y轴文本, x轴刻度文本列表, y轴数据列表, y轴数据标题列表)
            drawChart_Line(chartID, chartText, xText, yText, xLabels, Object.values(datas), Object.keys(datas));
            // 复制数据
            copydata += "<td>";
            copydata += "<table>";
            copydata += "<tr><td>服务器: " + chartText + "</td></tr>";
            copydata += "<tr><td>关卡ID</td><td>人数</td></tr>";
            for (let index = 0; index < xLabels.length; index++) {
                const lv = xLabels[index];
                const playerCount = yDatas[index];
                copydata += "<tr><td>" + lv + "</td><td>" + playerCount + "</td></tr>";
            }
            copydata += "<tr></tr>";
            copydata += "</table>";
            copydata += "</td>";
        }
        copydata += "</tr></table>";
    }
    function onCopyData() {
        if (!copydata) {
            alert("没有数据");
            return
        }
        copyToClipboard(copydata);
        alert("表格复制成功,可直接粘贴到Excel工作表!");
    }
</script>
</html>
serverrep/allplayerTask.php
New file
@@ -0,0 +1,168 @@
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
include_once "/serverrep/report.php";
\Logging\CreateLogging("rep.allplayerTask.php");
$Permission = \User\Permission::P_All_PlayerTask;
$alertMsg = "";
$channel = $_SESSION['spid'];
$UserAccount = $_SESSION['UserAccount'];
$user = new \User\User($UserAccount);
if (!$user->HavePermission($Permission)) {
    exit;
}
// $startDate = array_key_exists("startDate", $_POST) ? $_POST["startDate"] : date("Y-m-d", strtotime("-7 days"));
// $endDate = array_key_exists("endDate", $_POST) ? $_POST["endDate"] : date("Y-m-d");
$match = array("Channel" => $channel);
\CommFunc\MatchServerIDCond($match, $serverIDCondArray);
\Logging\LogInfo("match:" . print_r($match, true));
$showByServerID = $_POST["showByServerID"];
$_id = array('MainTaskID' => '$MainTaskID');
if ($showByServerID) {
    $_id = array('ServerID' => '$ServerID', 'MainTaskID' => '$MainTaskID');
}
$ret = \DBOper\Aggregate("ServerRoles", array(
    array(
        '$match' => $match,
    ),
    array(
        '$group' => array(
            '_id' => $_id,
            'count' => array('$sum' => 1),
        )
    )
), $retInfo);
// \Logging\LogInfo("retInfo:" . print_r($retInfo, true));
$serverDataCountInfo = array();
foreach ($retInfo as $info) {
    $_idInfo = $info["_id"];
    $key = $showByServerID ? $_idInfo["ServerID"] . "" : "0";
    $MainTaskID = $_idInfo["MainTaskID"];
    $count = $info["count"];
    if (!$serverDataCountInfo[$key]) {
        $serverDataCountInfo[$key] = array();
    }
    $lvCountInfo = $serverDataCountInfo[$key];
    $lvCountInfo[$MainTaskID . ""] = $count;
    $serverDataCountInfo[$key] = $lvCountInfo;
}
// \Logging\LogInfo("serverDataCountInfo:" . print_r($serverDataCountInfo, true));
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo \Lang\gettext("全服主线任务"); ?></title>
    <link rel="gettext" type="application/x-po" href="../language/<?php echo \Lang\getLang(); ?>/LC_MESSAGES/<?php echo \Lang\getjspodomain(); ?>.po" />
</head>
<body>
    <center>
        <p><b><?php echo \Lang\gettext("全服主线任务"); ?></b></P>
    </center>
    <form method="post">
        &nbsp;&nbsp;<input type="button" value="添加服务器ID条件" onclick="AddServerIDCondition('', '', '')" />
        &nbsp;&nbsp;<input type="button" value="重置条件" onclick="ResetServerIDCondition()" />
        &nbsp;&nbsp;
        <input type="checkbox" name="showByServerID" id="showByServerID" <?php echo $showByServerID == "on" ? "checked" : ""; ?> />区服独立显示
        &nbsp;&nbsp;<input type="submit" value="<?php echo \Lang\gettext("查询"); ?>" />
        &nbsp;&nbsp;<input type="button" value="<?php echo \Lang\gettext("复制数据"); ?>" onclick="onCopyData()" />
        <div id="ServerIDCondition"></div>
        <hr />
        <div id="MyChart"></div>
    </form>
</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' src="/js/chart.min.js"></script>
<script type="text/javascript">
    var copydata = "";
    window.onload = function() {
        LoadServerIDCondition('<?php echo json_encode($serverIDCondArray); ?>');
        var showByServerID = <?php echo json_encode($showByServerID); ?>;
        var serverDataCountInfo = JSON.parse('<?php echo json_encode($serverDataCountInfo); ?>');
        // console.log("showByServerID", showByServerID);
        // console.log("serverDataCountInfo", serverDataCountInfo);
        var serverIDList = [];
        for (const serverID in serverDataCountInfo) {
            serverIDList.push(parseInt(serverID));
        }
        serverIDList.sort((a, b) => a - b); // 按区服顺序展示
        // console.log("serverIDList", serverIDList);
        copydata += "<table><tr>";
        for (let index = 0; index < serverIDList.length; index++) {
            const serverID = serverIDList[index];
            const lvCountInfo = serverDataCountInfo[serverID + ""];
            // console.log("serverID", serverID, lvCountInfo);
            let xLabels = [];
            let yDatas = [];
            let totalCnt = 0;
            for (const lv in lvCountInfo) {
                const lvCnt = lvCountInfo[lv];
                xLabels.push(lv);
                yDatas.push(lvCnt);
                totalCnt += lvCnt;
            }
            let datas = {
                "人数": yDatas
            };
            let chartID = "myChart" + serverID; // 图表ID,关联html中的元素ID
            let insHtml = "";
            insHtml += "<canvas id=\"" + chartID + "\" ></canvas>"; // 插入画布
            insHtml += "<hr />";
            document.getElementById("MyChart").insertAdjacentHTML("beforeEnd", insHtml);
            let chartText = serverID == 0 ? "全服" : "s" + serverID; // 图表总标题
            chartText += " 总人数: " + totalCnt;
            let xText = "任务ID"; // x轴文本, 如等级
            let yText = "人数"; // y轴文本, 如人数
            // (图标ID, 图标标题, x轴文本, y轴文本, x轴刻度文本列表, y轴数据列表, y轴数据标题列表)
            drawChart_Line(chartID, chartText, xText, yText, xLabels, Object.values(datas), Object.keys(datas));
            // 复制数据
            copydata += "<td>";
            copydata += "<table>";
            copydata += "<tr><td>服务器: " + chartText + "</td></tr>";
            copydata += "<tr><td>任务ID</td><td>人数</td></tr>";
            for (let index = 0; index < xLabels.length; index++) {
                const lv = xLabels[index];
                const playerCount = yDatas[index];
                copydata += "<tr><td>" + lv + "</td><td>" + playerCount + "</td></tr>";
            }
            copydata += "<tr></tr>";
            copydata += "</table>";
            copydata += "</td>";
        }
        copydata += "</tr></table>";
    }
    function onCopyData() {
        if (!copydata) {
            alert("没有数据");
            return
        }
        copyToClipboard(copydata);
        alert("表格复制成功,可直接粘贴到Excel工作表!");
    }
</script>
</html>