Stzqresult.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Support\Facades\DB;
  4. class Stzqresult extends BaseModel
  5. {
  6. protected $table = 'st_zq_result';
  7. public $timestamps = false;
  8. protected $fillable = ['id','lg_id','home_team','guest_team','home_rate','guest_rate','home_score','status','first_score','last_score','match_score','guest_score','match_winer','update_time','match_time','match_process','tag','u_home_score','u_guest_score','match_id','all_goal','penalty_card','corner_ball','source','p_code'];
  9. function resultlist($list = 10, $page, $where = '',$orwhere = '')
  10. {
  11. if (is_array ($where) && count ($where) > 0) {
  12. $data = $this->join('st_zq_league','st_zq_result.lg_id','=','st_zq_league.lg_id')->join('st_zq_competition','st_zq_competition.match_id','=','st_zq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_zq_result.guest_team','st_zq_result.home_rate','st_zq_result.guest_rate','st_zq_result.first_score','st_zq_result.status','st_zq_result.last_score','st_zq_result.match_score','st_zq_result.match_winer','st_zq_result.update_time','st_zq_competition.match_time','st_zq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.start_time',$this->table.'.u_home_score','st_zq_league.name_chinese as saisname')->orderby('st_zq_result.id','desc')->where($where)->orwhere($orwhere)->paginate ($list);
  13. } else {
  14. $data = $this->join('st_zq_league','st_zq_result.lg_id','=','st_zq_league.lg_id')->join('st_zq_competition','st_zq_competition.match_id','=','st_zq_result.match_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_zq_result.guest_team','st_zq_result.home_rate','st_zq_result.guest_rate','st_zq_result.first_score','st_zq_result.status','st_zq_result.last_score','st_zq_result.match_score','st_zq_result.match_winer','st_zq_result.update_time','st_zq_competition.match_time','st_zq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.start_time',$this->table.'.u_home_score','st_zq_league.name_chinese as saisname')->orderby('st_zq_result.id','desc')->paginate ($list);
  15. }
  16. return $data->toArray ();
  17. }
  18. //地区联赛赛事查询
  19. function alldiqu(){
  20. $data = $this->join('st_zq_league','st_zq_result.lg_id','=','st_zq_league.id')->select('st_zq_result.id','st_zq_result.lg_id','st_zq_result.home_team','st_zq_result.guest_team','st_zq_result.home_rate','st_zq_result.guest_rate','st_zq_result.first_score','st_zq_result.status','st_zq_result.last_score','st_zq_result.match_score','st_zq_result.match_winer','st_zq_result.update_time','st_zq_result.match_time','st_zq_result.match_process','st_zq_league.name_chinese as saisname')->orderby('st_zq_result.id','desc')->get();
  21. return $data->toArray ();
  22. }
  23. //更新
  24. function updateInfo($data, $id)
  25. {
  26. $res = $this->where ('id', $id)->update ($data);
  27. if (!$res) {
  28. return -7010101202; //更新失败
  29. }
  30. return 1;
  31. }
  32. //计算总进球数
  33. function totalgoal($match_id)
  34. {
  35. $data = $this->where('match_id',$match_id)->first();
  36. $all_goal = $data['home_score']+$data['guest_score'];
  37. $res = $this->where ('match_id', $match_id)->update (['all_goal'=>$all_goal]);
  38. if (!$res) {
  39. return -7010101202; //更新失败
  40. }
  41. return 1;//
  42. }
  43. //更新状态
  44. function updatestatus($field,$where,$data){
  45. $res=$this->where($field,$where)->update($data);
  46. if(!$res) {
  47. return -7020050022;//更新失败
  48. }
  49. return 1;
  50. }
  51. }