SportsTennis.php 6.6 KB

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