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);