setName('order:autoclose') ->setDescription('自动关闭下单超过后台配置天数仍无师傅接单的订单并退款提醒'); } protected function execute(Input $input, Output $output) { $res = OrderAutoCloseService::closeExpiredOrders(100); if ($res['days'] <= 0) { $output->writeln('[OrderAutoclose] 后台配置超时自动关闭天数为 0,功能已关闭'); return; } $output->writeln("[OrderAutoclose] 配置天数={$res['days']}天,扫描到 {$res['scanned']} 笔超时未接单订单"); foreach ($res['details'] as $item) { if ($item['status'] === 'closed') { $output->writeln(" [OK] 订单 #{$item['order_id']} ({$item['order_no']}) 已自动关闭,退款状态={$item['refund_state']}"); } elseif ($item['status'] === 'error') { $output->writeln(" [FAIL] 订单 #{$item['order_id']} 处理失败: {$item['error']}"); } } $output->writeln("[OrderAutoclose] 执行结束:关闭 {$res['closed']} 笔,退款成功 {$res['refunded']} 笔,退款待重试 {$res['refund_failed']} 笔"); } }