|
|
@@ -2,14 +2,16 @@
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
+use App\Logistic;
|
|
|
use App\OracleDocOrderDeliveryInfo;
|
|
|
use App\OracleDOCOrderHeader;
|
|
|
-use App\PrintPartImage;
|
|
|
+use App\Owner;
|
|
|
+use App\OwnerLogisticPrintTemplate;
|
|
|
use App\Services\Interfaces\DeliveryInterface;
|
|
|
use App\Traits\DrawImage;
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\File;
|
|
|
-use Illuminate\Support\Str;
|
|
|
-use Intervention\Image\Facades\Image;
|
|
|
|
|
|
class PDDDeliveryService implements DeliveryInterface
|
|
|
{
|
|
|
@@ -54,15 +56,30 @@ class PDDDeliveryService implements DeliveryInterface
|
|
|
|
|
|
function processing(&$params)
|
|
|
{
|
|
|
- $data = $params['data'];
|
|
|
- $image = Image::make($data);
|
|
|
- $orderDeliveryInfo = OracleDocOrderDeliveryInfo::query()->where('')->with('docOrderHead')->where('trackingNo', $params['trackingNo'])->first();
|
|
|
- $info = [
|
|
|
- 'ORDERNO' => $orderDeliveryInfo->orderno,
|
|
|
- 'TRACKINGNO' => $orderDeliveryInfo->trackingNo,
|
|
|
- ];
|
|
|
- $printPartTemp = PrintPartImage::query()->first();
|
|
|
- $image = $this->draw($info, $printPartTemp, $image);
|
|
|
- $params['base64'] = $this->getBase64($image,$params);
|
|
|
+ // TODO 获取模板
|
|
|
+ $owner_query = Owner::query()->selectRaw('id')->where('code', $params['owner_code']);
|
|
|
+ $logistic_query = Logistic::query()->selectRaw('id')->where('code', $params['logistic_code']);
|
|
|
+ $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', $owner_query)->where('logistic_id', $logistic_query)->first();
|
|
|
+ $item = $item->printTemplate;
|
|
|
+ $item->printTemplate;
|
|
|
+ $path = '';
|
|
|
+ $img = $this->getImage($params['base64'],$path);
|
|
|
+ $img = $this->draw(null,$item,$img);
|
|
|
+ $img->save($path);
|
|
|
+
|
|
|
+ $arr = Cache::get('print-template-file-list') ?? [];
|
|
|
+
|
|
|
+ $arr[] = ['time' => Carbon::now(),'path' => $path];
|
|
|
+
|
|
|
+ Cache::put('print-template-file-list',$arr);
|
|
|
+
|
|
|
+ // TODO 将文件进行base64编码
|
|
|
+ if ($fp = fopen($path,"rp",0)){
|
|
|
+ $gambar = fread($fp,filesize($path));
|
|
|
+ fclose($fp);
|
|
|
+ $params['base64'] = chunk_split(base64_encode($gambar));
|
|
|
+ }
|
|
|
+ $params['is_process'] = true;
|
|
|
+ return $params;
|
|
|
}
|
|
|
}
|