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
<?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");
$payOrderTypeGroup = $_POST["payOrderTypeGroup"];
 
$reportInfo = null;
$errorServerInfo = array();
$payOrderTypes = 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();
        foreach ($retInfo as $serverName => $ret) {
            if (is_array($ret) && $ret["OK"] == 1) {
                foreach ($ret["reportInfo"] as $key => $orderInfoDict) {
                    if (!array_key_exists($key, $reportInfo)) {
                        $reportInfo[$key] = array();
                    }
                    $repOrderInfoDict = $reportInfo[$key];
                    foreach ($orderInfoDict as $orderInfo => $retData) {
                        if (!array_key_exists($orderInfo, $repOrderInfoDict)) {
                            $repOrderInfoDict[$orderInfo] = $retData;
                        } else {
                            $retDataTotal = $repOrderInfoDict[$orderInfo];
                            foreach ($retData as $k => $v) {
                                if ($k == "orderCoin") {
                                    continue;
                                }
                                $retDataTotal[$k] = ($retDataTotal[$k] ? $retDataTotal[$k] : 0) + $v;
                            }
                            $repOrderInfoDict[$orderInfo] = $retDataTotal;
                        }
                        foreach ($repOrderInfoDict[$orderInfo] as $k => $v) {
                            if (\CommFunc\startsWith($k, "payOrderType")) {
                                $payOrderTypes[$k] = intval(substr($k, strlen("payOrderType")));
                            }
                        }
                    }
                    $reportInfo[$key] = $repOrderInfoDict;
                }
                foreach ($reportInfo as $key => $repOrderInfoDict) {
                    //排序 根据 payCount 倒序排序  SORT_ASC 和 SORT_DESC
                    array_multisort(array_column($repOrderInfoDict, 'payCount'), SORT_DESC, $repOrderInfoDict);
                    $reportInfo[$key] = $repOrderInfoDict;
                }
            } else {
                $errorServerInfo[$serverName] = $ret;
            }
        }
    }
}
 
// \Logging\LogInfo("reportInfo: " .  print_r($reportInfo, true));
// \Logging\LogInfo("errorServerInfo: " .  print_r($errorServerInfo, true));
// \Logging\LogInfo("payOrderTypes: " .  print_r($payOrderTypes, true));
 
//显示表格字段配置 key-参数名,value-说明
$tableArray = array(
    "Num" => array("编号", "5%", "center"),
    "orderInfo" => array("商品编号", "5%", "center"),
    "orderCoin" => array("orderCoin", "5%", "center"),
    "payCount" => array("总次数", "5%", "center"),
);
if (!$payOrderTypeGroup) {
    ksort($payOrderTypes);
    foreach ($payOrderTypes as $k => $payOrderType) {
        $payName = \CommFunc\getPayOrderTypeName($payOrderType);
        $tableArray[$k] = array($payName . "次数", "5%", "center");
    }
}
 
?>
 
<!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" />
        <input type="checkbox" name="payOrderTypeGroup" <?php echo $payOrderTypeGroup ? "checked" : "" ?> />按支付类型分组<br />
        <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)) {
            if (count($reportInfo) == 0) {
                echo \Lang\gettext("无充值记录") . "<br/>";
            }
            foreach ($reportInfo as $payOrderTypeKey => $orderInfoDict) {
                if ($payOrderTypeKey == "") {
                    $caption = "所有";
                } else {
                    $caption = \CommFunc\getPayOrderTypeName(intval($payOrderTypeKey));
                }
                $caption = "【" . $caption . "订单】";
                echo "<table width=\"50%\" border frame=box rules=all>";
                echo "<caption>" . $caption . "</caption>";
                echo "<thead><tr>";
                foreach ($tableArray as $value) {
                    echo "<th width=\"" . $value[1] . "\">" . $value[0] . "</td>";
                }
                echo "</tr></thead>";
                $Num = 0;
                foreach ($orderInfoDict 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/>";
            }
        }
        ?>
        <?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>