ajun 4 лет назад
Родитель
Сommit
1c04b472f5
1 измененных файлов с 55 добавлено и 0 удалено
  1. 55 0
      app/Services/DeliveryService.php

+ 55 - 0
app/Services/DeliveryService.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace App\Services;
+
+use App\OracleDOCOrderHeader;
+
+class DeliveryService
+{
+
+    public function getDelivery($printStr): array
+    {
+        list($batchCodes, $orderCodes, $logisticNumbers) = $this->conversionPrintData($printStr);
+        if ($batchCodes){
+            $orderHeaders = OracleDOCOrderHeader::query()->selectRaw('orderno')->whereIn('WaveNo',$batchCodes)->get()->toArray();
+            $orderCodes = array_unique(array_merge($orderCodes,array_column($orderHeaders,'orderno')));
+        }
+
+        $tbParams = app(TBDeliveryService::class)->getDeliveryInfo($orderCodes,$logisticNumbers);
+        $pddParams = app(PDDDeliveryService::class)->getDeliveryInfo($orderCodes,$logisticNumbers);
+        $sfParams = app(SFDeliveryService::class)->getDeliveryInfo($orderCodes,$logisticNumbers);
+        $jdParams = app(JDDeliveryService::class)->getDeliveryInfo($orderCodes,$logisticNumbers);
+        $sfQhdParams = app(SFQHDDeliveryService::class)->getDeliveryInfo($orderCodes,$logisticNumbers);
+
+        $params = array_merge($tbParams,$pddParams,$sfParams,$jdParams,$sfQhdParams);
+        return $params;
+    }
+
+    public function conversionPrintData($printStr): array
+    {
+        preg_match_all('/[\w]+/', $printStr, $nos);
+
+        foreach ($nos[0] as $no) {
+            if (strstr($no, 'SO')) $orderCodes[] = $no;
+            elseif (strstr($no, 'W')) $batchesCodes[] = $no;
+            else $logisticNumbers[] = $no;
+        }
+
+        return [$batchesCodes ?? [], $orderCodes ?? [], $logisticNumbers ?? []];
+    }
+
+    public function encodeBase64($params){
+        foreach ($params as $param) {
+
+        }
+    }
+
+    /**
+     * 快递面单填充自定义区域内容 或 自制面单
+     * @param $params
+     */
+    public function customProcessing($params)
+    {
+
+    }
+}