Commission.php 853 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace addons\shopro\controller\commission;
  3. use addons\shopro\controller\Common;
  4. use addons\shopro\service\commission\Agent as AgentService;
  5. use app\admin\model\shopro\commission\Agent as AgentModel;
  6. class Commission extends Common
  7. {
  8. protected AgentService $service;
  9. public function _initialize()
  10. {
  11. parent::_initialize();
  12. $on = sheep_config('shop.commission.level');
  13. if (!$on) {
  14. $this->error('分销中心已关闭,该功能暂不可用', null, 101);
  15. }
  16. $user = auth_user();
  17. // 检查分销商状态
  18. $this->service = new AgentService($user);
  19. if ($this->service->agent && $this->service->agent->status === AgentModel::AGENT_STATUS_FORBIDDEN) {
  20. $this->error('账户已被禁用,该功能暂不可用', null, 102);
  21. }
  22. }
  23. }