Commission.php 933 B

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