1
This commit is contained in:
parent
0ebcd49f49
commit
620a968436
23
doc/Ranking.py
Normal file
23
doc/Ranking.py
Normal file
@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import _common
|
||||
|
||||
class Ranking(object):
|
||||
|
||||
def __init__(self):
|
||||
self.apis = [
|
||||
{
|
||||
'name': 'rankingList',
|
||||
'desc': '获取排行榜',
|
||||
'group': 'Ranking',
|
||||
'url': 'webapp/index.php?c=Ranking&a=rankingList',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['type', 0, '排行榜类型 1:积分榜']
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['ranking_list', [_common.RankingList], '排行榜数据']
|
||||
]
|
||||
}
|
||||
]
|
@ -218,3 +218,29 @@ class Season(object):
|
||||
['noshow_score_bar', 0, '不要显示积分条界面(xx/xx)'],
|
||||
['mission', SeasonMission(), '赛季任务'],
|
||||
]
|
||||
|
||||
class RankingItem(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['ranked', 0, '排名'],
|
||||
['account_id', '', '账号id'],
|
||||
['name', '', '用户名字'],
|
||||
['head_id', 0, '头像id'],
|
||||
['head_frame', 0, '头像框id'],
|
||||
['level', 0, '等级'],
|
||||
['exp', 0, '经验'],
|
||||
['gold', 0, '金币'],
|
||||
['diamond', 0, '钻石'],
|
||||
['hero_id', 0, '当前使用的英雄ID'],
|
||||
['rank', 0, '段位'],
|
||||
]
|
||||
|
||||
class RankingList(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['type', 0, '排行榜类型 1:积分榜'],
|
||||
['!ranking_list', [_RankingItem()], '排行榜']
|
||||
['my_ranked', 0, '我的排名'],
|
||||
]
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
class GMController extends BaseController {
|
||||
|
||||
function __construct()
|
||||
@ -11,7 +10,6 @@ class GMController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function clearDB()
|
||||
{
|
||||
global $g_conf_mysql_cluster;
|
||||
|
@ -1,336 +0,0 @@
|
||||
<?php
|
||||
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
require_once('mt/SeasonPoint.php');
|
||||
|
||||
class RankController extends BaseAuthedController {
|
||||
|
||||
public function rankInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->_getMysql($account_id);
|
||||
$kill_list = array();
|
||||
$kill_rank = 0;
|
||||
$win_list = array();
|
||||
$win_rank = 0;
|
||||
$user_list = array();
|
||||
$integral_rank = 0;
|
||||
$integral_list = array();
|
||||
$score = 0;
|
||||
$myname = '';
|
||||
$myavatar_url = '';
|
||||
//个人信息
|
||||
$row = $conn->execQueryOne('SELECT user_name, avatar_url, kills, alive_time, harm, win_times, game_times, integral FROM user ' .
|
||||
' WHERE account_id=:account_id;',
|
||||
array(
|
||||
':account_id' => $account_id
|
||||
));
|
||||
if ($row) {
|
||||
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||
$seaPoint = mt\SeasonPoint::getOldSeasonPoint($ii);
|
||||
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|
||||
|| $seaPoint['max'] == -1) {
|
||||
$rank = $ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($row['avatar_url'] == '' || $row['user_name'] == '') {
|
||||
$address = '../res/robot@robot' . 1 . '.php';
|
||||
$robot_meta_cluster = require($address);
|
||||
$i = Rand(1, 100);
|
||||
$robot_id = 1000 + $i;
|
||||
$robot_meta = getRobotConfig($robot_meta_cluster, $robot_id);
|
||||
$rob = array(
|
||||
'name' => $robot_meta['name'],
|
||||
'avatar_url' => $robot_meta['avatar_url'],
|
||||
);
|
||||
if ($row['user_name'] == '') {
|
||||
$myname = $rob['name'];
|
||||
} else {
|
||||
$myname = $row['user_name'];
|
||||
}
|
||||
if ($row['avatar_url'] == '') {
|
||||
$myavatar_url = $rob['avatar_url'];
|
||||
} else {
|
||||
$myavatar_url = $row['avatar_url'];
|
||||
}
|
||||
} else {
|
||||
$myname = $row['user_name'];
|
||||
$myavatar_url = $row['avatar_url'];
|
||||
}
|
||||
$myavatar_url = urldecode($myavatar_url);
|
||||
array_push($user_list, array(
|
||||
'account_id' => $account_id,
|
||||
'name' => $myname,
|
||||
'avatar_url' => $myavatar_url,
|
||||
'kill' => phpcommon\safediv($row['kills'], $row['game_times']),
|
||||
'alive'=> phpcommon\safediv($row['alive_time'], $row['game_times']),
|
||||
'harm' => phpcommon\safediv($row['harm'], $row['game_times']),
|
||||
'win_rate' => phpcommon\safediv($row['win_times'], $row['game_times']),
|
||||
'win_game' => $row['win_times'],
|
||||
'score' => $row['integral'],
|
||||
'level' => $rank,
|
||||
));
|
||||
}
|
||||
ini_set('memory_limit','3072M');
|
||||
//击杀榜
|
||||
$r = $this->_getRedis('');
|
||||
//胜场榜
|
||||
$channel = phpcommon\extractChannel($account_id);
|
||||
$win_rank_db = $r->get("game2005api:win_rank_" . $channel);
|
||||
$win_db = json_decode($win_rank_db);
|
||||
$i = 0;
|
||||
foreach ($win_db as $win) {
|
||||
$name = '';
|
||||
$avatar_url = '';
|
||||
if ($i > 49) {
|
||||
break;
|
||||
}
|
||||
if ($win_db[$i][0] == $account_id) {
|
||||
$win_rank = $i + 1;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT head_kuang_id, sex FROM user WHERE account_id=:account_id;',
|
||||
array(
|
||||
':account_id' => $win_db[$i][0],
|
||||
));
|
||||
$head_kuang_id = 0;
|
||||
if ($row['head_kuang_id']) {
|
||||
$head_kuang_id = $row['head_kuang_id'];
|
||||
}
|
||||
$sex = 2;
|
||||
if ($row['sex']) {
|
||||
$sex = $row['sex'];
|
||||
}
|
||||
$addreward = new classes\Addreward();
|
||||
$vip_level = $addreward->getVipLevel($win_db[$i][0]);
|
||||
if ($win_db[$i][2] == '' || $win_db[$i][1] == '') {
|
||||
if ($win_db[$i][0] == $account_id) {
|
||||
$name = $myname;
|
||||
$avatar_url = $myavatar_url;
|
||||
} else {
|
||||
$address = '../res/robot@robot' . 1 . '.php';
|
||||
$robot_meta_cluster = require($address);
|
||||
$j = Rand(1, 100);
|
||||
$robot_id = 1000 + $j;
|
||||
$robot_meta = getRobotConfig($robot_meta_cluster, $robot_id);
|
||||
$rob = array(
|
||||
'name' => $robot_meta['name'],
|
||||
'avatar_url' => $robot_meta['avatar_url'],
|
||||
);
|
||||
if ($win_db[$i][1] == '') {
|
||||
$name = $rob['name'];
|
||||
} else {
|
||||
$name = $win_db[$i][1];
|
||||
}
|
||||
if ($win_db[$i][2] == '') {
|
||||
$avatar_url = $rob['avatar_url'];
|
||||
} else {
|
||||
$avatar_url = $win_db[$i][2];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$name = $win_db[$i][1];
|
||||
$avatar_url = $win_db[$i][2];
|
||||
}
|
||||
$url = urldecode($avatar_url);
|
||||
array_push($win_list, array(
|
||||
'account_id' => $win_db[$i][0],
|
||||
'name' => $name,
|
||||
'avatar_url' => $url,
|
||||
'kill' => $win_db[$i][3],
|
||||
'alive'=> $win_db[$i][4],
|
||||
'harm' => $win_db[$i][5],
|
||||
'win_rate' => $win_db[$i][6],
|
||||
'win_game' => $win_db[$i][7],
|
||||
'head_kuang_id' => $head_kuang_id,
|
||||
'vip_level' => $vip_level,
|
||||
'sex' => $sex,
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
|
||||
//积分榜
|
||||
$channel = phpcommon\extractChannel($account_id);
|
||||
$integral_rank_db = $r->get("game2005api:integral_rank_" . $channel);
|
||||
$integral_db = json_decode($integral_rank_db);
|
||||
$i = 0;
|
||||
foreach ($integral_db as $integral) {
|
||||
$name = '';
|
||||
$avatar_url = '';
|
||||
if ($i > 49) {
|
||||
break;
|
||||
}
|
||||
$score = 0;
|
||||
$rank = 0;
|
||||
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||
$seaPoint = mt\SeasonPoint::getOldSeasonPoint($ii);
|
||||
if ($integral_db[$i][8] >= $seaPoint['min'] && $integral_db[$i][8] <= $seaPoint['max']
|
||||
|| $integral_db[$i][8] >= $seaPoint['min'] && $seaPoint['max'] == -1)
|
||||
{
|
||||
$rank = $ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT head_kuang_id, sex FROM user WHERE account_id=:account_id;',
|
||||
array(
|
||||
':account_id' => $integral_db[$i][0],
|
||||
));
|
||||
$head_kuang_id = 0;
|
||||
if ($row['head_kuang_id']) {
|
||||
$head_kuang_id = $row['head_kuang_id'];
|
||||
}
|
||||
$sex = 2;
|
||||
if ($row['sex']) {
|
||||
$sex = $row['sex'];
|
||||
}
|
||||
$addreward = new classes\Addreward();
|
||||
$vip_level = $addreward->getVipLevel($integral_db[$i][0]);
|
||||
if ($integral_db[$i][0] == $account_id) {
|
||||
$integral_rank = $i + 1;
|
||||
}
|
||||
if ($integral_db[$i][2] == '' || $integral_db[$i][1] == '') {
|
||||
if ($integral_db[$i][0] == $account_id) {
|
||||
$name = $myname;
|
||||
$avatar_url = $myavatar_url;
|
||||
} else {
|
||||
$address = '../res/robot@robot' . 1 . '.php';
|
||||
$robot_meta_cluster = require($address);
|
||||
$j = Rand(1, 100);
|
||||
$robot_id = 1000 + $j;
|
||||
$robot_meta = getRobotConfig($robot_meta_cluster, $robot_id);
|
||||
$rob = array(
|
||||
'name' => $robot_meta['name'],
|
||||
'avatar_url' => $robot_meta['avatar_url'],
|
||||
);
|
||||
if ($integral_db[$i][1] == '') {
|
||||
$name = $rob['name'];
|
||||
} else {
|
||||
$name = $integral_db[$i][1];
|
||||
}
|
||||
if ($integral_db[$i][2] == '') {
|
||||
$avatar_url = $rob['avatar_url'];
|
||||
} else {
|
||||
$avatar_url = $integral_db[$i][2];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$name = $integral_db[$i][1];
|
||||
$avatar_url = $integral_db[$i][2];
|
||||
}
|
||||
$url = urldecode($avatar_url);
|
||||
array_push($integral_list, array(
|
||||
'account_id' => $integral_db[$i][0],
|
||||
'name' => $name,
|
||||
'avatar_url' => $url,
|
||||
'kill' => $integral_db[$i][3],
|
||||
'alive'=> $integral_db[$i][4],
|
||||
'harm' => $integral_db[$i][5],
|
||||
'win_rate' => $integral_db[$i][6],
|
||||
'win_game' => $integral_db[$i][7],
|
||||
'score' => $integral_db[$i][8],
|
||||
'level' => $rank,
|
||||
'head_kuang_id' => $head_kuang_id,
|
||||
'vip_level' => $vip_level,
|
||||
'sex' => $sex,
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => "",
|
||||
'user_list' => $user_list,
|
||||
'win_rank' => $win_rank,
|
||||
'win_list' => $win_list,
|
||||
'integral_rank' => $integral_rank,
|
||||
'integral_list' => $integral_list,
|
||||
));
|
||||
}
|
||||
|
||||
public function getRankInfo()
|
||||
{
|
||||
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->_getMysql($account_id);
|
||||
|
||||
|
||||
$killResultArr = array();
|
||||
$rankPointArr = array();
|
||||
//获得自己的击杀排行榜
|
||||
$sqlStr = "SELECT account_id,user_name,hi_id,head_kuang_id,kills,win_times FROM user WHERE account_id=:account_id";
|
||||
$row = $conn->execQuery($sqlStr,array(':account_id' => $account_id));
|
||||
if($row)
|
||||
{
|
||||
array_push($killResultArr,$row[0]);
|
||||
}
|
||||
//击杀排行榜
|
||||
$sqlStr = "SELECT account_id,user_name,hi_id,head_kuang_id,kills,win_times FROM user order by win_times desc limit 50";
|
||||
$row = $conn->execQuery($sqlStr);
|
||||
if($row) {
|
||||
$len = count($row);
|
||||
for($i = 0 ; $i < $len ; $i ++)
|
||||
{
|
||||
array_push($killResultArr,$row[$i]);
|
||||
}
|
||||
}
|
||||
//获得自己的排位积分
|
||||
$sqlStr = "SELECT account_id,user_name,hi_id,head_kuang_id,integral FROM user WHERE account_id=:account_id";
|
||||
$row = $conn->execQuery($sqlStr,array(':account_id' => $account_id));
|
||||
if($row)
|
||||
{
|
||||
array_push($rankPointArr,$row[0]);
|
||||
}
|
||||
//积分排行榜
|
||||
$sqlStr = "SELECT account_id,user_name,hi_id,head_kuang_id,integral FROM user order by integral desc limit 50";
|
||||
$row = $conn->execQuery($sqlStr);
|
||||
if($row) {
|
||||
$len = count($row);
|
||||
for($i = 0 ; $i < $len ; $i ++)
|
||||
{
|
||||
array_push($rankPointArr,$row[$i]);
|
||||
}
|
||||
}
|
||||
//好友排行榜
|
||||
|
||||
$resultData = array();
|
||||
array_push($resultData,$killResultArr);
|
||||
array_push($resultData,$rankPointArr);
|
||||
|
||||
|
||||
|
||||
|
||||
$this->sendDataToClient(100,"getRankInfo",$resultData);
|
||||
}
|
||||
public function mailTest()
|
||||
{
|
||||
$url = '';
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
$url = 'https://gamemail.kingsome.cn/webapp/index.php?c=MailMgr&a=sendMail&';
|
||||
} else {
|
||||
$url = 'https://gamemail-test.kingsome.cn/webapp/index.php?c=MailMgr&a=sendMail&';
|
||||
}
|
||||
$params = array(
|
||||
'gameid' => "1234",
|
||||
'to' => $account_id,
|
||||
'from' => $account_id,
|
||||
'mailsubtype'=>12,
|
||||
'content'=>"采蘑菇的小朋友",
|
||||
'subject'=>"皮卡猪",
|
||||
"attachments"=>"1001:10|1002:20",
|
||||
"ext"=>"10"
|
||||
);
|
||||
if (!phpcommon\HttpClient::get($url, $params, $response)) {
|
||||
phpcommon\sendError(ERR_RETRY, '系统繁忙');
|
||||
return;
|
||||
}
|
||||
$data = json_decode($response, true);
|
||||
//error_log("邮件测试=====".json_encode($data));
|
||||
$this->sendDataToClient(100,"MailTest",$data);
|
||||
}
|
||||
|
||||
}
|
13
webapp/controller/RankingController.class.php
Normal file
13
webapp/controller/RankingController.class.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
require_once('mt/SeasonPoint.php');
|
||||
|
||||
class RankingController extends BaseAuthedController {
|
||||
|
||||
public function rankingList()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user