| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Jonlin
- * Date: 2019/3/28
- * Time: 9:05
- */
- namespace App\Models;
- use Illuminate\Support\Facades\DB;
- class SportsBase extends BaseModel {
- protected $table = "st_bq_competition";
- public $timestamps = false;
- function getinfo($list = 10, $page, $where = '',$orwhere = '')
- {
- if (is_array ($where) && count ($where) > 0) {
- $data = $this->join('st_bq_league','st_bq_competition.lg_id','=','st_bq_league.lg_id')
- ->select('st_bq_competition.id','st_bq_competition.match_id','st_bq_competition.lg_id','st_bq_league.name_chinese','st_bq_competition.home_team','st_bq_competition.guest_team','st_bq_competition.match_date','st_bq_competition.match_time','st_bq_competition.status','st_bq_competition.recommend')
- ->orderby('st_bq_competition.match_date','desc')
- ->orderby('st_bq_competition.match_time','desc')
- ->where($where)
- ->orwhere($orwhere)
- ->paginate ($list);
- } else {
- $data = $this->join('st_bq_league','st_bq_competition.lg_id','=','st_bq_league.lg_id')
- ->select('st_bq_competition.id','st_bq_competition.match_id','st_bq_competition.lg_id','st_bq_league.name_chinese','st_bq_competition.home_team','st_bq_competition.guest_team','st_bq_competition.match_date','st_bq_competition.match_time','st_bq_competition.status','st_bq_competition.recommend')
- ->orderby('st_bq_competition.match_date','desc')
- ->orderby('st_bq_competition.match_time','desc')
- ->paginate ($list);
- }
- if (!$data < 0) {
- return -2021052003; //
- }
- for($i=0;$i<count($data);$i++){
- if($data[$i]->match_date < date('Y-m-d',time())){
- $data[$i]->status = '2';
- //$this->where('id', $data[$i]->id)->update(['status' => 2]);
- }else if($data[$i]->match_date == date('Y-m-d',time()) && strtotime($data[$i]->match_time)+5400 <= strtotime(date('H:i:s',time()))){
- $data[$i]->status = '2';
- //$this->where('id', $data[$i]->id)->update(['status' => 2]);
- }
- else if($data[$i]->match_date == date('Y-m-d',time()) && strtotime($data[$i]->match_time) < strtotime(date('H:i:s',time())) && strtotime(date('H:i:s',time())) < strtotime($data[$i]->match_time)+5400){
- $data[$i]->status = '1';
- //$this->where('id', $data[$i]->id)->update(['status' => 1]);
- }else if($data[$i]->match_date == date('Y-m-d',time()) && strtotime($data[$i]->match_time) > strtotime(date('H:i:s',time()))){
- $data[$i]->status = '0';
- //$this->where('id', $data[$i]->id)->update(['status' => 0]);
- }
- else if($data[$i]->match_date > date('Y-m-d',time())){
- $data[$i]->status = '0';
- //$this->where('id', $data[$i]->id)->update(['status' => 0]);
- }
- 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 = '已结束';
- }
- 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;
- }
- $result = \App\Models\Comendnotice::where('match_id',$data[$i]->match_id)->where('game_code','bq')->first();
- if(!empty($result)){
- if($result->status == '0'){
- $data[$i]->result = '<a class="layui-btn layui-btn-sm dealwith" lay-event="detail" pid="id" uri="/admin/SportsBase/dealwith/?id=" href="javascript:dealwith(\'/admin/SportsBase/dealwith/?id='.$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: grey;"> 已处理 </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;
- }
- }
|