whereIn('platform_id',$platform_id)->where('admin_id',$channel_id)->select()){ return true; }else{ return false; } } /** * 检查指定平台是否授权 * @param $platform_id * @param $admin_id * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function checkPlatformIsAuth($platform_id,$admin_id){ $is_auth = true; $auth_platform = []; if(!$platform = model('platform')->whereIn('id',$platform_id)->where(['status'=>'1'])->select()){ return false; } if(!$ptoken = $this->where(['admin_id'=>$admin_id])->select()){ return false; } foreach($ptoken as $token){ if(!empty($token['refresh_token'])){ array_push($auth_platform,$token['platform_id']); } } foreach($platform as $info){ if(!in_array($info['id'],$auth_platform)){ $is_auth = false; } } return $is_auth; } //根据平台获取refresh_token public function getToken($platform_id,$admin_id){ $info = $this->where(['platform_id'=>$platform_id,'admin_id'=>$admin_id])->find(); if($info){ $info = $info->toArray(); return $info['refresh_token']; }else{ return false; } } }