St_zq_league.php 3.3 KB

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