From 0d0f3df620e011e65430dc71267393e6940eeece Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Thu, 23 Jan 2025 10:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E8=8E=B7=E5=8F=96=E7=BB=93?= =?UTF-8?q?=E6=8A=A5=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Test.php | 17 +++++++++ app/service/invoice/TempInvoiceService.php | 42 ++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/app/controller/api/Test.php b/app/controller/api/Test.php index 47f2700..2947187 100644 --- a/app/controller/api/Test.php +++ b/app/controller/api/Test.php @@ -55,4 +55,21 @@ class Test extends Base return $this->buildFailed(0, $e->getMessage()); } } + + public function saveSummaryReport() + { + try { + $param = $this->request->param(); + validate()->rule([ + 'report_date|结报日期' => 'require|number|max:11' + ])->check($param); + $data = (new \app\service\invoice\TempInvoiceService())->tempSaveSummaryReport($param['report_date']); + if (!is_array($data)) { + throw new \Exception($data); + } + return $this->buildSuccess($data); + } catch (\Exception $e) { + return $this->buildFailed(0, $e->getMessage()); + } + } } diff --git a/app/service/invoice/TempInvoiceService.php b/app/service/invoice/TempInvoiceService.php index 8373eda..76589ec 100644 --- a/app/service/invoice/TempInvoiceService.php +++ b/app/service/invoice/TempInvoiceService.php @@ -136,4 +136,46 @@ class TempInvoiceService } return $returnData; } + + /** + * 临时获取结报接口数据 + * @param $report_date + * @return array|string + */ + public function tempSaveSummaryReport($report_date) + { + try { + + $InvoiceIssuanceService = new InvoiceIssuanceService(); + $invoiceDate = $InvoiceIssuanceService->getInvoiceDate(strtotime($report_date)); + $bdznsrsbh = $InvoiceIssuanceService->getTaxNumber(0); // 被征纳税人 + + $ChinaTaxes = new ChinaTaxes([], $invoiceDate); + $daiZhengSummaryQuery = $ChinaTaxes->daiZhengSummaryQuery($bdznsrsbh); + + $save = []; + if (isset($daiZhengSummaryQuery['cxwjbList'])) { + foreach ($daiZhengSummaryQuery['cxwjbList'] as $value) { + foreach ($value['cxwjbVO'] as $val) { + $sbpch = $val['sbpch']; // 申报批次号 + $queryWhere = [ + 'sbpch' => $sbpch + ]; + $queryWhere['ydzse'] = $val['ydzse']; + $queryWhere['create_time'] = time(); + $save[] = $queryWhere; + } + } + } + + if (!$save) { + throw new FuncException($daiZhengSummaryQuery['message'] ?? '数据储存失败'); + } + + return $save; + } catch (\Exception $e) { + return $e->getMessage(); + } + + } }