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

55 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Order;
use Illuminate\Support\Facades\DB;
use Throwable;
class DistributeOrder extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'distribute:order {order}';
/**
* The console command description.
*
* @var string
*/
protected $description = '生成订单提成记录';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$service = new \App\Services\DistributeService();
$order = Order::find($this->argument('order'));
try {
DB::beginTransaction();
DB::commit();
$service->storeByOrder($order);
} catch (Throwable $th) {
DB::rollBack();
}
return 0;
}
}