| | |
| | | // 默认当天 |
| | | $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; |
| | | $payOrderInfo = null; |
| | | $errorServerInfo = array(); |
| | | $payOrderTypes = array(); |
| | | if (array_key_exists("submit", $_POST)) { |
| | | $_POST["eventType"] = "CTGReportAll"; |
| | | $_POST["queryAllData"] = "on"; // 设置可查询备份数据 |
| | |
| | | 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["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 ($ret["payOrderInfo"] as $orderInfo => $retData) { |
| | | if (!array_key_exists($orderInfo, $payOrderInfo)) { |
| | | $payOrderInfo[$orderInfo] = $retData; |
| | | } else { |
| | | $payOrderInfo[$orderInfo]["payCount"] = $payOrderInfo[$orderInfo]["payCount"] + $retData["payCount"]; |
| | | } |
| | | 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; |
| | | } |
| | | } |
| | | //排序 根据 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)); |
| | | // \Logging\LogInfo("payOrderTypes: " . print_r($payOrderTypes, 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"), |
| | | "orderInfo" => array("商品编号", "5%", "center"), |
| | | "orderCoin" => array("orderCoin", "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); |
| | | if (!$payOrderTypeGroup) { |
| | | ksort($payOrderTypes); |
| | | foreach ($payOrderTypes as $k => $payOrderType) { |
| | | $payName = \CommFunc\getPayOrderTypeName($payOrderType); |
| | | $tableArray[$k] = array($payName . "次数", "5%", "center"); |
| | | } |
| | | } |
| | | |
| | | ?> |
| | | |
| | |
| | | <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)) { |
| | |
| | | |
| | | <?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>"; |
| | | foreach ($reportInfo as $payOrderTypeKey => $orderInfoDict) { |
| | | if ($payOrderTypeKey == "0") { |
| | | $caption = "所有"; |
| | | } else { |
| | | $caption = \CommFunc\getPayOrderTypeName(intval($payOrderTypeKey)); |
| | | } |
| | | 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>"; |
| | | $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>"; |
| | | 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/>"; |
| | | } |
| | | echo "</table>"; |
| | | echo "<hr/>"; |
| | | } |
| | | ?> |
| | | <?php |