From fa7b11b0d9e1f6b7d8fc9f00504b1579a14662c5 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Fri, 10 May 2024 14:11:57 +0800 Subject: [PATCH] 1 --- webapp/bootstrap/constant.php | 1 + .../controller/BaseAuthedController.class.php | 15 ++++++--- .../controller/OutAppNftController.class.php | 33 +++++++++++-------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 8df938a5..858c1cb8 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -9,6 +9,7 @@ define('LAST_SESSION_KEY', 'last_session:'); define('MATCH_CURRENT_TEAM_KEY', 'match:current_team:'); define('MATCH_OK_KEY', 'match:ok:'); define('DEC_BATTLE_TICKET', 'battle_ticket:'); +define('LAST_ACTIVE_TIME', 'last_active_time:'); define('V_ITEM_GOLD', 10001); //金币 define('V_ITEM_GOLDS', 10017); //金堆 diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 54c72507..1c5eab19 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -96,11 +96,11 @@ class BaseAuthedController extends BaseController { die(); } } + $r = $this->_getRedis($this->_getAccountId()); if (!(getReqVal('c', '') == 'User' && getReqVal('a', '') == 'login')) { if ((getReqVal('c', '') == 'Battle')) { return; } - $r = $this->_getRedis($this->_getAccountId()); $sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId()); // error_log('SERVER_ENV:' . SERVER_ENV . '_DEBUG:' . _DEBUG); if (SERVER_ENV != _DEBUG) @@ -116,9 +116,8 @@ class BaseAuthedController extends BaseController { die(); } } - } - + $this->updateActive($r); /*if (SERVER_ENV == _ONLINE) { if (phpcommon\cmpVersion(getReqVal('_version', ''), '0.2.0') > 0) { if (!$this->isWhiteList() || myself()->_getChannel() != BC_CHANNEL) { @@ -129,7 +128,15 @@ class BaseAuthedController extends BaseController { }*/ } - + protected function updateActive($r) + { + $lastActiveTime = $r->get(LAST_ACTIVE_TIME . $this->_getAccountId()); + //第一次登录或者跨天更新最后活跃时间 + if (empty($lastActiveTime) || + $lastActiveTime < $this->_getNowDaySeconds()) { + $r->setNxPx(LAST_ACTIVE_TIME . $this->_getAccountId(), $this->_getNowTime(), 1000 * 3600 * 24); + } + } protected function updateSession($accountId, $sessionId) { diff --git a/webapp/controller/OutAppNftController.class.php b/webapp/controller/OutAppNftController.class.php index b5e225c8..ed95f0fa 100644 --- a/webapp/controller/OutAppNftController.class.php +++ b/webapp/controller/OutAppNftController.class.php @@ -66,21 +66,26 @@ class OutAppNftController extends BaseController { ) ); $accountId = $accountBindDb ? $accountBindDb['cur_account_id'] : $accountId ; - $loginDyn = SqlHelper::ormSelectOne( - myself()->_getMysql($openId), - 't_dyndata', - array( - 'account_id' => $accountId, - 'x' => TN_DAILY_LOGINS, - 'y' => 0, - ) - ); - if ($loginDyn){ - $info['loginVal'] = $loginDyn['val']; - if (myself()->_getDaySeconds($loginDyn['modifytime']) < myself()->_getNowDaySeconds()) { - $info['loginVal'] = 0; - } + $redis = $this->_getRedis($accountId); + $lastActiveTime = $redis->get(LAST_ACTIVE_TIME . $accountId); + if (!empty($lastActiveTime) && $lastActiveTime > myself()->_getNowDaySeconds()){ + $info['loginVal'] = 1; } +// $loginDyn = SqlHelper::ormSelectOne( +// myself()->_getMysql($openId), +// 't_dyndata', +// array( +// 'account_id' => $accountId, +// 'x' => TN_DAILY_LOGINS, +// 'y' => 0, +// ) +// ); +// if ($loginDyn){ +// $info['loginVal'] = $loginDyn['val']; +// if (myself()->_getDaySeconds($loginDyn['modifytime']) < myself()->_getNowDaySeconds()) { +// $info['loginVal'] = 0; +// } +// } $battleDb = SqlHelper::ormSelectOne( myself()->_getMysql($openId),