StZqMatch.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Http\Model;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Http\Model\StLqMatch as LqMatchModel;
  5. use App\Http\Model\StWqMatch as WqMatchModel;
  6. use App\Http\Model\StBqMatch as BqMatchModel;
  7. /**
  8. * Class Account
  9. * @package App\Sports\Model
  10. * 用户账号
  11. */
  12. class StZqMatch extends Model
  13. {
  14. protected $table = 'st_zq_competition';
  15. public $timestamps = false;
  16. /**
  17. * 赛事异常处理
  18. * 当前时间大于赛事开始时间,赛事还未开始
  19. * 则设置为 已取消
  20. * $time int执行间隔时间 默认60秒
  21. * $time_sec int 查询范围 默认100秒
  22. */
  23. public static function HandleMatch($time = 60,$time_sec = 100){
  24. //拼接查询条件
  25. $time_unx_max = time() - $time;//查询最大时间 时间戳
  26. $time_unx_min = $time_unx_max - $time_sec;//查询最小时间 时间戳
  27. $where = [
  28. ['match_date','=',date('Y-m-d',$time_unx_min)],
  29. ['match_time','>',date('H:i:s',$time_unx_min)],
  30. ['match_time','<',date('H:i:s',$time_unx_max)],
  31. ['status','=',0]
  32. ];
  33. //更新数据
  34. $up_data = ['status'=>6,'handle_mark'=>trans('handleMatch.re_match_auto')];
  35. //更新开赛时间为前一分钟 并且 未开始的赛事 为已取消
  36. self::where($where)->update($up_data);
  37. LqMatchModel::where($where)->update($up_data);
  38. WqMatchModel::where($where)->update($up_data);
  39. BqMatchModel::where($where)->update($up_data);
  40. }
  41. }