<?php




namespace ln\listens;


use app\common\repositories\store\order\StoreOrderRepository;
use ln\interfaces\ListenerInterface;
use ln\jobs\OrderReplyJob;
use ln\services\TimerService;
use Swoole\Timer;
use think\facade\Queue;

class AutoOrderReplyListen extends TimerService implements ListenerInterface
{

    public function handle($event): void
    {
        $this->tick(1000 * 60 * 60, function () {
            $storeOrderRepository = app()->make(StoreOrderRepository::class);
            $time = date('Y-m-d H:i:s', strtotime('- 7 day'));
            $ids = $storeOrderRepository->getFinishTimeoutIds($time);
            foreach ($ids as $id) {
                Queue::push(OrderReplyJob::class, $id);
            }
        });
    }
}