SportsSoccer.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/3/29
  6. * Time: 9:28
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\DB;
  10. class SportsSoccer extends BaseModel {
  11. protected $table = "st_zq_competition";
  12. public $timestamps = false;
  13. function getinfo($list = 10, $page, $where = '',$orwhere = '')
  14. {
  15. $zqmatch = $this->where('status','<','2')->where('match_date','<=',date("Y-m-d",time()))->get();
  16. for($b=0;$b<count($zqmatch);$b++){
  17. if($zqmatch[$b]->match_date < date("Y-m-d",time()) && strtotime($zqmatch[$b]->match_time.' '.$zqmatch[$b]->match_time)+7200 < time()){
  18. \App\Models\SportsSoccer::where('id',$zqmatch[$b]->id)->update(['status'=>'2']);
  19. \App\Models\Stzqresultrecord::where('match_id',$zqmatch[$b]->match_id)->update(['status'=>'2']);
  20. }
  21. if($zqmatch[$b]->match_date == date("Y-m-d",time()) && strtotime($zqmatch[$b]->match_date.' '.$zqmatch[$b]->match_time)+7200 < time()){
  22. \App\Models\SportsSoccer::where('id',$zqmatch[$b]->id)->update(['status'=>'2']);
  23. \App\Models\Stzqresultrecord::where('match_id',$zqmatch[$b]->match_id)->update(['status'=>'2']);
  24. }
  25. }
  26. $where[] = array('st_zq_league.name_chinese','<>','');
  27. // $source = \App\Models\Setinfo::where('id','1000')->first();
  28. // if($source->infocontent != '混合数据'){
  29. // $where[] = array('st_zq_local_match.source', '=', $source->infocontent);
  30. // $where[] = array('st_zq_local_league.source', '=', $source->infocontent);
  31. // }
  32. // if (is_array ($where) && count ($where) > 0) {
  33. // $data = $this->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.id')
  34. // ->join('st_zq_local_match','st_zq_competition.id','=','st_zq_local_match.match_id')
  35. // ->join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')
  36. // ->select('st_zq_competition.id','st_zq_local_match.match_id','st_zq_local_league.lg_id','st_zq_league.name_chinese','st_zq_league.last_time','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time','st_zq_competition.status','st_zq_competition.recommend')
  37. // ->orderby('st_zq_competition.match_date','desc')
  38. // ->orderby('st_zq_competition.match_time','desc')
  39. // ->where($where)
  40. // ->orwhere($orwhere)
  41. // ->paginate ($list);
  42. // } else {
  43. // $data = $this->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.id')
  44. // ->join('st_zq_local_match','st_zq_competition.id','=','st_zq_local_match.match_id')
  45. // ->join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')
  46. // ->select('st_zq_competition.id','st_zq_local_match.match_id','st_zq_local_league.lg_id','st_zq_league.name_chinese','st_zq_league.last_time','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time','st_zq_competition.status','st_zq_competition.recommend')
  47. // ->orderby('st_zq_competition.match_date','desc')
  48. // ->orderby('st_zq_competition.match_time','desc')
  49. // ->paginate ($list);
  50. // }
  51. if (is_array ($where) && count ($where) > 0) {
  52. $data = $this->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.lg_id')
  53. ->select('st_zq_competition.id','st_zq_competition.match_id','st_zq_competition.lg_id','st_zq_league.name_chinese','st_zq_league.last_time','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time','st_zq_competition.status','st_zq_competition.recommend','st_zq_competition.is_rollball','st_zq_competition.is_today','st_zq_competition.is_morningplate','st_zq_competition.is_stringscene')
  54. ->orderby('st_zq_competition.match_date','desc')
  55. ->orderby('st_zq_competition.match_time','desc')
  56. ->where($where)
  57. ->orwhere($orwhere)
  58. ->paginate ($list);
  59. } else {
  60. $data = $this->join('st_zq_league','st_zq_competition.lg_id','=','st_zq_league.lg_id')
  61. ->select('st_zq_competition.id','st_zq_competition.match_id','st_zq_competition.lg_id','st_zq_league.name_chinese','st_zq_league.last_time','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time','st_zq_competition.status','st_zq_competition.recommend','st_zq_competition.is_rollball','st_zq_competition.is_today','st_zq_competition.is_morningplate','st_zq_competition.is_stringscene')
  62. ->orderby('st_zq_competition.match_date','desc')
  63. ->orderby('st_zq_competition.match_time','desc')
  64. ->paginate ($list);
  65. }
  66. if (!$data < 0) {
  67. return -2021052003; //
  68. }
  69. for($i=0;$i<count($data);$i++){
  70. if($data[$i]->match_date == '' && $data[$i]->last_time != ''){
  71. $datetime = explode(' ',$data[$i]->last_time);
  72. $data[$i]->match_date = $datetime[0];
  73. $data[$i]->match_time = $datetime[1];
  74. }
  75. if($data[$i]->status==0){
  76. $data[$i]->status = '未开始';
  77. }else if($data[$i]->status==1){
  78. $data[$i]->status = '正在进行';
  79. }else if($data[$i]->status==2){
  80. $data[$i]->status = '已结束';
  81. }else if($data[$i]->status==3){
  82. $data[$i]->status = '已结算';
  83. }else if($data[$i]->status==4){
  84. $data[$i]->status = '已作废';
  85. }else if($data[$i]->status==5){
  86. $data[$i]->status = '待结算';
  87. }else if($data[$i]->status==6){
  88. $data[$i]->status = '已取消';
  89. }
  90. if($data[$i]->guest_team == ''){
  91. $data[$i]->home_guest = $data[$i]->home_team;
  92. }else{
  93. $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
  94. }
  95. }
  96. return $data->toArray();
  97. }
  98. //更新设置
  99. function updateInfos($data,$id){
  100. $res=$this->where('id',$id)->update($data);
  101. if(!$res) {
  102. return -7020050022;//更新失败
  103. }
  104. return 1;
  105. }
  106. function getmatchid($id){
  107. $res=$this->where('id',$id)->first();
  108. if(!$res){
  109. return -2021052003;
  110. }
  111. return $res->match_id;
  112. }
  113. //更新状态
  114. function updatestatus($field,$where,$data){
  115. $res=$this->where($field,$where)->update($data);
  116. if(!$res) {
  117. return -7020050022;//更新失败
  118. }
  119. return 1;
  120. }
  121. }