ajun 4 lat temu
rodzic
commit
30aedf8194
2 zmienionych plików z 30 dodań i 37 usunięć
  1. 30 9
      app/Services/DeliveryService.php
  2. 0 28
      app/Services/PrintService.php

+ 30 - 9
app/Services/DeliveryService.php

@@ -4,6 +4,8 @@ namespace App\Services;
 
 use App\OracleDocOrderDeliveryInfo;
 use App\OracleDOCOrderHeader;
+use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\Cache;
 
 class DeliveryService
 {
@@ -19,10 +21,9 @@ class DeliveryService
             $deliveryInfo = OracleDocOrderDeliveryInfo::query()->selectRaw('trackingNo')->whereIn('orderno',$orderCodes)->get()->toArray();
             $logisticNumbers = array_unique(array_merge($logisticNumbers,array_column($deliveryInfo,'trackingno')));
         }
-
         $OracleDocOrderDeliveryInfos = OracleDocOrderDeliveryInfo::query()->with('docOrderHeader')->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);
@@ -43,18 +44,38 @@ class DeliveryService
         return [$batchesCodes ?? [], $orderCodes ?? [], $logisticNumbers ?? []];
     }
 
-    public function encodeBase64($params){
-        foreach ($params as $param) {
-
-        }
-    }
 
     /**
      * 快递面单填充自定义区域内容 或 自制面单
-     * @param $params
+     * @param $items
+     * @return array
      */
-    public function customProcessing($params)
+    public function customProcessing(array $items)
     {
+        foreach ($items as $key =>$item) {
+            if ($item['is_process'] == false) continue;
+             $items[$key] = app(TBDeliveryService::class)->processing($item);
+        }
+        return $items;
+    }
 
+    /**
+     * 根据缓存删除十分钟前的文件
+     */
+    public function destroyFile(){
+        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);
+        }
     }
 }

+ 0 - 28
app/Services/PrintService.php

@@ -41,32 +41,4 @@ class PrintService
 
     }
 
-    /**
-     * 数据转图片
-     * @param $image
-     * @param $printTemplate
-     * @param null $order_package
-     * @return mixed
-     */
-    public function convertPrintImage($image,$printTemplate,$order_package = null)
-    {
-        $items = $printTemplate->value;
-        $bg = array_filter($items,function ($item){
-            return $item['type'] == 'bg';
-        });
-        $items = array_filter($items,function($item){
-            return $item['type'] !== 'bg';
-        });
-        usort($items,function ($a, $b) {
-            return $a['z_index'] > $b['z_index'] ? 1 : 0;
-        });
-
-        foreach ($items as $item) {
-
-        }
-
-        return $image;
-    }
-
-
 }