From 20890dc0fc65df4645cfb656d4bfcce7beddff3f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 22 Oct 2019 15:47:45 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 1 + third_party/phpcommon | 2 +- webapp/controller/RoleController.class.php | 12 +++++++----- webapp/controller/TankController.class.php | 11 +++++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 9a2a0d9..3e6e0e7 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -55,6 +55,7 @@ CREATE TABLE `user` ( `tank_data` mediumblob NOT NULL COMMENT '坦克信息', `daily_reward` int(11) NOT NULL DEFAULT '0' COMMENT '每日奖励次数', `cumul_coin` varchar(256) NOT NULL DEFAULT '' COMMENT '累计金币', + `off_time` int(11) NOT NULL DEFAULT '0' COMMENT '离线时间', PRIMARY KEY (`idx`), UNIQUE KEY `accountid` (`accountid`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; diff --git a/third_party/phpcommon b/third_party/phpcommon index d00056a..8453d4b 160000 --- a/third_party/phpcommon +++ b/third_party/phpcommon @@ -1 +1 @@ -Subproject commit d00056a7ea77d281991ae4f826a1d13b5ddd990b +Subproject commit 8453d4b26e65ad7cee91d26b1a2ede39910c7117 diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index fffcb57..3745854 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, 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)', + $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, off_time) ' . + ' VALUES(:accountid, :user_name, :avatar_url, 1000, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, :buy_data, :tank_data, 0, :off_time)', array( ':accountid' => $account_id, ':user_name' => $user_name, @@ -49,7 +49,8 @@ class RoleController{ ':tank_data' => '', ':buy_data' => '', ':create_time' => time(), - ':modify_time' => time() + ':modify_time' => time(), + ':off_time' => time() )); if (!$ret) { die(); @@ -105,7 +106,7 @@ class RoleController{ phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } - $row = $conn->execQueryOne('SELECT modify_time FROM user WHERE accountid=:accountid;', + $row = $conn->execQueryOne('SELECT off_time FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id )); @@ -113,10 +114,11 @@ class RoleController{ phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } + error_log(time() - $row['off_time']); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - 'time' => time() - $row['modify_time'], + 'time' => time() - $row['off_time'], )); } diff --git a/webapp/controller/TankController.class.php b/webapp/controller/TankController.class.php index b070f6b..a7922d9 100644 --- a/webapp/controller/TankController.class.php +++ b/webapp/controller/TankController.class.php @@ -157,6 +157,17 @@ class TankController{ return; } } + $ret = $conn->execScript('UPDATE user SET off_time=:off_time, modify_time=:modify_time ' . + ' WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + ':off_time' => time(), + ':modify_time' => time(), + )); + if (!$ret) { + die(); + return; + } echo json_encode(array( 'errcode' => 0, 'errmsg' => '',