1
This commit is contained in:
parent
4798a45cd2
commit
0c8f7a74ac
@ -28,18 +28,12 @@ def info(msg):
|
|||||||
def take_kills(elem):
|
def take_kills(elem):
|
||||||
return elem[3]
|
return elem[3]
|
||||||
|
|
||||||
def take_alive_time(elem):
|
|
||||||
return elem[4]
|
|
||||||
|
|
||||||
def take_harms(elem):
|
|
||||||
return elem[5]
|
|
||||||
|
|
||||||
def take_win_times(elem):
|
|
||||||
return elem[6]
|
|
||||||
|
|
||||||
def take_game_times(elem):
|
def take_game_times(elem):
|
||||||
return elem[7]
|
return elem[7]
|
||||||
|
|
||||||
|
def take_integral_times(elem):
|
||||||
|
return elem[8]
|
||||||
|
|
||||||
def safeDiv(a, b):
|
def safeDiv(a, b):
|
||||||
if b == 0:
|
if b == 0:
|
||||||
return 0
|
return 0
|
||||||
@ -78,37 +72,20 @@ def refreshData(row, data_list, data_info):
|
|||||||
alive_time = safeDiv(row[4], row[7])
|
alive_time = safeDiv(row[4], row[7])
|
||||||
harm = safeDiv(row[5], row[7])
|
harm = safeDiv(row[5], row[7])
|
||||||
win_times = safeDiv(row[6], row[7])
|
win_times = safeDiv(row[6], row[7])
|
||||||
|
print(row[9])
|
||||||
data_list.append((row[0], row[1].decode('utf-8'), row[2], kill, alive_time, harm, win_times, row[6], row[9]))
|
data_list.append((row[0], row[1].decode('utf-8'), row[2], kill, alive_time, harm, win_times, row[6], row[9]))
|
||||||
data_list.sort(key=key_info, reverse=True)
|
data_list.sort(key=key_info, reverse=True)
|
||||||
if (len(data_list) > 50):
|
if (len(data_list) > 50):
|
||||||
del data_list[50:]
|
del data_list[50:]
|
||||||
|
|
||||||
#更新排行榜
|
#更新排行榜
|
||||||
def updateRank(r, kill_list, alive_list, harm_list, rate_list, win_list):
|
def updateRank(r, kill_list, win_list ,integral_list):
|
||||||
kill_list.sort(key=take_kills, reverse=True)
|
kill_list.sort(key=take_kills, reverse=True)
|
||||||
kill_rank = []
|
kill_rank = []
|
||||||
for kill_index in range(min(50, len(kill_list))):
|
for kill_index in range(min(50, len(kill_list))):
|
||||||
kill_rank.append(kill_list[kill_index])
|
kill_rank.append(kill_list[kill_index])
|
||||||
r.set("game2001api: kill_rank", json.dumps(kill_rank))
|
r.set("game2001api: kill_rank", json.dumps(kill_rank))
|
||||||
|
|
||||||
alive_list.sort(key=take_alive_time, reverse=True)
|
|
||||||
alive_rank = []
|
|
||||||
for alive_index in range(min(50, len(alive_list))):
|
|
||||||
alive_rank.append(alive_list[alive_index])
|
|
||||||
r.set("game2001api: alive_rank", json.dumps(alive_rank))
|
|
||||||
|
|
||||||
harm_list.sort(key=take_harms, reverse=True)
|
|
||||||
harm_rank = []
|
|
||||||
for harm_index in range(min(50, len(harm_list))):
|
|
||||||
harm_rank.append(harm_list[harm_index])
|
|
||||||
r.set("game2001api: harm_rank", json.dumps(harm_rank))
|
|
||||||
|
|
||||||
rate_list.sort(key=take_win_times, reverse=True)
|
|
||||||
rate_rank = []
|
|
||||||
for rate_index in range(min(50, len(rate_list))):
|
|
||||||
rate_rank.append(rate_list[rate_index])
|
|
||||||
r.set("game2001api: rate_rank", json.dumps(rate_rank))
|
|
||||||
|
|
||||||
win_list.sort(key=take_game_times, reverse=True)
|
win_list.sort(key=take_game_times, reverse=True)
|
||||||
win_rank = []
|
win_rank = []
|
||||||
for win_index in range(min(50, len(win_list))):
|
for win_index in range(min(50, len(win_list))):
|
||||||
@ -150,12 +127,6 @@ def dayReadMysqlData(rushtime):
|
|||||||
has_data = True
|
has_data = True
|
||||||
#更新击杀榜
|
#更新击杀榜
|
||||||
refreshData(row, kill_list, take_kills)
|
refreshData(row, kill_list, take_kills)
|
||||||
#更新生存榜
|
|
||||||
refreshData(row, alive_list, take_alive_time)
|
|
||||||
#更新伤害榜
|
|
||||||
refreshData(row, harm_list, take_harms)
|
|
||||||
#更新胜率榜
|
|
||||||
refreshData(row, rate_list, take_win_times)
|
|
||||||
#更新胜场榜
|
#更新胜场榜
|
||||||
refreshData(row, win_list, take_game_times)
|
refreshData(row, win_list, take_game_times)
|
||||||
#更新积分榜
|
#更新积分榜
|
||||||
@ -168,7 +139,7 @@ def dayReadMysqlData(rushtime):
|
|||||||
break
|
break
|
||||||
|
|
||||||
r = getRedis()
|
r = getRedis()
|
||||||
updateRank(r, kill_list, alive_list, harm_list, rate_list, win_list, integral_list)
|
updateRank(r, kill_list, win_list, integral_list)
|
||||||
tornado.ioloop.IOLoop.current().call_later(getDaySeconds(time.time(), 1) + rushtime,
|
tornado.ioloop.IOLoop.current().call_later(getDaySeconds(time.time(), 1) + rushtime,
|
||||||
lambda : dayReadMysqlData(rushtime)
|
lambda : dayReadMysqlData(rushtime)
|
||||||
)
|
)
|
||||||
@ -183,24 +154,6 @@ def readMysqlData(rushtime):
|
|||||||
else:
|
else:
|
||||||
kill_list = json.loads(kill_list_str)
|
kill_list = json.loads(kill_list_str)
|
||||||
|
|
||||||
alive_list_str = r.get("game2001api: alive_rank")
|
|
||||||
if (not alive_list_str):
|
|
||||||
alive_list = []
|
|
||||||
else:
|
|
||||||
alive_list = json.loads(alive_list_str)
|
|
||||||
|
|
||||||
harm_list_str = r.get("game2001api: harm_rank")
|
|
||||||
if (not harm_list_str):
|
|
||||||
harm_list = []
|
|
||||||
else:
|
|
||||||
harm_list = json.loads(harm_list_str)
|
|
||||||
|
|
||||||
rate_list_str = r.get("game2001api: rate_rank")
|
|
||||||
if (not rate_list_str):
|
|
||||||
rate_list = []
|
|
||||||
else:
|
|
||||||
rate_list = json.loads(rate_list_str)
|
|
||||||
|
|
||||||
win_list_str = r.get("game2001api: win_rank")
|
win_list_str = r.get("game2001api: win_rank")
|
||||||
if (not win_list_str):
|
if (not win_list_str):
|
||||||
win_list = []
|
win_list = []
|
||||||
@ -222,6 +175,8 @@ def readMysqlData(rushtime):
|
|||||||
charset = 'utf8'
|
charset = 'utf8'
|
||||||
)
|
)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
last_idx = 0
|
||||||
|
temp_idx = 0
|
||||||
while 1:
|
while 1:
|
||||||
cursor.execute('SELECT accountid, user_name, avatar_url, kills, alive_time,'
|
cursor.execute('SELECT accountid, user_name, avatar_url, kills, alive_time,'
|
||||||
' harm, win_times, game_times, idx, integral, modify_time FROM user '
|
' harm, win_times, game_times, idx, integral, modify_time FROM user '
|
||||||
@ -232,15 +187,6 @@ def readMysqlData(rushtime):
|
|||||||
#更新击杀榜
|
#更新击杀榜
|
||||||
delRepeatData(row, kill_list)
|
delRepeatData(row, kill_list)
|
||||||
refreshData(row, kill_list, take_kills)
|
refreshData(row, kill_list, take_kills)
|
||||||
#更新生存榜
|
|
||||||
delRepeatData(row, alive_list)
|
|
||||||
refreshData(row, alive_list, take_alive_time)
|
|
||||||
#更新伤害榜
|
|
||||||
delRepeatData(row, harm_list)
|
|
||||||
refreshData(row, harm_list, take_harms)
|
|
||||||
#更新胜率榜
|
|
||||||
delRepeatData(row, rate_list)
|
|
||||||
refreshData(row, rate_list, take_win_times)
|
|
||||||
#更新胜场榜
|
#更新胜场榜
|
||||||
delRepeatData(row, win_list)
|
delRepeatData(row, win_list)
|
||||||
refreshData(row, win_list, take_game_times)
|
refreshData(row, win_list, take_game_times)
|
||||||
@ -252,8 +198,7 @@ def readMysqlData(rushtime):
|
|||||||
last_idx = int(row[8])
|
last_idx = int(row[8])
|
||||||
if not has_data:
|
if not has_data:
|
||||||
break
|
break
|
||||||
|
updateRank(r, kill_list, win_list, integral_list)
|
||||||
updateRank(r, kill_list, alive_list, harm_list, rate_list, win_list, integral_list)
|
|
||||||
tornado.ioloop.IOLoop.current().call_later(rushtime,
|
tornado.ioloop.IOLoop.current().call_later(rushtime,
|
||||||
lambda : readMysqlData(rushtime)
|
lambda : readMysqlData(rushtime)
|
||||||
)
|
)
|
||||||
@ -279,7 +224,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
app = make_app()
|
app = make_app()
|
||||||
app.listen(conf['listen_port'])
|
app.listen(conf['listen_port'])
|
||||||
conf['rushtime'] = 300
|
conf['rushtime'] = 5
|
||||||
tornado.ioloop.IOLoop.current().call_later(conf['rushtime'],
|
tornado.ioloop.IOLoop.current().call_later(conf['rushtime'],
|
||||||
lambda : readMysqlData(conf['rushtime'])
|
lambda : readMysqlData(conf['rushtime'])
|
||||||
)
|
)
|
||||||
|
@ -100,6 +100,10 @@ class AddReward {
|
|||||||
//添加角色碎片
|
//添加角色碎片
|
||||||
$this->addSkinFragment($item['itemid'], $item['itemnum'], $account_id);
|
$this->addSkinFragment($item['itemid'], $item['itemnum'], $account_id);
|
||||||
break;
|
break;
|
||||||
|
case 7:
|
||||||
|
//添加通行证
|
||||||
|
$this->addPass($item['itemid'], $item['itemnum'], $account_id);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -320,5 +324,23 @@ class AddReward {
|
|||||||
'itemnum' => $item_num,
|
'itemnum' => $item_num,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
//添加通行证
|
||||||
|
protected function addPass($item_id, $item_num, $accountid)
|
||||||
|
{
|
||||||
|
$conn = $this->getMysql($accountid);
|
||||||
|
if (!$conn) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$user_ret = $conn->execScript('UPDATE user SET pass_status=1, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$user_ret) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -66,6 +66,7 @@ class PassController{
|
|||||||
'min' => $seaPoint_meta['min_point'],
|
'min' => $seaPoint_meta['min_point'],
|
||||||
'max' => $seaPoint_meta['max_point'],
|
'max' => $seaPoint_meta['max_point'],
|
||||||
'des' => $seaPoint_meta['des'],
|
'des' => $seaPoint_meta['des'],
|
||||||
|
'reward' => $seaPoint_meta['season_reward'],
|
||||||
);
|
);
|
||||||
return $seaPoint;
|
return $seaPoint;
|
||||||
}
|
}
|
||||||
@ -94,6 +95,17 @@ class PassController{
|
|||||||
if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
|
if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
|
||||||
$open_time = strtotime($season['open_time']);
|
$open_time = strtotime($season['open_time']);
|
||||||
$end_time = strtotime($season['end_time']);
|
$end_time = strtotime($season['end_time']);
|
||||||
|
$ret = $conn->execScript('UPDATE user SET season_time=:season_time, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $accountid,
|
||||||
|
':season_time' => $end_time,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$ret) {
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
$number = $i;
|
$number = $i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -106,6 +118,7 @@ class PassController{
|
|||||||
$rank = 0;
|
$rank = 0;
|
||||||
$rank_score = 0;
|
$rank_score = 0;
|
||||||
$max_rank_score = 0;
|
$max_rank_score = 0;
|
||||||
|
$reward = array();
|
||||||
$row = $conn->execQueryOne('SELECT integral, pass_status, score FROM user WHERE accountid=:accountid;',
|
$row = $conn->execQueryOne('SELECT integral, pass_status, score FROM user WHERE accountid=:accountid;',
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
@ -118,13 +131,20 @@ class PassController{
|
|||||||
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||||
$seaPoint = $this->getSeasonPoint($ii);
|
$seaPoint = $this->getSeasonPoint($ii);
|
||||||
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|
||||||
|| $seaPoint['max'] == -1) {
|
|| $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1)
|
||||||
|
{
|
||||||
|
$delim = ':';
|
||||||
|
$drop_multiply = explode($delim, $seaPoint['reward']);
|
||||||
|
array_push($reward, array(
|
||||||
|
'item_id' => $drop_multiply[0],
|
||||||
|
'item_num' => $drop_multiply[1],
|
||||||
|
));
|
||||||
$rank = $ii;
|
$rank = $ii;
|
||||||
|
$max_rank_score = $seaPoint['max'] + 1;
|
||||||
$rank_score = $row['integral'] - $seaPoint['min'];
|
$rank_score = $row['integral'] - $seaPoint['min'];
|
||||||
$max_rank_score = $seaPoint['max'];
|
if ($seaPoint['max'] == -1) {
|
||||||
}
|
$max_rank_score = $seaPoint['min'];
|
||||||
if ($ii == count($seaPoint_meta_table)) {
|
}
|
||||||
$max_rank_score = $seaPoint['min'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($rank == 0) {
|
if ($rank == 0) {
|
||||||
@ -146,44 +166,60 @@ class PassController{
|
|||||||
$drop_multiply = array();
|
$drop_multiply = array();
|
||||||
$status = 0;
|
$status = 0;
|
||||||
$seaReward = $this->getSeasonReward($id - 1);
|
$seaReward = $this->getSeasonReward($id - 1);
|
||||||
if ($row['score'] >= $seaReward['point'] && $seaReward['point'] >= 0) {
|
if ($row['score'] <= $seaReward['point']) {
|
||||||
$level = $seaReward['level'];
|
$level = $seaReward['level'];
|
||||||
$pass_score = $row['score'] - $seaReward['point'];
|
$pass_score = $seaReward['point'] - $row['score'];
|
||||||
$max_pass_score = $seaReward['point'];
|
$max_pass_score = $seaReward['point'];
|
||||||
|
if ($id - 1 == 100) {
|
||||||
|
$pass_score = $row['score'];
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
foreach ($seaReward_meta_table as $seaR) {
|
||||||
//如果是最大等级,则返回上一级的最大值
|
//如果是最大等级,则返回上一级的最大值
|
||||||
if ($max_pass_score == -1) {
|
if ($seaR['point'] == -1) {
|
||||||
$seaR = $this->getSeasonReward($id - 2);
|
$sea = $this->getSeasonReward($seaR['id'] - 1);
|
||||||
$sum_score = $seaR['point'];
|
$sum_score = $sea['point'];
|
||||||
} else {
|
} else {
|
||||||
$sum_score = $seaReward['point'];
|
$sum_score = $seaR['point'];
|
||||||
}
|
}
|
||||||
$rowPass = $conn->execQueryOne('SELECT active_status, honor_status ' .
|
$rowPass = $conn->execQueryOne('SELECT active_status, honor_status ' .
|
||||||
' FROM passinfo WHERE accountid=:accountid AND passid=:passid;',
|
' FROM passinfo WHERE accountid=:accountid AND passid=:passid;',
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
':passid' => $seaReward['id']
|
':passid' => $seaR['id']
|
||||||
));
|
));
|
||||||
|
$itemid = 0;
|
||||||
|
$itemnum = 0;
|
||||||
for ($t = 1; $t <= 2; $t++) {
|
for ($t = 1; $t <= 2; $t++) {
|
||||||
$delim = ":";
|
$delim = ":";
|
||||||
if ($t == 1) {
|
if ($t == 1) {
|
||||||
$drop_multiply = explode($delim, $seaReward['active']);
|
if ($seaR['reward1'] != '') {
|
||||||
|
$drop_multiply = explode($delim, $seaR['reward1']);
|
||||||
|
$itemid = $drop_multiply[0];
|
||||||
|
$itemnum = $drop_multiply[1];
|
||||||
|
}
|
||||||
if ($rowPass) {
|
if ($rowPass) {
|
||||||
$status = $rowPass['active_status'];
|
$status = $rowPass['active_status'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($t == 2) {
|
if ($t == 2) {
|
||||||
$drop_multiply = explode($delim, $seaReward['honor']);
|
if ($seaR['reward2'] != '') {
|
||||||
|
$drop_multiply = explode($delim, $seaR['reward2']);
|
||||||
|
$itemid = $drop_multiply[0];
|
||||||
|
$itemnum = $drop_multiply[1];
|
||||||
|
}
|
||||||
if ($rowPass) {
|
if ($rowPass) {
|
||||||
$status = $rowPass['honor_status'];
|
$status = $rowPass['honor_status'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
array_push($item_list, array(
|
array_push($item_list, array(
|
||||||
'id' => $id - 1,
|
'id' => $seaR['id'],
|
||||||
'type' => $t,
|
'type' => $t,
|
||||||
'point' => $seaReward['point'],
|
'point' => $seaR['point'],
|
||||||
'item_id' => $drop_multiply[0],
|
'item_id' => $itemid,
|
||||||
'item_num' => $drop_multiply[1],
|
'item_num' => $itemnum,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -202,10 +238,12 @@ class PassController{
|
|||||||
'sum_score' => $sum_score,
|
'sum_score' => $sum_score,
|
||||||
'pass_score' => $pass_score,
|
'pass_score' => $pass_score,
|
||||||
'max_pass_score' => $max_pass_score,
|
'max_pass_score' => $max_pass_score,
|
||||||
|
'reward' => $reward,
|
||||||
'item_list' => $item_list
|
'item_list' => $item_list
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getPassReward()
|
public function getPassReward()
|
||||||
{
|
{
|
||||||
$account_id = $_REQUEST['account_id'];
|
$account_id = $_REQUEST['account_id'];
|
||||||
@ -332,5 +370,68 @@ class PassController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSeaReward()
|
||||||
|
{
|
||||||
|
$account_id = $_REQUEST['account_id'];
|
||||||
|
//登录校验
|
||||||
|
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||||
|
if (!$login) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$conn = $this->getMysql($account_id);
|
||||||
|
if (!$conn) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = $conn->execQueryOne('SELECT integral, season_status FROM user WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
));
|
||||||
|
if (!$row) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row['season_status'] == 1) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2, '赛季未结束');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$reward = array();
|
||||||
|
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||||
|
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||||
|
$seaPoint = $this->getSeasonPoint($ii);
|
||||||
|
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|
||||||
|
|| $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1)
|
||||||
|
{
|
||||||
|
$delim = ':';
|
||||||
|
$drop_multiply = explode($delim, $seaPoint['reward']);
|
||||||
|
array_push($reward, array(
|
||||||
|
'item_id' => $drop_multiply[0],
|
||||||
|
'item_num' => $drop_multiply[1],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($reward as $r) {
|
||||||
|
$addreward = new classes\AddReward();
|
||||||
|
$addreward->addReward($r['item_id'], $r['item_num'], $account_id);
|
||||||
|
}
|
||||||
|
$ret = $conn->execScript('UPDATE user SET integral=0, season_status=1, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $accountid,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$ret) {
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg'=> '',
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -17,6 +17,78 @@ class PayNotifyController{
|
|||||||
return $conn;
|
return $conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function insertNewOrder($conn, $nowtime, $item_list)
|
||||||
|
{
|
||||||
|
$ret = $conn->execScript('INSERT INTO orderinfo(accountid, orderid, itemid, coin, status, '.
|
||||||
|
' confirmtime, create_time, modify_time, item_list)' .
|
||||||
|
'VALUES(:accountid, :orderid, :itemid, :coin, :status,' .
|
||||||
|
' :confirmtime, :create_time, :modify_time, :item_list);',
|
||||||
|
array(
|
||||||
|
':accountid' => $_REQUEST['account_id'],
|
||||||
|
':orderid' => $_REQUEST['orderid'],
|
||||||
|
':coin' => $_REQUEST['amount'],
|
||||||
|
':itemid' => $_REQUEST['itemid'],
|
||||||
|
':status' => 1,
|
||||||
|
':confirmtime' => $nowtime,
|
||||||
|
':create_time' => $nowtime,
|
||||||
|
':modify_time' => $nowtime,
|
||||||
|
':item_list' => json_encode($item_list)
|
||||||
|
));
|
||||||
|
if (!$ret) {
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 2,
|
||||||
|
'errmsg'=> '服务器内部错误'
|
||||||
|
));
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function updateOrder($conn, $item_list)
|
||||||
|
{
|
||||||
|
$ret = $conn->execScript('UPDATE orderinfo SET status=1, item_list=:item_list WHERE orderid=:orderid'.
|
||||||
|
array(
|
||||||
|
':orderid' => $_REQUEST['orderid'],
|
||||||
|
':item_list' => json_encode($item_list)
|
||||||
|
));
|
||||||
|
if (!$ret) {
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 2,
|
||||||
|
'errmsg'=> '服务器内部错误'
|
||||||
|
));
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function updateUserTable($conn, $amount)
|
||||||
|
{
|
||||||
|
$ret = $conn->execScript('UPDATE user SET recharge_times_total=recharge_times_total + 1, ' .
|
||||||
|
' sum_coin=sum_coin + :amount WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $_REQUEST['account_id'],
|
||||||
|
':amount' => $amount
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addToBuyHis($conn, $nowtime)
|
||||||
|
{
|
||||||
|
$dayseconds = phpcommon\getdayseconds($nowtime);
|
||||||
|
$conn->execScript('INSERT INTO buy_his(accountid, itemid, sum_times, today_times, ' .
|
||||||
|
' last_buy_time, create_time, modify_time)' .
|
||||||
|
'VALUES(:accountid, :itemid, 1, 1, ' .
|
||||||
|
' :last_buy_time, :create_time, :modify_time)' .
|
||||||
|
'ON DUPLICATE KEY UPDATE sum_times=sum_times + 1, ' .
|
||||||
|
' modify_time=:modify_time, last_buy_time=:last_buy_time,' .
|
||||||
|
' today_times=' .
|
||||||
|
" CASE WHEN last_buy_time < $dayseconds THEN 1 ELSE today_times + 1 END;",
|
||||||
|
array(
|
||||||
|
':accountid' => $_REQUEST['account_id'],
|
||||||
|
':itemid' => $_REQUEST['itemid'],
|
||||||
|
':last_buy_time' => $nowtime,
|
||||||
|
':create_time' => $nowtime,
|
||||||
|
':modify_time' => $nowtime,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public function payNotify()
|
public function payNotify()
|
||||||
{
|
{
|
||||||
$params = array(
|
$params = array(
|
||||||
@ -48,28 +120,7 @@ class PayNotifyController{
|
|||||||
':orderid' => $_REQUEST['orderid']
|
':orderid' => $_REQUEST['orderid']
|
||||||
));
|
));
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
$ret = $conn->execScript('INSERT INTO orderinfo(accountid, orderid, itemid, coin, status, '.
|
$this->insertNewOrder($conn, $nowtime, $item_list);
|
||||||
' confirmtime, create_time, modify_time, item_list)' .
|
|
||||||
'VALUES(:accountid, :orderid, :itemid, :coin, :status,' .
|
|
||||||
' :confirmtime, :create_time, :modify_time, :item_list);',
|
|
||||||
array(
|
|
||||||
':accountid' => $_REQUEST['account_id'],
|
|
||||||
':orderid' => $_REQUEST['orderid'],
|
|
||||||
':coin' => $_REQUEST['amount'],
|
|
||||||
':itemid' => $_REQUEST['itemid'],
|
|
||||||
':status' => 1,
|
|
||||||
':confirmtime' => $nowtime,
|
|
||||||
':create_time' => $nowtime,
|
|
||||||
':modify_time' => $nowtime,
|
|
||||||
':item_list' => json_encode($item_list)
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
echo json_encode(array(
|
|
||||||
'errcode' => 2,
|
|
||||||
'errmsg'=> '服务器内部错误'
|
|
||||||
));
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ($row['status'] == 1) {
|
if ($row['status'] == 1) {
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
@ -78,35 +129,10 @@ class PayNotifyController{
|
|||||||
));
|
));
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
$ret = $conn->execScript('UPDATE orderinfo SET status=1, item_list=:item_list WHERE orderid=:orderid'.
|
$this->updateOrder($conn, $item_list);
|
||||||
array(
|
|
||||||
':orderid' => $_REQUEST['orderid'],
|
|
||||||
':item_list' => json_encode($item_list)
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
echo json_encode(array(
|
|
||||||
'errcode' => 2,
|
|
||||||
'errmsg'=> '服务器内部错误'
|
|
||||||
));
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$dayseconds = phpcommon\getdayseconds($nowtime);
|
$this->updateUserTable($conn, $_REQUEST['amount']);
|
||||||
$conn->execScript('INSERT INTO buy_his(accountid, itemid, sum_times, today_times, ' .
|
$this->addToBuyHis($conn, $nowtime);
|
||||||
' last_buy_time, create_time, modify_time)' .
|
|
||||||
'VALUES(:accountid, :itemid, 1, 1, ' .
|
|
||||||
' :last_buy_time, :create_time, :modify_time)' .
|
|
||||||
'ON DUPLICATE KEY UPDATE sum_times=sum_times + 1, ' .
|
|
||||||
' modify_time=:modify_time, last_buy_time=:last_buy_time,' .
|
|
||||||
' today_times=' .
|
|
||||||
" CASE WHEN last_buy_time < $dayseconds THEN 1 ELSE today_times + 1 END;",
|
|
||||||
array(
|
|
||||||
':accountid' => $_REQUEST['account_id'],
|
|
||||||
':itemid' => $_REQUEST['itemid'],
|
|
||||||
':last_buy_time' => $nowtime,
|
|
||||||
':create_time' => $nowtime,
|
|
||||||
':modify_time' => $nowtime,
|
|
||||||
));
|
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'errcode' => 0,
|
'errcode' => 0,
|
||||||
'errmsg'=> ''
|
'errmsg'=> ''
|
||||||
|
@ -77,20 +77,21 @@ class RankController{
|
|||||||
|| $seaPoint['max'] == -1) {
|
|| $seaPoint['max'] == -1) {
|
||||||
$rank = $ii;
|
$rank = $ii;
|
||||||
$score = $row['integral'] - $seaPoint['min'];
|
$score = $row['integral'] - $seaPoint['min'];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
array_push($user_list, array(
|
|
||||||
'account_id' => $account_id,
|
|
||||||
'name' => $row['user_name'],
|
|
||||||
'avatar_url' => $row['avatar_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' => $score,
|
|
||||||
'level' => $rank,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
array_push($user_list, array(
|
||||||
|
'account_id' => $account_id,
|
||||||
|
'name' => $row['user_name'],
|
||||||
|
'avatar_url' => $row['avatar_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' => $score,
|
||||||
|
'level' => $rank,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
ini_set('memory_limit','3072M');
|
ini_set('memory_limit','3072M');
|
||||||
//击杀榜
|
//击杀榜
|
||||||
@ -102,31 +103,32 @@ class RankController{
|
|||||||
if ($i > 49) {
|
if ($i > 49) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
/*$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||||
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||||
$seaPoint = $this->getSeasonPoint($ii);
|
$seaPoint = $this->getSeasonPoint($ii);
|
||||||
if ($kill_db[$i][8] >= $seaPoint['min'] && $kill_db[$i][8] <= $seaPoint['max']
|
if ($kill_db[$i][8] >= $seaPoint['min'] && $kill_db[$i][8] <= $seaPoint['max']
|
||||||
|| $seaPoint['max'] == -1) {
|
|| $seaPoint['max'] == -1) {
|
||||||
$rank = $ii;
|
$rank = $ii;
|
||||||
$score = $kill_db[$i][8] - $seaPoint['min'];
|
$score = $kill_db[$i][8] - $seaPoint['min'];
|
||||||
}
|
}
|
||||||
if ($kill_db[$i][0] == $account_id) {
|
}*/
|
||||||
$kill_rank = $i + 1;
|
if ($kill_db[$i][0] == $account_id) {
|
||||||
}
|
$kill_rank = $i + 1;
|
||||||
array_push($kill_list, array(
|
|
||||||
'account_id' => $kill_db[$i][0],
|
|
||||||
'name' => $kill_db[$i][1],
|
|
||||||
'avatar_url' => $kill_db[$i][2],
|
|
||||||
'kill' => $kill_db[$i][3],
|
|
||||||
'alive'=> $kill_db[$i][4],
|
|
||||||
'harm' => $kill_db[$i][5],
|
|
||||||
'win_rate' => $kill_db[$i][6],
|
|
||||||
'win_game' => $kill_db[$i][7],
|
|
||||||
'score' => $score,
|
|
||||||
'level' => $rank,
|
|
||||||
));
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
|
array_push($kill_list, array(
|
||||||
|
'account_id' => $kill_db[$i][0],
|
||||||
|
'name' => $kill_db[$i][1],
|
||||||
|
'avatar_url' => $kill_db[$i][2],
|
||||||
|
'kill' => $kill_db[$i][3],
|
||||||
|
'alive'=> $kill_db[$i][4],
|
||||||
|
'harm' => $kill_db[$i][5],
|
||||||
|
'win_rate' => $kill_db[$i][6],
|
||||||
|
'win_game' => $kill_db[$i][7],
|
||||||
|
'score' => $score,
|
||||||
|
'level' => $rank,
|
||||||
|
));
|
||||||
|
$i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//胜场榜
|
//胜场榜
|
||||||
@ -137,7 +139,7 @@ class RankController{
|
|||||||
if ($i > 49) {
|
if ($i > 49) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
/*$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||||
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||||
$seaPoint = $this->getSeasonPoint($ii);
|
$seaPoint = $this->getSeasonPoint($ii);
|
||||||
if ($win_db[$i][8] >= $seaPoint['min'] && $win_db[$i][8] <= $seaPoint['max']
|
if ($win_db[$i][8] >= $seaPoint['min'] && $win_db[$i][8] <= $seaPoint['max']
|
||||||
@ -145,7 +147,7 @@ class RankController{
|
|||||||
$rank = $ii;
|
$rank = $ii;
|
||||||
$score = $win_db[$i][8] - $seaPoint['min'];
|
$score = $win_db[$i][8] - $seaPoint['min'];
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
if ($win_db[$i][0] == $account_id) {
|
if ($win_db[$i][0] == $account_id) {
|
||||||
$win_rank = $i + 1;
|
$win_rank = $i + 1;
|
||||||
}
|
}
|
||||||
@ -158,32 +160,44 @@ class RankController{
|
|||||||
'harm' => $win_db[$i][5],
|
'harm' => $win_db[$i][5],
|
||||||
'win_rate' => $win_db[$i][6],
|
'win_rate' => $win_db[$i][6],
|
||||||
'win_game' => $win_db[$i][7],
|
'win_game' => $win_db[$i][7],
|
||||||
'score' => $score,
|
//'score' => $score,
|
||||||
'level' => $rank,
|
//'level' => $rank,
|
||||||
));
|
));
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//胜场榜
|
//积分榜
|
||||||
$win_rank_db = $r->get("game2001api: win_rank");
|
$integral_rank_db = $r->get("game2001api: integral_rank");
|
||||||
$win_db = json_decode($win_rank_db);
|
$integral_db = json_decode($integral_rank_db);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($win_db as $win) {
|
foreach ($integral_db as $integral) {
|
||||||
if ($i > 49) {
|
if ($i > 49) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($win_db[$i][0] == $account_id) {
|
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||||
$win_rank = $i + 1;
|
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||||
|
$seaPoint = $this->getSeasonPoint($ii);
|
||||||
|
if ($integral_db[$i][8] >= $seaPoint['min'] && $integral_db[$i][8] <= $seaPoint['max']
|
||||||
|
|| $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1)
|
||||||
|
{
|
||||||
|
$rank = $ii;
|
||||||
|
$score = $integral_db[$i][8] - $seaPoint['min'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
array_push($win_list, array(
|
if ($integral_db[$i][0] == $account_id) {
|
||||||
'account_id' => $win_db[$i][0],
|
$integral_rank = $i + 1;
|
||||||
'name' => $win_db[$i][1],
|
}
|
||||||
'avatar_url' => $win_db[$i][2],
|
array_push($integral_list, array(
|
||||||
'kill' => $win_db[$i][3],
|
'account_id' => $integral_db[$i][0],
|
||||||
'alive'=> $win_db[$i][4],
|
'name' => $integral_db[$i][1],
|
||||||
'harm' => $win_db[$i][5],
|
'avatar_url' => $integral_db[$i][2],
|
||||||
'win_rate' => $win_db[$i][6],
|
'kill' => $integral_db[$i][3],
|
||||||
'win_game' => $win_db[$i][7]
|
'alive'=> $integral_db[$i][4],
|
||||||
|
'harm' => $integral_db[$i][5],
|
||||||
|
'win_rate' => $integral_db[$i][6],
|
||||||
|
'win_game' => $integral_db[$i][7],
|
||||||
|
'score' => $score,
|
||||||
|
'level' => $rank,
|
||||||
));
|
));
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,9 @@ class RoleController{
|
|||||||
':accountid' => $account_id
|
':accountid' => $account_id
|
||||||
));
|
));
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift) ' .
|
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time) ' .
|
||||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0) ' .
|
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0) ' .
|
||||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0;',
|
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=0;',
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
':user_name' => $user_name,
|
':user_name' => $user_name,
|
||||||
|
@ -363,7 +363,33 @@ class SignController{
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
//刷新赛季奖励状态
|
//刷新赛季奖励状态
|
||||||
|
$rowUser = $conn->execQueryOne('SELECT season_time, pass_status ' .
|
||||||
|
' FROM user WHERE accountid=:accountid AND passid=:passid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':passid' => $$passid
|
||||||
|
));
|
||||||
|
|
||||||
|
if (time() > $rowUser['season_time']) {
|
||||||
|
$user_ret = $conn->execScript('UPDATE user SET pass_status=0, score=0, season_status=0, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$user_ret) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$pass_ret = $conn->execScript('UPDATE passinfo SET active_status=0, honor_status=0, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$pass_ret) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user