SeckillTImeCheckListen.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace ln\listens;
  3. use ln\services\TimerService;
  4. use Swoole\Timer;
  5. use think\facade\Log;
  6. use ln\interfaces\ListenerInterface;
  7. use app\common\repositories\store\StoreSeckillActiveRepository;
  8. use app\common\repositories\store\product\ProductAssistRepository;
  9. use app\common\repositories\store\product\ProductGroupRepository;
  10. use app\common\repositories\store\product\ProductPresellRepository;
  11. class SeckillTImeCheckListen extends TimerService implements ListenerInterface
  12. {
  13. public function handle($event): void
  14. {
  15. $this->tick(1000 * 60, function () {
  16. $make = app()->make(StoreSeckillActiveRepository::class);
  17. $make_1 = app()->make(ProductAssistRepository::class);
  18. $make_2 = app()->make(ProductPresellRepository::class);
  19. $make_3 = app()->make(ProductGroupRepository::class);
  20. try {
  21. $make->valActiveStatus();
  22. $make_1->valActiveStatus();
  23. $make_2->valActiveStatus();
  24. $make_3->valActiveStatus();
  25. } catch (\Exception $e) {
  26. Log::info('自动检测秒杀结束失败' . date('Y-m-d H:i:s', time()));
  27. }
  28. });
  29. }
  30. }