JDDeliveryService.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Services;
  3. use App\OracleDocOrderDeliveryInfo;
  4. use App\OracleDOCOrderHeader;
  5. use App\OwnerLogisticPrintTemplate;
  6. use App\Services\Interfaces\DeliveryInterface;
  7. use App\Traits\DrawImage;
  8. use Illuminate\Database\Query\Builder;
  9. use Illuminate\Support\Str;
  10. class JDDeliveryService implements DeliveryInterface
  11. {
  12. use DrawImage;
  13. function getDeliveryInfo($logistic_number)
  14. {
  15. return OracleDOCOrderHeader::query()->whereIn('deliveryno',$logistic_number)
  16. ->whereIn('consigneeId',['JD','BSZX','BSZFC','BSZXDF','BSZFCDF'])
  17. ->get()->map(function($item){
  18. return [
  19. // TODO 需要动态获取面单获取的组件 TYPE
  20. 'type' => 'JD',
  21. 'is_process' => false,
  22. 'task_id' => Str::uuid(),
  23. 'data' => '',
  24. 'component_type' => 'JD',
  25. 'owner_code' => $item->customerid ?? '',
  26. 'logistic_code' => $item->userdefine1 ?? '',
  27. 'logistic_number' => $item['deliveryno'],
  28. 'delivery' => null,
  29. 'base64' => $this->getBase64($item),
  30. ];
  31. })->toArray();
  32. }
  33. public function getBase64($item): string
  34. {
  35. $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function(Builder $query)use($item){
  36. $query->from("owners")->where("code",$item['owner_code']);
  37. })->where('logistic_id', function(Builder $query)use($item){
  38. $query->from("logistic")->where("code",$item['logistic_code']);
  39. })->first();
  40. $image = $this->draw($item['delivery'],$item,null);
  41. $path = '';
  42. $this->saveImage($image,$path);
  43. return $this->readImageBase64($path);
  44. }
  45. /*
  46. * 订单号
  47. * 波次号
  48. * 运单号
  49. * 店铺
  50. * 商家联系号
  51. * 商家订单号
  52. * 发货地址,省,市区
  53. *
  54. * 发货分拣中心
  55. * 发货人
  56. * 发货人号码
  57. * 收货地址
  58. * 收货分拣中心
  59. * 收件人
  60. * 商品
  61. * 备注
  62. *
  63. */
  64. function getDelivery($item)
  65. {
  66. $delivery = [
  67. 'oerderno' => $item['orderno'],
  68. 'waveno' => $item['waveno'],
  69. 'logistic_number' => $item['deliveryno'],
  70. 'shop' => $item[''],
  71. 'c_address1' => $item['c_address1'],
  72. 'c_city' => $item['c_city'],
  73. 'c_province' => $item['c_province'],
  74. 'c_district' => $item['c_district'],
  75. 'c_tel' => $item['c_tel1'] ?? $item['c_tel2'],
  76. 'i_contact' => $item['i_contact'],
  77. 'i_tel1' => $item['i_tel1'],
  78. 'i_tel2' => $item['i_tel2'],
  79. 'soreference1' => $item['soreference1'],
  80. 'b_addresss1' => $item['MJ-ZP'], // 目的地分拣中心
  81. 'd_addresss1' => 'BB-Y3-21',
  82. ];
  83. }
  84. function processing(&$params)
  85. {
  86. }
  87. }