<?php
|
include_once "/Common/Logging.php";
|
include_once "/Account/User.php";
|
include_once "/language/lang.php";
|
include_once "/serverrep/report.php";
|
|
\Logging\CreateLogging("rep.ltv.php");
|
$Permission = \User\Permission::P_REP_LTV;
|
|
$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");
|
$dayList = json_decode($_POST["dayList"], true);
|
$dayTotalList = json_decode($_POST["dayTotalList"], true);
|
if (!isset($dayList)) {
|
$dayList = array(1, 2, 3, 4, 5, 6, 7);
|
}
|
if (!isset($dayTotalList)) {
|
$dayTotalList = array(7, 14, 15, 21, 30);
|
}
|
if (!in_array(1, $dayList)) {
|
array_push($dayList, 1);
|
}
|
$maxDay = max(max($dayList), max($dayTotalList));
|
|
sort($dayList);
|
sort($dayTotalList);
|
\Logging\LogInfo("dayList: " . print_r($dayList, true));
|
\Logging\LogInfo("dayTotalList: " . print_r($dayTotalList, true));
|
\Logging\LogInfo("maxDay:" . $maxDay);
|
|
\Report\GetAccountFirstLoginPayReport($channel, $startDate, $endDate, $fistLoginReportArray, $fistPayReportArray);
|
// \Logging\LogInfo("dayTotalList: " . print_r($fistLoginReportArray, true));
|
|
?>
|
|
<!DOCTYPE html>
|
<html>
|
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<title><?php echo \Lang\gettext("全服LTV"); ?></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("全服LTV"); ?></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("查询"); ?>" />
|
<p />
|
LTV天当日: <input type="text" name="dayList" id="dayList" value="<?php echo json_encode($dayList) ?>" size="50" />
|
<p />
|
LTV天汇总: <input type="text" name="dayTotalList" id="dayTotalList" value="<?php echo json_encode($dayTotalList) ?>" size="50" />
|
<hr />
|
<table width="100%">
|
<?php
|
echo "<caption>【LTV】</caption>";
|
echo "<thead><tr>";
|
echo "<th align='center' width='70'>首登日期</th>";
|
echo "<th align='center' width='70'>首登人数</th>";
|
foreach ($dayList as $day) {
|
$title = "第" . $day . "日LTV";
|
echo "<th align='center' width='70'>" . $title . "</th>";
|
}
|
foreach ($dayTotalList as $day) {
|
$title = $day . "日总LTV";
|
echo "<th align='center' width='70'>" . $title . "</th>";
|
}
|
echo "<th align='center' width='70'>总LTV(天)</th>";
|
echo "<th align='center' width='70'>总充值</th>";
|
echo "</tr></thead>";
|
$curDate = new DateTime();
|
foreach ($fistLoginReportArray as $firstYMD => $statYMDInfo) {
|
echo "<tr class='trc'>";
|
echo "<td align='center' width='70'>" . $firstYMD . "</td>";
|
$firstYMDTime = strtotime($firstYMD);
|
$firstCount = 0;
|
// 当日ltv
|
foreach ($dayList as $day) {
|
$statYMD = date("Y-m-d", strtotime("+" . ($day - 1) . " days", $firstYMDTime));
|
$statInfo = $statYMDInfo[$statYMD] ? $statYMDInfo[$statYMD] : array();
|
if ($day == 1) {
|
$firstCount = $statInfo["keepCount"] ? $statInfo["keepCount"] : 0;
|
echo "<td align='center' width='70'>" . $firstCount . "</td>";
|
}
|
|
$payTotal = $statInfo["payTotal"] ? $statInfo["payTotal"] : 0;
|
if ($payTotal == 0 || $firstCount == 0) {
|
$text = "";
|
} else {
|
$ltv = $payTotal / $firstCount;
|
$ltv = $ltv > 0.001 ? round($ltv, 3) : round($ltv, 5);
|
// $text = $ltv . "(" . $payTotal . ")";
|
$text = $ltv;
|
}
|
echo "<td align='center' width='90'>" . $text . "</td>";
|
}
|
|
// 统计累计天ltv
|
$paySumArray = array();
|
$interval = $curDate->diff(new DateTime($firstYMD));
|
$ltvDays = $interval->days + 1; // ltv总天数 - 创角 ~ 今日
|
$paySum = 0; // 总充值
|
for ($i = 0; $i < $ltvDays; $i++) {
|
$statYMD = date("Y-m-d", strtotime("+" . $i . " days", $firstYMDTime));
|
$statInfo = $statYMDInfo[$statYMD] ? $statYMDInfo[$statYMD] : array();
|
$payTotal = $statInfo["payTotal"] ? $statInfo["payTotal"] : 0;
|
$paySum += $payTotal;
|
$paySumArray[$i + 1] = $paySum;
|
}
|
// \Logging\LogInfo("firstYMD:" . $firstYMD . " ltvDays:" . $ltvDays);
|
// \Logging\LogInfo("paySumArray: " . print_r($paySumArray, true));
|
|
// 汇总ltv
|
foreach ($dayTotalList as $days) {
|
$daysPaySum = $paySumArray[$days] ? $paySumArray[$days] : 0;
|
if ($daysPaySum == 0 || $firstCount == 0) {
|
$text = "";
|
} else {
|
$ltv = round($daysPaySum / $firstCount, 3);
|
$text = $ltv;
|
}
|
echo "<td align='center' width='90'>" . $text . "</td>";
|
}
|
|
// 总LTV(天)
|
$ltvTotal = $firstCount == 0 ? 0 : round($paySum / $firstCount, 3);
|
echo "<td align='center' width='90'>" . $ltvTotal . "(" . $ltvDays . ")</td>";
|
// 总充值
|
echo "<td align='center' width='90'>" . $paySum . "</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>
|