6
0
Fork 0
jiqu-library-server/app/Console/Commands/OrderCompleteCommand.php

39 lines
841 B
PHP

<?php
namespace App\Console\Commands;
use App\Models\Order;
use App\Services\OrderService;
use Illuminate\Console\Command;
class OrderCompleteCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'order:complete';
/**
* The console command description.
*
* @var string
*/
protected $description = '将可自动完成的订单标记为已完成';
/**
* Execute the console command.
*
* @return int
*/
public function handle(OrderService $orderService)
{
Order::with('packages')->completable()->chunkById(200, function ($orders) use ($orderService) {
foreach ($orders as $order) {
$orderService->confirm($order);
}
});
}
}