<?php

namespace App\Http\Controllers\QuickApp;

use App\Modules\User\Services\QappUserService;
use Illuminate\Routing\Controller;

/**
 * @property $user_info 用户基本信息
 * @property $uid 
 * @property $phone 手机号
 * @property $distribution_channel_id 渠道号ID
 * @property $send_order_id 派单ID
 */
class BaseController extends Controller
{
    private $field = [];

    public function __get($name)
    {
        if (!isset($this->field[$name])) {
            // QappUserService::setGolableUserStatic(env('QUICKAPP_TEST_UID',162261523));
            $qapp_user = QappUserService::getGolableUserStatic();
            if ($name == 'user_info') {
                $this->field[$name] = $qapp_user->user;
            }
            if ($name == 'uid') {
                $this->field[$name] = $qapp_user->uid;
            }
            if ($name == 'phone') {
                $this->field[$name] = $qapp_user->phone;
            }
            if ($name == 'distribution_channel_id') {
                $this->field[$name] = $qapp_user->user->distribution_channel_id;
            }
            if ($name == 'send_order_id') {
                $this->field[$name] = $qapp_user->send_order_id;
            }
        }
        return  $this->field[$name];
    }
}
