St_zq_league.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. public static function getRollLeagueData($source,$models,$where,$search=''){
  14. $model_match = $models['model_match'];
  15. $model_league = $models['model_league'];
  16. $model_result = $models['model_result'];
  17. //当前状态下所有联赛
  18. $data = lm($model_league,"Sports")
  19. ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
  20. ->join($model_result,$model_result.'.match_id',$model_match.'.match_id')
  21. ->select($model_league.'.lg_id',$model_league.'.name_chinese as leagueName')
  22. ->distinct($model_league.'.name_chinese')
  23. ->where($model_league.'.source',$source['source'])
  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. public static function getSoonLeagueData($source,$models,$where,$search=''){
  38. $model_match = $models['model_match'];
  39. $model_league = $models['model_league'];
  40. $model_result = $models['model_result'];
  41. //当前状态下所有联赛
  42. $data = lm($model_league,"Sports")
  43. ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
  44. ->select($model_league.'.lg_id',$model_league.'.name_chinese as leagueName')
  45. ->distinct($model_league.'.name_chinese')
  46. ->where($model_league.'.source',$source['source'])
  47. ->where([[$model_league.'.name_chinese','!=','']])
  48. ->where($where)
  49. ->where(function($query)use ($model_match,$search){
  50. $query->where($model_match.'.home_team','like','%'.$search.'%')
  51. ->orWhere(function($query)use ($model_match,$search) {
  52. $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
  53. });
  54. })
  55. ->get()
  56. ->toarray();
  57. return $data;
  58. }
  59. //获取非滚球 联赛下赛事数据 用于统计数量
  60. public static function getLeagueMatchData($models,$where){
  61. $model_match = $models['model_match'];
  62. $model_league = $models['model_league'];
  63. $model_result = $models['model_result'];
  64. //当前状态下所有联赛
  65. $data = lm($model_league,"Sports")
  66. ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
  67. ->select($model_league.'.lg_id',$model_league.'.name_chinese as leagueName',$model_match.'.id',$model_match.'.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')
  68. ->where([[$model_league.'.name_chinese','!=','']])
  69. ->where([[$model_match.'.status','<',2]])
  70. ->get()
  71. ->toarray();
  72. return $data;
  73. }
  74. }