MemberController.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. $userId = request()->get('user_id', 0);
  43. $info = $this->service->getUserInfo(['m.id'=> $this->userId],'',$type);
  44. return message(MESSAGE_OK,true, $info);
  45. }
  46. /**
  47. * 获取用户信息
  48. * @return array|mixed
  49. */
  50. public function master(){
  51. $userId = request()->get('user_id', 0);
  52. $info = $this->masterService->getUserInfo($userId,$this->userId);
  53. return message(MESSAGE_OK,true, $info);
  54. }
  55. /**
  56. * 保存资料
  57. * @param MemberValidator $validator
  58. * @return array
  59. */
  60. public function saveInfo(MemberValidator $validator){
  61. $params = $validator->check(request()->all(),'save');
  62. if(!is_array($params)){
  63. return message($params, false);
  64. }
  65. return $this->service->saveInfo($this->userId);
  66. }
  67. /**
  68. * 法师申请
  69. * @param MasterValidator $validator
  70. * @return array
  71. */
  72. public function masterApply(MasterValidator $validator){
  73. $params = $validator->check(request()->all(),'save');
  74. if(!is_array($params)){
  75. return message($params, false);
  76. }
  77. return $this->masterService->apply($this->userId);
  78. }
  79. /**
  80. * 法师列表
  81. * @return mixed
  82. */
  83. public function masterList(){
  84. return $this->masterService->getDataList($this->userId);
  85. }
  86. /**
  87. * 加入会员
  88. * @return array
  89. */
  90. public function vip(){
  91. return $this->service->buyVip($this->userId);
  92. }
  93. /**
  94. * 签到
  95. * @return mixed
  96. */
  97. public function sign(){
  98. return $this->service->sign($this->userId);
  99. }
  100. /**
  101. * 功德榜
  102. * @return array
  103. */
  104. public function gdList(){
  105. return $this->service->gdList($this->userId);
  106. }
  107. /**
  108. * 关注
  109. * @return array
  110. */
  111. public function follow(){
  112. return $this->service->follow($this->userId);
  113. }
  114. /**
  115. * 关注列表
  116. * @return array
  117. */
  118. public function followList(){
  119. return $this->service->followList($this->userId);
  120. }
  121. /**
  122. * 感兴趣的人
  123. * @return array
  124. */
  125. public function recommand(){
  126. return $this->service->recommand($this->userId);
  127. }
  128. /**
  129. * 义工申请信息
  130. * @return mixed
  131. */
  132. public function yigong(){
  133. return $this->yigongService->applyInfo($this->userId);
  134. }
  135. /**
  136. * 申请成为义工
  137. * @param Request $request
  138. * @param YigongValidator $validate
  139. * @return array
  140. */
  141. public function yigongApply(Request $request, YigongValidator $validate){
  142. $params = $validate->check($request->all(),'apply');
  143. if(!is_array($params)){
  144. return message($params, false);
  145. }
  146. return $this->yigongService->apply($this->userId);
  147. }
  148. /**
  149. * 工资提现
  150. * @param Request $request
  151. * @param WithdrawValidator $validate
  152. * @return array
  153. */
  154. public function withdraw(Request $request, WithdrawValidator $validate){
  155. $params = $validate->check($request->all(),'pay');
  156. if(!is_array($params)){
  157. return message($params, false);
  158. }
  159. return $this->withdrawService->withdraw($this->userId);
  160. }
  161. /**
  162. * 注销账号
  163. */
  164. public function logout(){
  165. return $this->service->logout($this->userId);
  166. }
  167. }