Apply.php 1.2 KB

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