request->input('type'); $res = match ($type) { CateringCode::OPTION_PRINT_YLY => $this->printerCache->getYlyPrinter(), CateringCode::OPTION_PRINT_CODING => $this->printerCache->getOtherPrinter(), default => throw new ErrException('参数错误') }; return $this->return->success('success', ['list' => $res]); } use PrintTrait; /** * @var OrderOptionCateringLog */ #[Inject] protected OrderOptionCateringLog $orderOptionCateringLogModel; /** * @var OrderOptionCateringLog */ protected OrderOptionCateringLog $logInfo; /** * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function checkPrint(): array { $id = (int)$this->request->input('id'); // 获取数据源 $this->logInfo = $this->orderOptionCateringLogModel->find($id); if (empty($this->logInfo)) throw new ErrException('配餐记录不存在'); $this->__initRedisKey(); $res = $this->checkIsPrint(); return $this->return->success('success', ['status' => $res]); } /** * @var PrintOrderFactory */ #[Inject] protected PrintOrderFactory $printOrderFactory; /** * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function cancel(): array { $service = $this->printOrderFactory->handle($this->request->input('type')); $service->printId = (int)$this->request->input('print_id'); $service->handle(); $service->printCancel(); return $this->return->success('success'); } }