hxp
2025-06-04 f4a514d5ac952110da846636ecbb9de951eaf3d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?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;
}
 
$perdayltv = $_POST["perdayltv"];
$nomulti = $_POST["nomulti"];
$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, 8, 9, 10, 11, 12, 13, 14);
}
if (!isset($dayTotalList)) {
    $dayTotalList = array();
}
if (!in_array(1, $dayList)) {
    array_push($dayList, 1);
}
sort($dayList);
$maxDay = max($dayList);
if (count($dayTotalList) > 0) {
    $maxDay = max($maxDay, max($dayTotalList));
    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));
 
\DBOper\Find("Versionlog", array(
    "Channel" => $channel,
    "UpdTime" => array('$gte' => $startDate . " 00:00:00", '$lte' => $endDate . " 23:59:59")
), $versions, null, array("UpdTime" => -1));
 
?>
 
<!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" />
        <input type="checkbox" name="perdayltv" id="perdayltv" <?php echo $perdayltv ? "checked" : ""  ?> />不累加每日ltv
        <input type="checkbox" name="nomulti" id="nomulti" <?php echo $nomulti ? "checked" : ""  ?> />不显示与首日ltv比值
        <!-- <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='75'>首登日期</th>";
            echo "<th align='center' width='55'>首登人数</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>";
            $curYMD = date("Y-m-d");
            $curDate = new DateTime();
            foreach ($fistLoginReportArray as $firstYMD => $statYMDInfo) {
                if ($firstYMD < $startDate) {
                    continue;
                }
                echo "<tr class='trc'>";
                echo "<td align='center' width='70'>" . $firstYMD . "</td>";
                $firstYMDTime = strtotime($firstYMD);
                $firstCount = 0;
                // 当日ltv
                $firstLTV = 0;
                $daysPayTotal = 0;
                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;
                    $daysPayTotal += $payTotal;
 
                    if ($firstCount == 0 || $statYMD > $curYMD) {
                        $text = "";
                    } else {
                        if ($perdayltv) {
                            $ltv = $payTotal / $firstCount;
                        } else {
                            $ltv = $daysPayTotal / $firstCount;
                        }
                        $ltv =  $ltv > 0.001 ? round($ltv, 3) : round($ltv, 5);
 
                        if ($day == 1) {
                            $firstLTV = $ltv;
                            $text = $ltv;
                        } else {
                            $text = $ltv;
                            if (!$perdayltv && $firstLTV && !$nomulti) {
                                $multi = $ltv / $firstLTV;
                                $text .= "<br/>" . round($multi, 2) . "倍";
                            }
                        }
                    }
                    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);
                $totalText = $ltvTotal . "(" . $ltvDays . ")";
                if (!$perdayltv && $firstLTV && !$nomulti) {
                    $multi = $ltvTotal / $firstLTV;
                    $totalText .= "<br/>" . round($multi, 2) . "倍";
                }
                echo "<td align='center' width='90'>" . $totalText . "</td>";
                // 总充值
                echo "<td align='center' width='90'>" . $paySum . "</td>";
                echo "</tr>";
            }
            if (count($fistLoginReportArray) == 0) {
                echo "<tr class='trc'><td>无数据</td></tr>";
            }
            ?>
        </table>
        <hr />
        <?php
        if (isset($versions) && count($versions)) {
            // "<span title='" . $title . "'>" . $retShort . "<span>"
            $detalHtml = "<ul>";
            foreach ($versions as $vInfo) {
                $VerNum = $vInfo["VerNum"];
                $UpdTime = $vInfo["UpdTime"];
                $VerTitle = $vInfo["VerTitle"];
                $VerDetail = $vInfo["VerDetail"];
 
                $itemName = $VerNum . " (" . $UpdTime . ") " . $VerTitle;
                $detalHtml .= '<hr/>';
                $detalHtml .= '<li><font style="font-size: 25px;"><b>' . $itemName . '</b></font></li>';
                $detalHtml .= $vInfo["VerDetail"];
            }
            $detalHtml . "</ul>";
 
            echo "版本记录<p/>";
            echo $detalHtml;
        } else {
            echo "没有版本更新日志";
        }
        ?>
    </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>