Browse Source

开票数据记录日志

master
wanghongjun 2 months ago
parent
commit
d15af9c706
  1. 10
      app/common.php
  2. 13
      app/service/webService/ChinaTaxes.php

10
app/common.php

@ -17,4 +17,14 @@ function generate_random_string(int $length):string
}
return $randomString;
}
// 记录日志
function http_write_log(string $msg, array $data = [])
{
$write_log = env('app.write_log') ?? false;
if ($write_log) {
$message = $msg . ':' . json_encode($data);
\think\facade\Log::info($message);
}
}

13
app/service/webService/ChinaTaxes.php

@ -171,6 +171,8 @@ class ChinaTaxes
$this->xmlType = 2;
http_write_log('mxGrid', $mxGrid);
http_write_log('body', $body);
$param = $this->getParamData('SSGZ_GZPT_SZQKL_WTDZDRJK', $body);
$res = $this->resultXml($param, 0);
@ -202,7 +204,9 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_JGWTDZ', $body);
return $this->resultXml($param, 3);
$data = $this->resultXml($param, 3);
http_write_log('realTimeProcessing', $data);
return $data;
}
/**
@ -271,7 +275,9 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_DW_DZSCMXYC_QUERY', $body);
$this->xmlKey = '03';
return $this->resultXml($param, 0);
$data = $this->resultXml($param, 0);
http_write_log('queryUploadErrorData', $data);
return $data;
}
/**
@ -699,6 +705,7 @@ xmlns:ns2="http://www.chinatax.gov.cn/dataspec/">';
{
$key = "SZQKLDZSPSB00{$this->xmlKey}ZipBase64ResponsBw";
$result = $this->json_curl(json_encode($param));
http_write_log('param', $param);
// 恢复修改
$this->xmlKey = '01';
@ -711,6 +718,7 @@ xmlns:ns2="http://www.chinatax.gov.cn/dataspec/">';
throw new FuncException('请求失败!!');
}
$data = $this->xmlDom($result['result']);
http_write_log('data'.$type, $data);
if (isset($data['code']) && $data['code'] != 200) {
if ($type == 3 && $data['code'] == 302) return $data;
@ -727,6 +735,7 @@ xmlns:ns2="http://www.chinatax.gov.cn/dataspec/">';
if ($deData) {
$xmlData = $this->xmlDom($deData);
http_write_log('xmlData'.$type, $xmlData);
if (isset($xmlData['ns2:message']) && $xmlData['ns2:message'] == '已结报的属期,不允许导入') {
return ['code' => '123456'];
}

Loading…
Cancel
Save