From ee07f2f6fec2d62e30e7e4fc0fe0347212ec1d7b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 17 Oct 2019 16:39:33 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 20 +++ tools/rankserver/game2003rank.py | 14 +- webapp/bootstrap/config_loader.php | 5 + webapp/controller/QuestController.class.php | 59 +++---- webapp/controller/RankController.class.php | 6 +- webapp/controller/RoleController.class.php | 43 ++++- webapp/controller/ShareController.class.php | 182 ++++++++++++++++++-- webapp/controller/SignController.class.php | 42 ++++- webapp/controller/TankController.class.php | 92 +++++++--- 9 files changed, 370 insertions(+), 93 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index c811830..304fee0 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -54,6 +54,7 @@ CREATE TABLE `user` ( `buy_data` mediumblob NOT NULL COMMENT '购买次数信息', `tank_data` mediumblob NOT NULL COMMENT '坦克信息', `daily_reward` int(11) NOT NULL DEFAULT '0' COMMENT '每日奖励次数', + `cumul_coin` varchar(256) NOT NULL DEFAULT '' COMMENT '累计金币', PRIMARY KEY (`idx`), UNIQUE KEY `accountid` (`accountid`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; @@ -136,6 +137,25 @@ CREATE TABLE `try_play` ( UNIQUE KEY `try_uuid` (`accountid`, `appid`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Table structrure for table `daily_reward` +-- + +DROP TABLE IF EXISTS `daily_reward`; +/*!40101 SET @saved_cs_client = @@character_set_client*/; +/*!40101 SET character_set_client = utf8*/; +CREATE TABLE `daily_reward` ( + `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `free_coin_time` int(11) NOT NULL DEFAULT '0' COMMENT '免费金币次数', + `free_jewel_time` int(11) NOT NULL DEFAULT '0' COMMENT '免费钻石次数', + `free_power_time` int(11) NOT NULL DEFAULT '0' COMMENT '免费体力次数', + `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; diff --git a/tools/rankserver/game2003rank.py b/tools/rankserver/game2003rank.py index 55be66f..96d4cfe 100644 --- a/tools/rankserver/game2003rank.py +++ b/tools/rankserver/game2003rank.py @@ -79,14 +79,14 @@ def refreshCoinData(row, coin_list): #字符串排序 def customCmp(a, b): - if len(a) < len(b): + if len(a[4]) < len(b[4]): return -1 - elif len(a) > len(b): + elif len(a[4]) > len(b[4]): return 1 #endif - if a < b: + if a[4] < b[4]: return -1 - elif a > b: + elif a[4] > b[4]: return 1 else: return 0 @@ -121,7 +121,7 @@ def internalDayReadMysqlData(): last_idx = 0 temp_idx = 0 while 1: - cursor.execute('SELECT accountid, user_name, avatar_url, pass, coin_num, idx' + cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx' ' FROM user WHERE idx > %s LIMIT 0, 1000' % (last_idx)) has_data = False @@ -176,7 +176,7 @@ def readMysqlData(rushtime): last_idx = 0 temp_idx = 0 while 1: - cursor.execute('SELECT accountid, user_name, avatar_url, pass, coin_num, idx FROM user ' + cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx FROM user ' ' WHERE idx > %s LIMIT 0, 1000' % (last_idx)) has_data = False for row in cursor: @@ -193,7 +193,7 @@ def readMysqlData(rushtime): last_idx = 0 temp_idx = 0 while 1: - cursor.execute('SELECT accountid, user_name, avatar_url, pass, coin_num, idx FROM user ' + cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx FROM user ' ' WHERE idx > %s LIMIT 0, 1000' % (last_idx)) has_data = False for row in cursor: diff --git a/webapp/bootstrap/config_loader.php b/webapp/bootstrap/config_loader.php index b8b3451..00aef45 100644 --- a/webapp/bootstrap/config_loader.php +++ b/webapp/bootstrap/config_loader.php @@ -84,6 +84,11 @@ function getRobotConfig($robot_table, $robot_id) return array_key_exists($robot_id, $robot_table) ? $robot_table[$robot_id] : null; } +function getQuestConfig($task_table, $task_id) +{ + $task_id = (int)$task_id; + return array_key_exists($task_id, $task_table) ? $task_table[$task_id] : null; +} checkMysqlConfig(); checkRedisConfig(); diff --git a/webapp/controller/QuestController.class.php b/webapp/controller/QuestController.class.php index d5a3d95..3a2fca3 100644 --- a/webapp/controller/QuestController.class.php +++ b/webapp/controller/QuestController.class.php @@ -46,23 +46,18 @@ class QuestController{ phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } - $rows= $conn->execQueryRowCount('SELECT * FROM quest WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - )); - if (!$rows) { - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'quest_list' => $quest_list, - )); - } - foreach ($rows as $row) { - array_push($quest_list, array( - 'quest_id' => $row['quest_id'], - 'quest_num' => $row['quest_num'], - 'quest_status' => $row['quest_status'] - )); + $rows= $conn->execQuery('SELECT * FROM quest WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + )); + if ($rows) { + foreach ($rows as $row) { + array_push($quest_list, array( + 'quest_id' => $row['quest_id'], + 'quest_num' => $row['quest_num'], + 'quest_status' => $row['quest_status'] + )); + } } echo json_encode(array( 'errcode' => 0, @@ -104,11 +99,11 @@ class QuestController{ if ($condition != $q['condition']) { continue; } - if ($num < $q['condition']) { + if ($num < $q['value']) { $sum = $num ; $status = 0; } else { - $sum = $q['condition']; + $sum = $q['value']; $status = 1; array_push($quest_list, array( 'id' => $q['id'], @@ -122,15 +117,15 @@ class QuestController{ //更新任务 foreach ($rows as $row) { $q = $this->getQuest($row['quest_id']); - if ($row['quest_num'] + $num < $q['condition']) { - $sum = $row['quest_num'] + $num ; - $status = 0; + if ($row['quest_num'] + $num < $q['value']) { + $sum = $row['quest_num'] + $num ; + $status = 0; } else { if ($row['quest_status'] != 0) { - $sum = $q['condition']; + $sum = $q['value']; $status = $row['quest_status']; } else { - $sum = $q['condition']; + $sum = $q['value']; $status = 1; array_push($quest_list, array( 'id' => $row['quest_id'], @@ -181,17 +176,9 @@ class QuestController{ return; } - if ($row['quest_status'] == 1) { - //更新任务 - $this->updateQuest($quest_id, $account_id, $row['quest_num'], 2); - //添加奖励 - $addreward = new classes\AddReward(); - $addreward->addReward(10003, $q['jewel_reward'], $account_id); - } else { - phpcommon\sendError(ERR_USER_BASE + 2, '任务未完成'); - return; - } + //更新任务 + $this->updateQuest($quest_id, $account_id, $row['quest_num'], 2); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', @@ -201,13 +188,13 @@ class QuestController{ protected function updateQuest($id, $account_id, $num, $status) { $conn = $this->getMysql($account_id); - $ret = $conn->execScript('UPDATE quest SET quest_status=:status, quest_num=:num modify_time=:modify_time ' . + $ret = $conn->execScript('UPDATE quest SET quest_status=:status, quest_num=:num, modify_time=:modify_time ' . ' WHERE accountid=:accountid AND quest_id =:quest_id;', array( ':accountid' => $account_id, ':quest_id' => $id, ':num' => $num, - ':status' => status, + ':status' => $status, ':modify_time' => time() )); if (!$ret) { diff --git a/webapp/controller/RankController.class.php b/webapp/controller/RankController.class.php index fa2a904..266822f 100644 --- a/webapp/controller/RankController.class.php +++ b/webapp/controller/RankController.class.php @@ -85,7 +85,7 @@ class RankController{ $r = $this->getRedis(); $pass_rank_db = $r->get("game2003api:pass_rank"); $pass_db = json_decode($pass_rank_db); - $pass_list = $this->getRank($account_id, $pass_db); + $pass_list = $this->getRank($account_id, $pass_db, $myname, $myavatar_url); $i = 0; foreach ($pass_db as $pass) { $name = ''; @@ -113,7 +113,7 @@ class RankController{ } $i++; } - $coin_list = $this->getRank($account_id, $coin_db); + $coin_list = $this->getRank($account_id, $coin_db, $myname, $myavatar_url); echo json_encode(array( 'errcode' => 0, 'errmsg' => "", @@ -126,7 +126,7 @@ class RankController{ } - protected function getRank($account_id, $user_db) + protected function getRank($account_id, $user_db, $myname, $myavatar_url) { $i = 0; $user_list = array(); diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 4797071..fffcb57 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -40,8 +40,8 @@ class RoleController{ ':accountid' => $account_id )); if (!$row) { - $ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, coin_num, create_time, modify_time, collect_status, kefu_status, sign_sum, diamond_num, pass_status, pass, energy, buy_data, tank_data, daily_reward) ' . - ' VALUES(:accountid, :user_name, :avatar_url, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, :buy_data, :tank_data, 0)', + $ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, coin_num, create_time, modify_time, collect_status, kefu_status, sign_sum, diamond_num, pass_status, pass, energy, buy_data, tank_data, cumul_coin) ' . + ' VALUES(:accountid, :user_name, :avatar_url, 1000, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, :buy_data, :tank_data, 0)', array( ':accountid' => $account_id, ':user_name' => $user_name, @@ -58,7 +58,7 @@ class RoleController{ echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - 'coin_num' => 0, + 'coin_num' => 1000, 'collect_status' => 0, 'energy' => 0, 'kefu_status' => 0, @@ -67,7 +67,7 @@ class RoleController{ 'pass' => 0, 'buy_list' => '', 'tank_list' => '', - 'daily_reward' => 0, + 'cumul_coin' => 0 )); } else { echo json_encode(array( @@ -82,7 +82,7 @@ class RoleController{ 'pass' => $row['pass'], 'buy_list' => $row['buy_data'], 'tank_list' => $row['tank_data'], - 'daily_reward' => $row['daily_reward'], + 'cumul_coin' => $row['cumul_coin'], )); } } @@ -119,5 +119,38 @@ class RoleController{ 'time' => time() - $row['modify_time'], )); } + + public function getDiamondNum() + { + $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; + } + if (empty($_REQUEST['account_id'])) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'diamond_num' => $row['diamond_num'], + )); + } } ?> diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index 86ba9c0..6351b04 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -160,22 +160,35 @@ class ShareController{ phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } + $row = $conn->execQueryOne('SELECT collect_status, pass_status ' . + ' FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } $type = $_REQUEST['type']; switch ($type) { case 1: //收藏 + if ($row['collect_status'] >= 1) { + phpcommon\sendError(ERR_USER_BASE + 3, '奖励已领取'); + return; + } $this->updateCollectStatus($account_id); - $item_list = $this->rewardList(COLLECT_REWARDS, $account_id); + //$item_list = $this->rewardList(COLLECT_REWARDS, $account_id); break; case 2: //浮窗 + if ($row['pass_status'] >= 1) { + phpcommon\sendError(ERR_USER_BASE + 3, '奖励已领取'); + return; + } $this->updateWindowStatus($account_id); - $item_list = $this->rewardList(WINDOWS_REWARDS, $account_id); + //$item_list = $this->rewardList(WINDOWS_REWARDS, $account_id); break; - case 3: //限时 - $this->updateDailyReward($account_id); - $item_list = $this->rewardList(FREE_DIAMOND, $account_id); - break; - default: + default: break; } echo json_encode(array( @@ -216,7 +229,7 @@ class ShareController{ public function updateWindowStatus($account_id) { $conn = $this->getMysql($account_id); - $ret = $conn->execScript('UPDATE user SET collect_status=1, modify_time=:modify_time ' . + $ret = $conn->execScript('UPDATE user SET pass_status=1, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':modify_time' => time(), @@ -292,7 +305,6 @@ class ShareController{ phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } - $play_list = array(); $row = $conn->execQueryOne('SELECT status FROM try_play WHERE accountid=:accountid AND appid=:appid;', array( ':accountid' => $account_id, @@ -305,7 +317,7 @@ class ShareController{ ' ON DUPLICATE KEY UPDATE accountid=:account_id, appid=:appid, status=:status, modify_time=:modify_time;', array( ':account_id' => $account_id, - ':ach_id' => $appid, + ':appid' => $appid, ':status' => 1, ':create_time' => time(), ':modify_time' => time() @@ -315,9 +327,13 @@ class ShareController{ return; } } else { + if ($row['status'] == 1) { + phpcommon\sendError(ERR_USER_BASE + 2, '奖励已领取'); + return; + } //更新 $ret = $conn->execScript('UPDATE try_play SET status=1, modify_time=:modify_time ' . - ' WHERE accountid=:accountid AND appid=:ach_appid;', + ' WHERE accountid=:accountid AND appid=:appid;', array( ':accountid' => $account_id, ':modify_time' => time(), @@ -329,13 +345,153 @@ class ShareController{ } } //获得奖励 - $item_list = $this->rewardList(NEWGAME_REWARDS, $account_id); + //$item_list = $this->rewardList(NEWGAME_REWARDS, $account_id); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - 'play_list' => $play_list )); } + public function dailyInfo() + { + $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 + 2, '没有这个玩家'); + return; + } + $row = $conn->execQueryOne('SELECT free_coin_time, free_jewel_time, free_power_time ' . + ' FROM daily_reward WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + $ret = $conn->execScript('INSERT INTO daily_reward(accountid, free_coin_time, free_jewel_time, free_power_time, create_time, modify_time) ' . + ' VALUES(:account_id, 0, 0, 0, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, free_coin_time=0, free_jewel_time=0, free_power_time=0, modify_time=:modify_time;', + array( + ':account_id' => $account_id, + ':create_time' => time(), + ':modify_time' => time() + )); + if(!$ret){ + die(); + return; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'free_coin_time' => 0, + 'free_jewel_time' => 0, + 'free_power_time' => 0 + )); + } else { + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'free_coin_time' => $row['free_coin_time'], + 'free_jewel_time' => $row['free_jewel_time'], + 'free_power_time' => $row['free_power_time'] + )); + } + } + + public function dailyReward() + { + $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 + 2, '没有这个玩家'); + return; + } + $row = $conn->execQueryOne('SELECT free_coin_time, free_jewel_time, free_power_time ' . + ' FROM daily_reward WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $type = $_REQUEST['type']; + switch ($type) + { + case 1: //免费金币 + if ($row['free_coin_time'] >= 5) { + phpcommon\sendError(ERR_USER_BASE + 3, '奖励已领取'); + return; + } + $this->updateDailyStatus($account_id, 1); + break; + case 2: //免费钻石 + if ($row['free_jewel_time'] >= 5) { + phpcommon\sendError(ERR_USER_BASE + 3, '奖励已领取'); + return; + } + $this->updateDailyStatus($account_id, 2); + break; + case 3: //免费体力 + if ($row['free_power_time'] >= 5) { + phpcommon\sendError(ERR_USER_BASE + 3, '奖励已领取'); + return; + } + $this->updateDailyStatus($account_id, 3); + break; + default: + break; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + )); + } + + protected function updateDailyStatus($account_id, $type) + { + $conn = $this->getMysql($account_id); + if ($type == 1) { + $ret = $conn->execScript('UPDATE daily_reward SET free_coin_time=free_coin_time+1, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':modify_time' => time(), + ':accountid' => $account_id + )); + if (!$ret) { + die(); + } + } else if ($type == 2) { + $ret = $conn->execScript('UPDATE daily_reward SET free_jewel_time=free_jewel_time+1, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':modify_time' => time(), + ':accountid' => $account_id + )); + if (!$ret) { + die(); + } + } else if ($type == 3) { + $ret = $conn->execScript('UPDATE daily_reward SET free_power_time=free_power_time+1, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':modify_time' => time(), + ':accountid' => $account_id + )); + if (!$ret) { + die(); + } + } + } } ?> diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index de36f5b..c5b6907 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -115,7 +115,7 @@ class SignController{ if ($nowTime - phpcommon\getdayseconds($last_sign_time) > 0) { //每日刷新 - //$this->updateDaily($account_id); + $this->updateDaily($account_id); //$this->updateSeasonStatus($account_id); $passed_days = floor(($nowTime - phpcommon\getdayseconds($last_sign_time)) / (3600 * 24)); if ($passed_days > 7 - $last_sign_id) { @@ -276,8 +276,8 @@ class SignController{ 'item_id' => $s['item_id'], 'item_num' => $s['num'], )); - $addreward = new classes\AddReward(); - $addreward->addReward($item_id, $num, $account_id); + //$addreward = new classes\AddReward(); + //$addreward->addReward($item_id, $num, $account_id); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', @@ -308,6 +308,7 @@ class SignController{ $item_list = array(); $week = ceil($rowUser['sign_sum'] / 7); $dayid = ($week - 1) * 7 + $_REQUEST['sign_id']; + //如果大于配置表最后一周,按最后一周奖励 $g_conf_sign_cluster = require('../res/signDaily@signDaily.php'); if ($dayid > count($g_conf_sign_cluster)) { @@ -319,13 +320,44 @@ class SignController{ $p = $this->getParameter(SIGNREWARD_TIMES); $times = $p['param_value'] - 1; $num = $num * $times; - $addreward = new classes\AddReward(); - $addreward->addReward($item_id, $num, $account_id); + //$addreward = new classes\AddReward(); + //$addreward->addReward($item_id, $num, $account_id); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', )); } + protected function updateDaily($account_id) + { + $conn = $this->getMysql($account_id); + //更新每日奖励次数 + $ret = $conn->execScript('UPDATE daily_reward SET free_coin_time=0, free_jewel_time=0, free_power_time=0, ' . + ' modify_time=:modify_time WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':modify_time' => time() + )); + if (!$ret) { + die(); + } + //更新每日任务 + $ret = $conn->execScript('DELETE FROM quest WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + )); + if (!$ret) { + die(); + } + //更新试玩次数 + $ret = $conn->execScript('DELETE FROM try_play WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + )); + if (!$ret) { + die(); + } + //更新分享好友信息 + } } ?> diff --git a/webapp/controller/TankController.class.php b/webapp/controller/TankController.class.php index daaba87..cff965b 100644 --- a/webapp/controller/TankController.class.php +++ b/webapp/controller/TankController.class.php @@ -57,8 +57,10 @@ class TankController{ return; } $tankInfo = json_decode(file_get_contents('php://input'), true); - $tank_data = $tankInfo['tank']; - if ($tank_data) { + //error_log(file_get_contents('php://input')); + //error_log(json_encode($tankInfo)); + if (isset($tankInfo['tank_list'])) { + $tank_data = $tankInfo['tank_list']; $ret = $conn->execScript('UPDATE user SET tank_data=:tank_data, modify_time=:modify_time ' . ' WHERE accountid=:account_id;', array( @@ -71,13 +73,13 @@ class TankController{ return; } } - $money = $tankInfo['money']; - if ($money) { + if (isset($tankInfo['coin_num'])) { + $coin_num = $tankInfo['coin_num']; $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' . ' WHERE accountid=:account_id;', array( ':account_id' => $account_id, - ':coin_num' => $money, + ':coin_num' => $coin_num, ':modify_time' => time() )); if (!$ret) { @@ -85,8 +87,8 @@ class TankController{ return; } } - $buy_data = $tankInfo['times']; - if ($buy_data) { + if (isset($tankInfo['buy_list'])) { + $buy_data = $tankInfo['buy_list']; $ret = $conn->execScript('UPDATE user SET buy_data=:buy_data, modify_time=:modify_time ' . ' WHERE accountid=:account_id;', array( @@ -99,13 +101,55 @@ class TankController{ return; } } - $pass = $tankInfo['pass']; - if ($pass) { + if (isset($tankInfo['pass'])) { + $pass = $tankInfo['pass']; $ret = $conn->execScript('UPDATE user SET pass=:pass, modify_time=:modify_time ' . ' WHERE accountid=:account_id;', array( ':account_id' => $account_id, - ':pass' => json_encode($pass), + ':pass' => $pass, + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + } + if (isset($tankInfo['energy'])) { + $energy = $tankInfo['energy']; + $ret = $conn->execScript('UPDATE user SET energy=:energy, modify_time=:modify_time ' . + ' WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + ':energy' => $energy, + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + } + if (isset($tankInfo['diamond_num'])) { + $diamond_num = $tankInfo['diamond_num']; + $ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' . + ' WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + ':diamond_num' => $diamond_num, + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + } + if (isset($tankInfo['cumul_coin'])) { + $cumul_coin = $tankInfo['cumul_coin']; + $ret = $conn->execScript('UPDATE user SET cumul_coin=:cumul_coin, modify_time=:modify_time ' . + ' WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + ':cumul_coin' => $cumul_coin, ':modify_time' => time() )); if (!$ret) { @@ -337,7 +381,7 @@ class TankController{ die(); } } - + */ public function buyTank() { $account_id = $_REQUEST['account_id']; @@ -353,7 +397,7 @@ class TankController{ return; } $level = $_REQUEST['level']; - $row = $conn->execQueryOne('SELECT max_level, coin_num, diamond_num FROM user WHERE accountid=:accountid;', + $row = $conn->execQueryOne('SELECT coin_num, diamond_num FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id, )); @@ -361,17 +405,17 @@ class TankController{ phpcommon\sendError(ERR_USER_BASE + 1,'没有这个玩家'); return; } - $max_tank = $this->getTank(10000 + $row['max_level']); + //$max_tank = $this->getTank(10000 + $row['max_level']); $t = $this->getTank(10000 + $level); $num = 0; $times = 0; - $row_times = $conn->execQueryOne('SELECT times FROM buy_times ' . - ' WHERE accountid=:accountid AND level=:level;', - array( - ':accountid' => $account_id, - ':level' => $level, - )); - $this->buyLevelLimit($level, $max_tank['diamond_lv']); + //$row_times = $conn->execQueryOne('SELECT times FROM buy_times ' . + // ' WHERE accountid=:accountid AND level=:level;', + // array( + // ':accountid' => $account_id, + // ':level' => $level, + // )); + //$this->buyLevelLimit($level, $max_tank['diamond_lv']); if ($row['diamond_num'] < $t['diamond']) { phpcommon\sendError(ERR_USER_BASE + 3,'钻石不足'); return; @@ -443,7 +487,7 @@ class TankController{ if (!$ret) { die(); return; - } + }*/ echo json_encode(array( 'errcode' => 0, 'errmsg' => '', @@ -459,7 +503,7 @@ class TankController{ } } - protected function insertBuyInfo($account_id, $level) + /* protected function insertBuyInfo($account_id, $level) { $conn = $this->getMysql($account_id); $ret = $conn->execScript('INSERT INTO buy_times(accountid, level, times, create_time, modify_time) ' . @@ -474,7 +518,7 @@ class TankController{ die(); } } - + */ protected function updateBuyInfo($account_id, $num, $level, $times) { $conn = $this->getMysql($account_id); @@ -513,7 +557,7 @@ class TankController{ } } } - + /* public function tankListInfo() { $account_id = $_REQUEST['account_id'];