<?php




namespace ln\listens;

use ln\services\TimerService;
use Swoole\Timer;
use think\facade\Log;
use ln\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()));
            }
        });
    }
}
