Browse Source

汇总结报脚本2

master
wanghongjun 11 months 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
{
$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();
}

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;
use app\model\InvoiceFinalReport;
use app\model\InvoiceHead;
use app\model\InvoiceIssuance;
use app\model\InvoiceIssuanceData;
@ -405,26 +406,35 @@ class InvoiceIssuanceService
/**
* 汇总结报 (汇总、结报)
* @param $invoiceIssuance
* @return bool
* @throws FuncException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function summaryReport($invoiceIssuance)
public function summaryReport()
{
if (empty($invoiceIssuance['expire_time'])) {
throw new FuncException('申请日期不能为空');
}
$invoiceDate = $this->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;
}

51
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;
}

Loading…
Cancel
Save