RefundOrderAgreeListen.php 965 B

123456789101112131415161718192021222324252627282930313233
  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\order\StoreRefundOrderRepository;
  8. class RefundOrderAgreeListen extends TimerService implements ListenerInterface
  9. {
  10. public function handle($event): void
  11. {
  12. $this->tick(1000 * 60 * 5, function () {
  13. $make = app()->make(StoreRefundOrderRepository::class);
  14. request()->clearCache();
  15. $merAgree = systemConfig('mer_refund_order_agree') ?? 7;
  16. $time = date('Y-m-d H:i:s', strtotime('-' . $merAgree . ' day'));
  17. $data = $make->getTimeOutIds($time);
  18. foreach ($data as $id) {
  19. try {
  20. $make->adminRefund($id, 0);
  21. } catch (\Exception $e) {
  22. Log::info('自动退款失败' . var_export($id, true));
  23. }
  24. }
  25. });
  26. }
  27. }