AuthController.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace addons\AvoidTax\backend\controllers;
  3. use addons\AvoidTax\common\service\AuthService;
  4. use common\enums\ApiStatusEnum;
  5. /**
  6. * 实名认证
  7. *
  8. * Class AuthController
  9. * @package addons\AvoidTax\backend\controllers
  10. */
  11. class AuthController extends BaseController
  12. {
  13. public $enableCsrfValidation = false;
  14. /**
  15. * @var AuthService
  16. */
  17. protected $service;
  18. public function init()
  19. {
  20. parent::init();
  21. $this->service = new AuthService(['mall_id' => $this->mall_id]);
  22. }
  23. /**
  24. * 列表
  25. *
  26. * @return void
  27. */
  28. public function actionIndex()
  29. {
  30. if ($this->request->isAjax) {
  31. return $this->success(
  32. 'ok',
  33. $this->service->getList(
  34. array_merge(
  35. $this->request->getBodyParams(),
  36. $this->request->get(),
  37. )
  38. ),
  39. ApiStatusEnum::CODE_SUCCESS,
  40. JSON_UNESCAPED_UNICODE
  41. );
  42. }
  43. return $this->render($this->action->id);
  44. }
  45. /**
  46. * 信息修改
  47. *
  48. * @return void
  49. */
  50. public function actionChange()
  51. {
  52. if ($this->request->isPost) {
  53. $id = $this->request->get('id');
  54. $mobile = $this->request->post('mobile');
  55. $account = $this->request->post('account');
  56. return $this->service->changeMobile($id, $mobile, $account)
  57. ? $this->success()
  58. : $this->error($this->service->getError());
  59. }
  60. }
  61. /**
  62. * 转换
  63. *
  64. * @return void
  65. */
  66. public function actionConvert()
  67. {
  68. if ($this->request->isAjax) {
  69. $this->service->convert();
  70. return $this->success('转换任务已添加,请等待');
  71. }
  72. }
  73. /**
  74. * 解除绑定
  75. *
  76. * @return void
  77. */
  78. public function actionUnbind()
  79. {
  80. if ($this->request->isAjax) {
  81. $id = $this->request->get('id');
  82. return $this->service->unbind($id)
  83. ? $this->success('解除成功')
  84. : $this->error($this->service->getError());
  85. }
  86. }
  87. }