StZqMatch.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. use App\Http\Model\StZqResult as ZqResultModel;
  8. use App\Http\Model\StLqResult as LqResultModel;
  9. use App\Http\Model\StWqResult as WqResultModel;
  10. use App\Http\Model\StBqResult as BqResultModel;
  11. /**
  12. * Class Account
  13. * @package App\Sports\Model
  14. * 用户账号
  15. */
  16. class StZqMatch extends Model
  17. {
  18. protected $table = 'st_zq_competition';
  19. public $timestamps = false;
  20. /**
  21. * 赛事异常处理
  22. * 当前时间大于赛事开始时间,赛事还未开始
  23. * 则设置为 已取消
  24. * $time int执行间隔时间 默认60秒
  25. * $time_sec int 查询范围 默认100秒
  26. */
  27. public static function HandleMatch($time = 60,$time_sec = 100){
  28. //拼接查询条件
  29. $time_unx_max = time() - $time;//查询最大时间 时间戳 5分钟前
  30. $time_unx_min = $time_unx_max - $time;//查询最小时间 时间戳 十分钟前
  31. $where = [
  32. ['match_date','=',date('Y-m-d',$time_unx_min)],
  33. ['match_time','>',date('H:i:s',$time_unx_min)],
  34. ['match_time','<',date('H:i:s',$time_unx_max)],
  35. ['status','=',0]
  36. ];
  37. //更新数据
  38. $up_data = ['status'=>6,'handle_mark'=>trans('handleMatch.re_match_auto')];
  39. //更新开赛时间为前一分钟 并且 未开始的赛事 为已取消
  40. self::where($where)->update($up_data);
  41. LqMatchModel::where($where)->update($up_data);
  42. WqMatchModel::where($where)->update($up_data);
  43. BqMatchModel::where($where)->update($up_data);
  44. //更新赛事结果 表
  45. $result_where = [
  46. ['start_time','>',date('Y-m-d H:i:s',$time_unx_min)],
  47. ['start_time','<',date('Y-m-d H:i:s',$time_unx_max)],
  48. ['status','=',0]
  49. ];
  50. $result_up_data = ['status'=>6];
  51. ZqResultModel::where($result_where)->update($result_up_data);
  52. LqResultModel::where($result_where)->update($result_up_data);
  53. WqResultModel::where($result_where)->update($result_up_data);
  54. BqResultModel::where($result_where)->update($result_up_data);
  55. }
  56. }