St_zq_competition.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_competition extends Model
  10. {
  11. protected $table = 'st_zq_competition';
  12. /**
  13. * @param array $where 条件
  14. * @param string $select 字段
  15. * @param string $sort 排序字段
  16. * @param string $orderby 排序方式
  17. * @return mixed
  18. * 获取赛事数据
  19. */
  20. public static function getMatchData($where=[],$select='id',$sort='id',$orderby='asc'){
  21. $matchData = self::select($select)->where($where)->orderBy($sort,$orderby)->get();
  22. return $matchData;
  23. }
  24. //获取各球类 滚球赛事关联赛事结果数据
  25. public static function getRollMatchDataAll($source,$models,$where,$lg_ids=[]){
  26. $model_match = $models['model_match'];
  27. $model_result = $models['model_result'];
  28. $select = [$model_match.'.lg_id',$model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team','home_score','guest_score',$model_result.'.match_time as a_time','match_process'];
  29. if($model_result == 'st_wq_result'){
  30. $select = [$model_match.'.lg_id',$model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team','home_player_score','guest_player_score',$model_result.'.match_time as a_time','match_process'];
  31. }
  32. $data = lm($model_match,"Sports")
  33. ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
  34. // ->select($model_match.'.lg_id',$model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team','home_score','guest_score',$model_result.'.match_time as a_time','match_process')
  35. ->select($select)
  36. ->where($model_match.'.source',$source['source'])
  37. ->whereIn($model_match.'.lg_id',$lg_ids)
  38. ->where($where)
  39. ->get()
  40. ->toarray();
  41. return $data;
  42. }
  43. //获取各球类 非滚球赛事关联赛事结果数据
  44. public static function getSoonMatchDataAll($source,$models,$where,$lg_ids=[]){
  45. $model_match = $models['model_match'];
  46. $data = lm($model_match,"Sports")
  47. ->select($model_match.'.lg_id',$model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team',$model_match.'.us_time')
  48. ->where($source)
  49. ->where($where)
  50. ->whereIn($model_match.'.lg_id',$lg_ids)
  51. ->orderBy('match_time','asc')
  52. ->get()
  53. ->toarray();
  54. return $data;
  55. }
  56. }