diff --git a/app/controller/task/InvoiceIssuanceTask.php b/app/controller/task/InvoiceIssuanceTask.php index 249b421..e0686c8 100644 --- a/app/controller/task/InvoiceIssuanceTask.php +++ b/app/controller/task/InvoiceIssuanceTask.php @@ -65,14 +65,7 @@ class InvoiceIssuanceTask extends Base */ public function runSummaryReport(): Response { - $where = ['status' => 3, 'delete_time' => 0]; - $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $this->limit)->select(); - foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) { - $result = (new InvoiceIssuanceService())->summaryReport($InvoiceIssuanceValue); - if ($result === true) { - $this->invoiceSuccess($InvoiceIssuanceValue); - } - } + $result = (new InvoiceIssuanceService())->summaryReport(); return $this->buildSuccess(); } diff --git a/app/model/InvoiceFinalReport.php b/app/model/InvoiceFinalReport.php new file mode 100644 index 0000000..8d0aac7 --- /dev/null +++ b/app/model/InvoiceFinalReport.php @@ -0,0 +1,10 @@ +getInvoiceDate($invoiceIssuance['expire_time']); - $bdznsrsbh = ''; // 被征纳税人 + $final_report_date = time(); + $invoiceDate = $this->getInvoiceDate($final_report_date); + $bdznsrsbh = $this->getTaxNumber(0); // 被征纳税人 $ChinaTaxes = new ChinaTaxes([], $invoiceDate); $daiZhengSummaryQuery = $ChinaTaxes->daiZhengSummaryQuery($bdznsrsbh); - $sbpch = $daiZhengSummaryQuery['cxwjbList']['cxwjbVO']['sbpch']; // 申报批次号 - $ydzse = $daiZhengSummaryQuery['cxwjbList']['cxwjbVO']['ydzse']; // 应代征税额 + $ydzse = 0; + $save = []; + foreach ($daiZhengSummaryQuery['cxwjbList'][0] as $value) { + foreach ($value['cxwjbVO'] as $val) { + $sbpch = $val['sbpch']; // 申报批次号 + $ydzse += $val['ydzse']; // 应代征税额 + $save[] = [ + 'sbpch' => $sbpch, + 'ydzse' => $ydzse + ]; + } + } + $result = $ChinaTaxes->daiZhengSummaryReport($ydzse); - $ChinaTaxes->daiZhengSummaryReport($ydzse); + (new InvoiceFinalReport())->saveAll($save); return true; } diff --git a/app/service/webService/ChinaTaxes.php b/app/service/webService/ChinaTaxes.php index 5adb956..43fe053 100644 --- a/app/service/webService/ChinaTaxes.php +++ b/app/service/webService/ChinaTaxes.php @@ -26,6 +26,8 @@ class ChinaTaxes protected $invoiceIssuance; // 加密XML Base标签的key protected $xmlKey = '01'; + // + protected $xmlDataType = 0; /** * @throws FuncException @@ -262,9 +264,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_SZQKL_DW_DZSCMXYC_QUERY', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -286,9 +286,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_PZ_QUERYDKDZJKP', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -316,9 +314,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_SZQKL_SFJYJK', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result, 0); + return $this->resultXml($param, 0); } /** @@ -356,9 +352,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_SZQKL_SB_XNHGZ', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -374,9 +368,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_SZQKL_DELETEWTDZ', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -393,11 +385,11 @@ class ChinaTaxes 'skssqz' => $this->invoiceIssuance['skssqz'], // 税款所属期止,格式,年-月-日 ]; - $param = $this->getParamData('SSGZ_GZPT_SZQKL_SB_CXDZMXSJHZ', $body); + $this->xmlDataType = 1; - $result = $this->json_curl(json_encode($param)); + $param = $this->getParamData('SSGZ_GZPT_SZQKL_SB_CXDZMXSJHZ', $body); - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -417,9 +409,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_SZQKL_SB_BCWTDZHZJK', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -439,9 +429,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_SZQKL_ZM_SAVEPLSQKJSSWSZMJK', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -459,9 +447,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_SZQKL_PZ_QUERYDZJKPZZFQK', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -485,9 +471,7 @@ class ChinaTaxes $param = $this->getParamData('SSGZ_GZPT_SZQKL_ZM_SAVEPLSQKJSSWSZMFORWXT', $body); - $result = $this->json_curl(json_encode($param)); - - return $this->resultXml($result); + return $this->resultXml($param); } /** @@ -682,7 +666,12 @@ xmlns:ns2="http://www.chinatax.gov.cn/dataspec/">'; if ($node->hasChildNodes()) { foreach ($node->childNodes as $child) { if ($child->nodeType === XML_ELEMENT_NODE) { - $output[$child->nodeName] = $this->xmlToArray($child); + $data = $this->xmlToArray($child); + if ($this->xmlDataType == 1 && is_array($data)) { + $output[$child->nodeName][] = $data; + } else { + $output[$child->nodeName] = $data; + } } elseif ($child->nodeType === XML_TEXT_NODE) { $output = $child->nodeValue; }