AuthController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace addons\AvoidTax\api\modules\v1\controllers;
  3. use addons\AvoidTax\common\service\AuthService;
  4. use addons\AvoidTax\common\service\UserService;
  5. use api\controllers\OnAuthController;
  6. use Yii;
  7. /**
  8. * 认证控制器
  9. *
  10. * Class AuthController
  11. * @package addons\AvoidTax\api\modules\v1\controllers
  12. */
  13. class AuthController extends OnAuthController
  14. {
  15. public $modelClass = '';
  16. /**
  17. * 提交认证
  18. *
  19. * @return void
  20. */
  21. public function actionSubmit()
  22. {
  23. if ($this->request->isPost) {
  24. $post = $this->request->post();
  25. if (Yii::$app->services->validate->validate($post, [
  26. [['name', 'id_card', 'mobile'], 'required'],
  27. ], [
  28. 'name' => '真实姓名',
  29. 'id_card' => '身份证',
  30. 'mobile' => '手机号码',
  31. ]) === false) {
  32. return $this->error(Yii::$app->services->validate->getErrorMessage());
  33. }
  34. $service = new UserService(['mall_id' => $this->mall_id]);
  35. return $service->silentSign($this->user_id, $post['name'], $post['mobile'], $post['id_card'])
  36. ? $this->success('ok')
  37. : $this->error($service->getError());
  38. }
  39. }
  40. }