ajun 4 lat temu
rodzic
commit
3af331f1aa

+ 23 - 5
app/Services/PDDDeliveryService.php

@@ -2,8 +2,10 @@
 
 namespace App\Services;
 
+use App\OwnerLogisticPrintTemplate;
 use App\Services\Interfaces\DeliveryInterface;
 use App\Traits\DeliveryProcess;
+use Illuminate\Database\Query\Builder;
 use Illuminate\Support\Facades\File;
 
 class PDDDeliveryService implements DeliveryInterface
@@ -27,17 +29,15 @@ class PDDDeliveryService implements DeliveryInterface
                 'owner_code' => $item->docOrderHeader->customerid ?? '',
                 'logistic_code' => $item->docOrderHeader->userdefine1 ?? '',
                 'logistic_number' => $item['trackingno'],
-                'delivery' => $this->getDocOrderDeliveryInfo($item),
+                'delivery' => $this->getDelivery($item),
                 'base64' => null,
             ];
         })->toArray();
     }
 
-    public function getDelivery($item)
+    public function getDelivery($item): array
     {
-
-
-        return null;
+        return $this->getDocOrderDeliveryInfo($item);
     }
 
     public function getBase64($img = null, $item = null): ?string
@@ -48,4 +48,22 @@ class PDDDeliveryService implements DeliveryInterface
         $img->save($path);
         return File::get($path);
     }
+
+    function processing(&$item)
+    {
+        $item['is_process'] = true;
+        $PrintTemplate = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function (Builder $query) use ($item) {
+            $query->from('owners')->selectRaw('id')->where("code", $item['owner_code']);
+        })->where('logistic_id', function (Builder $query) use ($item) {
+            $query->from('logistics')->selectRaw('id')->where("code", $item['logistic_code']);
+        })->first();
+
+        if (!$item) return $item;
+        $path = '';
+        $img = $this->getImage($item['base64'], $path);
+        $image = $this->draw($item['delivery'], $PrintTemplate, $img);
+        $this->saveImage($image, $path);
+        $item['base64'] = $this->readImageBase64($path);
+        return $item;
+    }
 }

+ 23 - 1
app/Services/TBDeliveryService.php

@@ -2,17 +2,20 @@
 
 namespace App\Services;
 
+use App\OwnerLogisticPrintTemplate;
 use App\Services\Interfaces\DeliveryInterface;
 use App\Traits\DeliveryProcess;
+use Illuminate\Database\Query\Builder;
 use Illuminate\Support\Str;
 
 class TBDeliveryService implements DeliveryInterface
 {
     use DeliveryProcess;
+
     function getDeliveryInfo($OracleDocOrderDeliveryInfos): array
     {
         $items = $OracleDocOrderDeliveryInfos->filter(function ($item) {
-            return in_array($item->docOrderHeader->consigneeid,['TB','TMMK','TM']) || $item->docOrderheader['h_edi_01'] == '幼岚天猫超市';
+            return in_array($item->docOrderHeader->consigneeid, ['TB', 'TMMK', 'TM']) || $item->docOrderheader['h_edi_01'] == '幼岚天猫超市';
         });
 
         return $items->map(function ($item) {
@@ -43,4 +46,23 @@ class TBDeliveryService implements DeliveryInterface
     {
         return $this->getDocOrderDeliveryInfo($item);
     }
+
+    function processing($item)
+    {
+        $item['is_process'] = true;
+        $PrintTemplate = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function (Builder $query) use ($item) {
+            $query->from('owners')->selectRaw('id')->where("code", $item['owner_code']);
+        })->where('logistic_id', function (Builder $query) use ($item) {
+            $query->from('logistics')->selectRaw('id')->where("code", $item['logistic_code']);
+        })->first();
+
+        if (!$item) return $item;
+        $path = '';
+        $img = $this->getImage($item['base64'], $path);
+        $image = $this->draw($item['delivery'], $PrintTemplate, $img);
+        $this->saveImage($image, $path);
+        $item['base64'] = $this->readImageBase64($path);
+        return $item;
+    }
+
 }