conversionPrintData($printStr); if ($batchCodes) { $orderHeaders = OracleDOCOrderHeader::query()->selectRaw('orderno')->whereIn('WaveNo', $batchCodes)->get()->toArray(); $orderCodes = array_unique(array_merge($orderCodes, array_column($orderHeaders, 'orderno'))); } if ($orderCodes) { $deliveryInfo = OracleDocOrderDeliveryInfo::query()->selectRaw('trackingNo')->whereIn('orderno', $orderCodes)->get()->toArray(); $deliveryNos = OracleDOCOrderHeader::query()->selectRaw('deliveryno')->whereIn('orderno', $orderCodes)->get()->toArray(); $logisticNumbers = array_unique(array_merge($logisticNumbers, array_column($deliveryInfo, 'trackingno'), array_column($deliveryNos, 'deliveryno'))); } $OracleDocOrderDeliveryInfos = OracleDocOrderDeliveryInfo::query()->with('docOrderHeader.docOrderDeliveryInfo')->whereIn('trackingNo', $logisticNumbers)->get(); $tbParams = app(TBDeliveryService::class)->getDeliveryInfo($OracleDocOrderDeliveryInfos); $pddParams = app(PDDDeliveryService::class)->getDeliveryInfo($OracleDocOrderDeliveryInfos); $sfParams = app(SFDeliveryService::class)->getDeliveryInfo($OracleDocOrderDeliveryInfos); $jdParams = app(JDDeliveryService::class)->getDeliveryInfo($logisticNumbers); $sfQhdParams = app(SFQHDDeliveryService::class)->getDeliveryInfo($logisticNumbers); return array_merge($tbParams, $pddParams, $sfParams, $jdParams, $sfQhdParams); } public function conversionPrintData($printStr): array { preg_match_all('/[\w]+/', $printStr, $nos); foreach ($nos[0] as $no) { if (strstr($no, 'SO') || strstr($no, 'so')) $orderCodes[] = $no; elseif (strstr($no, 'W') || strstr($no, 'w')) $batchesCodes[] = $no; else $logisticNumbers[] = $no; } return [$batchesCodes ?? [], $orderCodes ?? [], $logisticNumbers ?? []]; } /** * 快递面单填充自定义区域内容 或 自制面单 * @param array $items * @return array */ public function customProcessing(array $items): array { foreach ($items as $key => &$item) { if ($item['is_process'] == true) continue; switch ($item['component_type']) { case 'TB': $items[$key] = app(TBDeliveryService::class)->processing($item); break; case 'PDD': $items[$key] = app(PDDDeliveryService::class)->processing($item); break; default: break; } } return $items; } /** * 根据缓存删除十分钟前的文件 */ public function destroyFileOfCache() { if (Cache::has('print-template-file-list')) { $arr = Cache::get('print-template-file-list'); $now = Carbon::now(); foreach ($arr as $key => $item) { $time = (new Carbon($item['time']))->addMilliseconds(10); if ($now->lt($time)) { if (file_exists($item['path'])) { unlink($item['path']); } unset($arr[$key]); } } Cache::put('print-template-file-list', $arr); } } public function pushClearCache($path) { if (!Cache::has("print-template-file-list")){ Cache::put('print-template-file-list',[$path]); return; } $arr = Cache::get("print-template-file-list"); $arr[] = $path; Cache::put('print-template-file-list',$arr); } }