Browse Source

临时获取结报数据接口

master
wanghongjun 11 months ago
parent
commit
0d0f3df620
  1. 17
      app/controller/api/Test.php
  2. 42
      app/service/invoice/TempInvoiceService.php

17
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());
}
}
}

42
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();
}
}
}

Loading…
Cancel
Save