AutoOrderReplyListen.php 746 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace ln\listens;
  3. use app\common\repositories\store\order\StoreOrderRepository;
  4. use ln\interfaces\ListenerInterface;
  5. use ln\jobs\OrderReplyJob;
  6. use ln\services\TimerService;
  7. use Swoole\Timer;
  8. use think\facade\Queue;
  9. class AutoOrderReplyListen extends TimerService implements ListenerInterface
  10. {
  11. public function handle($event): void
  12. {
  13. $this->tick(1000 * 60 * 60, function () {
  14. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  15. $time = date('Y-m-d H:i:s', strtotime('- 7 day'));
  16. $ids = $storeOrderRepository->getFinishTimeoutIds($time);
  17. foreach ($ids as $id) {
  18. Queue::push(OrderReplyJob::class, $id);
  19. }
  20. });
  21. }
  22. }