Stlqresult.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Support\Facades\DB;
  4. class Stlqresult extends BaseModel
  5. {
  6. protected $table = 'st_lq_result';
  7. public $timestamps = false;
  8. protected $fillable = ['lg_id','home_team','guest_team','home_rate','guest_rate','home_score','status','first_score','last_score','match_score','guest_score','match_winer','update_time','match_time','match_process','tag','u_home_score','u_guest_score','match_id','all_goal','source'];
  9. function resultbklist($list = 10, $page, $where = '', $orwhere = '')
  10. {
  11. if (is_array ($where) && count ($where) > 0) {
  12. $data = $this->join('st_lq_league','st_lq_result.lg_id','=','st_lq_league.id')->select($this->table.'.id',$this->table.'.lg_id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.home_rate',$this->table.'.guest_rate',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.all_goal',$this->table.'.status',$this->table.'.first_score',$this->table.'.last_score',$this->table.'.match_score',$this->table.'.match_winer',$this->table.'.update_time',$this->table.'.match_time',$this->table.'.match_process',$this->table.'.tag',$this->table.'.match_id',$this->table.'.u_home_score',$this->table.'.u_guest_score','st_lq_league.name_chinese')->orderby($this->table.'.id','desc')->where($where)->orwhere($orwhere)->paginate ($list);
  13. } else {
  14. $data = $this->join('st_lq_league','st_lq_result.lg_id','=','st_lq_league.id')->select($this->table.'.id',$this->table.'.lg_id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.home_rate',$this->table.'.guest_rate',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.all_goal',$this->table.'.status',$this->table.'.first_score',$this->table.'.last_score',$this->table.'.match_score',$this->table.'.match_winer',$this->table.'.update_time',$this->table.'.match_time',$this->table.'.match_process',$this->table.'.tag',$this->table.'.match_id',$this->table.'.u_home_score',$this->table.'.u_guest_score','st_lq_league.name_chinese')->orderby($this->table.'.id','desc')->paginate ($list);
  15. }
  16. return $data->toArray ();
  17. }
  18. //根据match_id查询比赛1-4节比分
  19. function allscore($match_id,$count=4){
  20. for ($i=1; $i < $count; $i++) {
  21. $where = array(
  22. 'match_id'=>$match_id,
  23. 'match_process'=>$i,
  24. );
  25. $data[] = $this->where($where)->select($this->table.'.home_score',$this->table.'.guest_score')->first();
  26. }
  27. return $data;
  28. }
  29. //根据match_id查询
  30. function onlyselect($match_id){
  31. $data = $this->where('match_id',$match_id)->select('lg_id','home_team','guest_team','home_rate','guest_rate','all_goal','first_score','last_score','match_score','match_winer','match_time','tag','match_id','u_home_score','u_guest_score','source')->first();
  32. if (!$data) {
  33. return -5040000102; //无相关信息
  34. }
  35. return $data->toArray();
  36. }
  37. //更新状态
  38. function updatastatus($match_id,$data){
  39. $res = $this->where ('match_id', $match_id)->update ($data);
  40. if (!$res) {
  41. return -7010101202; //更新失败
  42. }
  43. return 1;
  44. }
  45. //查询赛事
  46. function matchjg($match_id){
  47. $data = $this->where('match_id',$match_id)->select('id','home_team','guest_team')->first();
  48. if (!$data) {
  49. return -5040000102; //无相关信息
  50. }
  51. return $data->toArray();
  52. }
  53. }
  54. ?>