Head.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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['status'] < 2 and $vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time()-(90*60)) and $vv['match_time'] < date("H:i:s", time())){
  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. //重写方法
  121. public function typeList(){
  122. //获取所有未结束赛事
  123. $where = [
  124. ['status','<','2']
  125. ];
  126. $zqModel = $this->commonFunction->getModels('zq');
  127. $lqModel = $this->commonFunction->getModels('lq');
  128. $wqModel = $this->commonFunction->getModels('wq');
  129. $bqModel = $this->commonFunction->getModels('bq');
  130. $ZQmatchData = leagueModel::getLeagueMatchData($zqModel,$where,'zq');
  131. $LQmatchData = leagueModel::getLeagueMatchData($lqModel,$where,'lq');
  132. $WQmatchData = leagueModel::getLeagueMatchData($wqModel,$where,'wq');
  133. $BQmatchData = leagueModel::getLeagueMatchData($bqModel,$where,'bq');
  134. //处理空赔率赛事
  135. $ZQmatchData = $this->commonFunction->Handle_Odds_Null($ZQmatchData,$zqModel);
  136. $LQmatchData = $this->commonFunction->Handle_Odds_Null($LQmatchData,$lqModel);
  137. $WQmatchData = $this->commonFunction->Handle_Odds_Null($WQmatchData,$wqModel);
  138. $BQmatchData = $this->commonFunction->Handle_Odds_Null($BQmatchData,$bqModel);
  139. //合并所有球类赛事
  140. $matchAll = array_merge_recursive($ZQmatchData,$LQmatchData,$WQmatchData,$BQmatchData);
  141. //获取所有冠军盘口
  142. $where = [
  143. ['type','=',1],
  144. // ['source','=',$this->source]
  145. ];
  146. $select = ['match_id','type'];
  147. $ZQoddsData = ZQoddsModel::getOddsData($where,$select)->toArray();
  148. $LQoddsData = LQoddsModel::getOddsData($where,$select)->toArray();
  149. $WQoddsData = WQoddsModel::getOddsData($where,$select)->toArray();
  150. $BQoddsData = BQoddsModel::getOddsData($where,$select)->toArray();
  151. //合并所有球类冠军盘口
  152. $oddsAll = array_merge_recursive($ZQoddsData,$LQoddsData,$WQoddsData,$BQoddsData);
  153. $StRollBall = [];
  154. $StSoon = [];
  155. $StToday = [];
  156. $StMorningPlate = [];
  157. $StStringScene = [];
  158. //按状态条件分装数组
  159. foreach ($matchAll as $kk=>$vv){
  160. //滚球
  161. if($vv['status'] < 2 and $vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time()-(90*60)) and $vv['match_time'] < date("H:i:s", time())){
  162. $StRollBall[] = $vv;
  163. }
  164. //即将
  165. 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())){
  166. $StSoon[] = $vv;
  167. }
  168. //今日
  169. if($vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time()) and $vv['status'] < 2){
  170. $StToday[] = $vv;
  171. }
  172. //早盘
  173. 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")){
  174. $StMorningPlate[] = $vv;
  175. }
  176. //串场
  177. if($vv['is_stringscene'] == 1 and $vv['us_time'] > $this->commonFunction->qgmdate('Y-m-d H:i:s', '', -4) and $vv['status'] < 2){
  178. $StStringScene[] = $vv;
  179. }
  180. }
  181. //获取所有状态
  182. $type = lang('GameTypes','Sports')->getAll();
  183. foreach ($type as $k=>$v){
  184. switch ($v['type_code']) {
  185. case 'StRollBall'://滚球
  186. $type[$k]['matchNum'] = count($StRollBall);
  187. break;
  188. case 'StSoon'://即将
  189. $type[$k]['matchNum'] = count($StSoon);
  190. break;
  191. case 'StToday'://今日
  192. $type[$k]['matchNum'] = count($StToday);
  193. break;
  194. case 'StMorningPlate'://早盘
  195. $type[$k]['matchNum'] = count($StMorningPlate);
  196. break;
  197. case 'StStringScene'://串场
  198. $type[$k]['matchNum'] = count($StStringScene);
  199. break;
  200. case 'StChampion'://冠军
  201. $type[$k]['matchNum'] = count($oddsAll);
  202. break;
  203. default:
  204. throw new \Exception(Render([], '10002', lang('Tips', 'Sports')->get('PARAM_ERROR')));
  205. }
  206. }
  207. Render($type, '1', lang('Tips','Sports')->get('success'));
  208. }
  209. }