From 4722efaac352d83e7ca8ff7564f0b2a91fa970a9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 22 十一月 2024 14:30:51 +0800
Subject: [PATCH] 10284 【后台】 优化导出中心备档流向日活数据方式;

---
 serverrep/ImportAccountLoginpay.php |   91 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 64 insertions(+), 27 deletions(-)

diff --git a/serverrep/ImportAccountLoginpay.php b/serverrep/ImportAccountLoginpay.php
index bb66dde..6e86830 100644
--- a/serverrep/ImportAccountLoginpay.php
+++ b/serverrep/ImportAccountLoginpay.php
@@ -17,7 +17,7 @@
 	echo "no appID";
 	exit();
 }
-logweb("寮�濮嬪鍏�:" . $Channel);
+logweb("寮�濮嬪鍏�:" . $Channel . " opt:" . $opt);
 if (array_key_exists("reset", $_GET)) {
 	logweb("閲嶇疆閲嶆柊瀵煎嚭:" . $Channel);
 	$AccountFirstLoginOK = \DBOper\Remove("AccountFirstLogin", array("Channel" => $Channel));
@@ -42,12 +42,29 @@
 }
 if (!$opt || $opt == "day") {
 	logweb("daydaydaydayday:" . $Channel);
-	impAccountDayActive();
+	impAccountDayActive("rar");
 	// impAccountDayActiveTestData();
 }
-if (!$opt || $opt == "rep") {
-	logweb("repreprepreprep:" . $Channel);
+// 閲嶅鏃ユ椿銆侀噸鍒锋姤琛紱鍓嶆彁鏄厛璇曠敤 /Server/eventdata/ImportBakDailyActive.py 杩愯瀵煎嚭涓績娴佸悜澶囨。鏃ユ椿鏁版嵁缁撴灉淇濆瓨鍒癹son鏂囦欢
+if ($opt == "reDayActive") {
+	$AccountDayActiveOK = \DBOper\Remove("AccountDayActive", array("Channel" => $Channel));
+	logweb("AccountDayActiveOK:" . $AccountDayActiveOK);
+	impAccountDayActive("json");
+}
+if (!$opt || $opt == "rep" || $opt == "reDayActive") {
+	logweb("寮�濮嬪鍑烘瘡鏃ユ姤琛�:" . $Channel);
+	if ($opt == "reDayActive") {
+		$DailyReportOK = \DBOper\Remove("DailyReport", array("Channel" => $Channel));
+		$AccountFirstLoginReportOK = \DBOper\Remove("AccountFirstLoginReport", array("Channel" => $Channel));
+		$AccountFirstPayReportOK = \DBOper\Remove("AccountFirstPayReport", array("Channel" => $Channel));
+		$eventYMDOK = \DBOper\Remove("ServerEvent", array("Key" => "FirstKeepReportYMD_" . $Channel));
+		logweb("DailyReportOK:" . $DailyReportOK);
+		logweb("AccountFirstLoginReportOK:" . $AccountFirstLoginReportOK);
+		logweb("AccountFirstPayReportOK:" . $AccountFirstPayReportOK);
+		logweb("eventYMDOK:" . $eventYMDOK);
+	}
 	\Report\CheckAndExportDailyReport($Channel);
+	logweb("寮�濮嬪鍑虹暀瀛樻姤琛�:" . $Channel);
 	\Report\CheckAndExportFirstKeepReport($Channel);
 }
 logweb("澶勭悊瀹屾瘯!");
@@ -234,7 +251,7 @@
 	echo "<hr/>";
 }
 
-function impAccountDayActive()
+function impAccountDayActive($bakWay = "")
 {
 	global $Channel;
 	$startDate = $_GET["startDate"];
@@ -245,30 +262,44 @@
 
 	$allDateAccIDInfo = array(); // 鎵�鏈夎褰�
 	// 鏌ヨ澶囦唤娴佸悜
-	$pack_data = array();
-	$pack_data["spID"] = $Channel;
-	$pack_data["eventType"] = "QueryAccountLoginOut";
-	$pack_data["queryCenterbak"] = 1; # 璁剧疆鏌ヨ涓績鐨�
-	$pack_data["allServer"] = 1; # 璁剧疆妫�绱㈡墍鏈夋湇鍔″櫒娴佸悜
-	$pack_data["startDate"] = $startDate;
-	$pack_data["endDate"] = "";
-	$centerToolUrl = 'http://' . $_SERVER['HTTP_HOST'] . "/Server/eventdata/toolcenter.php";
-	logweb("centerToolUrl:" . $centerToolUrl);
+	if ($bakWay == "rar") {
+		$pack_data = array();
+		$pack_data["spID"] = $Channel;
+		$pack_data["eventType"] = "QueryAccountLoginOut";
+		$pack_data["queryCenterbak"] = 1; # 璁剧疆鏌ヨ涓績鐨�
+		$pack_data["allServer"] = 1; # 璁剧疆妫�绱㈡墍鏈夋湇鍔″櫒娴佸悜
+		$pack_data["startDate"] = $startDate;
+		$pack_data["endDate"] = "";
+		$centerToolUrl = 'http://' . $_SERVER['HTTP_HOST'] . "/Server/eventdata/toolcenter.php";
+		logweb("centerToolUrl:" . $centerToolUrl);
 
-	$retStr = \CommFunc\DoPost($centerToolUrl, $pack_data, false, 300);
-	$ret = json_decode($retStr, true);
-	if (isset($ret)) {
-		$allDateAccIDInfo = $ret[0];
-		ksort($allDateAccIDInfo);
-		foreach ($allDateAccIDInfo as $dateStr => $accIDInfo) {
-			logweb("涓績娴佸悜澶囨。鏃ユ椿鏁伴噺:" . " dateStr:" . $dateStr . " count:" . count($accIDInfo));
-			// foreach ($accIDInfo as $accID => $loginoutInfo) {
-			// 	logweb("	accID:" . $accID. json_encode($loginoutInfo));
-			// }
+		$retStr = \CommFunc\DoPost($centerToolUrl, $pack_data, false, 300);
+		$ret = json_decode($retStr, true);
+		if (isset($ret)) {
+			$allDateAccIDInfo = $ret[0];
+		} else {
+			logweb("query center backup error: " . $retStr);
+			return;
 		}
-	} else {
-		logweb("query center backup error: " . $retStr);
+	} elseif ($bakWay == "json") {
+		if (!\CommFunc\GetConfig("ServerInfo", "PlayerCenterRoot", $PlayerCenterRoot)) {
+			return "";
+		}
+		$jsonFile = $PlayerCenterRoot . "/Server/eventdata/BakDailyActive.json";
+		logweb("jsonFile:" . $jsonFile);
+		if (!file_exists($jsonFile)) {
+			logweb("###jsonFile is not exists:" . $jsonFile);
+			return;
+		}
+		$allDateAccIDInfo = json_decode(file_get_contents($jsonFile), true);
+	}
+	if (!isset($allDateAccIDInfo)) {
+		logweb("###center bak AccountDayActive error.");
 		return;
+	}
+	ksort($allDateAccIDInfo);
+	foreach ($allDateAccIDInfo as $dateStr => $accIDInfo) {
+		logweb("涓績娴佸悜澶囨。鏃ユ椿鏁伴噺:" . " dateStr:" . $dateStr . " count:" . count($accIDInfo));
 	}
 
 	logweb("寮�濮嬩粠瀛愭湇瀵煎叆鏃ユ椿鏁版嵁! startDate:" . $startDate);
@@ -326,7 +357,8 @@
 
 	ksort($allDateAccIDInfo);
 	foreach ($allDateAccIDInfo as $dateStr => $accIDInfo) {
-		logweb("鏈�缁堟棩娲绘暟閲�:" . " dateStr:" . $dateStr . " count:" . count($accIDInfo));
+		logweb("鏃ユ椿娓告垙璐﹀彿鏁伴噺:" . " dateStr:" . $dateStr . " count:" . count($accIDInfo));
+		$accountIDArray = array();
 		$dateInsInfo = array();
 		foreach ($accIDInfo as $accID => $loginoutInfo) {
 			// logweb("	accID:" . $accID. json_encode($loginoutInfo));
@@ -343,6 +375,11 @@
 				$ActiveYMD = substr($LogoffTime, 0, 10);
 			}
 
+			if ($accountIDArray[$AccountID]) {
+				logweb("###浠婃棩鏃ユ椿璐﹀彿宸插瓨鍦�:AccountID:" . $$AccountID . " accID:" . $accID);
+				continue;
+			}
+			$accountIDArray[$AccountID] = 1;
 			array_push($dateInsInfo, array(
 				"Channel" => $Channel,
 				"AccountID" => $AccountID,

--
Gitblit v1.8.0