StZqMatch.php 1.1 KB

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