whereRaw('state&'.$StateConfig.'='.$StateConfig) ->with('subs.subs.subs') // 根据实际层级深度调整 ->get(); } /** * 通过访问的网站获取配置区分 * @param Request|null $request * @return int */ public static function getStateConfig(Request $request=null) { // if(!$request){ // $origin = $_SERVER['HTTP_ORIGIN'] ?? '*'; // }else{ // $origin = $request->server('HTTP_ORIGIN') ?? '*'; // } // //// $routes = $this->routeService->getAllRoutesWithHierarchy(); // $StateConfig=1; // if(strstr($origin,"24680.pro")||strstr($origin,"localhost")){ // $StateConfig=2; // } $config=self::getChannelConfig($request); $StateConfig=$config->StateNo; return $StateConfig; } /** * @param Request|null $request * @return string */ public static function getStateToWhereRaw(Request $request=null) { $StateConfig=self::getStateConfig($request); return 'state&'.$StateConfig.'='.$StateConfig; } private static $_ChannelConfig=null; public static function clearChannelConfig(){ self::$_ChannelConfig=null; } /** * @param Request|null $request * @return WebChannelConfig|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|\LaravelIdea\Helper\App\Game\_IH_WebChannelConfig_QB|mixed|object|null */ public static function getChannelConfig(Request $request=null) { if(!is_null(self::$_ChannelConfig)){ return self::$_ChannelConfig; } $Channel=self::getChannel($request); $config=WebChannelConfig::getByChannel($Channel); if(!$config){ $config=WebChannelConfig::getByChannel(env('REGION_24680_DEFAULT_CHANNEL',100)); if(!$config)$config=WebChannelConfig::query()->first(); }else if($config->SHADOW_CHANNEL()!=$config->Channel){ $config=WebChannelConfig::getByChannel($config->SHADOW_CHANNEL()); } self::$_ChannelConfig=$config; return $config; } public static function getChannel(Request $request=null) { //从参数获取 if(!$request){ $origin = $_SERVER['HTTP_ORIGIN'] ??$_SERVER['HTTP_REFERER']?? '*'; if(isset($_REQUEST['c'])&&!empty($_REQUEST['c'])){ $Channel=$_REQUEST['c']; $Channel=explode('/',$Channel)[0]; } }else{ $origin = $request->server('HTTP_ORIGIN') ?? $request->server('HTTP_REFERER') ?? '*'; $Channel=$request->input('c',''); $Channel=explode('/',$Channel)[0]; } //从用户获取 if(GlobalUserInfo::$me){ $Channel=GlobalUserInfo::$me->Channel; }else if(isset($_REQUEST['act'])&&!empty($_REQUEST['act'])){ $ActCode = $_REQUEST['act']; $link = AgentLinks::getByCode($ActCode); if ($link) { $Channel = $link->Channel; } } //默认站点 if(!isset($Channel)||!$Channel||$Channel==env('REGION_24680_DEFAULT_CHANNEL',100)) { if (strstr($origin, "24680.pro") || strstr($origin, "localhost")) { $Channel = 100; } else { $Channel = env('REGION_24680_DEFAULT_CHANNEL',100); } } return $Channel; } public static function isTestSite() { $origin = $_SERVER['HTTP_ORIGIN'] ??$_SERVER['HTTP_REFERER']?? '*'; // if(isset($_REQUEST['c'])&&!empty($_REQUEST['c'])){ // $Channel=$_REQUEST['c']; // $Channel=explode('/',$Channel)[0]; // } if (strstr($origin, "test")) { // $Channel = 44; return $origin; } return false; } public static function isTestOrLocalSite() { // return true; $origin = self::isTestSite(); // if(isset($_REQUEST['c'])&&!empty($_REQUEST['c'])){ // $Channel=$_REQUEST['c']; // $Channel=explode('/',$Channel)[0]; // } if (strstr($origin, "localhost")) { // $Channel = 44; return $origin; } return false; } }