From 0c8f7a74aceaa6044089e567ed89a6ce9bd0e276 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 24 Aug 2019 16:42:09 +0800 Subject: [PATCH] 1 --- tools/rankserver/app.py | 75 ++-------- webapp/classes/AddReward.php | 22 +++ webapp/controller/PassController.class.php | 137 +++++++++++++++--- .../controller/PayNotifyController.class.php | 126 +++++++++------- webapp/controller/RankController.class.php | 112 +++++++------- webapp/controller/RoleController.class.php | 6 +- webapp/controller/SignController.class.php | 26 ++++ 7 files changed, 319 insertions(+), 185 deletions(-) diff --git a/tools/rankserver/app.py b/tools/rankserver/app.py index 26f8cd0..1083243 100644 --- a/tools/rankserver/app.py +++ b/tools/rankserver/app.py @@ -28,18 +28,12 @@ def info(msg): def take_kills(elem): 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): return elem[7] +def take_integral_times(elem): + return elem[8] + def safeDiv(a, b): if b == 0: return 0 @@ -78,37 +72,20 @@ def refreshData(row, data_list, data_info): alive_time = safeDiv(row[4], row[7]) harm = safeDiv(row[5], 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.sort(key=key_info, reverse=True) if (len(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_rank = [] for kill_index in range(min(50, len(kill_list))): kill_rank.append(kill_list[kill_index]) 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_rank = [] for win_index in range(min(50, len(win_list))): @@ -150,12 +127,6 @@ def dayReadMysqlData(rushtime): has_data = True #更新击杀榜 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) #更新积分榜 @@ -168,7 +139,7 @@ def dayReadMysqlData(rushtime): break 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, lambda : dayReadMysqlData(rushtime) ) @@ -183,24 +154,6 @@ def readMysqlData(rushtime): else: 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") if (not win_list_str): win_list = [] @@ -222,6 +175,8 @@ def readMysqlData(rushtime): charset = 'utf8' ) cursor = conn.cursor() + last_idx = 0 + temp_idx = 0 while 1: cursor.execute('SELECT accountid, user_name, avatar_url, kills, alive_time,' ' harm, win_times, game_times, idx, integral, modify_time FROM user ' @@ -232,15 +187,6 @@ def readMysqlData(rushtime): #更新击杀榜 delRepeatData(row, kill_list) 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) refreshData(row, win_list, take_game_times) @@ -252,8 +198,7 @@ def readMysqlData(rushtime): last_idx = int(row[8]) if not has_data: break - - 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(rushtime, lambda : readMysqlData(rushtime) ) @@ -279,7 +224,7 @@ if __name__ == "__main__": app = make_app() app.listen(conf['listen_port']) - conf['rushtime'] = 300 + conf['rushtime'] = 5 tornado.ioloop.IOLoop.current().call_later(conf['rushtime'], lambda : readMysqlData(conf['rushtime']) ) diff --git a/webapp/classes/AddReward.php b/webapp/classes/AddReward.php index 12ae14b..ee0db22 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -100,6 +100,10 @@ class AddReward { //添加角色碎片 $this->addSkinFragment($item['itemid'], $item['itemnum'], $account_id); break; + case 7: + //添加通行证 + $this->addPass($item['itemid'], $item['itemnum'], $account_id); + break; default: break; } @@ -320,5 +324,23 @@ class AddReward { '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(); + } + } } ?> diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index b86dc91..e80ad92 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -66,6 +66,7 @@ class PassController{ 'min' => $seaPoint_meta['min_point'], 'max' => $seaPoint_meta['max_point'], 'des' => $seaPoint_meta['des'], + 'reward' => $seaPoint_meta['season_reward'], ); return $seaPoint; } @@ -94,6 +95,17 @@ class PassController{ if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) { $open_time = strtotime($season['open_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; break; } @@ -106,6 +118,7 @@ class PassController{ $rank = 0; $rank_score = 0; $max_rank_score = 0; + $reward = array(); $row = $conn->execQueryOne('SELECT integral, pass_status, score FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id, @@ -118,13 +131,20 @@ class PassController{ for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { $seaPoint = $this->getSeasonPoint($ii); 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; + $max_rank_score = $seaPoint['max'] + 1; $rank_score = $row['integral'] - $seaPoint['min']; - $max_rank_score = $seaPoint['max']; - } - if ($ii == count($seaPoint_meta_table)) { - $max_rank_score = $seaPoint['min']; + if ($seaPoint['max'] == -1) { + $max_rank_score = $seaPoint['min']; + } } } if ($rank == 0) { @@ -146,44 +166,60 @@ class PassController{ $drop_multiply = array(); $status = 0; $seaReward = $this->getSeasonReward($id - 1); - if ($row['score'] >= $seaReward['point'] && $seaReward['point'] >= 0) { + if ($row['score'] <= $seaReward['point']) { $level = $seaReward['level']; - $pass_score = $row['score'] - $seaReward['point']; + $pass_score = $seaReward['point'] - $row['score']; $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) { - $seaR = $this->getSeasonReward($id - 2); - $sum_score = $seaR['point']; + if ($seaR['point'] == -1) { + $sea = $this->getSeasonReward($seaR['id'] - 1); + $sum_score = $sea['point']; } else { - $sum_score = $seaReward['point']; + $sum_score = $seaR['point']; } $rowPass = $conn->execQueryOne('SELECT active_status, honor_status ' . ' FROM passinfo WHERE accountid=:accountid AND passid=:passid;', array( ':accountid' => $account_id, - ':passid' => $seaReward['id'] + ':passid' => $seaR['id'] )); + $itemid = 0; + $itemnum = 0; for ($t = 1; $t <= 2; $t++) { $delim = ":"; 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) { $status = $rowPass['active_status']; } } 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) { $status = $rowPass['honor_status']; } } array_push($item_list, array( - 'id' => $id - 1, + 'id' => $seaR['id'], 'type' => $t, - 'point' => $seaReward['point'], - 'item_id' => $drop_multiply[0], - 'item_num' => $drop_multiply[1], + 'point' => $seaR['point'], + 'item_id' => $itemid, + 'item_num' => $itemnum, 'status' => $status, )); } @@ -202,10 +238,12 @@ class PassController{ 'sum_score' => $sum_score, 'pass_score' => $pass_score, 'max_pass_score' => $max_pass_score, + 'reward' => $reward, 'item_list' => $item_list )); } + public function getPassReward() { $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'=> '', + )); + } } ?> diff --git a/webapp/controller/PayNotifyController.class.php b/webapp/controller/PayNotifyController.class.php index 74d350e..50b767c 100644 --- a/webapp/controller/PayNotifyController.class.php +++ b/webapp/controller/PayNotifyController.class.php @@ -17,6 +17,78 @@ class PayNotifyController{ 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() { $params = array( @@ -48,28 +120,7 @@ class PayNotifyController{ ':orderid' => $_REQUEST['orderid'] )); if (!$row) { - $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(); - } + $this->insertNewOrder($conn, $nowtime, $item_list); } else { if ($row['status'] == 1) { echo json_encode(array( @@ -78,35 +129,10 @@ class PayNotifyController{ )); die(); } - $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(); - } + $this->updateOrder($conn, $item_list); } - $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, - )); + $this->updateUserTable($conn, $_REQUEST['amount']); + $this->addToBuyHis($conn, $nowtime); echo json_encode(array( 'errcode' => 0, 'errmsg'=> '' diff --git a/webapp/controller/RankController.class.php b/webapp/controller/RankController.class.php index dcf1ef9..8f79757 100644 --- a/webapp/controller/RankController.class.php +++ b/webapp/controller/RankController.class.php @@ -77,20 +77,21 @@ class RankController{ || $seaPoint['max'] == -1) { $rank = $ii; $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'); //击杀榜 @@ -102,31 +103,32 @@ class RankController{ if ($i > 49) { 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++) { $seaPoint = $this->getSeasonPoint($ii); if ($kill_db[$i][8] >= $seaPoint['min'] && $kill_db[$i][8] <= $seaPoint['max'] || $seaPoint['max'] == -1) { $rank = $ii; $score = $kill_db[$i][8] - $seaPoint['min']; - } - 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++; + } + }*/ + 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++; + } //胜场榜 @@ -137,7 +139,7 @@ class RankController{ if ($i > 49) { 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++) { $seaPoint = $this->getSeasonPoint($ii); if ($win_db[$i][8] >= $seaPoint['min'] && $win_db[$i][8] <= $seaPoint['max'] @@ -145,7 +147,7 @@ class RankController{ $rank = $ii; $score = $win_db[$i][8] - $seaPoint['min']; } - } + }*/ if ($win_db[$i][0] == $account_id) { $win_rank = $i + 1; } @@ -158,32 +160,44 @@ class RankController{ 'harm' => $win_db[$i][5], 'win_rate' => $win_db[$i][6], 'win_game' => $win_db[$i][7], - 'score' => $score, - 'level' => $rank, + //'score' => $score, + //'level' => $rank, )); $i++; } - //胜场榜 - $win_rank_db = $r->get("game2001api: win_rank"); - $win_db = json_decode($win_rank_db); + //积分榜 + $integral_rank_db = $r->get("game2001api: integral_rank"); + $integral_db = json_decode($integral_rank_db); $i = 0; - foreach ($win_db as $win) { + foreach ($integral_db as $integral) { if ($i > 49) { break; } - if ($win_db[$i][0] == $account_id) { - $win_rank = $i + 1; + $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); + 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( - 'account_id' => $win_db[$i][0], - 'name' => $win_db[$i][1], - 'avatar_url' => $win_db[$i][2], - '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] + if ($integral_db[$i][0] == $account_id) { + $integral_rank = $i + 1; + } + array_push($integral_list, array( + 'account_id' => $integral_db[$i][0], + 'name' => $integral_db[$i][1], + 'avatar_url' => $integral_db[$i][2], + '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' => $score, + 'level' => $rank, )); $i++; } diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index f01c5f1..ec34568 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -100,9 +100,9 @@ class RoleController{ ':accountid' => $account_id )); 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) ' . - ' 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) ' . - ' 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;', + $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, 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( ':accountid' => $account_id, ':user_name' => $user_name, diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index d511faa..9749b65 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -363,7 +363,33 @@ class SignController{ 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(); + } + } } } ?>