Explorar el Código

修改 JD PDD SF TB DeliveryService

ajun hace 4 años
padre
commit
333a26552a

+ 6 - 3
app/Services/JDDeliveryService.php

@@ -11,18 +11,21 @@ class JDDeliveryService implements DeliveryInterface
 {
     function getDeliveryInfo($logistic_number)
     {
-        return OracleDOCOrderHeader::query()->whereIn('deliveryno',$logistic_number)->where('consigneeId',"JD")->where('sostatus', '<>','90')->get()->map(function($item){
+        return OracleDOCOrderHeader::query()->whereIn('deliveryno',$logistic_number)
+            ->where('consigneeId',"JD")
+//            ->where('sostatus', '<>',90)
+            ->get()->map(function($item){
             return [
                 // TODO 需要动态获取面单获取的组件 TYPE
-
                 'type' => 'JD',
+                'is_process' => false,
                 'task_id' => Str::uuid(),
                 'data' => '',
                 'component_type' => 'JD',
                 'owner_code' => $item->customerid ?? '',
                 'logistic_code' => $item->userdefine1 ?? '',
                 'logistic_number' => $item['deliveryno'],
-                'delivery' => $this->getDelivery($item),
+                'delivery' => null,
                 'base64' => null,
             ];
         })->toArray();

+ 1 - 0
app/Services/PDDDeliveryService.php

@@ -26,6 +26,7 @@ class PDDDeliveryService implements DeliveryInterface
                 // TODO 需要动态获取面单获取的组件 TYPE
                 'type' => 'CAINIAO',
                 'task_id' => Str::uuid(),
+                'is_process' => false,
                 'data' => $item['userdefine1'],
                 'component_type' => 'CAINIAO',
                 'owner_code' => $item->docOrderHeader->customerid ?? '',

+ 1 - 0
app/Services/SFDeliveryService.php

@@ -20,6 +20,7 @@ class SFDeliveryService implements DeliveryInterface
                 // TODO 需要动态获取面单获取的组件 TYPE
                 'type' => 'SF',
                 'task_id' => Str::uuid(),
+                'is_process' => false,
                 'data' => $item->docOrderHeader['user'],
                 'component_type' => 'SF',
                 'owner_code' => $item->docOrderHeader->customerid ?? '',

+ 33 - 3
app/Services/TBDeliveryService.php

@@ -8,11 +8,17 @@ use App\OracleDocOrderDeliveryInfo;
 use App\OracleDOCOrderHeader;
 use App\Owner;
 use App\OwnerLogisticPrintTemplate;
+use App\PrintTemplate;
 use App\Services\Interfaces\DeliveryInterface;
+use App\Traits\DrawImage;
+use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Str;
 
 class TBDeliveryService implements DeliveryInterface
 {
+    use DrawImage;
+
     function getDeliveryInfo($OracleDocOrderDeliveryInfos): array
     {
         $items = $OracleDocOrderDeliveryInfos->filter(function($item){
@@ -24,6 +30,7 @@ class TBDeliveryService implements DeliveryInterface
                 // TODO 需要动态获取面单获取的组件 TYPE
                 'type' => 'CAINIAO',     // PDD 或 CAINIAO  动态
                 'task_id' => Str::uuid(),
+                'is_process' => false,
                 'data' => $item['userdefine1'],
                 'component_type' => 'TB',
                 'owner_code' => $item->docOrderHeader->customerid ?? '',
@@ -48,9 +55,32 @@ class TBDeliveryService implements DeliveryInterface
 
     function processing(&$params)
     {
-        $owner_query = Owner::query()->selectRaw('id')->where('code', $params['owner_code']);
-        $logistic_query = Logistic::query()->selectRaw('id')->where('code', $params['owner_code']);
-        $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', $owner_query)->where('logistic_id', $logistic_query)->first();
+        // TODO 获取模板
+//        $owner_query = Owner::query()->selectRaw('id')->where('code', $params['owner_code']);
+//        $logistic_query = Logistic::query()->selectRaw('id')->where('code', $params['owner_code']);
+//        $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', $owner_query)->where('logistic_id', $logistic_query)->first();
+        $item = PrintTemplate::query()->first();
         $item->printTemplate;
+        $path = '';
+        $img = $this->getImage($params['base64'],$path);
+        $img = $this->draw(null,$item,$img);
+        $img->save($path);
+
+        $arr = [];
+        if (Cache::has('print-template-file-list')){
+            $arr = Cache::get('print-template-file-list');
+        }
+        $arr[] = ['time' => Carbon::now(),'path' => $path];
+        Cache::put('print-template-file-list',$arr);
+
+        // TODO 将文件进行base64编码
+        if ($fp = fopen($path,"rp",0)){
+            $gambar = fread($fp,filesize($path));
+            fclose($fp);
+            $params['base64'] = chunk_split(base64_encode($gambar));
+        }
+        $params['is_process'] = true;
+        return $params;
     }
+
 }