MemberController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. $type = request()->get('type', 1);
  39. $info = $this->service->getUserInfo(['m.id'=> $this->userId],'',$type);
  40. return message(MESSAGE_OK,true, $info);
  41. }
  42. /**
  43. * 保存资料
  44. * @param MemberValidator $validator
  45. * @return array
  46. */
  47. public function saveInfo(MemberValidator $validator){
  48. $params = $validator->check(request()->all(),'save');
  49. if(!is_array($params)){
  50. return message($params, false);
  51. }
  52. return $this->service->saveInfo($this->userId);
  53. }
  54. /**
  55. * 加入会员
  56. * @return array
  57. */
  58. public function vip(){
  59. return $this->service->buyVip($this->userId);
  60. }
  61. /**
  62. * 签到
  63. * @return mixed
  64. */
  65. public function sign(){
  66. return $this->service->sign($this->userId);
  67. }
  68. /**
  69. * 功德榜
  70. * @return array
  71. */
  72. public function gdList(){
  73. return $this->service->gdList($this->userId);
  74. }
  75. /**
  76. * 关注
  77. * @return array
  78. */
  79. public function follow(){
  80. return $this->service->follow($this->userId);
  81. }
  82. /**
  83. * 关注列表
  84. * @return array
  85. */
  86. public function followList(){
  87. return $this->service->followList($this->userId);
  88. }
  89. /**
  90. * 感兴趣的人
  91. * @return array
  92. */
  93. public function recommand(){
  94. return $this->service->recommand($this->userId);
  95. }
  96. /**
  97. * 义工申请信息
  98. * @return mixed
  99. */
  100. public function yigong(){
  101. return $this->yigongService->applyInfo($this->userId);
  102. }
  103. /**
  104. * 申请成为义工
  105. * @param Request $request
  106. * @param YigongValidator $validate
  107. * @return array
  108. */
  109. public function yigongApply(Request $request, YigongValidator $validate){
  110. $params = $validate->check($request->all(),'apply');
  111. if(!is_array($params)){
  112. return message($params, false);
  113. }
  114. return $this->yigongService->apply($this->userId);
  115. }
  116. /**
  117. * 工资提现
  118. * @param Request $request
  119. * @param WithdrawValidator $validate
  120. * @return array
  121. */
  122. public function withdraw(Request $request, WithdrawValidator $validate){
  123. $params = $validate->check($request->all(),'pay');
  124. if(!is_array($params)){
  125. return message($params, false);
  126. }
  127. return $this->withdrawService->withdraw($this->userId);
  128. }
  129. /**
  130. * 注销账号
  131. */
  132. public function logout(){
  133. return $this->service->logout($this->userId);
  134. }
  135. }