diff --git a/app/controller/task/InvoiceIssuanceTask.php b/app/controller/task/InvoiceIssuanceTask.php index 367a4df..c3e95fb 100644 --- a/app/controller/task/InvoiceIssuanceTask.php +++ b/app/controller/task/InvoiceIssuanceTask.php @@ -24,7 +24,7 @@ class InvoiceIssuanceTask extends Base public function runIssueAnInvoice(): Response { $where = ['status' => 0, 'delete_time' => 0]; - $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $this->limit)->select(); + $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $this->limit)->select()->toArray(); foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) { $result = (new InvoiceIssuanceService())->tempIssueAnInvoice($InvoiceIssuanceValue); if ($result === true) { @@ -46,7 +46,7 @@ class InvoiceIssuanceTask extends Base public function runCancelInitiateAgain(): Response { $where = ['status' => 1, 'delete_time' => 0]; - $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $this->limit)->select(); + $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $this->limit)->select()->toArray(); foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) { $result = (new InvoiceIssuanceService())->cancelInitiateAgain($InvoiceIssuanceValue); if ($result === true) { diff --git a/app/service/invoice/InvoiceIssuanceService.php b/app/service/invoice/InvoiceIssuanceService.php index 738451d..1744d1e 100644 --- a/app/service/invoice/InvoiceIssuanceService.php +++ b/app/service/invoice/InvoiceIssuanceService.php @@ -182,6 +182,7 @@ class InvoiceIssuanceService */ public function IssueAnInvoice($invoiceIssuance) { + $sbpch = ''; try { // 用户编码 $pucode = $invoiceIssuance['pucode']; @@ -285,6 +286,10 @@ class InvoiceIssuanceService return true; } catch (\Exception $e) { (new InvoiceIssuanceData())->saveField($invoiceIssuance['id'], 'ycms', $e->getMessage()); + // 未获取到批次号报错 + if (empty($sbpch)) { + + } $this->writeLog($e); return $e->getMessage(); } @@ -520,18 +525,22 @@ class InvoiceIssuanceService if (isset($resultData['code']) && $resultData['code'] == 1) { + $r_data = $resultData['data']; + // 存在错误 - if (!empty($resultData['ycms'])) { - (new InvoiceIssuanceData())->saveField($data['id'], 'ycms', $resultData['ycms']); - throw new \Exception($resultData['ycms']); + if (!empty($r_data['ycms'])) { + (new InvoiceIssuanceData())->saveField($data['id'], 'ycms', $r_data['ycms']); + if (empty($r_data['sbpch'])) { + throw new \Exception($r_data['ycms']); + } } - if (!empty($resultData['sbpch'])) { + if (!empty($r_data['sbpch'])) { - (new InvoiceIssuanceData())->saveField($data['id'], 'sbpch', $resultData['sbpch']); + (new InvoiceIssuanceData())->saveField($data['id'], 'sbpch', $r_data['sbpch']); - if (isset($resultData['i_i_d_data'])) { + if (isset($r_data['i_i_d_data'])) { - $d_data = $resultData['i_i_d_data']; + $d_data = $r_data['i_i_d_data']; // 拼接pdf 盖章 $requestData = ['data' => $d_data['pdf_data'], 'meta' => $d_data['pdf_meta']]; @@ -548,8 +557,8 @@ class InvoiceIssuanceService (new InvoiceIssuanceData())->saveData($d_data['i_i_id'], $d_data['bdznsrsbh'], $d_data['jsyj'], $d_data['assetID'], $pdfFilepath); } - if (isset($resultData['i_i_data'])) { - $i_i_data = $resultData['i_i_data']; + if (isset($r_data['i_i_data'])) { + $i_i_data = $r_data['i_i_data']; if ($i_i_data['status'] == 3) { (new InvoiceIssuance())->where('id', $data['id'])->save(['status' => 3, 'issuance_time' => $i_i_data['issuance_time']]); @@ -600,6 +609,12 @@ class InvoiceIssuanceService ], ]); + // 跳过证书验证(不推荐在生产环境使用) + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + + // 跳过主机名验证 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + $response = curl_exec($curl); $err = curl_error($curl);