|
|
@@ -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;
|
|
|
+ }
|
|
|
}
|