ajun 4 лет назад
Родитель
Сommit
fd4b06866c

+ 27 - 30
app/Services/JDDeliveryService.php

@@ -6,23 +6,26 @@ use App\OracleDocOrderDeliveryInfo;
 use App\OracleDOCOrderHeader;
 use App\OwnerLogisticPrintTemplate;
 use App\Services\Interfaces\DeliveryInterface;
+use App\Traits\DeliveryProcess;
 use App\Traits\DrawImage;
 use Illuminate\Database\Query\Builder;
 use Illuminate\Support\Str;
 
 class JDDeliveryService implements DeliveryInterface
 {
-    use DrawImage;
+    use DeliveryProcess;
 
-    function getDeliveryInfo($logistic_number)
+    function getDeliveryInfo($logistic_number): array
     {
-        return OracleDOCOrderHeader::query()->whereIn('deliveryno',$logistic_number)
+        $oracleDocOrderHeaders = OracleDOCOrderHeader::query()
+            ->with('oracleBASCustomer','oracleDOCWaveDetail')
+            ->whereIn('deliveryno',$logistic_number)
             ->whereIn('consigneeId',['JD','BSZX','BSZFC','BSZXDF','BSZFCDF'])
-            ->get()->map(function($item){
+            ->get();
+        return $oracleDocOrderHeaders->map(function ($item){
             return [
-                // TODO 需要动态获取面单获取的组件 TYPE
                 'type' => 'JD',
-                'is_process' => false,
+                'is_process' => true,
                 'task_id' => Str::uuid(),
                 'data' => '',
                 'component_type' => 'JD',
@@ -37,14 +40,22 @@ class JDDeliveryService implements DeliveryInterface
 
     public function getBase64($item): string
     {
-        $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function(Builder $query)use($item){
-            $query->from("owners")->where("code",$item['owner_code']);
+        $printTemplate = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function(Builder $query)use($item){
+            $query->from("owners")->selectRaw('id')->where("code",$item['customerid']);
         })->where('logistic_id', function(Builder $query)use($item){
-            $query->from("logistic")->where("code",$item['logistic_code']);
+            $query->from("logistics")->selectRaw('id')->where("code",$item['userdefine1']);
         })->first();
-        $image = $this->draw($item['delivery'],$item,null);
+
+        $delivery = $this->getDelivery($item);
+
+        $image = $this->draw($delivery,$printTemplate->printTemplate ?? null,null);
+
+        if (!$image) return '';
+
         $path = '';
+
         $this->saveImage($image,$path);
+
         return $this->readImageBase64($path);
     }
 
@@ -68,30 +79,16 @@ class JDDeliveryService implements DeliveryInterface
      *
      */
 
-    function getDelivery($item)
+    function getDelivery($item): array
     {
-
-        $delivery =  [
-            'oerderno' => $item['orderno'],
-            'waveno' => $item['waveno'],
-            'logistic_number' => $item['deliveryno'],
-            'shop' => $item[''],
-            'c_address1' => $item['c_address1'],
-            'c_city' => $item['c_city'],
-            'c_province' => $item['c_province'],
-            'c_district' => $item['c_district'],
-            'c_tel' => $item['c_tel1'] ?? $item['c_tel2'],
-            'i_contact' => $item['i_contact'],
-            'i_tel1' => $item['i_tel1'],
-            'i_tel2' => $item['i_tel2'],
-            'soreference1' => $item['soreference1'],
-            'b_addresss1' => $item['MJ-ZP'],    // 目的地分拣中心
-            'd_addresss1' => 'BB-Y3-21',
-        ];
+        $delivery = $this->getDocOrderInfo($item);
+        $delivery['b_addresss1'] = $item['MJ-ZP'];
+        $delivery['d_addresss1'] = $item['BB-Y3-21'];
+        return $delivery;
     }
 
     function processing(&$params)
     {
-
+        return null;
     }
 }

+ 1 - 1
app/Services/PDDDeliveryService.php

@@ -27,7 +27,7 @@ class PDDDeliveryService implements DeliveryInterface
                 'owner_code' => $item->docOrderHeader->customerid ?? '',
                 'logistic_code' => $item->docOrderHeader->userdefine1 ?? '',
                 'logistic_number' => $item['trackingno'],
-                'delivery' => $this->getDelivery($item),
+                'delivery' => $this->getDocOrderDeliveryInfo($item),
                 'base64' => null,
             ];
         })->toArray();

+ 5 - 4
app/Services/SFDeliveryService.php

@@ -6,13 +6,14 @@ use App\OracleDocOrderDeliveryInfo;
 use App\OracleDOCOrderHeader;
 use App\OwnerLogisticPrintTemplate;
 use App\Services\Interfaces\DeliveryInterface;
+use App\Traits\DeliveryProcess;
 use App\Traits\DrawImage;
 use Illuminate\Database\Query\Builder;
 use Illuminate\Support\Str;
 
 class SFDeliveryService implements DeliveryInterface
 {
-    use DrawImage;
+    use DeliveryProcess;
 
     function getDeliveryInfo($OracleDocOrderDeliveryInfos): array
     {
@@ -34,7 +35,7 @@ class SFDeliveryService implements DeliveryInterface
                 'owner_code' => $item->docOrderHeader->customerid ?? '',
                 'logistic_code' => $item->docOrderHeader->userdefine1 ?? '',
                 'logistic_number' => $item['trackingno'],
-                'delivery' => $this->getDelivery($item),
+                'delivery' => $this->getDocOrderDeliveryInfo($item),
                 'base64' => $this->getBase64($item),
             ];
         })->toArray();
@@ -43,9 +44,9 @@ class SFDeliveryService implements DeliveryInterface
     public function getBase64($item): string
     {
         $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function(Builder $query)use($item){
-            $query->from("owners")->where("code",$item['owner_code']);
+            $query->from('owners')->selectRaw('id')->where("code",$item['customerid']);
         })->where('logistic_id', function(Builder $query)use($item){
-            $query->from("logistic")->where("code",$item['logistic_code']);
+            $query->from('logistics')->selectRaw('id')->where("code",$item['userdefine1']);
         })->first();
         $image = $this->draw($item['delivery'],$item,null);
         $path = '';

+ 11 - 11
app/Services/SFQHDDeliveryService.php

@@ -7,6 +7,7 @@ use App\OracleDocOrderDeliveryInfo;
 use App\OracleDOCOrderHeader;
 use App\OwnerLogisticPrintTemplate;
 use App\Services\Interfaces\DeliveryInterface;
+use App\Traits\DeliveryProcess;
 use App\Traits\DrawImage;
 use Illuminate\Database\Query\Builder;
 use Illuminate\Support\Str;
@@ -14,16 +15,17 @@ use Illuminate\Support\Str;
 class SFQHDDeliveryService implements DeliveryInterface
 {
 
-    use DrawImage;
+    use DeliveryProcess;
 
     function getDeliveryInfo($logistic_number): array
     {
-        return OracleDOCOrderHeader::query()
+        $oracleDocOrderHeaders = OracleDOCOrderHeader::query()
             ->whereIn('deliveryNo', $logistic_number)
             ->whereIn('ConsigneeId', ["SFQHD",'SFSYQHD','SFTHQHD'])
-            ->where('SoStatus', '<>', '90')
-            ->get()
-            ->map(function ($item) {
+//            ->where('SoStatus', '<>', '90')
+            ->get();
+
+        return$oracleDocOrderHeaders->map(function ($item) {
                 return [
                     // TODO 需要动态获取面单获取的组件 TYPE
                     'type' => 'SFQHD',
@@ -39,13 +41,12 @@ class SFQHDDeliveryService implements DeliveryInterface
             })->toArray();
     }
 
-
     public function getBase64($item)
     {
         $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function (Builder $query) use ($item) {
-            $query->from("owners")->where("code", $item['owner_code']);
+            $query->from("owners")->selectRaw('id')->where("code", $item['customerid']);
         })->where('logistic_id', function (Builder $query) use ($item) {
-            $query->from("logistic")->where("code", $item['logistic_code']);
+            $query->from("logistic")->selectRaw('id')->where("code", $item['userdefine1']);
         })->first();
         $image = $this->draw($item['delivery'], $item, null);
         $path = '';
@@ -53,10 +54,9 @@ class SFQHDDeliveryService implements DeliveryInterface
         return $this->readImageBase64($path);
     }
 
-
-    function getDelivery($item)
+    function getDelivery($item): array
     {
-        return null;
+        return $this->getDocOrderInfo($item);
     }
 
     function processing(&$params)

+ 2 - 9
app/Services/TBDeliveryService.php

@@ -38,15 +38,8 @@ class TBDeliveryService implements DeliveryInterface
     }
 
 
-    function getDelivery($item)
+    function getDelivery($item): array
     {
-//       $WaveDetail = $item->docOrderHeader->oracleDOCWaveDetail;
-        // 订单所在波次总数
-
+        return $this->getDocOrderDeliveryInfo($item);
     }
-
-
-
-
-
 }