MemberController.php 3.6 KB

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