| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Services;
- use App\OwnerLogisticPrintTemplate;
- use App\Services\Interfaces\DeliveryInterface;
- use App\Traits\DeliveryProcess;
- use Illuminate\Database\Query\Builder;
- use Illuminate\Support\Str;
- class SFDeliveryService implements DeliveryInterface
- {
- use DeliveryProcess;
- function getDeliveryInfo($OracleDocOrderDeliveryInfos): array
- {
- $items = $OracleDocOrderDeliveryInfos->filter(function($item){
- $consigned = $item->docOrderHeader['carrierid'];
- if ((strpos($consigned,'SF') != false ) && (!in_array($consigned,['SFSYQHD','SFTHQHD']))){
- return true;
- }
- return false;
- });
- return $items->map(function($item) {
- $delivery = $this->getDocOrderDeliveryInfo($item);
- $item['delivery'] = $delivery;
- return [
- // TODO 需要动态获取面单获取的组件 TYPE
- 'type' => 'SF',
- 'task_id' => Str::uuid(),
- 'is_process' => true,
- 'data' => $item->docOrderHeader['user'],
- 'component_type' => 'SF',
- 'owner_code' => $item->docOrderHeader->customerid ?? '',
- 'logistic_code' => $item->docOrderHeader->userdefine1 ?? '',
- 'logistic_number' => $item['trackingno'],
- 'delivery' => $this->getDelivery($item),
- 'base64' => $this->getBase64($item),
- 'printerName' => '',
- ];
- })->toArray();
- }
- public function getBase64($item): string
- {
- $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function(Builder $query)use($item){
- $query->from('owners')->selectRaw('id')->where("code",$item['customerid']);
- })->where('logistic_id', function(Builder $query)use($item){
- $query->from('logistics')->selectRaw('id')->where("code",$item['userdefine1']);
- })->first();
- if (!$item) return '';
- $image = $this->draw($item['delivery'],$item,null);
- $path = '';
- $this->saveImage($image,$path);
- app(DeliveryService::class)->pushClearCache($path);
- return $this->readImageBase64($path);
- }
- function getDelivery($item): array
- {
- return $this->getDocOrderDeliveryInfo($item);
- }
- }
|