Stlqresult.php 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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')->join('st_lq_competition','st_lq_competition.id','=','st_lq_result.match_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','st_lq_competition.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.'.start_time',$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')->join('st_lq_competition','st_lq_competition.id','=','st_lq_result.match_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','st_lq_competition.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.'.start_time',$this->table.'.u_guest_score','st_lq_league.name_chinese')->orderby($this->table.'.id','desc')->paginate ($list);
  15. }
  16. $newsim = new \App\Models\SportsNoteList();
  17. $simplex = $newsim->getsim('lq');
  18. $newstr = new \App\Models\MoneyBuyStr();
  19. $str = $newstr->strmatchs();
  20. //print_r($str);exit;
  21. for ($i=0; $i < count($data); $i++) {
  22. $data[$i]->numsim = 0;
  23. for ($j=0; $j < count($simplex); $j++) {
  24. if($simplex[$j]['match_id'] == $data[$i]->match_id){
  25. $data[$i]->numsim = $data[$i]->numsim+1;
  26. }
  27. }
  28. $data[$i]->numstr = 0;
  29. for ($a=0; $a < count($str); $a++) {
  30. if(in_array($data[$i]->match_id,$str[$a]['match_ids'])){
  31. $data[$i]->numstr = $data[$i]->numstr+1;
  32. }
  33. }
  34. }
  35. return $data->toArray ();
  36. }
  37. //根据match_id查询比赛1-4节比分
  38. function allscore($match_id,$count=4){
  39. for ($i=1; $i < $count; $i++) {
  40. $where = array(
  41. 'match_id'=>$match_id,
  42. 'match_process'=>$i,
  43. );
  44. $data[] = $this->where($where)->select($this->table.'.home_score',$this->table.'.guest_score')->first();
  45. }
  46. return $data;
  47. }
  48. //根据match_id查询
  49. function onlyselect($match_id){
  50. $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();
  51. if (!$data) {
  52. return -5040000102; //无相关信息
  53. }
  54. return $data->toArray();
  55. }
  56. //更新状态
  57. function updatastatus($match_id,$data){
  58. $res = $this->where ('match_id', $match_id)->update ($data);
  59. if (!$res) {
  60. return -7010101202; //更新失败
  61. }
  62. return 1;
  63. }
  64. //查询赛事
  65. function matchjg($match_id){
  66. $data = $this->where('match_id',$match_id)->select('id','home_team','guest_team')->first();
  67. if (!$data) {
  68. return -5040000102; //无相关信息
  69. }
  70. return $data->toArray();
  71. }
  72. //更新状态
  73. function updatestatus($field,$where,$data){
  74. $res=$this->where($field,$where)->update($data);
  75. if(!$res) {
  76. return -7020050022;//更新失败
  77. }
  78. return 1;
  79. }
  80. }
  81. ?>