|
@@ -3,12 +3,14 @@
|
|
namespace app\common\controller;
|
|
namespace app\common\controller;
|
|
|
|
|
|
use app\common\library\Auth;
|
|
use app\common\library\Auth;
|
|
|
|
+use think\Cache;
|
|
use think\Config;
|
|
use think\Config;
|
|
use think\exception\HttpResponseException;
|
|
use think\exception\HttpResponseException;
|
|
use think\exception\ValidateException;
|
|
use think\exception\ValidateException;
|
|
use think\Hook;
|
|
use think\Hook;
|
|
use think\Lang;
|
|
use think\Lang;
|
|
use think\Loader;
|
|
use think\Loader;
|
|
|
|
+use think\Log;
|
|
use think\Request;
|
|
use think\Request;
|
|
use think\Response;
|
|
use think\Response;
|
|
use think\Route;
|
|
use think\Route;
|
|
@@ -378,9 +380,21 @@ class Api
|
|
|
|
|
|
//更新用户活跃
|
|
//更新用户活跃
|
|
protected function user_active(){
|
|
protected function user_active(){
|
|
- if($this->auth->isLogin()){
|
|
|
|
- db('user_active')->where('user_id',$this->auth->id)->update(['requesttime'=>time()]);
|
|
|
|
- }
|
|
|
|
|
|
+ $user_id = $this->auth->id;
|
|
|
|
+ $gender = $this->auth->gender;
|
|
|
|
+ $is_active = $this->auth->is_active;
|
|
|
|
+ $isLogin = $this->auth->isLogin();
|
|
|
|
+ Cache::remember("user_active_{$user_id}",function () use ($user_id,$gender,$is_active,$isLogin){
|
|
|
|
+ // 闭包处理
|
|
|
|
+ if($isLogin && $gender == 1){
|
|
|
|
+ db('user_active')->where('user_id',$user_id)->update(['requesttime'=>time()]);
|
|
|
|
+ if ($is_active == 0){
|
|
|
|
+ db('user')->where('id',$user_id)->update(['is_active' => 1]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Log::record("user_active_{$user_id}");
|
|
|
|
+ return 1;
|
|
|
|
+ },1800);
|
|
}
|
|
}
|
|
|
|
|
|
protected function request_log_update($log_result){
|
|
protected function request_log_update($log_result){
|