PDDDeliveryService.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Services;
  3. use App\Services\Interfaces\DeliveryInterface;
  4. use App\Traits\DeliveryProcess;
  5. use Illuminate\Support\Facades\File;
  6. class PDDDeliveryService implements DeliveryInterface
  7. {
  8. use DeliveryProcess;
  9. function getDeliveryInfo($OracleDocOrderDeliveryInfos): ?array
  10. {
  11. $items = $OracleDocOrderDeliveryInfos->filter(function($item){
  12. return $item->docOrderHeader->consigneeid == 'PDD' || $item->docOrderHeader['h_edi_01'] == 'PDD';
  13. });
  14. return $items->map(function($item) {
  15. return [
  16. // TODO 需要动态获取面单获取的组件 TYPE
  17. 'type' => 'PDD',
  18. 'task_id' => $item['trackingno'],
  19. 'is_process' => false,
  20. 'data' => $item['userdefine1'],
  21. 'component_type' => 'PDD',
  22. 'owner_code' => $item->docOrderHeader->customerid ?? '',
  23. 'logistic_code' => $item->docOrderHeader->userdefine1 ?? '',
  24. 'logistic_number' => $item['trackingno'],
  25. 'delivery' => $this->getDocOrderDeliveryInfo($item),
  26. 'base64' => null,
  27. ];
  28. })->toArray();
  29. }
  30. public function getDelivery($item)
  31. {
  32. return null;
  33. }
  34. public function getBase64($img = null, $item = null): ?string
  35. {
  36. if (!$img) return null;
  37. $imgName = 'PDD-' . $item['logistic_code'] . 'png';
  38. $path = storage_path(['app/public/files/' . $imgName]);
  39. $img->save($path);
  40. return File::get($path);
  41. }
  42. }