hxp
2025-02-11 527a9041ecc0f5067a7cac9d5abdab641cb7f395
10162 后台优化(优化日留存报表统计)
1个文件已修改
42 ■■■■ 已修改文件
serverrep/report.php 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
serverrep/report.php
@@ -294,13 +294,13 @@
        return;
    }
    $dayActiveAccIDList = array(); // 统计日期活跃账号ID列表 [accountID, ..]
    $dayActiveAccIDDict = array(); // 统计日期活跃账号充值额度 {accountID:充值总额, ...}
    $queryFirstLoginAccIDList = array(); // 需要查询首登日期的账号列表 [accountID, ..]
    $queryFirstPayAccIDList = array(); // 需要查询首充日期的账号列表 [accountID, ..]
    foreach ($activeRetArray as $activeInfo) {
        $AccountID = $activeInfo["AccountID"];
        array_push($dayActiveAccIDList, $AccountID);
        $dayActiveAccIDDict[$AccountID] = 0;
        if (!isset($accountFirstLoginDateInfo[$AccountID])) {
            array_push($queryFirstLoginAccIDList, $AccountID);
@@ -354,31 +354,31 @@
        $accountFirstPayDict[$firstPayInfo["AccountID"]] = 1;
    }
    if (
        !\DBOper\Find(
            "PayOrder",
    $ret = \DBOper\Aggregate("PayOrder", array(
            array(
                "Channel" => $Channel, "State" => 1, "PayTime" => array('$gte' => $YMD . " 00:00:00", '$lte' => $YMD . " 23:59:59"),
                "AccountID" => array('$in' => $dayActiveAccIDList)
            '$match' => array(
                "Channel" => $Channel, "State" => 1, "PayTime" => array('$gte' => $YMD . " 00:00:00", '$lte' => $YMD . " 23:59:59")
            ),
            $payRetArray,
            array("AccountID" => 1, "PayTime" => 1, "OrderAmount" => 1)
        ) || !isset($payRetArray)
    ) {
        ),
        array(
            '$group' => array(
                '_id' => array('AccountID' => '$AccountID'),
                'total' => array('$sum' => '$OrderAmount'),
            ),
        ),
    ), $retInfo);
    if (!$ret || !isset($retInfo)) {
        return;
    }
    $accountPayDict = array(); // 统计日期活跃账号充值额 {accountID:充值总额, ...}
    foreach ($payRetArray as $payInfo) {
        $AccountID = $payInfo["AccountID"];
        $OrderAmount = $payInfo["OrderAmount"];
        $accountPayDict[$AccountID] = $accountPayDict[$AccountID] + $OrderAmount;
    foreach ($retInfo as $info) {
        $AccountID = $info["_id"]["AccountID"];
        if (isset($dayActiveAccIDDict[$AccountID])) {
            $dayActiveAccIDDict[$AccountID] = floatval($info["total"]);
        }
    }
    // 汇总信息
    for ($i = 0; $i < count($dayActiveAccIDList); $i++) {
        $AccountID = $dayActiveAccIDList[$i];
    foreach ($dayActiveAccIDDict as $AccountID => $payTotal) {
        // 首登
        $FirstLoginYMD = $accountFirstLoginDateInfo[$AccountID];
        if ($FirstLoginYMD) {
@@ -391,8 +391,6 @@
            }
            $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;