zx/crmeb/listens/SeckillTImeCheckListen.php

45 lines
1.8 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace crmeb\listens;
use crmeb\services\TimerService;
use Swoole\Timer;
use think\facade\Log;
use crmeb\interfaces\ListenerInterface;
use app\common\repositories\store\StoreSeckillActiveRepository;
use app\common\repositories\store\product\ProductAssistRepository;
use app\common\repositories\store\product\ProductGroupRepository;
use app\common\repositories\store\product\ProductPresellRepository;
class SeckillTImeCheckListen extends TimerService implements ListenerInterface
{
public function handle($event): void
{
$this->tick(1000 * 60, function () {
$make = app()->make(StoreSeckillActiveRepository::class);
$make_1 = app()->make(ProductAssistRepository::class);
$make_2 = app()->make(ProductPresellRepository::class);
$make_3 = app()->make(ProductGroupRepository::class);
try {
$make->valActiveStatus();//秒杀活动状态检查
$make_1->valActiveStatus();
$make_2->valActiveStatus();
$make_3->valActiveStatus();
} catch (\Exception $e) {
Log::info('自动检测秒杀结束失败' . date('Y-m-d H:i:s', time()));
}
});
}
}