Tree 2 semanas atrás
pai
commit
f695082fca

+ 5 - 2
app/Game/Banner.php

@@ -12,8 +12,11 @@ class Banner extends Model
     // 指定表名,如果表名与类名的复数相同则不需要
     protected $table = 'webgame.banners';
 
+    // 指定主键
+    protected $primaryKey = 'bid';
+
     // 确定哪些字段可以被赋值
-    protected $fillable = ['img','img_pt','img_es', 'alt', 'link_game', 'link_module'];
+    protected $fillable = ['img','img_pt','img_es', 'alt', 'link_game', 'link_module', 'theme_key'];
 
 
     // 隐藏不需要返回的字段
@@ -47,7 +50,7 @@ class Banner extends Model
 
         }
 
-        $cdn_org=["cdn.moeda777.com"];
+        $cdn_org=["cdn.moeda777.com","cdn.ouro777.com"];
         $cdn_replace="24680.imgix.net";
         $img_add_param="?auto=format,compress&cs=srgb&dpr=2&w=500";
         $img_add_param="";

+ 6 - 1
app/Game/PageModule.php

@@ -65,11 +65,16 @@ class PageModule extends Model
         // 这里简化处理,假设 game_ids 字段是逗号分隔的字符串
         return explode(',', $this->game_ids);
     }
+
     public function banners()
     {
-        return Banner::where('link_module',$this->id)->whereRaw(RouteService::getStateToWhereRaw())->orderBy('b_order','desc');
+        return Banner::where('link_module',$this->id)
+            ->whereRaw(RouteService::getStateToWhereRaw())
+            ->where('theme_key',RouteService::getThemeKey())
+            ->orderBy('b_order','desc');
 //        return $this->hasMany(Banner::class, 'link_module', 'id');
     }
+
     // 返回特定模块类型的结构化数据
     public function getSpecificDataAttribute()
     {

+ 48 - 41
app/Game/Services/RouteService.php

@@ -72,6 +72,29 @@ class RouteService
     public static function clearChannelConfig(){
         self::$_ChannelConfig=null;
     }
+    public static function getRegionConfig()
+    {
+        $RegionID = $_REQUEST['regionid'] ?? '';
+        if (empty($RegionID) ) {
+            $origin = ($_SERVER['HTTP_ORIGIN'] ?? $_SERVER['HTTP_REFERER'] ??'');
+            if(!empty($origin)) {
+                $RegionID = explode('.', $origin)[str_starts_with($origin, 'www') ? 1 : 0];
+            }
+        }
+
+        if(empty($RegionID)) {
+            $RegionID= env('DEFAULT_REGIONID','winus777');
+        }
+        $regionConfig = WebRegionConfig::query()->where('RegionID', $RegionID)->first();
+        if ($regionConfig) return $regionConfig;
+        return null;
+    }
+    public static function getThemeKey()
+    {
+        $regionConfig=self::getRegionConfig();
+        if($regionConfig)return $regionConfig->ThemeKey;
+        return env('DEFAULT_THEME_KEY','Theme1');
+    }
     /**
      * @param Request|null $request
      * @return WebChannelConfig|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|\LaravelIdea\Helper\App\Game\_IH_WebChannelConfig_QB|mixed|object|null
@@ -95,34 +118,24 @@ class RouteService
     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];
-            }
-            // 处理 pixel 参数(与 $request 分支保持一致)
-            if((!isset($Channel) || !$Channel) && isset($_REQUEST['pixel']) && !empty($_REQUEST['pixel'])){
-                $pixel = trim($_REQUEST['pixel']);
-                if($pixel){
-                    $config = WebChannelConfig::where('PlatformID', $pixel)->first();
-                    if($config){
-                        $Channel = $config->Channel;
-                    }
-                }
-            }
-        }else{
-            $origin = $request->server('HTTP_ORIGIN') ?? $request->server('HTTP_REFERER') ?? '*';
-            $Channel=$request->input('c','');
-            $Channel=explode('/',$Channel)[0];
-            $pixel = trim($request->input('pixel',''));
-            if(!$Channel && $pixel){
+        $origin = $request
+            ? ($request->server('HTTP_ORIGIN') ?? $request->server('HTTP_REFERER') ?? '*')
+            : ($_SERVER['HTTP_ORIGIN'] ?? $_SERVER['HTTP_REFERER'] ?? '*');
+
+        $Channel = $request ? $request->input('c', '') : ($_REQUEST['c'] ?? '');
+        $Channel = explode('/', $Channel)[0];
+
+        // 如果没有 Channel,尝试从 pixel 获取
+        if (!$Channel) {
+            $pixel = trim($request ? $request->input('pixel', '') : ($_REQUEST['pixel'] ?? ''));
+            if ($pixel) {
                 $config = WebChannelConfig::where('PlatformID', $pixel)->first();
-                if($config){
+                if ($config) {
                     $Channel = $config->Channel;
                 }
             }
         }
+
         //从用户获取
         if(GlobalUserInfo::$me){
             $Channel=GlobalUserInfo::$me->Channel;
@@ -133,26 +146,20 @@ class RouteService
                 $Channel = $link->Channel;
             }
         }
+        //默认值用region绑定
 
-        //TODO 根据域名获取渠道
-        //默认站点
-        if(!isset($Channel)||!$Channel||$Channel==env('REGION_24680_DEFAULT_CHANNEL',100)) {
-
-            $region = WebRegionConfig::where('DomainUrl', $origin)->first();
-
-            if ($region) {
-                $bindChannels = is_array($region->BindChannels) ? $region->BindChannels : [];
-                if ($bindChannels) {
-                    $Channel = @$bindChannels[0];
+        if(empty($Channel)||$Channel==env('REGION_24680_DEFAULT_CHANNEL',100)) {
+            //根据域名获取渠道
+            $RegionID = $request ? $request->input('regionid', '') : ($_REQUEST['regionid'] ?? '');
+            if (empty($RegionID) && !empty($origin)) {
+                $RegionID = explode('.', $origin)[str_starts_with($origin, 'www') ? 1 : 0];
+            }
+            if (!empty($RegionID)) {
+                $exist = WebChannelConfig::where('RegionID', $RegionID)->whereRaw('SpecialMode&' . SPECIAL_MODE_REGION_UNIQUE)->value('Channel');
+                if ($exist) {
+                    $Channel = $exist;
                 }
             }
-//
-//
-//            if (strstr($origin, "24680.pro") || strstr($origin, "localhost")) {
-//                $Channel = 100;
-//            } else {
-//                $Channel = env('REGION_24680_DEFAULT_CHANNEL',100);
-//            }
         }
         return $Channel??env('REGION_24680_DEFAULT_CHANNEL',100);
     }
@@ -163,7 +170,7 @@ class RouteService
 //            $Channel=$_REQUEST['c'];
 //            $Channel=explode('/',$Channel)[0];
 //        }
-        if (strstr($origin, "test")) {
+        if (strstr($origin, "test")||strstr($origin, "dev")) {
 //            $Channel = 44;
             return $origin;
         }

+ 1 - 1
app/Game/WebRegionConfig.php

@@ -12,7 +12,7 @@ class WebRegionConfig extends Model
     protected $connection = 'mysql';
 
     protected $fillable = [
-        'RegionID', 'DomainUrl', 'LogoUrl', 'IconUrl', 'BindChannels', 'GroupID','GameDesc'
+        'RegionID', 'DomainUrl', 'LogoUrl', 'IconUrl', 'BindChannels', 'GroupID', 'GameDesc','SuggestChannel', 'ThemeKey'
     ];
 
     protected $casts = [

+ 21 - 0
app/Game/WebThemeConfig.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Game;
+
+use Illuminate\Database\Eloquent\Model;
+
+class WebThemeConfig extends Model
+{
+    protected $table = 'webgame.WebThemeConfig';
+    protected $primaryKey = 'id';
+    public $timestamps = false;
+    protected $connection = 'mysql';
+
+    protected $fillable = [
+        'ThemeKey', 'BindRegions'
+    ];
+
+    protected $casts = [
+        'BindRegions' => 'json',
+    ];
+}

+ 39 - 9
app/Http/Controllers/Game/WebRouteController.php

@@ -162,25 +162,55 @@ class WebRouteController extends Controller
 
 
         // slotsPartner: 与 WebChannelConfig 通过 RegionID 关联且 RegionID 不为空的区域,且当前 $config 的 Channel 不在该区域的 BindChannels 中(即其他“伙伴”区域)
-        $currentChannel = $config->Channel;
+//        $currentChannel = $config->Channel;
+//        $slotsPartner = WebRegionConfig::query()
+//            ->where('RegionID', '!=', '')
+//            ->whereIn('RegionID', function ($q) use ($currentChannel) {
+//                $q->select('RegionID')
+//                    ->from((new WebChannelConfig())->getTable())
+//                    ->where('RegionID', '!=', '')
+//                    ->where('Channel', '!=', $currentChannel);
+//            })
+//            ->get()
+////            ->filter(function ($region) use ($currentChannel) {
+////                $bindChannels = $region->BindChannels;
+////                return !is_array($bindChannels) || !in_array((int)$currentChannel, $bindChannels);
+////            })
+//            ->map(function ($region) {
+//                return [
+//                    'DomainUrl' => $region->DomainUrl ?? '',
+//                    'LogoUrl'   => $region->LogoUrl ?? '',
+//                    'GameDesc'  => $region->GameDesc ?? '',
+//                ];
+//            })
+//            ->values()
+//            ->all();
+
+
+        $GroupID=0;
+        $RegionID = $request ? $request->input('regionid', '') : ($_REQUEST['regionid'] ?? '');
+        if (empty($RegionID) && !empty($origin)) {
+            $RegionID = explode('.', $origin)[str_starts_with($origin, 'www') ? 1 : 0];
+        }
+//        if(!empty($RegionID)){
+//            $GroupID=WebRegionConfig::query()->where('RegionID',$RegionID)->value('GroupID')??0;
+//        }
+        // slotsPartner: 与 WebChannelConfig 通过 RegionID 关联且 RegionID 不为空的区域,且当前 $config 的 Channel 不在该区域的 BindChannels 中(即其他“伙伴”区域)
+        // $currentChannel = $config->Channel;
         $slotsPartner = WebRegionConfig::query()
-            ->where('RegionID', '!=', '')
-            ->whereIn('RegionID', function ($q) use ($currentChannel) {
+            ->where('GroupID', $GroupID)
+            ->whereIn('RegionID', function ($q) {
                 $q->select('RegionID')
                     ->from((new WebChannelConfig())->getTable())
-                    ->where('RegionID', '!=', '')
-                    ->where('Channel', '!=', $currentChannel);
+                    ->where('RegionID', '!=', '');
             })
             ->get()
-//            ->filter(function ($region) use ($currentChannel) {
-//                $bindChannels = $region->BindChannels;
-//                return !is_array($bindChannels) || !in_array((int)$currentChannel, $bindChannels);
-//            })
             ->map(function ($region) {
                 return [
                     'DomainUrl' => $region->DomainUrl ?? '',
                     'LogoUrl'   => $region->LogoUrl ?? '',
                     'GameDesc'  => $region->GameDesc ?? '',
+                    'SC'        => $region->SuggestChannel ?? '',
                 ];
             })
             ->values()