hxp
2024-10-24 3378488ca2b447e30b6da21dc324bc69da9a85d9
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
222
223
224
225
<?php
include_once "/Common/Logging.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
 
\Logging\CreateLogging("ctgreportall.php");
$Permission = \User\Permission::P_CTGReportAll;
 
$alertMsg = "";
$channel = $_SESSION['spid'];
$UserAccount = $_SESSION['UserAccount'];
$user = new \User\User($UserAccount);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
$serversArray = $user->GetServers();
 
// 默认当天
$startDate = array_key_exists("startDate", $_POST) ? $_POST["startDate"] : \CommFunc\CalcToStrDateTime("-7 days", "Y-m-d");
$endDate = array_key_exists("endDate", $_POST) ? $_POST["endDate"] : date("Y-m-d");
 
$reportInfo = null;
$payOrderInfo = null;
$errorServerInfo = array();
if (array_key_exists("submit", $_POST)) {
    $_POST["eventType"] = "CTGReportAll";
    $_POST["queryAllData"] = "on"; // 设置可查询备份数据
    // echo "_POST:", print_r($_POST, true), "<br/>";
    \CommFunc\QueryEventData($user, $retInfo);
 
    if (isset($retInfo)) {
        // \Logging\LogInfo("返回查询结果: " .  print_r($retInfo, true));
        $reportInfo = array();
        $payOrderInfo = array();
        foreach ($retInfo as $serverName => $ret) {
            if (is_array($ret) && $ret["OK"] == 1) {
                foreach ($ret["reportInfo"] as $orderInfo => $retData) {
                    if (!array_key_exists($orderInfo, $reportInfo)) {
                        $reportInfo[$orderInfo] = $retData;
                    } else {
                        $reportInfo[$orderInfo]["payCount"] = $reportInfo[$orderInfo]["payCount"] + $retData["payCount"];
                    }
                }
                foreach ($ret["payOrderInfo"] as $orderInfo => $retData) {
                    if (!array_key_exists($orderInfo, $payOrderInfo)) {
                        $payOrderInfo[$orderInfo] = $retData;
                    } else {
                        $payOrderInfo[$orderInfo]["payCount"] = $payOrderInfo[$orderInfo]["payCount"] + $retData["payCount"];
                    }
                }
            } else {
                $errorServerInfo[$serverName] = $ret;
            }
        }
        //排序 根据 payCount 倒序排序  SORT_ASC 和 SORT_DESC
        array_multisort(array_column($reportInfo, 'payCount'), SORT_DESC, $reportInfo);
        array_multisort(array_column($payOrderInfo, 'payCount'), SORT_DESC, $payOrderInfo);
    }
}
 
// \Logging\LogInfo("reportInfo: " .  print_r($reportInfo, true));
// \Logging\LogInfo("errorServerInfo: " .  print_r($errorServerInfo, true));
 
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
    "Num" => array("编号", "5%", "center"),
    "orderInfo" => array("商品编号", "10%", "center"),
    "payOrderType" => array("订单类型", "5%", "center"),
    "orderCoin" => array("商品价格", "5%", "center"),
    "payCount" => array("购买次数", "5%", "center"),
);
 
$payOrderTableArray = array(
    "Num" => array("编号", "5%", "center"),
    "orderInfo" => array("商品编号", "10%", "center"),
    "payOrderType" => array("订单类型", "5%", "center"),
    "orderCoin" => array("商品价格", "5%", "center"),
    "orderMoneyType" => array("购买货币", "5%", "center"),
    "orderMoneyValue" => array("货币价格", "5%", "center"),
    "payCount" => array("购买次数", "5%", "center"),
);
 
$moneyNameInfo = \CommFunc\getCfgKeyNameContent("money", true);
 
?>
 
<!DOCTYPE html>
<html>
 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo \Lang\gettext("充值分析"); ?></title>
    <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 id="ctgreportall" action="ctgreportall.php" 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" />
        <hr />
        <?php
        if (count($errorServerInfo)) {
            echo \Lang\gettext("服务器错误信息") . "<br/>";
            echo "<font color='red'>";
            foreach ($errorServerInfo as $serverName => $errInfo) {
                echo $serverName;
                if (is_array($errInfo)) {
                    echo " => " . json_encode($errInfo);
                } else {
                    echo " => " . $errInfo;
                }
                echo "<br/>";
            }
            echo "</font>";
            echo "<hr/>";
        }
        ?>
 
        <?php
        if (isset($reportInfo)) {
            echo "<table width=\"30%\" border frame=box rules=all>";
            echo "<caption>" . \Lang\gettext("充值分析") . "</caption>";
            echo "<thead><tr>";
            foreach ($tableArray as $value) {
                echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
            }
            echo "</tr></thead>";
            if (count($reportInfo) == 0) {
                echo \Lang\gettext("无充值记录") . "<br/>";
            }
 
            $Num = 0;
            foreach ($reportInfo as $orderInfo => $orderData) {
                echo "<tr'>";
                foreach ($tableArray as $key => $value) {
                    $tdContent = $orderData[$key];
                    if ($key == "Num") {
                        $Num += 1;
                        $tdContent = $Num;
                    } else if ($key == "payOrderType") {
                        $tdContent = \CommFunc\getPayOrderTypeName($tdContent);
                    } else if ($key == "orderCoin") {
                        $tdContent = $tdContent / \CommFunc\getPayOrderCoinRate($orderData["payOrderType"]);
                    } else if ($key == "orderInfo") {
                        $tdContent = $orderInfo;
                    }
                    echo "<td align='" . $value[2] . "'>" . $tdContent . "</td>";
                }
                echo "</tr>";
            }
            echo "</table>";
            echo "<hr/>";
        }
        if (isset($payOrderInfo)) {
            echo "<table width=\"40%\" border frame=box rules=all>";
            echo "<caption>" . \Lang\gettext("充值订单购买分析") . "</caption>";
            echo "<thead><tr>";
            foreach ($payOrderTableArray as $value) {
                echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
            }
            echo "</tr></thead>";
            if (count($payOrderInfo) == 0) {
                echo \Lang\gettext("无充值记录") . "<br/>";
            }
 
            $Num = 0;
            foreach ($payOrderInfo as $orderInfo => $orderData) {
                echo "<tr'>";
                foreach ($payOrderTableArray as $key => $value) {
                    $tdContent = $orderData[$key];
                    if ($key == "Num") {
                        $Num += 1;
                        $tdContent = $Num;
                    } else if ($key == "payOrderType") {
                        $tdContent = \CommFunc\getPayOrderTypeName($tdContent);
                    } else if ($key == "orderCoin") {
                        $tdContent = $tdContent / \CommFunc\getPayOrderCoinRate($orderData["payOrderType"]);
                    } else if ($key == "orderInfo") {
                        $tdContent = $orderInfo;
                    } else if ($key == "orderMoneyType") {
                        $tdContent = $moneyNameInfo["" . $tdContent];
                    }
                    echo "<td align='" . $value[2] . "'>" . $tdContent . "</td>";
                }
                echo "</tr>";
            }
            echo "</table>";
            echo "<hr/>";
        }
        ?>
        <?php
        include_once "/Common/SelectServer.php";
        ?>
        <input type="submit" name="submit" id="submit" value="<?php echo \Lang\gettext("查询多服"); ?>" onclick="return checkMultiSubmit()" />
        <br />
        <br />
    </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' src="/Common/selectserver.js"></script>
<script type="text/javascript">
    function checkMultiSubmit() {
 
        if (!checkHaveServerSelected()) {
            return false;
        }
 
        if (!setSubmitQuerying("submit")) {
            return false;
        }
 
        return true;
    }
</script>
 
</html>