pickupCodeModel->find($this->request->input('id')); if (empty($pickupCodeInfo)) throw new ErrException('取餐数据不存在'); $orderInfo = $this->orderModel->find($pickupCodeInfo->order_id); if (empty($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); if ($siteInfo->sequence <= 0) throw new ErrException('请先配置点位顺序'); $userInfo = $this->userModel->find($orderInfo->user_id); $driverInfo = $this->driverSequenceModel->where('driver_id',$siteInfo->delivered_id)->first(); if (empty($driverInfo)) throw new ErrException('配送员信息丢失,请联系管理员'); if ($driverInfo->driver_num <= 0) throw new ErrException('配送员编号丢失,请联系管理员'); if (empty($driverInfo->driver_name)) throw new ErrException('配送员姓名丢失,请联系管理员'); $this->printService = $this->printOrderFactory->handle((int)$this->request->input('type')); // 打印或者喷码 match ((int)$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() {} }