MemberController.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\BaseController;
  4. use App\Http\Validator\MemberValidator;
  5. use App\Http\Validator\WithdrawValidator;
  6. use App\Http\Validator\YigongValidator;
  7. use App\Services\MemberService;
  8. use App\Services\WithdrawService;
  9. use App\Services\YigongService;
  10. use Illuminate\Http\Request;
  11. /**
  12. * 会员控制器类
  13. * @author wesmiler
  14. * @since 2020/11/10
  15. * Class MemberController
  16. * @package App\Http\Controllers
  17. */
  18. class MemberController extends BaseController
  19. {
  20. /**
  21. * 构造函数
  22. * @author wesmiler
  23. * @since 2020/11/11
  24. * MemberController constructor.
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. $this->service = new MemberService();
  30. $this->yigongService = new YigongService();
  31. $this->withdrawService = new WithdrawService();
  32. }
  33. /**
  34. * 获取用户信息
  35. * @return array|mixed
  36. */
  37. public function info(){
  38. $info = $this->service->getUserInfo(['m.id'=> $this->userId],'',1);
  39. return message(MESSAGE_OK,true, $info);
  40. }
  41. /**
  42. * 保存资料
  43. * @param MemberValidator $validator
  44. * @return array
  45. */
  46. public function saveInfo(MemberValidator $validator){
  47. $params = $validator->check(request()->all(),'save');
  48. if(!is_array($params)){
  49. return message($params, false);
  50. }
  51. return $this->service->saveInfo($this->userId);
  52. }
  53. /**
  54. * 加入会员
  55. * @return array
  56. */
  57. public function vip(){
  58. return $this->service->buyVip($this->userId);
  59. }
  60. /**
  61. * 签到
  62. * @return mixed
  63. */
  64. public function sign(){
  65. return $this->service->sign($this->userId);
  66. }
  67. /**
  68. * 功德榜
  69. * @return array
  70. */
  71. public function gdList(){
  72. return $this->service->gdList($this->userId);
  73. }
  74. /**
  75. * 关注
  76. * @return array
  77. */
  78. public function follow(){
  79. return $this->service->follow($this->userId);
  80. }
  81. /**
  82. * 关注列表
  83. * @return array
  84. */
  85. public function followList(){
  86. return $this->service->followList($this->userId);
  87. }
  88. /**
  89. * 义工申请信息
  90. * @return mixed
  91. */
  92. public function yigong(){
  93. return $this->yigongService->applyInfo($this->userId);
  94. }
  95. /**
  96. * 申请成为义工
  97. * @param Request $request
  98. * @param YigongValidator $validate
  99. * @return array
  100. */
  101. public function yigongApply(Request $request, YigongValidator $validate){
  102. $params = $validate->check($request->all(),'apply');
  103. if(!is_array($params)){
  104. return message($params, false);
  105. }
  106. return $this->yigongService->apply($this->userId);
  107. }
  108. /**
  109. * 工资提现
  110. * @param Request $request
  111. * @param WithdrawValidator $validate
  112. * @return array
  113. */
  114. public function withdraw(Request $request, WithdrawValidator $validate){
  115. $params = $validate->check($request->all(),'pay');
  116. if(!is_array($params)){
  117. return message($params, false);
  118. }
  119. return $this->withdrawService->withdraw($this->userId);
  120. }
  121. /**
  122. * 注销账号
  123. */
  124. public function logout(){
  125. return $this->service->logout($this->userId);
  126. }
  127. }