29 lines
773 B
PHP
29 lines
773 B
PHP
<?php
|
||
namespace App\Console\Commands;
|
||
|
||
use Illuminate\Console\Command;
|
||
use App\Models\ErpOrder;
|
||
use App\Jobs\SyncDeliveryToPlatform;
|
||
|
||
class RetrySyncCommand extends Command
|
||
{
|
||
protected $signature = 'orders:retry-sync';
|
||
protected $description = '重试回传失败的订单';
|
||
|
||
public function handle()
|
||
{
|
||
$failedOrders = ErpOrder::where('sync_status', 2)
|
||
->where('delivery_status', 2)
|
||
->limit(50)
|
||
->get();
|
||
|
||
foreach ($failedOrders as $order) {
|
||
$order->sync_status = 0;
|
||
$order->save();
|
||
SyncDeliveryToPlatform::dispatch($order->id);
|
||
$this->info("已加入重试队列:订单ID {$order->id}");
|
||
}
|
||
|
||
$this->info('重试任务触发完成');
|
||
}
|
||
} |