This commit is contained in:
hujiabin 2024-05-10 14:11:57 +08:00
parent e4161eb030
commit fa7b11b0d9
3 changed files with 31 additions and 18 deletions

View File

@ -9,6 +9,7 @@ define('LAST_SESSION_KEY', 'last_session:');
define('MATCH_CURRENT_TEAM_KEY', 'match:current_team:'); define('MATCH_CURRENT_TEAM_KEY', 'match:current_team:');
define('MATCH_OK_KEY', 'match:ok:'); define('MATCH_OK_KEY', 'match:ok:');
define('DEC_BATTLE_TICKET', 'battle_ticket:'); define('DEC_BATTLE_TICKET', 'battle_ticket:');
define('LAST_ACTIVE_TIME', 'last_active_time:');
define('V_ITEM_GOLD', 10001); //金币 define('V_ITEM_GOLD', 10001); //金币
define('V_ITEM_GOLDS', 10017); //金堆 define('V_ITEM_GOLDS', 10017); //金堆

View File

@ -96,11 +96,11 @@ class BaseAuthedController extends BaseController {
die(); die();
} }
} }
$r = $this->_getRedis($this->_getAccountId());
if (!(getReqVal('c', '') == 'User' && getReqVal('a', '') == 'login')) { if (!(getReqVal('c', '') == 'User' && getReqVal('a', '') == 'login')) {
if ((getReqVal('c', '') == 'Battle')) { if ((getReqVal('c', '') == 'Battle')) {
return; return;
} }
$r = $this->_getRedis($this->_getAccountId());
$sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId()); $sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId());
// error_log('SERVER_ENV:' . SERVER_ENV . '_DEBUG:' . _DEBUG); // error_log('SERVER_ENV:' . SERVER_ENV . '_DEBUG:' . _DEBUG);
if (SERVER_ENV != _DEBUG) if (SERVER_ENV != _DEBUG)
@ -116,9 +116,8 @@ class BaseAuthedController extends BaseController {
die(); die();
} }
} }
} }
$this->updateActive($r);
/*if (SERVER_ENV == _ONLINE) { /*if (SERVER_ENV == _ONLINE) {
if (phpcommon\cmpVersion(getReqVal('_version', ''), '0.2.0') > 0) { if (phpcommon\cmpVersion(getReqVal('_version', ''), '0.2.0') > 0) {
if (!$this->isWhiteList() || myself()->_getChannel() != BC_CHANNEL) { 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) protected function updateSession($accountId, $sessionId)
{ {

View File

@ -66,21 +66,26 @@ class OutAppNftController extends BaseController {
) )
); );
$accountId = $accountBindDb ? $accountBindDb['cur_account_id'] : $accountId ; $accountId = $accountBindDb ? $accountBindDb['cur_account_id'] : $accountId ;
$loginDyn = SqlHelper::ormSelectOne( $redis = $this->_getRedis($accountId);
myself()->_getMysql($openId), $lastActiveTime = $redis->get(LAST_ACTIVE_TIME . $accountId);
't_dyndata', if (!empty($lastActiveTime) && $lastActiveTime > myself()->_getNowDaySeconds()){
array( $info['loginVal'] = 1;
'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;
}
} }
// $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( $battleDb = SqlHelper::ormSelectOne(
myself()->_getMysql($openId), myself()->_getMysql($openId),