zhoulj 4 rokov pred
rodič
commit
a2c50b8b94

+ 46 - 0
app/Http/Controllers/Channel/BaseController.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace App\Http\Controllers\Channel;
+
+use Illuminate\Routing\Controller;
+
+class BaseController extends Controller
+{
+
+    //获取分销渠道ID
+    function getChannelId() {
+        if(empty(session('ydychannel'))) {
+            if(env('APP_ENV') =='local') return 1;
+        }
+
+        $distribution_channel = unserialize(session('ydychannel'));
+        return $distribution_channel->id;
+    }
+
+    //获取分销渠道名称
+    function getChannelName() {
+        if(empty(session('ydychannel'))) {
+            if(env('APP_ENV') =='local') return '测试';
+        }
+
+        $distribution_channel = unserialize(session('ydychannel'));
+        return $distribution_channel->distribution_channel_name;
+    }
+
+    //获取分销渠道域名
+    function getChannelDomain() {
+        if(empty(session('ydychannel'))) {
+            if(env('APP_ENV') =='local') return 'site1.aizhuishu.com';
+        }
+
+        $distribution_channel = unserialize(session('ydychannel'));
+        return "site{$distribution_channel->id}.leyuee.com";
+    }
+
+    //获取登陆用户ID
+    function getChannelUserId()
+    {
+        return session('ydyauth');
+    }
+
+}

+ 2 - 2
app/Http/Controllers/Wechat/OfficialAccount/OfficialMenusController.php

@@ -4,17 +4,17 @@ namespace App\Http\Controllers\Wechat\OfficialAccount;
 
 use App\Modules\Channel\Services\ChannelService;
 
+use App\Http\Controllers\Channel\BaseController as ChannelBaseController;
 use App\Modules\OfficialAccount\Models\OfficialAccount;
 use App\Modules\OfficialAccount\Models\OfficialInteractiveEvent;
 use App\Modules\Channel\Models\Channel;
 use App\Http\Controllers\Wechat\OfficialAccount\Transformers\OfficialMenuTransformer;
 use App\Modules\OfficialAccount\Services\SelfDefineService;
-use App\Http\Controllers\Controller;
 use Illuminate\Http\Request;
 use GuzzleHttp\Client;
 use App\Libs\OSS;
 
-class OfficialMenusController extends Controller
+class OfficialMenusController extends ChannelBaseController
 {
 
     /**