AuthCancelPresellOrderListen.php 849 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace ln\listens;
  3. use app\common\repositories\store\order\PresellOrderRepository;
  4. use ln\interfaces\ListenerInterface;
  5. use ln\services\TimerService;
  6. use Swoole\Timer;
  7. use think\facade\Log;
  8. class AuthCancelPresellOrderListen extends TimerService implements ListenerInterface
  9. {
  10. public function handle($event): void
  11. {
  12. $this->tick(1000 * 60 * 1.5, function () {
  13. $presellOrderRepository = app()->make(PresellOrderRepository::class);
  14. $ids = $presellOrderRepository->getTimeOutIds(date('Y-m-d H:i:s'));
  15. foreach ($ids as $id) {
  16. try {
  17. $presellOrderRepository->cancel($id);
  18. } catch (\Exception $e) {
  19. Log::info('自动关闭尾款订单失败' . var_export($id, 1));
  20. }
  21. }
  22. });
  23. }
  24. }