| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?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 TBDeliveryService implements DeliveryInterface
- {
- use DeliveryProcess;
- function getDeliveryInfo($OracleDocOrderDeliveryInfos): array
- {
- $items = $OracleDocOrderDeliveryInfos->filter(function ($item) {
- return in_array($item->docOrderHeader->consigneeid, ['TB', 'TMMK', 'TM']) || $item->docOrderheader['h_edi_01'] == '幼岚天猫超市';
- });
- return $items->map(function ($item) {
- return [
- // TODO 需要动态获取面单获取的组件 TYPE
- 'type' => 'CAINIAO', // PDD 或 CAINIAO 动态
- 'task_id' => Str::uuid(),
- 'is_process' => false,
- 'data' => $item['userdefine1'],
- 'component_type' => 'TB',
- 'owner_code' => $item->docOrderHeader->customerid ?? '',
- 'logistic_code' => $item->docOrderHeader->userdefine1 ?? '',
- 'logistic_number' => $item['trackingno'],
- 'delivery' => $this->getDelivery($item),
- 'base64' => null,
- 'printerName' => '',
- ];
- })->toArray();
- }
- public function getBase64($item)
- {
- }
- function getDelivery($item): array
- {
- return $this->getDocOrderDeliveryInfo($item);
- }
- function processing(array &$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);
- app(DeliveryService::class)->pushClearCache($path);
- $image = $this->draw($item['delivery'], $PrintTemplate->printTemplate, $img);
- $this->saveImage($image, $path);
- $item['base64'] = $this->readImageBase64($path);
- app(DeliveryService::class)->pushClearCache($path);
- return $item;
- }
- }
|