Browse Source

临时转发接口方法替换3

master
wanghongjun 1 year ago
parent
commit
f2f5f555b3
  1. 4
      app/controller/task/InvoiceIssuanceTask.php
  2. 33
      app/service/invoice/InvoiceIssuanceService.php

4
app/controller/task/InvoiceIssuanceTask.php

@ -24,7 +24,7 @@ class InvoiceIssuanceTask extends Base
public function runIssueAnInvoice(): Response public function runIssueAnInvoice(): Response
{ {
$where = ['status' => 0, 'delete_time' => 0]; $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) { foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) {
$result = (new InvoiceIssuanceService())->tempIssueAnInvoice($InvoiceIssuanceValue); $result = (new InvoiceIssuanceService())->tempIssueAnInvoice($InvoiceIssuanceValue);
if ($result === true) { if ($result === true) {
@ -46,7 +46,7 @@ class InvoiceIssuanceTask extends Base
public function runCancelInitiateAgain(): Response public function runCancelInitiateAgain(): Response
{ {
$where = ['status' => 1, 'delete_time' => 0]; $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) { foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) {
$result = (new InvoiceIssuanceService())->cancelInitiateAgain($InvoiceIssuanceValue); $result = (new InvoiceIssuanceService())->cancelInitiateAgain($InvoiceIssuanceValue);
if ($result === true) { if ($result === true) {

33
app/service/invoice/InvoiceIssuanceService.php

@ -182,6 +182,7 @@ class InvoiceIssuanceService
*/ */
public function IssueAnInvoice($invoiceIssuance) public function IssueAnInvoice($invoiceIssuance)
{ {
$sbpch = '';
try { try {
// 用户编码 // 用户编码
$pucode = $invoiceIssuance['pucode']; $pucode = $invoiceIssuance['pucode'];
@ -285,6 +286,10 @@ class InvoiceIssuanceService
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
(new InvoiceIssuanceData())->saveField($invoiceIssuance['id'], 'ycms', $e->getMessage()); (new InvoiceIssuanceData())->saveField($invoiceIssuance['id'], 'ycms', $e->getMessage());
// 未获取到批次号报错
if (empty($sbpch)) {
}
$this->writeLog($e); $this->writeLog($e);
return $e->getMessage(); return $e->getMessage();
} }
@ -520,18 +525,22 @@ class InvoiceIssuanceService
if (isset($resultData['code']) && $resultData['code'] == 1) { if (isset($resultData['code']) && $resultData['code'] == 1) {
$r_data = $resultData['data'];
// 存在错误 // 存在错误
if (!empty($resultData['ycms'])) { if (!empty($r_data['ycms'])) {
(new InvoiceIssuanceData())->saveField($data['id'], 'ycms', $resultData['ycms']); (new InvoiceIssuanceData())->saveField($data['id'], 'ycms', $r_data['ycms']);
throw new \Exception($resultData['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 盖章 // 拼接pdf 盖章
$requestData = ['data' => $d_data['pdf_data'], 'meta' => $d_data['pdf_meta']]; $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); (new InvoiceIssuanceData())->saveData($d_data['i_i_id'], $d_data['bdznsrsbh'], $d_data['jsyj'], $d_data['assetID'], $pdfFilepath);
} }
if (isset($resultData['i_i_data'])) { if (isset($r_data['i_i_data'])) {
$i_i_data = $resultData['i_i_data']; $i_i_data = $r_data['i_i_data'];
if ($i_i_data['status'] == 3) { if ($i_i_data['status'] == 3) {
(new InvoiceIssuance())->where('id', $data['id'])->save(['status' => 3, 'issuance_time' => $i_i_data['issuance_time']]); (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); $response = curl_exec($curl);
$err = curl_error($curl); $err = curl_error($curl);

Loading…
Cancel
Save