Apply.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. */
  31. public function submit($name = '', $mobile = '')
  32. {
  33. $model = new DealerApplyModel;
  34. if ($model->submit($this->user, $name, $mobile)) {
  35. return $this->renderSuccess();
  36. }
  37. return $this->renderError($model->getError() ?: '提交失败');
  38. }
  39. }