Head.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace App\Sports\Controller;
  3. use BaseController\Controller;
  4. use App\Sports\Model\St_zq_competition as ZQmatchModel;
  5. use App\Sports\Model\St_lq_competition as LQmatchModel;
  6. use App\Sports\Model\St_wq_competition as WQmatchModel;
  7. use App\Sports\Model\St_bq_competition as BQmatchModel;
  8. use App\Sports\Model\St_zq_odds as ZQoddsModel;
  9. use App\Sports\Model\St_lq_odds as LQoddsModel;
  10. use App\Sports\Model\St_wq_odds as WQoddsModel;
  11. use App\Sports\Model\St_bq_odds as BQoddsModel;
  12. use App\Sports\Model\St_zq_league as leagueModel;
  13. /**
  14. * Class Head
  15. * @package App\Sports\Controller
  16. * User: tank
  17. * Date: 2019/3/19
  18. */
  19. class Head extends Controller{
  20. public function init() {
  21. $this->commonFunction = C()->get('commonFunction');
  22. }
  23. /**
  24. * @throws \Exception
  25. * 返回首页球类列表
  26. */
  27. public function ballList (){
  28. $ret = lm('GameType', 'Sports')->select('id','game_name','game_code','game_ico_url')->where('status',1)->get();
  29. if(!empty($ret)) Render($ret, '1', lang('Tips','Sports')->get('success'));
  30. }
  31. //获取各状态下所有赛事数量
  32. public function typeList(){
  33. //获取所有未结束赛事
  34. $where = [
  35. ['status','<','2']
  36. ];
  37. $ZQmatchData = leagueModel::getLeagueMatchData($this->commonFunction->getModels('zq'),$where);
  38. $LQmatchData = leagueModel::getLeagueMatchData($this->commonFunction->getModels('lq'),$where);
  39. $WQmatchData = leagueModel::getLeagueMatchData($this->commonFunction->getModels('wq'),$where);
  40. $BQmatchData = leagueModel::getLeagueMatchData($this->commonFunction->getModels('bq'),$where);
  41. //合并所有球类赛事
  42. $matchAll = array_merge_recursive($ZQmatchData,$LQmatchData,$WQmatchData,$BQmatchData);
  43. //获取所有冠军盘口
  44. $where = [
  45. ['type','=',1],
  46. ['source','=',$this->source]
  47. ];
  48. $select = ['match_id','type'];
  49. $ZQoddsData = ZQoddsModel::getOddsData($where,$select)->toArray();
  50. $LQoddsData = LQoddsModel::getOddsData($where,$select)->toArray();
  51. $WQoddsData = WQoddsModel::getOddsData($where,$select)->toArray();
  52. $BQoddsData = BQoddsModel::getOddsData($where,$select)->toArray();
  53. //合并所有球类关键盘口
  54. $oddsAll = array_merge_recursive($ZQoddsData,$LQoddsData,$WQoddsData,$BQoddsData);
  55. $StRollBall = [];
  56. $StSoon = [];
  57. $StToday = [];
  58. $StMorningPlate = [];
  59. $StStringScene = [];
  60. //按状态条件分装数组
  61. foreach ($matchAll as $kk=>$vv){
  62. if($vv['status'] == '1'){
  63. $StRollBall[] = $vv;
  64. }
  65. if($vv['status'] == '0' and $vv['match_date'] == date("Y-m-d") and $vv['match_time'] < date("H:i:s", strtotime("+2 hour")) and $vv['match_time'] > date("H:i:s", time())){
  66. $StSoon[] = $vv;
  67. }
  68. if($vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time())){
  69. $StToday[] = $vv;
  70. }
  71. if($vv['is_morningplate'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4)){
  72. $StMorningPlate[] = $vv;
  73. }
  74. if($vv['is_stringscene'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4)){
  75. $StStringScene[] = $vv;
  76. }
  77. }
  78. //获取所有状态
  79. $type = lang('GameTypes','Sports')->getAll();
  80. foreach ($type as $k=>$v){
  81. switch ($v['type_code']) {
  82. case 'StRollBall'://滚球
  83. $type[$k]['matchNum'] = count($StRollBall);
  84. break;
  85. case 'StSoon'://即将
  86. $type[$k]['matchNum'] = count($StSoon);
  87. break;
  88. case 'StToday'://今日
  89. $type[$k]['matchNum'] = count($StToday);
  90. break;
  91. case 'StMorningPlate'://早盘
  92. $type[$k]['matchNum'] = count($StMorningPlate);
  93. break;
  94. case 'StStringScene'://串场
  95. $type[$k]['matchNum'] = count($StStringScene);
  96. break;
  97. case 'StChampion'://冠军
  98. $type[$k]['matchNum'] = count($oddsAll);
  99. break;
  100. default:
  101. throw new \Exception(Render([], '10002', lang('Tips', 'Sports')->get('PARAM_ERROR')));
  102. }
  103. }
  104. Render($type, '1', lang('Tips','Sports')->get('success'));
  105. }
  106. }