RankController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http\Controllers\Fpdx;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Fpdx\PairModel;
  5. use App\Models\Fpdx\MediaModel;
  6. class RankController extends Controller
  7. {
  8. /**
  9. * 分销榜单
  10. * @param int stage_id 期数
  11. * @return array [
  12. * 'code' => 200,
  13. * 'message' => 'success'
  14. * ]
  15. */
  16. public function fxRank(int $stage_id)
  17. {
  18. $pairModel = new PairModel();
  19. $datas = $pairModel->fxrank($stage_id);
  20. return [
  21. 'code' => 200,
  22. 'message' => 'success',
  23. 'data' => $datas
  24. ];
  25. }
  26. /**
  27. * 开启公众号报名排序
  28. * @return array
  29. * [
  30. * 'code' => 200,
  31. * 'message' => 'success',
  32. * 'data' => [
  33. * [
  34. * "media_id" => 公众号id,
  35. * "public_name" => 公众号名称,
  36. * "school" => 学校名称,
  37. * 'count' => 数量
  38. * ]
  39. * ]
  40. * ]
  41. */
  42. public function enrollRank()
  43. {
  44. $medaModel = new MediaModel();
  45. $datas = $medaModel->openMedias('fpdx');
  46. $datas->each(function (&$item) {
  47. $item->count = PairModel::where(array(
  48. ['stage_id', '=', 28],
  49. ['media_id', $item->media_id]
  50. ))->whereBetween('state', [100, 899])->count();
  51. });
  52. $datas = $datas->sortByDesc('count')->values();
  53. return [
  54. 'code' => 200,
  55. 'message' => 'success',
  56. 'data' => $datas
  57. ];
  58. }
  59. }