Apply.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\api\controller\plus\agent;
  3. use app\api\controller\Controller;
  4. use app\api\model\plus\agent\Apply as AgentApplyModel;
  5. use app\common\model\plus\agent\Setting;
  6. use app\common\exception\BaseException;
  7. /**
  8. * 分销商申请
  9. */
  10. class Apply extends Controller
  11. {
  12. // 当前用户
  13. private $user;
  14. /**
  15. * 构造方法
  16. */
  17. public function initialize()
  18. {
  19. parent::initialize();
  20. $this->user = $this->getUser(); // 用户信息
  21. }
  22. /**
  23. * 提交分销商申请
  24. */
  25. public function submit()
  26. {
  27. $data = $this->postData();
  28. if (empty($data['name']) || empty($data['mobile'])) {
  29. throw new BaseException(['msg' => '用户名或者手机号为空']);
  30. }
  31. $model = new AgentApplyModel;
  32. if ($model->submit($this->user, $data)) {
  33. return $this->renderSuccess('成功');
  34. }
  35. return $this->renderError($model->getError() ?: '提交失败');
  36. }
  37. /*
  38. *获取分销商协议
  39. */
  40. public function getAgreement()
  41. {
  42. $model = new Setting();
  43. $data = $model->getItem('license');
  44. return $this->renderSuccess('', compact('data'));
  45. }
  46. }