10162 后台优化(增加报表:首登首充人数、购买X礼包再付人数;)
4个文件已修改
2个文件已添加
333 ■■■■■ 已修改文件
Account/User.php 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
index.php 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverrep/ImportAccountLoginpay.php 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverrep/firstLoginFirstPayCnt.php 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverrep/report.php 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverrep/xpaypaycnt.php 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Account/User.php
@@ -20,12 +20,14 @@
        $PermissionModules = array(
            array(
                "ModuleID" => "ServerRep",
                "Name" => \Lang\gettext("报表"),
                "Name" => \Lang\gettext("全服报表"),
                "PList" => array(
                    Permission::P_REP_AllView => array("Name" => \Lang\gettext("全服总览")),
                    Permission::P_REP_DailyUser => array("Name" => \Lang\gettext("全服每日用户")),
                    Permission::P_REP_KeepLogin => array("Name" => \Lang\gettext("全服留存")),
                    Permission::P_REP_LTV => array("Name" => \Lang\gettext("全服LTV")),
                    Permission::P_REP_FirstLoginFirstPayCnt => array("Name" => \Lang\gettext("首登首充人数")),
                    Permission::P_REP_XPayPaycnt => array("Name" => \Lang\gettext("购买X礼包再付人数")),
                )
            ),
            array(
@@ -210,11 +212,13 @@
    const GroupAdmin = "admin";
    const P_System = "P_System";
    //报表
    //全服报表
    const P_REP_AllView = "P_REP_AllView";
    const P_REP_DailyUser = "P_REP_DailyUser";
    const P_REP_KeepLogin = "P_REP_KeepLogin";
    const P_REP_LTV = "P_REP_LTV";
    const P_REP_FirstLoginFirstPayCnt = "P_REP_FirstLoginFirstPayCnt";
    const P_REP_XPayPaycnt = "P_REP_XPayPaycnt";
    //服务器
    const P_Online = "P_Online";
index.php
@@ -38,11 +38,13 @@
\Logging\LogInfo("权限表: " . print_r($permissions, true));
$gmtMenu = array(
    \Lang\gettext("报表") => array(
    \Lang\gettext("全服报表") => array(
        array(\User\Permission::P_REP_AllView, "serverrep/allview.php", \Lang\gettext("全服总览")),
        array(\User\Permission::P_REP_DailyUser, "serverrep/dailyuser.php", \Lang\gettext("全服每日用户")),
        array(\User\Permission::P_REP_KeepLogin, "serverrep/keeplogin.php", \Lang\gettext("全服留存")),
        array(\User\Permission::P_REP_LTV, "serverrep/ltv.php", \Lang\gettext("全服LTV")),
        array(\User\Permission::P_REP_FirstLoginFirstPayCnt, "serverrep/firstLoginFirstPayCnt.php", \Lang\gettext("首登首充人数")),
        array(\User\Permission::P_REP_FirstLoginFirstPayCnt, "serverrep/xpaypaycnt.php", \Lang\gettext("购买X礼包再付人数")),
    ),
    \Lang\gettext("服务器") => array(
serverrep/ImportAccountLoginpay.php
@@ -64,11 +64,20 @@
        logweb("eventYMDOK:" . $eventYMDOK);
    }
    \Report\CheckAndExportDailyReport($Channel);
    logweb("开始导出留存报表:" . $Channel);
    logweb("开始导出首登首充报表:" . $Channel);
    \Report\CheckAndExportFirstKeepReport($Channel);
}
if ($opt == "keep") {
    logweb("开始导出留存报表:" . $Channel);
if ($opt == "refirst") {
    logweb("do refirst");
    $AccountFirstLoginReportOK = \DBOper\Remove("AccountFirstLoginReport", array("Channel" => $Channel));
    $AccountFirstPayReportOK = \DBOper\Remove("AccountFirstPayReport", array("Channel" => $Channel));
    $eventYMDOK = \DBOper\Remove("ServerEvent", array("Key" => "FirstKeepReportYMD_" . $Channel));
    logweb("AccountFirstLoginReportOK:" . $AccountFirstLoginReportOK);
    logweb("AccountFirstPayReportOK:" . $AccountFirstPayReportOK);
    logweb("eventYMDOK:" . $eventYMDOK);
}
if ($opt == "first" || $opt == "refirst") {
    logweb("开始导出首登首充报表:" . $Channel);
    \Report\CheckAndExportFirstKeepReport($Channel);
}
logweb("处理完毕!");
serverrep/firstLoginFirstPayCnt.php
New file
@@ -0,0 +1,116 @@
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
include_once "/serverrep/report.php";
\Logging\CreateLogging("rep.firstLoginFirstPayCnt.php");
$Permission = \User\Permission::P_REP_FirstLoginFirstPayCnt;
$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");
$dayList = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
\Report\GetAccountFirstLoginPayReport($channel, $startDate, $endDate, $fistLoginReportArray, $fistPayReportArray);
// \Logging\LogInfo(print_r($fistLoginReportArray, true));
?>
<!DOCTYPE html>
<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="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">
        <?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" value="<?php echo \Lang\gettext("查询"); ?>" />
        <hr />
        <table width="100%">
            <?php
            echo "<caption>【首登新增首充人数】</caption>";
            echo "<thead><tr>";
            echo "<th align='center' width='75'>首登日期</th>";
            echo "<th align='center' width='55'>首登人数</th>";
            foreach ($dayList as $day) {
                $title = $day . "日人数";
                echo "<th align='center' width='70'>" .  $title . "</th>";
            }
            echo "<th align='center' width='70'>总付费人数</th>";
            echo "</tr></thead>";
            $curYMD = date("Y-m-d");
            $curDate = new DateTime();
            foreach ($fistLoginReportArray as $firstYMD => $statYMDInfo) {
                if ($firstYMD < $startDate) {
                    continue;
                }
                $firstPayCntTotal = 0;
                foreach ($statYMDInfo as $statInfo) {
                    $firstPayCntTotal  += ($statInfo["firstPayCnt"] ? $statInfo["firstPayCnt"] : 0);
                }
                echo "<tr class='trc'>";
                echo "<td align='center' width='70'>" . $firstYMD . "</td>";
                $firstYMDTime = strtotime($firstYMD);
                $firstLoginCount = 0;
                foreach ($dayList as $day) {
                    $statYMD = date("Y-m-d", strtotime("+" . ($day - 1) . " days", $firstYMDTime));
                    $statInfo = $statYMDInfo[$statYMD] ? $statYMDInfo[$statYMD] : array();
                    if ($day == 1) {
                        $firstLoginCount = $statInfo["keepCount"] ? $statInfo["keepCount"] : 0;
                        echo "<td align='center' width='70'>" . $firstLoginCount . "</td>";
                    }
                    $firstPayCnt = $statInfo["firstPayCnt"] ? $statInfo["firstPayCnt"] : 0;
                    if ($statYMD > $curYMD) {
                        $text = "";
                    } else {
                        if ($day == 1) {
                            $text = $firstPayCnt;
                        } else {
                            $text = $firstPayCnt;
                            // if ($firstPayCnt) {
                            //     $ratio = $firstPayCnt / $firstLoginCount;
                            //     $text .= "<br/>" . round($ratio, 2) . "";
                            // }
                        }
                    }
                    echo "<td align='center' width='90'>" .  $text . "</td>";
                }
                echo "<td align='center' width='90'>" . $firstPayCntTotal . "</td>";
                echo "</tr>";
            }
            if (count($fistLoginReportArray) == 0) {
                echo "<tr class='trc'><td>无数据</td></tr>";
            }
            ?>
        </table>
        <hr />
    </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">
</script>
</html>
serverrep/report.php
@@ -147,7 +147,7 @@
    );
}
/**检查并导出首登/首充留存每日报表 */
/**检查并导出首登/首充每日报表 */
function CheckAndExportFirstKeepReport($Channel)
{
    $eventKey = "FirstKeepReportYMD_" . $Channel;
@@ -208,12 +208,16 @@
        foreach ($ymdArray as $ReportYMD => $statInfo) {
            $keepCount = $statInfo["keepCount"] ? $statInfo["keepCount"] : 0;
            $payTotal = $statInfo["payTotal"] ? $statInfo["payTotal"] : 0;
            $payCnt = $statInfo["payCnt"] ? $statInfo["payCnt"] : 0;
            $firstPayCnt = $statInfo["firstPayCnt"] ? $statInfo["firstPayCnt"] : 0;
            array_push($batchInsDatas, array(
                "Channel" => $Channel,
                "CreateYMD" => $CreateYMD,
                "ReportYMD" => $ReportYMD,
                "KeepCount" => $keepCount,
                "PayTotal" => $payTotal,
                "PayCnt" => $payCnt,
                "FirstPayCnt" => $firstPayCnt,
            ));
        }
    }
@@ -224,6 +228,7 @@
        if (!\DBOper\BatchInsert("AccountFirstLoginReport", $batchInsDatas)) {
            return;
        }
        \Logging\LogInfo("AccountFirstLoginReport 插入OK:" . count($batchInsDatas));
    }
    // 生成插入数据
@@ -246,6 +251,7 @@
        if (!\DBOper\BatchInsert("AccountFirstPayReport", $batchInsDatas)) {
            return;
        }
        \Logging\LogInfo("AccountFirstPayReport 插入OK:" . count($batchInsDatas));
    }
    // 全部处理完毕才更新
@@ -257,7 +263,7 @@
 * 统计首登相关留存日期报表,包含充值(用于ltv计算)
 * @param string $Channel
 * @param string $YMD 要统计的报表日期yyyy-MM-dd
 * @param array $fistLoginReportArray 统计首登报表结果 {首登日期:{统计日期:{keepCount:x, payTotal:x}} ...}}
 * @param array $fistLoginReportArray 统计首登报表结果 {首登日期:{统计日期:{keepCount:x, payTotal:x, payCnt:x, firstPayCnt:x}} ...}}
 * @param array $fistPayReportArray 统计首充报表结果 {首充日期:{统计日期:{keepCount:x}} ...}}
 * @param array $accountFirstLoginDateInfo 账号首登日期信息 {accountID:firstLoginYMD, ...}
 * @param array $accountFirstPayDateInfo 账号首充日期信息 {accountID:firstPayYMD, ...}
@@ -336,6 +342,18 @@
        }
    }
    // 今日首付账号
    if (
        !\DBOper\Find("AccountFirstPay", array("Channel" => $Channel, "PayYMD" => $YMD), $firstPayRetArray, array("AccountID" => 1))
        || !isset($firstPayRetArray)
    ) {
        return;
    }
    $accountFirstPayDict = array(); // 统计日期首付账号
    foreach ($firstPayRetArray as $firstPayInfo) {
        $accountFirstPayDict[$firstPayInfo["AccountID"]] = 1;
    }
    if (
        !\DBOper\Find(
            "PayOrder",
@@ -369,13 +387,20 @@
            }
            $statYMDInfo = $fistLoginReportArray[$FirstLoginYMD];
            if (!isset($statYMDInfo[$YMD])) {
                $statYMDInfo[$YMD] = array();
                $statYMDInfo[$YMD] = array("keepCount" => 0, "payTotal" => 0, "payCnt" => 0, "firstPayCnt" => 0);
            }
            $statInfo = $statYMDInfo[$YMD];
            $statInfo["keepCount"] = ($statInfo["keepCount"] ? $statInfo["keepCount"] : 0) + 1;
            $payTotal = $accountPayDict[$AccountID] ? $accountPayDict[$AccountID] : 0;
            $statInfo["payTotal"] = ($statInfo["payTotal"] ? $statInfo["payTotal"] : 0) + $payTotal;
            if ($payTotal > 0) {
                $statInfo["payCnt"] = ($statInfo["payCnt"] ? $statInfo["payCnt"] : 0) + 1;
            }
            if ($accountFirstPayDict[$AccountID]) {
                $statInfo["firstPayCnt"] = ($statInfo["firstPayCnt"] ? $statInfo["firstPayCnt"] : 0) + 1;
            }
            $statYMDInfo[$YMD] = $statInfo;
            $fistLoginReportArray[$FirstLoginYMD] = $statYMDInfo;
@@ -735,14 +760,14 @@
 * @param string $Channel
 * @param string $fromYMD 起始日期yyyy-MM-dd
 * @param string $toYMD 到日期yyyy-MM-dd
 * @param array &$fistLoginReportArray {首登日期:{统计日期:{keepCount:x, payTotal:x}} ...}}
 * @param array &$fistLoginReportArray {首登日期:{统计日期:{keepCount:x, payTotal:x, payCnt:x, firstPayCnt:x}} ...}}
 * @param array &$fistPayReportArray {首充日期:{统计日期:{keepCount:x}} ...}}
 */
function GetAccountFirstLoginPayReport($Channel, $fromYMD, $toYMD, &$fistLoginReportArray, &$fistPayReportArray)
{
    CheckAndExportFirstKeepReport($Channel); // 每次获取检查导出
    $find = array("Channel" => $Channel, "CreateYMD" => array('$gte' => $fromYMD, '$lte' => $toYMD));
    \DBOper\Find("AccountFirstLoginReport", $find, $newUserRetArray, array("CreateYMD" => 1, "ReportYMD" => 1, "KeepCount" => 1, "PayTotal" => 1));
    \DBOper\Find("AccountFirstLoginReport", $find, $newUserRetArray);
    if (!isset($newUserRetArray)) {
        $newUserRetArray = array();
    }
@@ -766,7 +791,10 @@
            $fistLoginReportArray[$FirstLoginYMD] = array();
        }
        $statYMDInfo = $fistLoginReportArray[$FirstLoginYMD];
        $statYMDInfo[$ReportYMD] = array("keepCount" => $info["KeepCount"], "payTotal" => $info["PayTotal"]);
        $statYMDInfo[$ReportYMD] = array(
            "keepCount" => $info["KeepCount"], "payTotal" => $info["PayTotal"],
            "payCnt" => $info["PayCnt"], "firstPayCnt" => $info["FirstPayCnt"]
        );
        $fistLoginReportArray[$FirstLoginYMD] = $statYMDInfo;
    }
    ksort($fistLoginReportArray);
serverrep/xpaypaycnt.php
New file
@@ -0,0 +1,150 @@
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
include_once "/serverrep/report.php";
\Logging\CreateLogging("rep.xpaypaycnt.php");
$Permission = \User\Permission::P_REP_XPayPaycnt;
$channel = $_SESSION['spid'];
$UserAccount = $_SESSION['UserAccount'];
$user = new \User\User($UserAccount);
if (!$user->HavePermission($Permission)) {
    exit;
}
$dayList = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
$maxDay = max($dayList);
$startDate = array_key_exists("startDate", $_POST) ? $_POST["startDate"] : date("Y-m-d", strtotime("-7 days"));
$startYMDTime = strtotime($startDate);
$endDate = date("Y-m-d", strtotime("+" . ($maxDay - 1) . " days", $startYMDTime));
$OrderInfo = array_key_exists("OrderInfo", $_POST) ? $_POST["OrderInfo"] : "cw.tjb.1";
\Logging\LogInfo("FindDate:" . $startDate . " ~ :" . $endDate);
!\DBOper\Find(
    "PayOrder",
    array(
        "Channel" => $channel, "State" => 1, "PayTime" => array('$gte' => $startDate . " 00:00:00", '$lte' => $endDate . " 23:59:59"),
    ),
    $payRetArray,
    array("AccountID" => 1, "PayTime" => 1, "OrderInfo" => 1),
    array("PayTime" => 1)
);
$xPayAccountInfo = array(); // 首购礼包账号信息 {accountID:首购日期, ...}
$xPayReportArray = array(); // 首购礼包统计信息 {"首购日期":[{accountID:1, ...}, {"statYMD":{再次付费accountID:1, ...}, ...}], ...}
foreach ($payRetArray as $payInfo) {
    $AccountID = $payInfo["AccountID"];
    $PayTime = $payInfo["PayTime"];
    $statYMD = substr($PayTime, 0, 10);
    if ($payInfo["OrderInfo"] == $OrderInfo) {
        if (!$xPayAccountInfo[$AccountID]) {
            $xPayAccountInfo[$AccountID] = $statYMD;
        }
    }
    if (!$xPayAccountInfo[$AccountID]) {
        // 没首购过的账号,不统计进来
        continue;
    }
    $xPayYMD = $xPayAccountInfo[$AccountID]; // x礼包日期
    if (!$xPayReportArray[$xPayYMD]) {
        $xPayReportArray[$xPayYMD] = array(array(), array());
    }
    $accountInfo = $xPayReportArray[$xPayYMD][0];
    $statYMDInfo = $xPayReportArray[$xPayYMD][1];
    if ($payInfo["OrderInfo"] == $OrderInfo) {
        $accountInfo[$AccountID] = 1;
    } else {
        $statAccountInfo = $statYMDInfo[$statYMD];
        $statAccountInfo[$AccountID] = 1;
        $statYMDInfo[$statYMD] = $statAccountInfo;
    }
    $xPayReportArray[$xPayYMD] = array($accountInfo, $statYMDInfo);
}
ksort($xPayReportArray);
// \Logging\LogInfo("xPayAccountInfo:" . print_r($xPayAccountInfo, true));
// \Logging\LogInfo("xPayReportArray:" . print_r($xPayReportArray, true));
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo \Lang\gettext("购买X礼包再付人数"); ?></title>
    <link rel="stylesheet" type="text/css" href="/css/table.css">
    <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("购买X礼包后再次付费人数"); ?></b></P>
    </center>
    <form method="post">
        <?php echo \Lang\gettext("X礼包日期"); ?>:
        <input type="text" name="startDate" id="startDate" onclick="new Calendar().show(this);" readonly value="<?php echo $startDate; ?>" size="8" />
        <p />
        X商品编号:
        <input type="text" name="OrderInfo" id="OrderInfo" value="<?php echo $OrderInfo; ?>" size="8" />
        <input type="submit" value="<?php echo \Lang\gettext("查询"); ?>" />
        <hr />
        <table width="100%">
            <?php
            echo "<caption>【购买X礼包后再次付费人数】</caption>";
            echo "<thead><tr>";
            echo "<th align='center' width='75'>X礼包日期</th>";
            echo "<th align='center' width='55'>首购人数</th>";
            foreach ($dayList as $day) {
                $title = $day . "日人数";
                echo "<th align='center' width='70'>" .  $title . "</th>";
            }
            // echo "<th align='center' width='70'>总付费人数</th>";
            echo "</tr></thead>";
            $curYMD = date("Y-m-d");
            foreach ($xPayReportArray as $xPayYMD => $statInfo) {
                if ($xPayYMD < $startDate) {
                    continue;
                }
                $accountInfo = $statInfo[0];
                $statYMDInfo = $statInfo[1];
                $xPayUserCnt = count($accountInfo);
                echo "<tr class='trc'>";
                echo "<td align='center'>" . $xPayYMD . "</td>";
                echo "<td align='center'>" . $xPayUserCnt . "</td>";
                $xPayYMDTime = strtotime($xPayYMD);
                foreach ($dayList as $day) {
                    $statYMD = date("Y-m-d", strtotime("+" . ($day - 1) . " days", $xPayYMDTime));
                    $statAccountInfo = $statYMDInfo[$statYMD] ? $statYMDInfo[$statYMD] : array();
                    $statCnt = count($statAccountInfo);
                    if ($statYMD > $curYMD) {
                        $text = "";
                    } else {
                        $text = $statCnt;
                    }
                    echo "<td align='center' width='90'>" .  $text . "</td>";
                }
                echo "</tr>";
            }
            if (count($xPayReportArray) == 0) {
                echo "<tr class='trc'><td>无数据</td></tr>";
            }
            ?>
        </table>
        <hr />
    </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">
</script>
</html>