From d15af9c7063cf9cb31784c462cc599f01a76773d Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Fri, 12 Dec 2025 16:08:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E7=A5=A8=E6=95=B0=E6=8D=AE=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common.php | 10 ++++++++++ app/service/webService/ChinaTaxes.php | 13 +++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/common.php b/app/common.php index 182d22a..5f3ba0a 100644 --- a/app/common.php +++ b/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); + } } \ No newline at end of file diff --git a/app/service/webService/ChinaTaxes.php b/app/service/webService/ChinaTaxes.php index a72728e..cd06f5d 100644 --- a/app/service/webService/ChinaTaxes.php +++ b/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']; }