Browse Source

汇总结报脚本2

master
wanghongjun 1 year ago
parent
commit
e5acf9fcc7
  1. 9
      app/controller/task/InvoiceIssuanceTask.php
  2. 10
      app/model/InvoiceFinalReport.php
  3. 34
      app/service/invoice/InvoiceIssuanceService.php
  4. 51
      app/service/webService/ChinaTaxes.php

9
app/controller/task/InvoiceIssuanceTask.php

@ -65,14 +65,7 @@ class InvoiceIssuanceTask extends Base
*/ */
public function runSummaryReport(): Response public function runSummaryReport(): Response
{ {
$where = ['status' => 3, 'delete_time' => 0]; $result = (new InvoiceIssuanceService())->summaryReport();
$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);
}
}
return $this->buildSuccess(); return $this->buildSuccess();
} }

10
app/model/InvoiceFinalReport.php

@ -0,0 +1,10 @@
<?php
namespace app\model;
use think\Model;
class InvoiceFinalReport extends Model
{
}

34
app/service/invoice/InvoiceIssuanceService.php

@ -2,6 +2,7 @@
namespace app\service\invoice; namespace app\service\invoice;
use app\model\InvoiceFinalReport;
use app\model\InvoiceHead; use app\model\InvoiceHead;
use app\model\InvoiceIssuance; use app\model\InvoiceIssuance;
use app\model\InvoiceIssuanceData; use app\model\InvoiceIssuanceData;
@ -405,26 +406,35 @@ class InvoiceIssuanceService
/** /**
* 汇总结报 (汇总、结报) * 汇总结报 (汇总、结报)
* @param $invoiceIssuance
* @return bool * @return bool
* @throws FuncException * @throws FuncException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/ */
public function summaryReport($invoiceIssuance) public function summaryReport()
{ {
$final_report_date = time();
if (empty($invoiceIssuance['expire_time'])) { $invoiceDate = $this->getInvoiceDate($final_report_date);
throw new FuncException('申请日期不能为空'); $bdznsrsbh = $this->getTaxNumber(0); // 被征纳税人
}
$invoiceDate = $this->getInvoiceDate($invoiceIssuance['expire_time']);
$bdznsrsbh = ''; // 被征纳税人
$ChinaTaxes = new ChinaTaxes([], $invoiceDate); $ChinaTaxes = new ChinaTaxes([], $invoiceDate);
$daiZhengSummaryQuery = $ChinaTaxes->daiZhengSummaryQuery($bdznsrsbh); $daiZhengSummaryQuery = $ChinaTaxes->daiZhengSummaryQuery($bdznsrsbh);
$sbpch = $daiZhengSummaryQuery['cxwjbList']['cxwjbVO']['sbpch']; // 申报批次号 $ydzse = 0;
$ydzse = $daiZhengSummaryQuery['cxwjbList']['cxwjbVO']['ydzse']; // 应代征税额 $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; return true;
} }

51
app/service/webService/ChinaTaxes.php

@ -26,6 +26,8 @@ class ChinaTaxes
protected $invoiceIssuance; protected $invoiceIssuance;
// 加密XML Base标签的key // 加密XML Base标签的key
protected $xmlKey = '01'; protected $xmlKey = '01';
//
protected $xmlDataType = 0;
/** /**
* @throws FuncException * @throws FuncException
@ -262,9 +264,7 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_DW_DZSCMXYC_QUERY', $body); $param = $this->getParamData('SSGZ_GZPT_SZQKL_DW_DZSCMXYC_QUERY', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param);
return $this->resultXml($result);
} }
/** /**
@ -286,9 +286,7 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_PZ_QUERYDKDZJKP', $body); $param = $this->getParamData('SSGZ_GZPT_PZ_QUERYDKDZJKP', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param);
return $this->resultXml($result);
} }
/** /**
@ -316,9 +314,7 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_SFJYJK', $body); $param = $this->getParamData('SSGZ_GZPT_SZQKL_SFJYJK', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param, 0);
return $this->resultXml($result, 0);
} }
/** /**
@ -356,9 +352,7 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_SB_XNHGZ', $body); $param = $this->getParamData('SSGZ_GZPT_SZQKL_SB_XNHGZ', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param);
return $this->resultXml($result);
} }
/** /**
@ -374,9 +368,7 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_DELETEWTDZ', $body); $param = $this->getParamData('SSGZ_GZPT_SZQKL_DELETEWTDZ', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param);
return $this->resultXml($result);
} }
/** /**
@ -393,11 +385,11 @@ class ChinaTaxes
'skssqz' => $this->invoiceIssuance['skssqz'], // 税款所属期止,格式,年-月-日 '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); $param = $this->getParamData('SSGZ_GZPT_SZQKL_SB_BCWTDZHZJK', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param);
return $this->resultXml($result);
} }
/** /**
@ -439,9 +429,7 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_ZM_SAVEPLSQKJSSWSZMJK', $body); $param = $this->getParamData('SSGZ_GZPT_SZQKL_ZM_SAVEPLSQKJSSWSZMJK', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param);
return $this->resultXml($result);
} }
/** /**
@ -459,9 +447,7 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_PZ_QUERYDZJKPZZFQK', $body); $param = $this->getParamData('SSGZ_GZPT_SZQKL_PZ_QUERYDZJKPZZFQK', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param);
return $this->resultXml($result);
} }
/** /**
@ -485,9 +471,7 @@ class ChinaTaxes
$param = $this->getParamData('SSGZ_GZPT_SZQKL_ZM_SAVEPLSQKJSSWSZMFORWXT', $body); $param = $this->getParamData('SSGZ_GZPT_SZQKL_ZM_SAVEPLSQKJSSWSZMFORWXT', $body);
$result = $this->json_curl(json_encode($param)); return $this->resultXml($param);
return $this->resultXml($result);
} }
/** /**
@ -682,7 +666,12 @@ xmlns:ns2="http://www.chinatax.gov.cn/dataspec/">';
if ($node->hasChildNodes()) { if ($node->hasChildNodes()) {
foreach ($node->childNodes as $child) { foreach ($node->childNodes as $child) {
if ($child->nodeType === XML_ELEMENT_NODE) { 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) { } elseif ($child->nodeType === XML_TEXT_NODE) {
$output = $child->nodeValue; $output = $child->nodeValue;
} }

Loading…
Cancel
Save