Head.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. $zqModel = $this->commonFunction->getModels('zq');
  38. $lqModel = $this->commonFunction->getModels('lq');
  39. $wqModel = $this->commonFunction->getModels('wq');
  40. $bqModel = $this->commonFunction->getModels('bq');
  41. $ZQmatchData = leagueModel::getLeagueMatchData($zqModel,$where,'zq');
  42. $LQmatchData = leagueModel::getLeagueMatchData($lqModel,$where,'lq');
  43. $WQmatchData = leagueModel::getLeagueMatchData($wqModel,$where,'wq');
  44. $BQmatchData = leagueModel::getLeagueMatchData($bqModel,$where,'bq');
  45. //处理空赔率赛事
  46. $ZQmatchData = $this->commonFunction->Handle_Odds_Null($ZQmatchData,$zqModel);
  47. $LQmatchData = $this->commonFunction->Handle_Odds_Null($LQmatchData,$lqModel);
  48. $WQmatchData = $this->commonFunction->Handle_Odds_Null($WQmatchData,$wqModel);
  49. $BQmatchData = $this->commonFunction->Handle_Odds_Null($BQmatchData,$bqModel);
  50. //合并所有球类赛事
  51. $matchAll = array_merge_recursive($ZQmatchData,$LQmatchData,$WQmatchData,$BQmatchData);
  52. //获取所有冠军盘口
  53. $where = [
  54. ['type','=',1],
  55. ['source','=',$this->source]
  56. ];
  57. $select = ['match_id','type'];
  58. $ZQoddsData = ZQoddsModel::getOddsData($where,$select)->toArray();
  59. $LQoddsData = LQoddsModel::getOddsData($where,$select)->toArray();
  60. $WQoddsData = WQoddsModel::getOddsData($where,$select)->toArray();
  61. $BQoddsData = BQoddsModel::getOddsData($where,$select)->toArray();
  62. //合并所有球类冠军盘口
  63. $oddsAll = array_merge_recursive($ZQoddsData,$LQoddsData,$WQoddsData,$BQoddsData);
  64. $StRollBall = [];
  65. $StSoon = [];
  66. $StToday = [];
  67. $StMorningPlate = [];
  68. $StStringScene = [];
  69. //按状态条件分装数组
  70. foreach ($matchAll as $kk=>$vv){
  71. //滚球
  72. if($vv['is_rollball'] == '1' and $vv['status'] < 2){
  73. $StRollBall[] = $vv;
  74. }
  75. //即将
  76. 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())){
  77. $StSoon[] = $vv;
  78. }
  79. //今日
  80. if($vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time()) and $vv['status'] < 2){
  81. $StToday[] = $vv;
  82. }
  83. //早盘
  84. if($vv['is_morningplate'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4) and $vv['status'] < 2 and $vv['match_date'] > date("Y-m-d")){
  85. $StMorningPlate[] = $vv;
  86. }
  87. //串场
  88. if($vv['is_stringscene'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4) and $vv['status'] < 2){
  89. $StStringScene[] = $vv;
  90. }
  91. }
  92. //获取所有状态
  93. $type = lang('GameTypes','Sports')->getAll();
  94. foreach ($type as $k=>$v){
  95. switch ($v['type_code']) {
  96. case 'StRollBall'://滚球
  97. $type[$k]['matchNum'] = count($StRollBall);
  98. break;
  99. case 'StSoon'://即将
  100. $type[$k]['matchNum'] = count($StSoon);
  101. break;
  102. case 'StToday'://今日
  103. $type[$k]['matchNum'] = count($StToday);
  104. break;
  105. case 'StMorningPlate'://早盘
  106. $type[$k]['matchNum'] = count($StMorningPlate);
  107. break;
  108. case 'StStringScene'://串场
  109. $type[$k]['matchNum'] = count($StStringScene);
  110. break;
  111. case 'StChampion'://冠军
  112. $type[$k]['matchNum'] = count($oddsAll);
  113. break;
  114. default:
  115. throw new \Exception(Render([], '10002', lang('Tips', 'Sports')->get('PARAM_ERROR')));
  116. }
  117. }
  118. Render($type, '1', lang('Tips','Sports')->get('success'));
  119. }
  120. }