pickupCodeModel->find($this->request->input('id')); if (empty($pickupCodeInfo)) throw new ErrException('取餐数据不存在'); $orderInfo = $this->orderModel->find($pickupCodeInfo->order_id); if (empty($this->orderInfo)) throw new ErrException('订单数据不存在'); $skuArr = $this->orderGoodModel->where('order_id',$pickupCodeInfo->order_id)->where('copies',$pickupCodeInfo->copies)->pluck('quantity','sku_id')->toArray(); if (empty($skuArr)) throw new ErrException('订单商品数据不存在'); $skuIds = array_keys($skuArr); $skuInfo = $this->skuModel->whereIn('id',$skuIds)->pluck('code_number','id'); $skuCopies = []; foreach ($skuArr as $skuId => $quantity) { $skuCopies[] = [ 'code_number' => $skuInfo[$skuId], 'quantity' => $quantity, ]; } $siteInfo = $this->siteModel->find($orderInfo->site_id); $userInfo = $this->userModel->find($orderInfo->user_id); $driverInfo = $this->driverSequenceModel->find($siteInfo->delivered_id); $this->printService = $this->printOrderFactory->handle($this->request->input('type')); // 打印或者喷码 match ($this->request->input('type')) { CateringCode::OPTION_PRINT_YLY => $this->printOrderByYly(), CateringCode::OPTION_PRINT_CODING => $this->printOrderByCoding(), }; $this->printService->data = [ 'pickup_code' => $pickupCodeInfo->pickup_code, 'driver_num' => $driverInfo->driver_num, 'site_order' => $siteInfo->sequence, 'site_text' => $siteInfo->name, 'order_sno' => $orderInfo->order_sno, 'username' => $userInfo->nickname, 'date' => date('Y-m-d'), 'mobile' => $userInfo->mobile, 'heapsort' => $pickupCodeInfo->heapsort, 'sku' => $skuCopies ]; $res = $this->printService->printSingleOrder(); return $this->return->success('success', ['data' => $res]); } /** * @return void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ private function printOrderByYly(): void { $this->printService->printId = (int)$this->request->input('print_id'); $this->printService->handle(); } /** * @return void */ private function printOrderByCoding() {} }