|
|
@@ -3,34 +3,57 @@
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
|
+use App\Logistic;
|
|
|
+use App\OracleDocOrderDeliveryInfo;
|
|
|
+use App\OracleDOCOrderHeader;
|
|
|
+use App\Owner;
|
|
|
+use App\OwnerLogisticPrintTemplate;
|
|
|
use App\Services\Interfaces\DeliveryInterface;
|
|
|
+use function GuzzleHttp\Promise\queue;
|
|
|
|
|
|
-class TBDeliveryService implements DeliveryInterface
|
|
|
+class TBDeliveryService implements DeliveryInterface
|
|
|
{
|
|
|
-
|
|
|
- function getDelivery($logisticNumber, $params)
|
|
|
+ function getDeliveryInfo($orderCodes, $logisticNumbers): array
|
|
|
{
|
|
|
- return [
|
|
|
- 'encryptedData' => $params['delivery']['userdefine1']['encryptedData'] ?? '',
|
|
|
- 'signature' => $params['delivery']['userdefine1']['signature'] ?? '',
|
|
|
- 'templateURL' => $params['delivery']['userdefine1']['templateURL'] ?? ''
|
|
|
- ];
|
|
|
+ $orderCodes = OracleDOCOrderHeader::query()->whereIn('orderNo', $orderCodes)->where('consigneeId','TB')->get()->map(function($item){
|
|
|
+ return $item->orderno;
|
|
|
+ });
|
|
|
+
|
|
|
+ $trackingNos = OracleDocOrderDeliveryInfo::query()->selectRaw('trackingNo')->whereIn('orderNo', $orderCodes)->get()->map(function ($item) {
|
|
|
+ return $item->trackingno;
|
|
|
+ })->toArray();
|
|
|
+
|
|
|
+ $trackingNos = array_unique(array_merge($logisticNumbers, $trackingNos));
|
|
|
+ return OracleDocOrderDeliveryInfo::query()->with('docOrderHeader')->whereIn('trackingNo', $trackingNos)->get()->map(function ($item) {
|
|
|
+ return [
|
|
|
+ 'type' => 'TB',
|
|
|
+ 'component_type' => 'CAINIAO',
|
|
|
+ 'owner_code' => $item->docOrderHeader->custemid ?? '',
|
|
|
+ 'logistic_code' => $item->docOrderHeader->userdefine1 ?? '',
|
|
|
+ 'data' => $item->userdefine1,
|
|
|
+ 'logistic_number' => $item['trackingno'],
|
|
|
+ 'delivery' => $this->getDelivery($item),
|
|
|
+ 'base64' => '',
|
|
|
+ ];
|
|
|
+ })->toArray();
|
|
|
}
|
|
|
|
|
|
- function getDeliveryInfo($logisticNumber, $params)
|
|
|
+ public function getBase64($item)
|
|
|
{
|
|
|
- return [
|
|
|
- 'type' => 'CAINIAO',
|
|
|
- 'owner_id' => '',
|
|
|
- 'logistic_id' => '',
|
|
|
- 'logistic_number' => '',
|
|
|
- 'data' => $this->getDelivery($logisticNumber,$params),
|
|
|
- 'base64' => null
|
|
|
- ];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- function getImg($logisticNumber, $params)
|
|
|
+
|
|
|
+ function getDelivery($item)
|
|
|
{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
+ function processing($params)
|
|
|
+ {
|
|
|
+ $owner_query = Owner::query()->selectRaw('id')->where('code',$params['owner_code']);
|
|
|
+ $logistic_query = Logistic::query()->selectRaw('id')->where('code',$params['owner_code']);
|
|
|
+ $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id',$owner_query)->where('logistic_id',$logistic_query)->first();
|
|
|
+ $item->printTemplate;
|
|
|
}
|
|
|
}
|