_getMysql($targetId); $data = array(); $survivalTime = 0; $sameTimes = 0; $sessionChgTimes = 0; { $rows = SqlHelper::ormSelect( $conn, 't_battle_record', array( 'account_id' => $targetId ) ); foreach ($rows as $row) { $reqObj = json_decode($row['request'], true); $reqObj['start_time'] = $reqObj['game_time'] - $reqObj['alive_time']/1000; $survivalTime += $reqObj['alive_time']/1000; array_push($data, $reqObj); } } usort($data, function ($a, $b) { return $a['start_time'] < $b['start_time'] ? -1 : 1; }); $lastSessionId = ''; { for ($i = 0; $i < count($data); ++$i){ if ($i + 1 >= count($data)) { break; } if ($data[$i]['start_time'] + $time > $data[$i + 1]['start_time']) { ++$i; ++$sameTimes; } if ($lastSessionId) { if ($lastSessionId != $data[$i]['session_id']) { ++$sessionChgTimes; $lastSessionId = $data[$i]['session_id']; } } else { $lastSessionId = $data[$i]['session_id']; } } } myself()->_rspData(array( 'battle_times' => count($data), 'same_times' => $sameTimes, 'session_chg_times' => $sessionChgTimes, 'survival_time' => $survivalTime, 'data' => $data )); } public function exportRankActivity() { $type = getReqVal('type', ''); $count = getReqVal('count', ''); $cond = getReqVal('cond', 0); $accounts = array(); $conn = myself()->_getMysql(''); { $rows = $conn->execQuery( 'SELECT * FROM t_rank_activity ' . 'WHERE type=:type AND channel=:channel AND value>=:value ' . 'ORDER BY value DESC, modifytime ASC ' . "LIMIT ${count}", array( ':type' => $type, ':channel' => 6516, ':value' => $cond ) ); $ranked = 1; foreach ($rows as $row) { array_push($accounts, array( 'account_id' => $row['account_id'], 'name' => '', 'ranked' => $ranked, 'score' => $row['value'], 'modifytime' => $row['modifytime'] )); ++$ranked; } } { foreach ($accounts as &$account) { $row = SqlHelper::ormSelectone( $conn, 't_user', array( 'account_id' => $account['account_id'] ) ); $account['name'] = $row['name']; } } { foreach ($accounts as &$account) { $row = $conn->execQueryOne( 'SELECT MAX(hero_lv) AS max_hero_lv FROM t_hero WHERE account_id=:account_id', array( ':account_id' => $account['account_id'], ) ); $account['max_hero_lv'] = $row['max_hero_lv']; } } { foreach ($accounts as &$account) { $row = $conn->execQueryOne( 'SELECT MAX(quality) AS max_hero_quality FROM t_hero WHERE account_id=:account_id', array( ':account_id' => $account['account_id'], ) ); $account['max_hero_quality'] = $row['max_hero_quality']; } } echo 'account_id,name,rank,score,max_hero_lv,max_hero_quality,flag, time' . "\n"; foreach ($accounts as $account) { $flag = 0; if ($type == 3) { $flag = $account['max_hero_lv'] != $account['score'] ? 1 : 0; } if ($type == 4) { $flag = $account['max_hero_quality'] != $account['score'] ? 1 : 0; } echo phpcommon\extractOpenId($account['account_id']) . ',' . $account['name'] . ',' . $account['ranked'] . ',' . $account['score'] . ',' . $account['max_hero_lv'] . ',' . $account['max_hero_quality'] . ',' . $flag . ',' . phpcommon\timestamp_to_datetime($account['modifytime']) . "\n"; } } public function getRiskAccounts() { $accounts = array(); $conn = myself()->_getMysql(''); { $count = 1000; $rows = $conn->execQuery( 'SELECT * FROM t_rank_activity ' . 'WHERE type=:type AND channel=:channel AND value>=:value ' . 'ORDER BY value DESC, modifytime ASC ' . "LIMIT ${count}", array( ':type' => 1, ':channel' => 6516, ':value' => 600 ) ); $ranked = 1; foreach ($rows as $row) { array_push($accounts, array( 'account_id' => $row['account_id'], 'ranked' => $ranked )); ++$ranked; } } $riskAccountHash = array(); foreach ($accounts as $account) { $rows = SqlHelper::ormSelect( $conn, 't_battle_record', array( 'account_id' => $account['account_id'] ) ); $sessionChgTimes = 0; $lastSessionId = ''; foreach ($rows as $row) { $reqObj = json_decode($row['request'], true); if ($lastSessionId) { if ($lastSessionId != $reqObj['session_id']) { ++$sessionChgTimes; $lastSessionId = $reqObj['session_id']; } } else { $lastSessionId = $reqObj['session_id']; } } $account['session_changed_times'] = $sessionChgTimes; array_push($riskAccountHash, $account); } usort($riskAccountHash, function ($a, $b) { return $a['session_changed_times'] > $b['session_changed_times'] ? -1 : 1; }); echo 'account_id,rank,session_changed_times' . "\n"; foreach ($riskAccountHash as $account) { echo $account['account_id'] . ',' . $account['ranked'] . ',' . $account['session_changed_times'] . "\n"; } } public function exportData() { $type = getReqVal('type', ''); if ($type == 1) { $this->exportData1(); } else if($type == 2) { $this->exportData2(); } else if($type == 3) { $this->exportData3(); } else if($type == 4) { $this->exportData4(); } } public function exportData1() { $type = getReqVal('type', ''); $accounts = array(); $conn = myself()->_getMysql(''); { $rows = $conn->execQuery( 'SELECT * FROM t_battle', array( ) ); echo 'account_id,first_battle_utc_time' . "\n"; foreach ($rows as $row) { $channel = phpcommon\extractChannel($row['account_id']); if ($channel == 6516) { echo phpcommon\extractOpenId($row['account_id']) . ',' . phpcommon\timestamp_to_datetime($row['createtime']) . "\n"; } } } } public function exportData2() { $type = getReqVal('type', ''); $accounts = array(); $conn = myself()->_getMysql(''); { $rows = $conn->execQuery( 'SELECT * FROM t_user', array( ) ); echo 'account_id' . "\n"; foreach ($rows as $row) { $channel = phpcommon\extractChannel($row['account_id']); if ($channel == 6516) { echo $row['account_id'] . "\n"; } } } } public function exportData3() { $type = getReqVal('type', ''); $accounts = array(); $conn = myself()->_getMysql(''); { $rows = $conn->execQuery( 'SELECT * FROM t_dyndata WHERE x=:x AND y=:y', array( ':x' => TN_ACTIVE, ':y' => 0, ) ); echo 'account_id' . ",name,active>=10,active>=30,active>=50,active_value\n"; foreach ($rows as $row) { $channel = phpcommon\extractChannel($row['account_id']); if ($channel == 6516) { $userDb = SqlHelper::ormSelectone( $conn, 't_user', array( 'account_id' => $row['account_id'] ) ); echo $row['account_id'] . ',' . ($userDb ? $userDb['name'] : '') . ',' . ($row['val'] >= 10 && $row['val'] < 30 ? 1 :0) . ',' . ($row['val'] >= 30 && $row['val'] < 50 ? 1 :0) . ',' . ($row['val'] >= 50 ? 1 :0) . ',' . $row['val'] . ',' . "\n"; } } } } public function exportData4() { $conn = myself()->_getMysql(''); $rows = $conn->execQuery( 'SELECT account_id, name FROM t_user', array( ) ); $data = array(); foreach ($rows as $row) { $channel = phpcommon\extractChannel($row['account_id']); if ($channel == BC_CHANNEL) { $row2 = $conn->execQueryOne( 'SELECT count(*) AS battle_times FROM t_battle_record WHERE account_id=:account_id', array( ':account_id' => $row['account_id'] ) ); $data[$row['account_id']] = array( 'account_id' => $row['account_id'], 'name' => $row['name'], 'battle_times' => $row2 ? $row2['battle_times'] : 0 ); } } echo 'account_id' . ",name,game_times\n"; foreach ($data as $item) { echo $item['account_id'] . ',' . $item['name'] . ',' . $item['battle_times'] . "\n"; } } public function exportLock() { $beginTime = getReqVal('begin_time', '0'); $endTime = getReqVal('end_time', '0'); $type = getReqVal('type', '0'); $bceventConn = null; $accountConn = null; { $mysql_conf = getMysqlConfig(crc32('')); if (SERVER_ENV == _ONLINE) { $mysql_conf['database'] = 'bcevent_prod_1'; } else { $mysql_conf['database'] = 'bcevent_dev'; } $bceventConn = new phpcommon\Mysql(array( 'host' => $mysql_conf['host'], 'port' => $mysql_conf['port'], 'user' => $mysql_conf['user'], 'passwd' => $mysql_conf['passwd'], 'dbname' => $mysql_conf['database'], )); } { $mysql_conf = getMysqlConfig(crc32('')); if (SERVER_ENV == _ONLINE) { $mysql_conf['database'] = 'accountdb_prod_1'; } else { $mysql_conf['database'] = 'accountdb1'; } $accountConn = new phpcommon\Mysql(array( 'host' => $mysql_conf['host'], 'port' => $mysql_conf['port'], 'user' => $mysql_conf['user'], 'passwd' => $mysql_conf['passwd'], 'dbname' => $mysql_conf['database'], )); } $heroContractAddress = HERO_CONTRACT_ADDRESS; if ($type == 0) { $sql = "select lock_to, count(idx) as lock_count from t_nft_lock_event where createtime>=$beginTime and createtime<=$endTime and JSON_EXTRACT(convert(return_values using utf8), '$.nft')='$heroContractAddress' group by lock_to;"; } else { $sql = "select lock_to, count(idx) as lock_count from t_nft_lock_event where createtime>=$beginTime and createtime<=$endTime group by lock_to;"; } $rows = $bceventConn->execQuery($sql); foreach ($rows as $row) { $email = $this->getAddressEmail($accountConn, $row['lock_to']); echo $row['lock_to'] . ',' . $email . ',' . $row['lock_count'] . "\n"; } } private function getAddressEmail($accountConn, $accountAddress) { $row = $accountConn->execQueryOne('select * from t_immutable_account where address=:address', array( 'address' => $accountAddress )); // error_log(json_encode($row)); if (!empty($row)) { $dataJson = json_decode($row['data'], true); return $dataJson['decoded']['email']; } else { return ''; } } public function repairInGameMallMail() { $gameDbConn = myself()->_getMysql(''); $mailDbConn = myself()->_getMailMysql(); $rows = $gameDbConn->execQuery( 'SELECT * FROM t_ingame_mall WHERE status=:status AND buy_ok_time<:buy_ok_time', array( 'status' => InGameMall::BUY_OK_STATE, 'buy_ok_time' => myself()->_getNowDaySeconds(), ) ); $mailApiService = new \services\MailApiService(); foreach ($rows as $row) { $goods = $row; $price = $row['price']; //发邮件给卖家 $itemMeta = \mt\Item::get($goods['item_id']); $languageMeta = \mt\Language::get($itemMeta['name']); $itemName = $languageMeta ? $languageMeta['en'] : "The Item"; $taxRate = \mt\Parameter::getVal("market_place_tax_rate",0.05); $taxGold = ceil($price*$taxRate); $falGold = $price - $taxGold; $mailContent = << V_ITEM_GOLD, 'itemnum' => $falGold ) ); echo $mailContent; $mailApiService->sendSellMail( $goods['order_id'], $goods['seller'], \services\MailApiService::SELL_MAIL_SUBJECT, $mailContent, $attachments ); } } public function exportBattleLog() { $accountConn = null; { $mysql_conf = getMysqlConfig(crc32('')); if (SERVER_ENV == _ONLINE) { $mysql_conf['database'] = 'accountdb_prod_1'; } else { $mysql_conf['database'] = 'accountdb1'; } $accountConn = new phpcommon\Mysql(array( 'host' => $mysql_conf['host'], 'port' => $mysql_conf['port'], 'user' => $mysql_conf['user'], 'passwd' => $mysql_conf['passwd'], 'dbname' => $mysql_conf['database'], )); } $data = file_get_contents('php://input'); $array = explode("\r\n", $data); foreach ($array as $accountId) { $row = SqlHelper::ormSelectOne( $accountConn, 't_immutable_account', array( 'account_id' => $accountId ) ); if (empty($row)) { echo "\n"; } else { echo $row['address'] . "\n"; } } } }