|
|
@@ -8,11 +8,17 @@ use App\OracleDocOrderDeliveryInfo;
|
|
|
use App\OracleDOCOrderHeader;
|
|
|
use App\Owner;
|
|
|
use App\OwnerLogisticPrintTemplate;
|
|
|
+use App\PrintTemplate;
|
|
|
use App\Services\Interfaces\DeliveryInterface;
|
|
|
+use App\Traits\DrawImage;
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
class TBDeliveryService implements DeliveryInterface
|
|
|
{
|
|
|
+ use DrawImage;
|
|
|
+
|
|
|
function getDeliveryInfo($OracleDocOrderDeliveryInfos): array
|
|
|
{
|
|
|
$items = $OracleDocOrderDeliveryInfos->filter(function($item){
|
|
|
@@ -24,6 +30,7 @@ class TBDeliveryService implements DeliveryInterface
|
|
|
// TODO 需要动态获取面单获取的组件 TYPE
|
|
|
'type' => 'CAINIAO', // PDD 或 CAINIAO 动态
|
|
|
'task_id' => Str::uuid(),
|
|
|
+ 'is_process' => false,
|
|
|
'data' => $item['userdefine1'],
|
|
|
'component_type' => 'TB',
|
|
|
'owner_code' => $item->docOrderHeader->customerid ?? '',
|
|
|
@@ -48,9 +55,32 @@ class TBDeliveryService implements DeliveryInterface
|
|
|
|
|
|
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();
|
|
|
+ // TODO 获取模板
|
|
|
+// $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::query()->first();
|
|
|
$item->printTemplate;
|
|
|
+ $path = '';
|
|
|
+ $img = $this->getImage($params['base64'],$path);
|
|
|
+ $img = $this->draw(null,$item,$img);
|
|
|
+ $img->save($path);
|
|
|
+
|
|
|
+ $arr = [];
|
|
|
+ if (Cache::has('print-template-file-list')){
|
|
|
+ $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;
|
|
|
}
|
|
|
+
|
|
|
}
|