St_zq_league.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Sports\Model;
  3. use \System\Model;
  4. /**
  5. * Class Account
  6. * @package App\Sports\Model
  7. * 足球联赛
  8. */
  9. class St_zq_league extends Model
  10. {
  11. protected $table = 'st_zq_league';
  12. /*
  13. * 获取滚球 联赛数据
  14. */
  15. public static function getRollLeagueData($source,$models,$where,$search=''){
  16. $model_match = $models['model_match'];
  17. $model_league = $models['model_league'];
  18. $model_result = $models['model_result'];
  19. //当前状态下所有联赛
  20. $data = lm($model_league,"Sports")
  21. ->join($model_match,$model_match.'.lg_id',$model_league.'.id')
  22. ->select($model_league.'.id as lg_id',$model_league.'.name_chinese as leagueName')
  23. ->distinct($model_league.'.name_chinese')
  24. ->where([[$model_league.'.name_chinese','!=','']])
  25. ->where($where)
  26. ->where(function($query)use ($model_match,$search){
  27. $query->where($model_match.'.home_team','like','%'.$search.'%')
  28. ->orWhere(function($query)use ($model_match,$search) {
  29. $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
  30. });
  31. })
  32. ->get()
  33. ->toarray();
  34. return $data;
  35. }
  36. /*
  37. * 获取即将 联赛数据
  38. */
  39. public static function getSoonLeagueData($source,$models,$where,$search=''){
  40. $model_match = $models['model_match'];
  41. $model_league = $models['model_league'];
  42. $model_result = $models['model_result'];
  43. //当前状态下所有联赛
  44. $data = lm($model_league,"Sports")
  45. ->join($model_match,$model_match.'.lg_id',$model_league.'.id')
  46. ->select($model_league.'.id as lg_id',$model_league.'.name_chinese as leagueName')
  47. ->distinct($model_league.'.name_chinese')
  48. ->where([[$model_league.'.name_chinese','!=','']])
  49. ->where($where)
  50. ->where(function($query)use ($model_match,$search){
  51. $query->where($model_match.'.home_team','like','%'.$search.'%')
  52. ->orWhere(function($query)use ($model_match,$search) {
  53. $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
  54. });
  55. })
  56. ->get()
  57. ->toarray();
  58. return $data;
  59. }
  60. /*
  61. * 获取非滚球 联赛下赛事数据 用于统计数量
  62. */
  63. public static function getLeagueMatchData($models,$where){
  64. $model_match = $models['model_match'];
  65. $model_league = $models['model_league'];
  66. $model_result = $models['model_result'];
  67. $model_odds = $models['model_odds'];
  68. //当前状态下所有联赛
  69. $data = lm($model_league,"Sports")
  70. ->join($model_match,$model_match.'.lg_id',$model_league.'.id')
  71. ->select($model_league.'.id as lg_id',$model_league.'.name_chinese as leagueName',$model_match.'.id as match_id',$model_match.'.status',$model_match.'.match_date',$model_match.'.match_time',$model_match.'.us_time',$model_match.'.is_morningplate',$model_match.'.is_stringscene',$model_match.'.is_rollball',$model_match.'.is_today')
  72. ->where([[$model_league.'.name_chinese','!=','']])
  73. ->where([[$model_match.'.status','<',2]])
  74. ->get()
  75. ->toArray();
  76. return $data;
  77. }
  78. }