| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace App\Http\Controllers\Api;
- use Illuminate\Routing\Controller as BaseController;
- use App\Http\Response\Response;
- use Illuminate\Support\Facades\DB;
- use App\Lib\Biz\Sport\Common as commonFunction;
- use App\Http\Model\StZqMatch as StMatchModel;
- use App\Models\SportsNoteList as SportsNoteListModel;
- /**
- * 定时处理任务
- * Tank
- * 2019/10/31
- */
- class CrontabController extends BaseController{
- //是否启用 数据写入记录
- protected $isRecord;
- public function __construct()
- {
- $this->isRecord = config('record.isRecord');
- }
- /**
- * 定时执行 滚球投注危险球审核
- * 每分钟执行一次
- */
- public function HandleOrder(){
- try {
- //开启事务
- DB::beginTransaction();
- $time =60*5;
- //处理指定时间内的滚球待审核订单
- SportsNoteListModel::getOrderData($time);
- //提交事务
- DB::commit();
- //写请求数据 日志记录
- if ($this->isRecord) commonFunction::SET_SPORTS_RECORD('zq', [], 'HandleOrder', Response::success());
- return Response::success();
- } catch (\Exception $e) {
- //回滚事务
- DB::rollBack();
- //写请求数据 日志记录
- if ($this->isRecord) commonFunction::SET_SPORTS_RECORD('zq', [], 'HandleOrder', $e->getMessage());
- return $e->getMessage();
- }
- }
- /**
- * 定时执行 处理到时间应该开始而未开始的赛事
- * 每分钟执行一次
- */
- public function HandleMatch(){
- try {
- //开启事务
- DB::beginTransaction();
- $time = 60*5;//60 秒
- //处理指定时间内的赛事
- StMatchModel::HandleMatch($time);
- //提交事务
- DB::commit();
- //写请求数据 日志记录
- if ($this->isRecord) commonFunction::SET_SPORTS_RECORD('all', [], 'HandleMatch', Response::success());
- return Response::success();
- } catch (\Exception $e) {
- //回滚事务
- DB::rollBack();
- //写请求数据 日志记录
- if ($this->isRecord) commonFunction::SET_SPORTS_RECORD('all', [], 'HandleMatch', $e->getMessage());
- return $e->getMessage();
- }
- }
- /**
- * 定时执行 处理时间段内赛事已取消的注单1
- */
- public function HandleOrderInvalid(){
- try {
- //开启事务
- DB::beginTransaction();
- $time = 60*5;//5分钟
- //处理指定时间内已取消赛事的注单
- SportsNoteListModel::HandleOrderInvalid($time);
- //提交事务
- DB::commit();
- //写请求数据 日志记录
- if ($this->isRecord) commonFunction::SET_SPORTS_RECORD('all', [], 'HandleOrderInvalid', Response::success());
- return Response::success();
- } catch (\Exception $e) {
- //回滚事务
- DB::rollBack();
- //写请求数据 日志记录
- if ($this->isRecord) commonFunction::SET_SPORTS_RECORD('all', [], 'HandleOrderInvalid', $e->getMessage());
- return $e->getMessage();
- }
- }
- }
|