MemberController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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->masterService = new MasterService();
  34. $this->withdrawService = new WithdrawService();
  35. }
  36. /**
  37. * 获取用户信息
  38. * @return array|mixed
  39. */
  40. public function info(){
  41. $type = request()->get('type', 1);
  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. * @param MasterValidator $validator
  60. * @return array
  61. */
  62. public function masterApply(MasterValidator $validator){
  63. $params = $validator->check(request()->all(),'save');
  64. if(!is_array($params)){
  65. return message($params, false);
  66. }
  67. return $this->masterService->apply($this->userId);
  68. }
  69. /**
  70. * 法师列表
  71. * @return mixed
  72. */
  73. public function masterList(){
  74. return $this->masterService->getDataList($this->userId);
  75. }
  76. /**
  77. * 加入会员
  78. * @return array
  79. */
  80. public function vip(){
  81. return $this->service->buyVip($this->userId);
  82. }
  83. /**
  84. * 签到
  85. * @return mixed
  86. */
  87. public function sign(){
  88. return $this->service->sign($this->userId);
  89. }
  90. /**
  91. * 功德榜
  92. * @return array
  93. */
  94. public function gdList(){
  95. return $this->service->gdList($this->userId);
  96. }
  97. /**
  98. * 关注
  99. * @return array
  100. */
  101. public function follow(){
  102. return $this->service->follow($this->userId);
  103. }
  104. /**
  105. * 关注列表
  106. * @return array
  107. */
  108. public function followList(){
  109. return $this->service->followList($this->userId);
  110. }
  111. /**
  112. * 感兴趣的人
  113. * @return array
  114. */
  115. public function recommand(){
  116. return $this->service->recommand($this->userId);
  117. }
  118. /**
  119. * 义工申请信息
  120. * @return mixed
  121. */
  122. public function yigong(){
  123. return $this->yigongService->applyInfo($this->userId);
  124. }
  125. /**
  126. * 申请成为义工
  127. * @param Request $request
  128. * @param YigongValidator $validate
  129. * @return array
  130. */
  131. public function yigongApply(Request $request, YigongValidator $validate){
  132. $params = $validate->check($request->all(),'apply');
  133. if(!is_array($params)){
  134. return message($params, false);
  135. }
  136. return $this->yigongService->apply($this->userId);
  137. }
  138. /**
  139. * 工资提现
  140. * @param Request $request
  141. * @param WithdrawValidator $validate
  142. * @return array
  143. */
  144. public function withdraw(Request $request, WithdrawValidator $validate){
  145. $params = $validate->check($request->all(),'pay');
  146. if(!is_array($params)){
  147. return message($params, false);
  148. }
  149. return $this->withdrawService->withdraw($this->userId);
  150. }
  151. /**
  152. * 注销账号
  153. */
  154. public function logout(){
  155. return $this->service->logout($this->userId);
  156. }
  157. }