RankController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <?php
  2. namespace App\Http\Controllers\Appearance;
  3. use App\Exceptions\AlertException;
  4. use App\Http\Controllers\Core\Auth;
  5. use App\Models\Appearance\PartnerRankModel;
  6. use App\Models\Appearance\SchoolRankModel;
  7. use App\Models\Appearance\AppearanceModel;
  8. use App\Models\Appearance\AppearanceVoteModel;
  9. use App\Models\Fpdx\MediaModel;
  10. use App\Models\User\UserModel;
  11. use App\Models\PartnerModel;
  12. use App\Models\SchoolModel;
  13. use App\Services\Appearance\RankService;
  14. use Illuminate\Http\Request;
  15. use App\Http\Controllers\Controller;
  16. class RankController extends Controller
  17. {
  18. /**
  19. * 学校榜
  20. * @param Request $request
  21. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  22. */
  23. public function schoolRank(Request $request)
  24. {
  25. $sex = $request->get('sex', 2);
  26. $page = $request->get('page', 1);
  27. $per_page = $request->get('per_page', 20);
  28. if ($request->filled('monthly')) {
  29. $type = 'monthly';
  30. $date = $request->get("date", date("Y-m-01"));
  31. $date = date("Y-05-01");
  32. } elseif ($request->filled("weekly")) {
  33. $type = 'weekly';
  34. $date = $request->get("date", date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)));
  35. $date = date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600));
  36. } else {
  37. $type = 'daily';
  38. $date = $request->get("date", date("Y-m-d"));
  39. $date = date("Y-m-d");
  40. }
  41. $school = $request->get('school', null);
  42. if (is_null($school)) {
  43. $random = rand(0, 460);
  44. $school = PartnerRankModel::where('date', $date)
  45. ->where('type', $type)
  46. ->where('sex', $sex)
  47. ->groupBy('school')
  48. ->havingRaw('count(*) > 20')
  49. ->skip($random)
  50. ->value('school');
  51. }
  52. $schoolModel = SchoolModel::where('school', $school)->firstOrFail();
  53. $builder = \DB::table("fpdx_appearance_partner_ranks as r")
  54. ->selectRaw("r.partner_id, r.sex, r.school, r.count")
  55. ->join("fpdx_appearances as a", "r.partner_id", '=', 'a.partner_id')
  56. ->where('r.date', $date)
  57. ->where('r.type', $type)
  58. ->where('r.school', $school)
  59. ->where('r.sex', $sex)
  60. ->where('a.state', 2);
  61. $total = $builder->count();
  62. $votes = $builder->orderBy('count', 'desc')->offset(($page - 1) * $per_page)->limit($per_page)->get();
  63. $last_page = ceil($total / $per_page);
  64. try {
  65. $uid = Auth::auth();
  66. $appearance = AppearanceModel::where('uid', $uid)->first();
  67. if ($appearance && $appearance->school == $school && $appearance->sex == $sex && $appearance->state == 2) {
  68. $partner = PartnerModel::select(
  69. 'address',
  70. 'age',
  71. 'check_photo',
  72. 'is_sell',
  73. 'id',
  74. 'media_id',
  75. 'photo_src',
  76. 'photo_1',
  77. 'photo_2',
  78. 'photo_3',
  79. 'photo_4',
  80. 'photo_1_check',
  81. 'photo_2_check',
  82. 'photo_3_check',
  83. 'photo_4_check',
  84. 'voice',
  85. 'voice_check',
  86. 'praises',
  87. 'school',
  88. 'star'
  89. )->find($appearance->partner_id);
  90. // 我的排名
  91. $count = PartnerRankModel::where('date', $date)->where('type', $type)->where(
  92. 'partner_id',
  93. $appearance->partner_id
  94. )->value('count');
  95. $rank = $count ?
  96. \DB::table("fpdx_appearance_partner_ranks as r")
  97. ->join("fpdx_appearances as a", "r.partner_id", "=", "a.partner_id")
  98. ->where('r.date', $date)
  99. ->where('r.type', $type)
  100. ->where('r.school', $school)
  101. ->where('r.count', '>', $count)
  102. ->where('r.sex', $sex)
  103. ->where("a.state", 2)
  104. ->count() + 1
  105. : null;
  106. $self = true;
  107. $pick = AppearanceVoteModel::where('uid', $uid)->where('type', 2)->where(
  108. 'partner_id',
  109. $appearance->partner_id
  110. )->today()->first() ? true : false;
  111. $my_rank = [
  112. 'appearance' => $appearance,
  113. 'partner' => $partner,
  114. 'user' => UserModel::select(
  115. 'nickname',
  116. 'headimgurl',
  117. 'identity_auth',
  118. 'sex',
  119. 'age',
  120. 'star'
  121. )->find($uid),
  122. 'count' => $count,
  123. 'self' => $self,
  124. 'pick' => $pick,
  125. 'rank' => $rank,
  126. ];
  127. } else {
  128. $my_rank = [
  129. 'appearance' => $appearance,
  130. ];
  131. }
  132. } catch (\Exception $e) {
  133. $uid = 0;
  134. $my_rank = null;
  135. }
  136. $picks = AppearanceVoteModel::where('uid', $uid)->where('type', 2)->whereIn(
  137. 'partner_id',
  138. $votes->pluck('partner_id')->toArray()
  139. )->today()->get();
  140. $partners = PartnerModel::whereIn('id', $votes->pluck('partner_id')->toArray())->get([
  141. 'uid',
  142. 'address',
  143. 'age',
  144. 'check_photo',
  145. 'is_sell',
  146. 'id',
  147. 'media_id',
  148. 'photo_src',
  149. 'photo_1',
  150. 'photo_2',
  151. 'photo_3',
  152. 'photo_4',
  153. 'photo_1_check',
  154. 'photo_2_check',
  155. 'photo_3_check',
  156. 'photo_4_check',
  157. 'voice',
  158. 'voice_check',
  159. 'praises',
  160. 'school',
  161. 'star'
  162. ])->toArray();
  163. $partners = array_combine(array_column($partners, 'id'), $partners);
  164. $users = UserModel::whereIn('uid', array_column($partners, 'uid'))->get([
  165. 'uid',
  166. 'nickname',
  167. 'headimgurl',
  168. 'identity_auth',
  169. 'sex',
  170. 'age',
  171. 'star'
  172. ])->toArray();
  173. $users = array_combine(array_column($users, 'uid'), $users);
  174. foreach ($votes as $vote) {
  175. $vote->self = $uid && $appearance && $appearance->partner_id == $vote->partner_id ? true : false;
  176. $vote->pick = $uid && in_array($vote->partner_id, $picks->pluck('partner_id')->toArray()) ? true : false;
  177. $vote->partner = $partners[$vote->partner_id];
  178. $vote->user = $users[$vote->partner['uid']];
  179. }
  180. // 学校票数
  181. $school_count = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  182. 'school',
  183. $school
  184. )->value('count') ?: 0;
  185. // 学校全国全省排名
  186. $country_school_number = SchoolRankModel::where('date', $date)->where('type', $type)->count() ?: 1;
  187. $country_school_rank = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  188. 'count',
  189. '>',
  190. $school_count
  191. )->count() + 1;
  192. $province_school_rank = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  193. 'province',
  194. $schoolModel->province
  195. )->where('count', '>', $school_count)->count() + 1;
  196. // 排名上一个学校
  197. if ($province_school_rank == 1) {
  198. $last = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  199. 'count',
  200. '>',
  201. $school_count
  202. )->orderBy('count', 'asc')->first();
  203. } else {
  204. $last = SchoolRankModel::where([
  205. 'date' => $date,
  206. 'type' => $type,
  207. 'province' => $schoolModel->province,
  208. ])->where('count', '>', $school_count)->orderBy('count', 'asc')->first();
  209. }
  210. // 跟上一名学校差距的票
  211. if ($last) {
  212. $last_school = $last->school;
  213. $disparity_count = $last->count - $school_count;
  214. } else {
  215. $last_school = null;
  216. $disparity_count = null;
  217. }
  218. $self = $uid && $appearance && $appearance->school == $school ? true : false;
  219. $pick = $uid && AppearanceVoteModel::where('uid', $uid)->where('type', 1)->where(
  220. 'school',
  221. $school
  222. )->today()->first() ? true : false;
  223. $ratio = round(($country_school_rank - 1) / $country_school_number * 100, 2) . '%';
  224. $media = (new RankService())->getSchoolFirstMedia($school);
  225. $meta = [
  226. 'self' => $self,
  227. 'pick' => $pick,
  228. 'school' => $school,
  229. 'count' => $school_count,
  230. 'last_school' => $last_school,
  231. 'disparity_count' => $disparity_count,
  232. 'ratio' => $ratio,
  233. 'my_rank' => $my_rank,
  234. 'province_school_rank' => $province_school_rank,
  235. 'country_school_rank' => $country_school_rank,
  236. 'country_school_number' => $country_school_number,
  237. 'sex' => $sex,
  238. 'current_page' => $page,
  239. 'per_page' => $per_page,
  240. 'last_page' => $last_page,
  241. 'total' => $total,
  242. 'media' => $media
  243. ];
  244. return response([
  245. 'code' => 200,
  246. 'message' => 'OK',
  247. 'data' => $votes,
  248. 'meta' => $meta,
  249. ]);
  250. }
  251. /**
  252. * 全国榜
  253. * @param Request $request
  254. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  255. */
  256. public function countryRank(Request $request)
  257. {
  258. $page = $request->get('page', 1);
  259. $per_page = $request->get('per_page', 20);
  260. if ($request->filled('monthly')) {
  261. $type = 'monthly';
  262. $date = $request->get("date", date("Y-m-01"));
  263. $date = date("Y-05-01");
  264. } elseif ($request->filled("weekly")) {
  265. $type = 'weekly';
  266. $date = $request->get("date", date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)));
  267. $date = date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600));
  268. } else {
  269. $type = 'daily';
  270. $date = $request->get("date", date("Y-m-d"));
  271. $date = date("Y-m-d");
  272. }
  273. $rankService = new RankService();
  274. $builder = SchoolRankModel::where('date', $date)->where('type', $type);
  275. $total = $builder->count();
  276. $votes = $builder->orderBy('count', 'desc')->offset(($page - 1) * $per_page)->limit($per_page)->get();
  277. $last_page = ceil($total / $per_page);
  278. try {
  279. $uid = Auth::auth();
  280. $user = UserModel::find($uid);
  281. $my_school = $user->school;
  282. if ($my_school && $schoolModel = SchoolModel::where('school', $my_school)->first()) {
  283. $pick = AppearanceVoteModel::where('uid', $uid)->where('type', 1)->where(
  284. 'school',
  285. $my_school
  286. )->today()->first() ? true : false;
  287. $count = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  288. 'school',
  289. $my_school
  290. )->value('count');
  291. $rank = $count ? SchoolRankModel::where('date', $date)->where('type', $type)->where(
  292. 'count',
  293. '>',
  294. $count
  295. )->count() + 1 : null;
  296. $partners = $rankService->getPartners($type, $date, $my_school);
  297. // 学校票数
  298. $school_count = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  299. 'school',
  300. $schoolModel->school
  301. )->value('count') ?: 0;
  302. // 学校全国全省排名
  303. $country_school_number = SchoolRankModel::where('date', $date)->where('type', $type)->count() ?: 1;
  304. $country_school_rank = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  305. 'count',
  306. '>',
  307. $school_count
  308. )->count() + 1;
  309. $province_school_rank = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  310. 'province',
  311. $schoolModel->province
  312. )->where('count', '>', $school_count)->count() + 1;
  313. // 排名上一个学校
  314. if ($province_school_rank == 1) {
  315. $last = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  316. 'count',
  317. '>',
  318. $school_count
  319. )->orderBy('count', 'asc')->first();
  320. } else {
  321. $last = SchoolRankModel::where([
  322. 'date' => $date,
  323. 'type' => $type,
  324. 'province' => $schoolModel->province,
  325. ])->where('count', '>', $school_count)->orderBy('count', 'asc')->first();
  326. }
  327. // 跟上一名学校差距的票
  328. if ($last) {
  329. $last_school = $last->school;
  330. $disparity_count = $last->count - $school_count;
  331. } else {
  332. $last_school = null;
  333. $disparity_count = null;
  334. }
  335. $ratio = round(($country_school_rank - 1) / $country_school_number * 100, 2) . '%';
  336. $my_rank = [
  337. 'school' => $schoolModel->school,
  338. 'province' => $schoolModel->province,
  339. 'city' => $schoolModel->city,
  340. 'partners' => $partners,
  341. 'count' => $count,
  342. 'rank' => $rank,
  343. 'self' => true,
  344. 'pick' => $pick,
  345. 'province_school_rank' => $province_school_rank,
  346. 'country_school_rank' => $country_school_rank,
  347. 'last_school' => $last_school,
  348. 'disparity_count' => $disparity_count,
  349. 'ratio' => $ratio,
  350. ];
  351. } else {
  352. $my_rank = [
  353. 'school' => $my_school
  354. ];
  355. }
  356. } catch (\Exception $e) {
  357. $uid = 0;
  358. $my_rank = null;
  359. }
  360. $schools = AppearanceVoteModel::where('uid', $uid)->where('type', 1)->whereIn(
  361. 'school',
  362. $votes->pluck('school')->toArray()
  363. )->today()->get();
  364. $schoolsRank = $rankService->getSchoolsFirstPartner($type, $date, $votes->pluck('school')->toArray());
  365. foreach ($votes as $vote) {
  366. $vote->pick = $uid && in_array($vote->school, $schools->pluck('school')->toArray()) ? true : false;
  367. $partners = array(
  368. 'men' => empty($schoolsRank[$vote->school]['men']['partner']['photo_src']) ? "" : "https://oss.pocketuniversity.cn" . $schoolsRank[$vote->school]['men']['partner']['photo_src'],
  369. 'women' => empty($schoolsRank[$vote->school]['women']['partner']['photo_src']) ? "" : "https://oss.pocketuniversity.cn" . $schoolsRank[$vote->school]['women']['partner']['photo_src'],
  370. );
  371. $vote->partners = $partners;
  372. }
  373. $meta = [
  374. 'current_page' => $page,
  375. 'per_page' => $per_page,
  376. 'last_page' => $last_page,
  377. 'total' => $total,
  378. 'my_rank' => $my_rank
  379. ];
  380. return response([
  381. 'code' => 200,
  382. 'message' => 'OK',
  383. 'data' => $votes,
  384. 'meta' => $meta,
  385. ]);
  386. }
  387. /**
  388. * 省榜
  389. * @param Request $request
  390. * @param $province
  391. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  392. */
  393. public function provinceRank(Request $request, $province)
  394. {
  395. $page = $request->get('page', 1);
  396. $per_page = $request->get('per_page', 20);
  397. if ($request->filled('monthly')) {
  398. $type = 'monthly';
  399. $date = $request->get("date", date("Y-m-01"));
  400. $date = date("Y-05-01");
  401. } elseif ($request->filled("weekly")) {
  402. $type = 'weekly';
  403. $date = $request->get("date", date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)));
  404. $date = date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600));
  405. } else {
  406. $type = 'daily';
  407. $date = $request->get("date", date("Y-m-d"));
  408. $date = date("Y-m-d");
  409. }
  410. $builder = SchoolRankModel::where('date', $date)->where('type', $type)->where('province', $province);
  411. $total = $builder->count();
  412. $votes = $builder->orderBy('count', 'desc')->offset(($page - 1) * $per_page)->limit($per_page)->get();
  413. $last_page = ceil($total / $per_page);
  414. $rankService = new RankService();
  415. try {
  416. $uid = Auth::auth();
  417. $user = UserModel::find($uid);
  418. $my_school = $user->school;
  419. if (
  420. $my_school && $schoolModel = SchoolModel::where('school', $my_school)->where(
  421. 'province',
  422. $province
  423. )->first()
  424. ) {
  425. $pick = AppearanceVoteModel::where('uid', $uid)->where('type', 1)->where(
  426. 'school',
  427. $my_school
  428. )->today()->first() ? true : false;
  429. $count = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  430. 'province',
  431. $province
  432. )->where('school', $schoolModel->school)->value('count');
  433. $rank = $count ? SchoolRankModel::where('date', $date)->where('type', $type)->where(
  434. 'province',
  435. $province
  436. )->where('count', '>', $count)->count() + 1 : null;
  437. // 学校排名第一的校花校草
  438. $partners = $rankService->getPartners($type, $date, $schoolModel->school);
  439. // 学校票数
  440. $school_count = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  441. 'school',
  442. $schoolModel->school
  443. )->value('count') ?: 0;
  444. // 学校全国全省排名
  445. $country_school_number = SchoolRankModel::where('date', $date)->where('type', $type)->count() ?: 1;
  446. $country_school_rank = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  447. 'count',
  448. '>',
  449. $school_count
  450. )->count() + 1;
  451. $province_school_rank = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  452. 'province',
  453. $schoolModel->province
  454. )->where('count', '>', $school_count)->count() + 1;
  455. // 排名上一个学校
  456. if ($province_school_rank == 1) {
  457. $last = SchoolRankModel::where('date', $date)->where('type', $type)->where(
  458. 'count',
  459. '>',
  460. $school_count
  461. )->orderBy('count', 'asc')->first();
  462. } else {
  463. $last = SchoolRankModel::where([
  464. 'date' => $date,
  465. 'type' => $type,
  466. 'province' => $schoolModel->province,
  467. ])->where('count', '>', $school_count)->orderBy('count', 'asc')->first();
  468. }
  469. // 跟上一名学校差距的票
  470. if ($last) {
  471. $last_school = $last->school;
  472. $disparity_count = $last->count - $school_count;
  473. } else {
  474. $last_school = null;
  475. $disparity_count = null;
  476. }
  477. $ratio = round(($country_school_rank - 1) / $country_school_number * 100, 2) . '%';
  478. $my_rank = [
  479. 'school' => $schoolModel->school,
  480. 'province' => $schoolModel->province,
  481. 'city' => $schoolModel->city,
  482. 'partners' => $partners,
  483. 'count' => $count,
  484. 'rank' => $rank,
  485. 'self' => true,
  486. 'pick' => $pick,
  487. 'province_school_rank' => $province_school_rank,
  488. 'country_school_rank' => $country_school_rank,
  489. 'last_school' => $last_school,
  490. 'disparity_count' => $disparity_count,
  491. 'ratio' => $ratio,
  492. ];
  493. } else {
  494. $my_rank = [
  495. 'school' => $my_school
  496. ];
  497. }
  498. } catch (\Exception $e) {
  499. $uid = 0;
  500. $my_rank = null;
  501. }
  502. $schools = AppearanceVoteModel::where('uid', $uid)->where('type', 1)->whereIn(
  503. 'school',
  504. $votes->pluck('school')->toArray()
  505. )->today()->get();
  506. $schoolsRank = $rankService->getSchoolsFirstPartner($type, $date, $votes->pluck('school')->toArray());
  507. foreach ($votes as $vote) {
  508. $vote->pick = $uid && in_array($vote->school, $schools->pluck('school')->toArray()) ? true : false;
  509. $partners = array(
  510. 'men' => empty($schoolsRank[$vote->school]['men']['partner']['photo_src']) ? "" : "https://oss.pocketuniversity.cn" . $schoolsRank[$vote->school]['men']['partner']['photo_src'],
  511. 'women' => empty($schoolsRank[$vote->school]['women']['partner']['photo_src']) ? "" : "https://oss.pocketuniversity.cn" . $schoolsRank[$vote->school]['women']['partner']['photo_src'],
  512. );
  513. $vote->partners = $partners;
  514. }
  515. $meta = [
  516. 'current_page' => $page,
  517. 'per_page' => $per_page,
  518. 'last_page' => $last_page,
  519. 'total' => $total,
  520. 'my_rank' => $my_rank
  521. ];
  522. return response([
  523. 'code' => 200,
  524. 'message' => 'OK',
  525. 'data' => $votes,
  526. 'meta' => $meta,
  527. ]);
  528. }
  529. /**
  530. * 卡片信息
  531. * @param Request $request
  532. * @param $partner_id
  533. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  534. * @throws AlertException
  535. */
  536. public function partner(Request $request, $partner_id)
  537. {
  538. $partner = PartnerModel::findOrFail($partner_id);
  539. $appearance = AppearanceModel::where('partner_id', $partner_id)->first();
  540. if (!$appearance) {
  541. throw new AlertException("卡片未参与投票");
  542. }
  543. $user = UserModel::find($partner->uid);
  544. $type = 'monthly';
  545. $date = date('Y-m-01');
  546. $count = PartnerRankModel::where('date', $date)->where('type', $type)->where(
  547. 'partner_id',
  548. $partner_id
  549. )->value('count');
  550. try {
  551. $uid = Auth::auth();
  552. $self = $user->partner_id == $partner_id ? true : false;
  553. $pick = AppearanceVoteModel::where('uid', $uid)->where('type', 2)->where(
  554. 'partner_id',
  555. $partner_id
  556. )->today()->first() ? true : false;
  557. } catch (\Exception $e) {
  558. $self = false;
  559. $pick = false;
  560. }
  561. return response([
  562. 'code' => 200,
  563. 'message' => 'OK',
  564. 'data' => [
  565. 'partner' => $partner,
  566. 'user' => $user,
  567. 'count' => $count,
  568. 'self' => $self,
  569. 'pick' => $pick,
  570. ]
  571. ]);
  572. }
  573. /**
  574. * logo墙
  575. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  576. */
  577. public function medias()
  578. {
  579. $medias = MediaModel::select('media_id', 'public_name', 'head_img')
  580. ->whereIn('media_id', \DB::table("pocket.kdgx_activity_enrolls")
  581. ->where("state", 1)
  582. ->pluck('media_id'))->get();
  583. return response([
  584. 'code' => 200,
  585. 'message' => 'OK',
  586. 'data' => $medias
  587. ]);
  588. }
  589. }