|
|
@@ -2,20 +2,23 @@
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
-use App\Batch;
|
|
|
use App\OracleDocOrderDeliveryInfo;
|
|
|
use App\OracleDOCOrderHeader;
|
|
|
-use App\Order;
|
|
|
-use App\OrderPackage;
|
|
|
-use App\Owner;
|
|
|
use App\Traits\ModelSearchWay;
|
|
|
use App\Traits\ServiceAppAop;
|
|
|
+use Illuminate\Database\Eloquent\Builder;
|
|
|
+use Illuminate\Database\Eloquent\Collection;
|
|
|
|
|
|
class PrintService
|
|
|
{
|
|
|
use ModelSearchWay;
|
|
|
use ServiceAppAop;
|
|
|
|
|
|
+ /**
|
|
|
+ * 分列 订单号,快递单号,波次号
|
|
|
+ * @param string $print
|
|
|
+ * @return array[]
|
|
|
+ */
|
|
|
public function conversionPrintData(string $print): array
|
|
|
{
|
|
|
preg_match_all('/[\w]+/',$print,$nos);
|
|
|
@@ -25,6 +28,7 @@ class PrintService
|
|
|
elseif(strstr($no,'W')) $batchesCodes[] = $no;
|
|
|
else $logistic_numbers[] = $no;
|
|
|
}
|
|
|
+
|
|
|
return [$batchesCodes ?? [],$orderCodes ?? [],$logistic_numbers ?? []];
|
|
|
}
|
|
|
|
|
|
@@ -35,7 +39,7 @@ class PrintService
|
|
|
* @param array $logistic_numbers
|
|
|
* @return array|mixed
|
|
|
*/
|
|
|
- public function getLogisticNumber($batchCodes=[],$orderCodes = [],$logistic_numbers = [])
|
|
|
+ public function getLogisticNumber($batchCodes=[],$orderCodes = [],$logistic_numbers = []): array
|
|
|
{
|
|
|
if($batchCodes){
|
|
|
$orderHeaders = OracleDOCOrderHeader::query()->selectRaw('OrderNo')->whereIn('WaveNo',$batchCodes)->get()->map(function($item) {
|
|
|
@@ -52,15 +56,35 @@ class PrintService
|
|
|
return $logistic_numbers ?? [];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取打印信息
|
|
|
+ * @param string $print
|
|
|
+ * @return Builder[]|Collection
|
|
|
+ */
|
|
|
public function getPrintData(string $print)
|
|
|
{
|
|
|
- list($batchesCodes,$orderCodes,$logistic_numbers) = $this->conversionPrintData($print);
|
|
|
+ list($batchesCodes,$orderCodes,$logistic_numbers) = $this->conversionPrintData($print);
|
|
|
$logistic_numbers = $this->getLogisticNumber($batchesCodes, $orderCodes, $logistic_numbers);
|
|
|
- $info = OracleDocOrderDeliveryInfo::query()->select(['TackingNo','OrderNO','UserDefine1'])->whereIn('tackingNo',$logistic_numbers)->get();
|
|
|
- return $info;
|
|
|
+ $items = OracleDocOrderDeliveryInfo::query()->select(['TackingNo','OrderNO','UserDefine1'])->whereIn('tackingNo',$logistic_numbers)->get();
|
|
|
+ return $this->disposesPrintInfo($items);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 处理打印请求参数
|
|
|
+ * @param $oracleDocOrderDeliveryInfos
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function disposesPrintInfo($oracleDocOrderDeliveryInfos): array
|
|
|
+ {
|
|
|
+ foreach ($oracleDocOrderDeliveryInfos as $key => $info){
|
|
|
+ $data[] = [
|
|
|
+ 'documentID' => $info->orderno ?? '',
|
|
|
+ 'encryptedData' => $info->userDefine4->encryptedData ?? '',
|
|
|
+ 'signature' => $info->userDefine4->signature ?? '',
|
|
|
+ 'templateURL' => $info->userDefine4->templateURL ?? '',
|
|
|
+ 'ver' => $info->userDefine4->ver ?? '',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return $data ?? [];
|
|
|
+ }
|
|
|
}
|