| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace app\event;
- use app\model\saas\SaasOrderDetail;
- use yzh52521\EasyHttp\Http;
- class MergePdf
- {
- public function imgMergePdf(array $data = [])
- {
- if (empty($data['shop'])) return true;
- $detail = (new SaasOrderDetail)->where(["shop_id" => $data['shop'],"openid" => $data['openid'],"order_sn" => $data['order'],'status' => 0])->select();
- if ($detail->isEmpty()) return true;
- foreach ($detail as $key=>$val) {
- if ($val['extension'] !== 'pdf') {
- $pathUri = [];
- for ($i = 1; $i <= $val['total_page']; $i ++) {
- $pathUri[$i] = "https://".sConf("storage.cos_http_domain")."/".$val['path']."?ci-process=doc-preview&dstType=jpg&imageDpi=300&page={$i}";
- }
- $resp = Http::asJson()->withHeaders(['x-api-key' => "your-api-key-here"])->post("http://127.0.0.1:3000/api/images-to-pdf",[
- "imageUrls" => array_values($pathUri),
- "pdfName" => $data['order']."_".$val['id'],
- "options" => [
- "compression" => false,
- "quality" => 100
- ]
- ])->array();
- if ($resp['success']) {
- (new SaasOrderDetail)->where("id",$val['id'])->update(['path' => $resp['data']['pdfUrl'],'old_path' => $val['path'], 'status' => 1]);
- }
- }
- }
- }
- }
|