| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Jonlin
- * Date: 2019/3/29
- * Time: 9:28
- */
- namespace App\Models;
- use Illuminate\Support\Facades\DB;
- class SportsBasket extends BaseModel {
- protected $table = "st_lq_competition";
- public $timestamps = false;
- function getinfo($list = 10, $page, $where = '',$orwhere = '')
- {
- $lqmatch = $this->get();
- for($b=0;$b<count($lqmatch);$b++){
- if($lqmatch[$b]->status == 0 || $lqmatch[$b]->status == 1){
- if($lqmatch[$b]->match_date < date("Y-m-d",time()) && strtotime($lqmatch[$b]->match_time.' '.$lqmatch[$b]->match_time)+4200 < time()){
- \App\Models\SportsBasket::where('id',$lqmatch[$b]->id)->update(['status'=>'2']);
- \App\Models\Stlqresultrecord::where('match_id',$lqmatch[$b]->match_id)->update(['status'=>'2']);
- // $comendnotice = \App\Model\Comendnotice::where('match_id',$lqmatch[$b]->match_id)->first();
- // if(empty($comendnotice)){
- // $db = new \App\Model\Comendnotice();
- // $db->status = 0;
- // $db->game_code = 'lq';
- // $db->match_id = $lqmatch[$b]->match_id;
- // $db->done_time = date("Y-m-d h:i:s", time());
- // $db->ctime = date("Y-m-d h:i:s", time());
- // $db->save();
- // }
- }
- if($lqmatch[$b]->match_date == date("Y-m-d",time()) && strtotime($lqmatch[$b]->match_date.' '.$lqmatch[$b]->match_time)+4200 < time()){
- \App\Models\SportsBasket::where('id',$lqmatch[$b]->id)->update(['status'=>'2']);
- \App\Models\Stlqresultrecord::where('match_id',$lqmatch[$b]->match_id)->update(['status'=>'2']);
- // $comendnotice = \App\Model\Comendnotice::where('match_id',$lqmatch[$b]->match_id)->first();
- // if(empty($comendnotice)){
- // $db = new \App\Model\Comendnotice();
- // $db->status = 0;
- // $db->game_code = 'lq';
- // $db->match_id = $lqmatch[$b]->match_id;
- // $db->done_time = date("Y-m-d h:i:s", time());
- // $db->ctime = date("Y-m-d h:i:s", time());
- // $db->save();
- // }
- }
- }
- }
- $where[] = array('st_lq_league.name_chinese','<>','');
- // $source = \App\Model\Setinfo::where('id','1000')->first();
- // if($source->infocontent != '混合数据'){
- // $where[] = array('st_lq_local_match.source', '=', $source->infocontent);
- // $where[] = array('st_lq_local_league.source', '=', $source->infocontent);
- // }
- //
- // if (is_array ($where) && count ($where) > 0) {
- // $data = $this->join('st_lq_league','st_lq_competition.lg_id','=','st_lq_league.id')
- // ->join('st_lq_local_match','st_lq_competition.id','=','st_lq_local_match.match_id')
- // ->join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')
- // ->select('st_lq_competition.id','st_lq_local_match.match_id','st_lq_local_league.lg_id','st_lq_league.name_chinese','st_lq_league.last_time','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time','st_lq_competition.status','st_lq_competition.recommend')
- // ->orderby('st_lq_competition.match_date','desc')
- // ->orderby('st_lq_competition.match_time','desc')
- // ->where($where)
- // ->orwhere($orwhere)
- // ->paginate ($list);
- // } else {
- // $data = $this->join('st_lq_league','st_lq_competition.lg_id','=','st_lq_league.id')
- // ->join('st_lq_local_match','st_lq_competition.id','=','st_lq_local_match.match_id')
- // ->join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')
- // ->select('st_lq_competition.id','st_lq_local_match.match_id','st_lq_local_league.lg_id','st_lq_league.name_chinese','st_lq_league.last_time','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time','st_lq_competition.status','st_lq_competition.recommend')
- // ->orderby('st_lq_competition.match_date','desc')
- // ->orderby('st_lq_competition.match_time','desc')
- // ->paginate ($list);
- // }
- if (is_array ($where) && count ($where) > 0) {
- $data = $this->join('st_lq_league','st_lq_competition.lg_id','=','st_lq_league.lg_id')
- ->select('st_lq_competition.id','st_lq_competition.match_id','st_lq_competition.lg_id','st_lq_league.name_chinese','st_lq_league.last_time','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time','st_lq_competition.status','st_lq_competition.recommend')
- ->orderby('st_lq_competition.match_date','desc')
- ->orderby('st_lq_competition.match_time','desc')
- ->where($where)
- ->orwhere($orwhere)
- ->paginate ($list);
- } else {
- $data = $this->join('st_lq_league','st_lq_competition.lg_id','=','st_lq_league.lg_id')
- ->select('st_lq_competition.id','st_lq_competition.match_id','st_lq_competition.lg_id','st_lq_league.name_chinese','st_lq_league.last_time','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time','st_lq_competition.status','st_lq_competition.recommend')
- ->orderby('st_lq_competition.match_date','desc')
- ->orderby('st_lq_competition.match_time','desc')
- ->paginate ($list);
- }
- if (!$data < 0) {
- return -2021052003; //
- }
- //赛事结果处理状态查询
- $result = \App\Models\Comendnotice::where('game_code','lq')->get();
- for($i=0;$i<count($data);$i++){
- if($data[$i]->match_date == '' && $data[$i]->last_time != ''){
- $datetime = explode(' ',$data[$i]->last_time);
- $data[$i]->match_date = $datetime[0];
- $data[$i]->match_time = $datetime[1];
- }
- if($data[$i]->status==0){
- $data[$i]->status = '未开始';
- }else if($data[$i]->status==1){
- $data[$i]->status = '正在进行';
- }else if($data[$i]->status==2){
- $data[$i]->status = '已结束';
- }else if($data[$i]->status==3){
- $data[$i]->status = '已结算';
- }else if($data[$i]->status==4){
- $data[$i]->status = '已作废';
- }
- if($data[$i]->guest_team == ''){
- $data[$i]->home_guest = $data[$i]->home_team;
- }else{
- $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
- }
- //赛事结果状态
- $data[$i]->result_status = -1;
- $data[$i]->result_id = -1;
- if(!empty($result)){
- for($j=0;$j<count($result);$j++){
- if($data[$i]->match_id == $result[$j]->match_id){
- $data[$i]->result_status = $result[$j]->status;
- $data[$i]->result_id = $result[$j]->id;
- }
- }
- }
- if($data[$i]->result_status != -1){
- if($data[$i]->result_status == 0){
- $data[$i]->result = '<a class="layui-btn layui-btn-sm dealwith" lay-event="detail" pid="id" uri="/admin/SportsBasket/dealwith/?id=" href="javascript:dealwith(\'/admin/SportsBasket/dealwith/?id='.$data[$i]->result_id.'\');" style="background-color: #FF5722;"> 处理 </a>';
- }else{
- $data[$i]->result = '<a class="layui-btn layui-btn-sm dealwith" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: #FFAF60;"> 已处理 </a>';
- }
- }else{
- $data[$i]->result = '<a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 处理 </a>';
- }
- }
- return $data->toArray();
- }
- //更新设置
- function updateInfos($data,$id){
- $res=$this->where('id',$id)->update($data);
- if(!$res) {
- return -7020050022;//更新失败
- }
- return 1;
- }
- function getmatchid($id){
- $res=$this->where('id',$id)->first();
- if(!$res){
- return -2021052003;
- }
- return $res->match_id;
- }
- //篮球赛事联赛查询
- function allcompetition($lg_id){
- $data = $this->where('lg_id',$lg_id)->select('lg_id','home_team')->get();
- if (!$data) {
- return -5040000102; //无相关信息
- }
- return $data->toArray();
- }
- }
|