Apply.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\api\controller\user\dealer;
  3. use app\api\controller\Controller;
  4. use app\api\model\dealer\Apply as DealerApplyModel;
  5. /**
  6. * 分销商申请
  7. * Class Apply
  8. * @package app\api\controller\user\dealer
  9. */
  10. class Apply extends Controller
  11. {
  12. /* @var \app\api\model\User $user */
  13. private $user;
  14. /**
  15. * 构造方法
  16. * @throws \app\common\exception\BaseException
  17. * @throws \think\exception\DbException
  18. */
  19. public function _initialize()
  20. {
  21. parent::_initialize();
  22. $this->user = $this->getUser(); // 用户信息
  23. }
  24. /**
  25. * 提交分销商申请
  26. * @param string $name
  27. * @param string $mobile
  28. * @return array
  29. * @throws \think\exception\DbException
  30. * @throws \think\exception\PDOException
  31. */
  32. public function submit($name = '', $mobile = '')
  33. {
  34. $model = new DealerApplyModel;
  35. if ($model->submit($this->user, $name, $mobile)) {
  36. return $this->renderSuccess();
  37. }
  38. return $this->renderError($model->getError() ?: '提交失败');
  39. }
  40. }