HomeController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. namespace App\Http\Controllers\User;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\User\HomeService;
  5. use Illuminate\Http\Request;
  6. use App\Http\Controllers\Core\Auth;
  7. use App\Models\Fpdx\RoomModel;
  8. use Illuminate\Support\Facades\Redis;
  9. /**
  10. * 个人主页接口
  11. * Class HomeController
  12. * @package App\Http\Controllers\User
  13. */
  14. class HomeController extends Controller
  15. {
  16. /**
  17. * 喜欢我的列表
  18. * @param Request $request
  19. * @return array
  20. * @deprecated
  21. */
  22. public function likeMeList(Request $request)
  23. {
  24. $uid = Auth::auth();
  25. $page = $request->get('page', 1);
  26. $pages = array(
  27. 'page' => $page,
  28. 'limit' => 20
  29. );
  30. $hs = new HomeService();
  31. $data = $hs->likeMeList($uid, $pages);
  32. return response([
  33. 'code' => 200,
  34. 'message' => 'success',
  35. 'data' => $data
  36. ]);
  37. }
  38. /**
  39. * 我喜欢的列表
  40. * @param Request $request
  41. * @return array
  42. */
  43. public function likeList(Request $request)
  44. {
  45. $uid = Auth::auth();
  46. $page = $request->get('page', 1);
  47. $pages = array(
  48. 'page' => $page,
  49. 'limit' => 20
  50. );
  51. $hs = new HomeService();
  52. $data = $hs->likeList($uid, $pages);
  53. return response([
  54. 'code' => 200,
  55. 'message' => 'success',
  56. 'data' => [
  57. 'page' => $data['pages']['page'],
  58. 'limit' => $data['pages']['limit'],
  59. 'total' => $data['pages']['total'],
  60. 'list' => $data['list']
  61. ],
  62. ]);
  63. }
  64. /**
  65. * 聊天列表数量
  66. * @return array
  67. */
  68. public function chatCount()
  69. {
  70. $uid = Auth::auth();
  71. $roomModel = new RoomModel();
  72. $cnt = $roomModel->getCountByType(2, $uid) ?? 0;
  73. return response([
  74. 'code' => 200,
  75. 'message' => 'success',
  76. 'data' => [
  77. 'count' => $cnt
  78. ]
  79. ]);
  80. }
  81. /**
  82. * 匹配历史数量
  83. * @return array
  84. */
  85. public function pairCount()
  86. {
  87. $uid = Auth::auth();
  88. $roomModel = new RoomModel();
  89. $cnt = $roomModel->getCountByType(1, $uid) ?? 0;
  90. return response([
  91. 'code' => 200,
  92. 'message' => 'success',
  93. 'data' => [
  94. 'count' => $cnt
  95. ]
  96. ]);
  97. }
  98. /**
  99. * 看过我的人数
  100. */
  101. public function lastLookMe()
  102. {
  103. $uid = Auth::auth();
  104. $hs = new HomeService();
  105. $cnt = $hs->lastLookMe($uid);
  106. return response([
  107. 'code' => 200,
  108. 'message' => 'success',
  109. 'data' => [
  110. 'cnt' => $cnt
  111. ]
  112. ]);
  113. }
  114. /**
  115. * 获取未解锁的「心动我的」卡片数量和最近三人的头像
  116. */
  117. public function unLookLikemeCnt()
  118. {
  119. $uid = Auth::auth();
  120. $hs = new HomeService();
  121. $data = $hs->unLookLikemeCnt($uid);
  122. return response([
  123. 'code' => 200,
  124. 'message' => 'success',
  125. 'data' => $data
  126. ]);
  127. }
  128. /**
  129. * 判断是否是内测用户
  130. */
  131. public function isTestUser()
  132. {
  133. $uid = Auth::auth();
  134. $exists = Redis::sismember("fpdx_supervip_test", $uid);
  135. if (1 == $exists) {
  136. $istest = true;
  137. } else {
  138. $istest = false;
  139. }
  140. return response([
  141. 'code' => 200,
  142. 'message' => 'success',
  143. 'data' => [
  144. 'istest' => $istest
  145. ]
  146. ]);
  147. }
  148. /**
  149. * 获取某人最近七天的热度
  150. */
  151. public function getLast7dayHot()
  152. {
  153. $uid = Auth::auth();
  154. $hs = new HomeService();
  155. $data = $hs->getLast7dayHot($uid);
  156. return response([
  157. 'code' => 200,
  158. 'message' => 'success',
  159. 'data' => $data
  160. ]);
  161. }
  162. /**
  163. * 获取当前人气值
  164. */
  165. public function getPopularity()
  166. {
  167. $uid = Auth::auth();
  168. $hs = new HomeService();
  169. $data = $hs->getPopularity($uid);
  170. return response([
  171. 'code' => 200,
  172. 'message' => 'success',
  173. 'data' => $data
  174. ]);
  175. }
  176. /**
  177. * 访客数据概览
  178. * @param Request $request
  179. * @return array
  180. */
  181. public function getVisitorOverView(Request $request)
  182. {
  183. $uid = Auth::auth();
  184. $hs = new HomeService();
  185. $data = $hs->getVisitorOverView($uid);
  186. return response([
  187. 'code' => 200,
  188. 'message' => 'success',
  189. 'data' => $data
  190. ]);
  191. }
  192. /**
  193. * 访客数据列表
  194. * @param Request $request
  195. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  196. * @deprecated
  197. */
  198. public function getVisitorList(Request $request)
  199. {
  200. $page = $request->get('page', 1);
  201. $pages = array(
  202. 'page' => $page,
  203. 'limit' => 20
  204. );
  205. $uid = Auth::auth();
  206. $hs = new HomeService();
  207. $data = $hs->getVisitorList($uid, $pages);
  208. return response([
  209. 'code' => 200,
  210. 'message' => 'success',
  211. 'data' => $data
  212. ]);
  213. }
  214. }