Apply.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. $this->user = $this->getUser(); // 用户信息
  20. }
  21. /**
  22. * 提交分销商申请
  23. */
  24. public function submit()
  25. {
  26. $data = $this->postData();
  27. if (empty($data['name']) || empty($data['mobile'])) {
  28. throw new BaseException(['msg' => '用户名或者手机号为空']);
  29. }
  30. $model = new AgentApplyModel;
  31. if ($model->submit($this->user, $data)) {
  32. return $this->renderSuccess('成功');
  33. }
  34. return $this->renderError($model->getError() ?: '提交失败');
  35. }
  36. /*
  37. *获取分销商协议
  38. */
  39. public function getAgreement()
  40. {
  41. $model = new Setting();
  42. $data = $model->getItem('license');
  43. return $this->renderSuccess('', compact('data'));
  44. }
  45. }