SeckillTImeCheckListen.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\listens;
  12. use crmeb\services\TimerService;
  13. use Swoole\Timer;
  14. use think\facade\Log;
  15. use crmeb\interfaces\ListenerInterface;
  16. use app\common\repositories\store\StoreSeckillActiveRepository;
  17. use app\common\repositories\store\product\ProductAssistRepository;
  18. use app\common\repositories\store\product\ProductGroupRepository;
  19. use app\common\repositories\store\product\ProductPresellRepository;
  20. class SeckillTImeCheckListen extends TimerService implements ListenerInterface
  21. {
  22. public function handle($event): void
  23. {
  24. $this->tick(1000 * 60, function () {
  25. $make = app()->make(StoreSeckillActiveRepository::class);
  26. $make_1 = app()->make(ProductAssistRepository::class);
  27. $make_2 = app()->make(ProductPresellRepository::class);
  28. $make_3 = app()->make(ProductGroupRepository::class);
  29. try {
  30. $make->valActiveStatus();//秒杀活动状态检查
  31. $make_1->valActiveStatus();
  32. $make_2->valActiveStatus();
  33. $make_3->valActiveStatus();
  34. } catch (\Exception $e) {
  35. Log::info('自动检测秒杀结束失败' . date('Y-m-d H:i:s', time()));
  36. }
  37. });
  38. }
  39. }