SFQHDDeliveryService.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Services;
  3. use App\OracleDOCOrderHeader;
  4. use App\OwnerLogisticPrintTemplate;
  5. use App\Services\Interfaces\DeliveryInterface;
  6. use App\Traits\DeliveryProcess;
  7. use Illuminate\Database\Query\Builder;
  8. use Illuminate\Support\Str;
  9. class SFQHDDeliveryService implements DeliveryInterface
  10. {
  11. use DeliveryProcess;
  12. function getDeliveryInfo($logistic_number): array
  13. {
  14. $oracleDocOrderHeaders = OracleDOCOrderHeader::query()
  15. ->whereIn('deliveryNo', $logistic_number)
  16. ->whereIn('ConsigneeId', ["SFQHD",'SFSYQHD','SFTHQHD'])
  17. ->get();
  18. return$oracleDocOrderHeaders->map(function ($item) {
  19. return [
  20. // TODO 需要动态获取面单获取的组件 TYPE
  21. 'type' => 'SFQHD',
  22. 'task_id' => Str::uuid(),
  23. 'data' => '',
  24. 'component_type' => 'SFQHD',
  25. 'owner_code' => $item->customerid ?? '',
  26. 'logistic_code' => $item->userdefine1 ?? '',
  27. 'logistic_number' => $item['deliveryno'],
  28. 'delivery' => $this->getDelivery($item),
  29. 'base64' => $this->getBase64($item),
  30. 'printerName' => '',
  31. ];
  32. })->toArray();
  33. }
  34. public function getBase64($item)
  35. {
  36. $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function (Builder $query) use ($item) {
  37. $query->from("owners")->selectRaw('id')->where("code", $item['customerid']);
  38. })->where('logistic_id', function (Builder $query) use ($item) {
  39. $query->from("logistic")->selectRaw('id')->where("code", $item['userdefine1']);
  40. })->first();
  41. $image = $this->draw($item['delivery'], $item, null);
  42. $path = '';
  43. $this->saveImage($image, $path);
  44. app(DeliveryService::class)->pushClearCache($path);
  45. return $this->readImageBase64($path);
  46. }
  47. function getDelivery($item): array
  48. {
  49. return $this->getDocOrderInfo($item);
  50. }
  51. function processing(&$params)
  52. {
  53. }
  54. function construct($param)
  55. {
  56. }
  57. }