6
0
Fork 0
jiqu-library-server/app/Admin/Actions/Store/ShowOrderPrint.php

41 lines
895 B
PHP

<?php
namespace App\Admin\Actions\Store;
use Dcat\Admin\Show\AbstractTool;
use App\Models\Store\Desk;
use App\Services\OrderService;
use App\Models\Order;
use App\Exceptions\BizException;
class ShowOrderPrint extends AbstractTool
{
protected $title = '打印小票';
protected $style = 'btn btn-sm btn-warning mr-1';
public function handle()
{
$order = Order::findOrFail($this->getKey());
try {
(new OrderService())->print($order);
} catch (BizException $e) {
return $this->response()->error($e->getMessage());
}
return $this->response()->success('操作成功');
}
public function confirm()
{
return ['是否确定?', '打印小票'];
}
public function allowed()
{
$model = $this->parent->model();
return $model->source_type == Desk::class;
}
}