| 1234567891011121314151617181920212223242526272829303132333435363738394041 | <?phpnamespace app\api\controller\commission;use app\common\Service\Commission\Agent as AgentService;use app\common\model\commission\Agent as AgentModel;use app\common\Service\ShopConfigService;use app\api\controller\Base;class Commission extends Base{    protected AgentService $service;    public function _initialize()    {        parent::_initialize();        $on = ShopConfigService::getConfigField('shop.commission.level');        if (!$on) {            $this->error('分销中心已关闭,该功能暂不可用', null, 101);        }                $user = auth_user();        // 检查分销商状态        $this->service = new AgentService($user);                // 检查用户是否是代理商        if (!$this->service->agent) {            $this->error('您还不是代理商,无法访问该功能', null);        }                // 检查代理商状态是否被禁用        if ($this->service->agent->status === AgentModel::AGENT_STATUS_FORBIDDEN) {            $this->error('您的账户已被禁用,该功能暂不可用', null);        }    }     }
 |