| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class Stwqresult extends Model
- {
- protected $table = 'st_wq_result';
- public $timestamps = false;
- function resultlist($list = 10, $page, $where = '', $orwhere = '',$if_order)
- {
- $match_ids = \App\Models\MoneyBuyMatch::select('match_id')->where('game_code','wq')->get()->toArray();
- $match_ids = array_column($match_ids,'match_id');
- //去重
- $match_ids = array_unique($match_ids);
- if($if_order == 1){
- if (is_array ($where) && count ($where) > 0) {
- $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_competition.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time',$this->table.'.manual_result','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->where($where)->wherein('st_wq_competition.id',$match_ids)->paginate ($list);
- } else {
- $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_competition.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time',$this->table.'.manual_result','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->wherein('st_wq_competition.id',$match_ids)->paginate ($list);
- }
- }else{
- if (is_array ($where) && count ($where) > 0) {
- $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_competition.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time',$this->table.'.manual_result','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->where($where)->paginate ($list);
- } else {
- $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_competition.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time',$this->table.'.manual_result','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->paginate ($list);
- }
- }
- $newsim = new \App\Models\SportsNoteList();
- $simplex = $newsim->getsim('wq');
- $newstr = new \App\Models\MoneyBuyStr();
- $str = $newstr->strmatchs('wq');
- //print_r($str);exit;
- for ($i=0; $i < count($data); $i++) {
- $data[$i]->numsim = 0;
- for ($j=0; $j < count($simplex); $j++) {
- if($simplex[$j]['match_id'] == $data[$i]->match_id){
- $data[$i]->numsim = $data[$i]->numsim+1;
- }
- }
- $data[$i]->numstr = 0;
- for ($a=0; $a < count($str); $a++) {
- if(in_array($data[$i]->match_id,$str[$a]['match_ids'])){
- $data[$i]->numstr = $data[$i]->numstr+1;
- }
- }
- $data[$i]->manual_result = json_decode($data[$i]->manual_result,true);
- }
- return $data->toArray ();
- }
- //查询赛事
- function matchjg($match_id){
- $data = $this->where('match_id',$match_id)->select('id','home_team','guest_team')->first();
- if (!$data) {
- return -5040000102; //无相关信息
- }
- return $data->toArray();
- }
- //更新状态
- function updatestatus($field,$where,$data){
- $res=$this->where($field,$where)->update($data);
- if(!$res) {
- return -7020050022;//更新失败
- }
- return 1;
- }
- }
- ?>
|