|
|
|
@ -8,6 +8,10 @@ class ChinaTaxes |
|
|
|
{ |
|
|
|
|
|
|
|
protected $accessToken; |
|
|
|
protected $sid; |
|
|
|
protected $reqId; |
|
|
|
protected $channelId; |
|
|
|
protected $channelSecret; |
|
|
|
protected $apiUrl; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -16,7 +20,12 @@ class ChinaTaxes |
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
|
|
|
|
$this->apiUrl = env('taxes.api_url'); |
|
|
|
$this->apiUrl = env('taxes.api_url'); |
|
|
|
$this->reqId = env('taxes.req_id'); // 接入端交易请求唯一标识,长度 32 位,5 秒内不得重复,否则抛出异常:交易请求唯一标识重复。 |
|
|
|
$this->channelId = env('taxes.channel_id'); // 接入渠道标识(ID) |
|
|
|
$this->channelSecret = env('taxes.channel_secret'); // 平台为接入渠道统一分配的密码,只有身份验证接口需要 |
|
|
|
|
|
|
|
$this->sid = 'bizAccessLogin'; // 调用的接口名称,固定为“bizAccessLogin” |
|
|
|
|
|
|
|
$this->getAccessToken(); |
|
|
|
} |
|
|
|
@ -29,10 +38,10 @@ class ChinaTaxes |
|
|
|
{ |
|
|
|
|
|
|
|
$param = [ |
|
|
|
'reqId' => '2334e6cedb1389057d715acf00e4d9441', // 接入端交易请求唯一标识,长度 32 位,5 秒内不得重复,否则抛出异常:交易请求唯一标识重复。 |
|
|
|
'sid' => 'bizAccessLogin', // 调用的接口名称,固定为“bizAccessLogin” |
|
|
|
'channelId' => 'SZSSJ', // 接入渠道标识(ID) |
|
|
|
'channelSecret' => 'F541D38364337959E0530B7F6796B44D', // 平台为接入渠道统一分配的密码,只有身份验证接口需要 |
|
|
|
'reqId' => $this->reqId, // 接入端交易请求唯一标识,长度 32 位,5 秒内不得重复,否则抛出异常:交易请求唯一标识重复。 |
|
|
|
'sid' => $this->sid, // 调用的接口名称,固定为“bizAccessLogin” |
|
|
|
'channelId' => $this->channelId, // 接入渠道标识(ID) |
|
|
|
'channelSecret' => $this->channelSecret, // 平台为接入渠道统一分配的密码,只有身份验证接口需要 |
|
|
|
'timestamp' => time(), // unix 时间戳 |
|
|
|
'data' => [ |
|
|
|
'flag' => '499' |
|
|
|
@ -60,9 +69,9 @@ class ChinaTaxes |
|
|
|
protected function getParamData($sid, $body): array |
|
|
|
{ |
|
|
|
return [ |
|
|
|
'reqId' => '2334e6cedb1389057d715acf00e4d944', |
|
|
|
'reqId' => $this->reqId, |
|
|
|
'sid' => $sid, |
|
|
|
'channelId' => 'SZSSJ', |
|
|
|
'channelId' => $this->channelId, |
|
|
|
'accessToken' => $this->accessToken, |
|
|
|
'timestamp' => time(), |
|
|
|
'data' => [ |
|
|
|
@ -366,16 +375,24 @@ class ChinaTaxes |
|
|
|
* @param $body |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
protected function bizXml($body): string |
|
|
|
protected function bizXml($body, $type = 2): string |
|
|
|
{ |
|
|
|
$xml = ''; |
|
|
|
$xml = ''; |
|
|
|
$xml2 = ''; |
|
|
|
foreach ($body as $key => $value) { |
|
|
|
if (is_array($value)) { |
|
|
|
$xml .= "<$key>" . $this->bizXml($value) . "</$key>"; |
|
|
|
$xml .= "<$key>" . $this->bizXml($value) . "</$key>"; |
|
|
|
$xml2 .= "<ns2:{$key}>" . $this->bizXml($value, $type) . "</ns2:{$key}>"; |
|
|
|
} else { |
|
|
|
$xml .= "<$key>$value</$key>"; |
|
|
|
$xml .= "<$key>$value</$key>"; |
|
|
|
$xml2 .= "<ns2:{$key}>" . $value . "</ns2:{$key}>"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($type == 2) { |
|
|
|
return $xml2; |
|
|
|
} |
|
|
|
|
|
|
|
return $xml; |
|
|
|
} |
|
|
|
|
|
|
|
@ -386,6 +403,14 @@ class ChinaTaxes |
|
|
|
*/ |
|
|
|
protected function mxGrid($mxGrid) |
|
|
|
{ |
|
|
|
|
|
|
|
$xmlArr = []; |
|
|
|
|
|
|
|
foreach ($mxGrid as $key => $value) { |
|
|
|
$xmlArr[] = "<ns2:{$key}>" . $value . "</ns2:{$key}>"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $mxGrid; |
|
|
|
} |
|
|
|
|
|
|
|
|