" . $EventID); exit; } if ($ok) { Response(); } exit; function Response($errorcode = 0, $errormsg = "ok") { $ret = array("errorcode" => $errorcode, "errormsg" => $errormsg); if ($errorcode != 0) { \Logging\LogError($errormsg . " _GET:" . print_r($_GET, true) . " ret:" . print_r($ret, true)); } echo \CommFunc\MyJson_encode($ret); } function EventReport_UpdateRole($eventType) { global $Channel, $RegionName, $Time; $AccountID = $_GET["AccountID"]; $PlayerID = intval($_GET["PlayerID"]); $PlayerName = $_GET["RoleID"]; $LV = intval($_GET["Level"]); $Job = intval($_GET["Job"]); $IP = $_GET["IP"]; $FamilyName = array_key_exists("FamilyName", $_GET) ? $_GET["FamilyName"] : ""; $FightPower = $_GET["FightPower"]; settype($FightPower, "float"); $AllCoinTotal = intval($_GET["AllCoinTotal"]); if (!$AccountID || !$PlayerID || !$PlayerName || !$LV || !$Job || !$IP) { Response(1003, "role param error"); return; } $find = array("Channel" => $Channel, "AccountID" => $AccountID); // 只找对应服的数据更新即可 if (!\DBOper\FindOne("GameRoles", $find, $findData, array($RegionName => 1))) { Response(2000, "db find error"); return; } $newAccount = false; if (!isset($findData)) { $newAccount = true; } \Logging\LogInfo("newAccount:" . $newAccount . " findData:" . print_r($findData, true)); $roleInfo = array(); if (isset($findData) && array_key_exists($RegionName, $findData)) { $regionRole = $findData[$RegionName]; // 如果是redis取出来的是json字符串 if (is_string($regionRole)) { $regionRole = json_decode($regionRole, true); // \Logging\LogInfo("json_decode regionRole:" . print_r($regionRole, true)); } foreach ($regionRole as $key => $value) { $roleInfo[$key] = $value; } } $roleInfo["PlayerID"] = $PlayerID; $roleInfo["PlayerName"] = $PlayerName; $roleInfo["LV"] = $LV; $roleInfo["Job"] = $Job; $roleInfo["IP"] = $IP; $roleInfo["FamilyName"] = $FamilyName; $roleInfo["FightPower"] = $FightPower; $roleInfo["AllCoinTotal"] = $AllCoinTotal; if (array_key_exists("CreateRoleTime", $_GET)) { $roleInfo["CreateRoleTime"] = $_GET["CreateRoleTime"]; } if ($eventType == "Login") { $roleInfo["LoginTime"] = $Time; } elseif ($eventType == "Logoff") { $roleInfo["LogoffTime"] = $Time; } if ($newAccount) { $insArray = array( "Channel" => $Channel, "AccountID" => $AccountID, "CreateTime" => date("Y-m-d H:i:s"), $RegionName => $roleInfo ); if (!\DBOper\Insert("GameRoles", $insArray, $find)) { Response(2001, "db Insert error"); return; } } else { $setRole = array($RegionName => $roleInfo); if (!\DBOper\Update("GameRoles", $find, $setRole, true)) { Response(2002, "db Update error"); return; } } $ServerID = \CommFunc\GetServerIDBySid($RegionName); AddAccountFirstLogin($ServerID, $roleInfo); AddAccountDayActive($ServerID, $roleInfo); // 附带更新服务器角色表,之后会替换 GameRoles 表 $find = array("Channel" => $Channel, "AccountID" => $AccountID, "ServerID" => $ServerID); if (\DBOper\Count("ServerRoles", $find) <= 0) { $insArray = array( "Channel" => $Channel, "AccountID" => $AccountID, "ServerID" => $ServerID, "CreateYMD" => date("Y-m-d"), ); if ($roleInfo["CreateRoleTime"]) { $insArray["CreateYMD"] = substr($roleInfo["CreateRoleTime"], 0, 10); } $insArray["RollCount"] = \DBOper\Count("ServerRoles", array("Channel" => $Channel, "AccountID" => $AccountID)); $insArray = array_merge($insArray, $roleInfo); \DBOper\Insert("ServerRoles", $insArray, $find); } else { \DBOper\Update("ServerRoles", $find, $roleInfo, true); } return true; } function EventReport_CreateRole() { global $Channel, $RegionName; $ServerID = \CommFunc\GetServerIDBySid($RegionName); if (!$ServerID) { return; } $find = array("Channel" => $Channel, "ServerID" => $ServerID); if (!\DBOper\FindOne("GameServerInfo", $find, $findData, null, false)) { Response(2000, "db find error"); return; } \Logging\LogInfo(" findData:" . print_r($findData, true)); if (!isset($findData)) { $insArray = array( "Channel" => $Channel, "ServerID" => $ServerID, "CreateRoleCount" => 1, ); if (!\DBOper\Insert("GameServerInfo", $insArray, $find)) { Response(2001, "db Insert error"); return; } \Logging\LogInfo(" insert ServerID:" . $ServerID . " CreateRoleCount:" . 1); } else { $CreateRoleCount = $findData["CreateRoleCount"] + 1; $setArray = array("CreateRoleCount" => $CreateRoleCount); if (!\DBOper\Update("GameServerInfo", $find, $setArray)) { Response(2002, "db Update error"); return; } \Logging\LogInfo(" update ServerID:" . $ServerID . " CreateRoleCount:" . $CreateRoleCount); } return true; } /**添加平台账号首登 */ function AddAccountFirstLogin($ServerID, $roleInfo) { global $Channel, $Time; $AccountID = $_GET["AccountID"]; $find = array("Channel" => $Channel, "AccountID" => $AccountID); if (!\DBOper\FindOne("AccountFirstLogin", $find, $findData, null, false)) { return; } if (isset($findData)) { // 已存在,不再重复添加 return; } $CreateRoleTime = $Time; if (array_key_exists("CreateRoleTime", $roleInfo)) { $CreateRoleTime = $roleInfo["CreateRoleTime"]; } $insArray = array( "Channel" => $Channel, "AccountID" => $AccountID, "CreateYMD" => substr($CreateRoleTime, 0, 10), "CreateTime" => $CreateRoleTime, "ServerID" => $ServerID, "PlayerID" => $roleInfo["PlayerID"], "PlayerName" => $roleInfo["PlayerName"], "Job" => $roleInfo["Job"], "IP" => $roleInfo["IP"], ); \DBOper\Insert("AccountFirstLogin", $insArray); } /**添加平台账号日活 */ function AddAccountDayActive($ServerID, $roleInfo) { global $Channel, $Time; $AccountID = $_GET["AccountID"]; $curYMD = substr($Time, 0, 10); $find = array("Channel" => $Channel, "AccountID" => $AccountID, "ActiveYMD" => $curYMD); $roleInfo["ServerID"] = $ServerID; // 直接更新 $actInfo = array( "Channel" => $Channel, "AccountID" => $AccountID, "ActiveYMD" => $curYMD, "ServerID" => $ServerID, "IP" => $roleInfo["IP"], ); if (array_key_exists("LoginTime", $roleInfo)) { $actInfo["LoginTime"] = $roleInfo["LoginTime"]; } if (array_key_exists("LogoffTime", $roleInfo)) { $actInfo["LogoffTime"] = $roleInfo["LogoffTime"]; } \DBOper\Update("AccountDayActive", $find, $actInfo, false, true); } /**记录媒体卡账号分组 */ function RecordCoupontypeGroup() { global $Channel, $RegionName; $ServerID = \CommFunc\GetServerIDBySid($RegionName); if (!$ServerID) { return; } CommFunc\GetConfig("ServerInfo", "CoupontypeGroup", $CoupontypeGroup); if (!$CoupontypeGroup) { // \Logging\LogInfo("CoupontypeGroup 不需要"); return; } $AccountID = $_GET["accid"]; $code = $_GET["code"]; $coupontype = $_GET["coupontype"]; $CoupontypeGroup = json_decode($CoupontypeGroup); if (!array_key_exists($coupontype, $CoupontypeGroup)) { // \Logging\LogInfo("CoupontypeGroup 不需要记录的组:" . $coupontype); return; } $find = array("Channel" => $Channel, "AccountID" => $AccountID, "ServerID" => $ServerID); if (!\DBOper\FindOne("CoupontypeGroup", $find, $findData)) { return; } if (isset($findData)) { // \Logging\LogInfo("已存在,不再重复添加: " . print_r($findData, true)); return true; } $insArray = array( "Channel" => $Channel, "AccountID" => $AccountID, "ServerID" => $ServerID, "CreateTime" => date("Y-m-d H:i:s"), "Coupontype" => $coupontype, "Code" => $code, ); if (\DBOper\Insert("CoupontypeGroup", $insArray, $find)) { \Logging\LogInfo("记录使用媒体卡首次分组: " . print_r($insArray, true)); return true; } }