Browse Source

测试深圳税务接口22

master
wanghongjun 1 year ago
parent
commit
818e4217ee
  1. 11
      app/controller/api/Test.php
  2. 34
      app/service/webService/ChinaTaxes.php

11
app/controller/api/Test.php

@ -13,7 +13,9 @@ class Test extends Base
{
try {
$ChinaTaxes = new ChinaTaxes();
$getWechatData = $this->getWechatData();
dump($getWechatData);die;
$ChinaTaxes = new ChinaTaxes($getWechatData);
$result = $ChinaTaxes->savingDetailedData();
dump($result);
@ -23,4 +25,11 @@ class Test extends Base
}
}
public function getWechatData()
{
$pucode = '41107311';
$FeeService = new FeeService($pucode);
return $FeeService->getUsers();
}
}

34
app/service/webService/ChinaTaxes.php

@ -7,6 +7,7 @@ use fast\FuncException;
class ChinaTaxes
{
protected $puCodeUser;
protected $accessToken;
protected $sid;
protected $reqId;
@ -18,11 +19,12 @@ class ChinaTaxes
/**
* @throws FuncException
*/
public function __construct()
public function __construct($data)
{
$this->puCodeUser = $data;
$this->apiUrl = env('taxes.api_url');
$this->reqId = md5(time());//env('taxes.req_id'); // 接入端交易请求唯一标识,长度 32 位,5 秒内不得重复,否则抛出异常:交易请求唯一标识重复。
$this->reqId = $this->getReqId();//env('taxes.req_id'); // 接入端交易请求唯一标识,长度 32 位,5 秒内不得重复,否则抛出异常:交易请求唯一标识重复。
$this->channelId = env('taxes.channel_id'); // 接入渠道标识(ID)
$this->channelSecret = env('taxes.channel_secret'); // 平台为接入渠道统一分配的密码,只有身份验证接口需要
@ -61,6 +63,15 @@ class ChinaTaxes
$this->accessToken = $result['result']['accessToken'];
}
/**
*
* @return string
*/
protected function getReqId(): string
{
return md5(time() . rand(0,9));
}
/**
* 获取请求参数
* @param $sid
@ -70,7 +81,7 @@ class ChinaTaxes
protected function getParamData($sid, $body): array
{
return [
'reqId' => md5(time() . rand(0,9)),
'reqId' => $this->getReqId(),
'sid' => $sid,
'channelId' => $this->channelId,
'accessToken' => $this->accessToken,
@ -91,11 +102,11 @@ class ChinaTaxes
{
$mxGrid = [
'bdznsrsbh' => '91440300MA5DD4XE43',// 被代征纳税人识别号
'bdznsrmc' => '九龙县桑专峯电子仪表仪器有限公司',// 被代征纳税人名称
'bdznsrsbh' => '91440300MA5DD4XE43',// 被代征纳税人识别号 *
'bdznsrmc' => '九龙县桑专峯电子仪表仪器有限公司',// 被代征纳税人名称 *
'gjhdqszDm' => '156',// 国家或地区数字代码
'sfzjlxDm' => '201',// 身份证件类型代码
'zjhm' => '142433197804217752',// 证件号码
'zjhm' => '142433197804217752',// 证件号码 *
'hyDm' => '6490',// 行业代码
'zsxmDm' => '30433',// 征收项目代码
'zspmDm' => '304331300',// 征收品目代码
@ -119,8 +130,8 @@ class ChinaTaxes
'sflsb' => 'N', //是否零申报 ,为非零申报”N”
'sbpch' => '0', //批次号,详见备注
'nsqxDm' => '06', //纳税期限代码,“06”按月
'skssqq' => '2023-06-01', //税款所属期起,格式,年-月-日
'skssqz' => '2023-06-30', //税款所属期止,格式,年-月-日
'skssqq' => '2023-06-01', //税款所属期起,格式,年-月-日 *
'skssqz' => '2023-06-30', //税款所属期止,格式,年-月-日 *
'zsxmdm' => '30433', //征收项目代码:30433
'my' => $this->my, //密钥,数字签名校验和资格校验
'mxGrid' => $this->mxGrid($mxGrid)
@ -130,11 +141,18 @@ class ChinaTaxes
$result = $this->json_curl(json_encode($param));
if (!isset($result['result'])) {
throw new \Exception('请求失败');
}
$data = $this->xmlDom($result['result']);
$deData = $this->deCompressXml($data['SZQKLDZSPSB0001ZipBase64ResponsBw']);
$returnData = $this->xmlDom($deData);
if ($returnData['ns2:code'] !== 200) {
throw new \Exception($returnData['ns2:message']);
}
dump($returnData);die;
}

Loading…
Cancel
Save