<?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');
    }

}
