TaxInvoice.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. <?php
  2. use think\facade\Cache;
  3. class Rmethod{
  4. public $header;
  5. public $method;
  6. public $body;
  7. public $url;
  8. public $timeout=5;
  9. public function __construct(){
  10. $this->header=["Content-Type"=>"application/json"];
  11. }
  12. /**
  13. * @return mixed
  14. */
  15. public function getBody(){
  16. return $this->body;
  17. }
  18. /**
  19. * @param mixed $body
  20. */
  21. public function setBody($body){
  22. $this->body = $body;
  23. }
  24. /**
  25. * @param mixed $method
  26. */
  27. public function setMethod($method){
  28. $this->method = $method;
  29. }
  30. /**
  31. * @param mixed $url
  32. */
  33. public function setUrl($url){
  34. $this->url = $url;
  35. }
  36. /**
  37. * @param mixed $header
  38. */
  39. public function setHeader($header){
  40. $this->header = $header;
  41. }
  42. /**
  43. * @param string $url
  44. * @param array $body
  45. * @param string $method
  46. * @return bool|string
  47. */
  48. public function request($url='',$body=[],$method=""){
  49. !empty($body)?$this->body=$body:"";
  50. $url!=""?$this->url=$url:"";
  51. $this->method= $method!=""?$method:"post";
  52. $data=$this->curlmothod();
  53. return json_decode($data,true);
  54. }
  55. protected function curlmothod() {
  56. //⽀持json数据数据提交
  57. $post_string =$this->checkBody();
  58. $header=$this->checkHeader();
  59. $URL = strtolower($this->method)=="get" && !empty($post_data) ? $this->url."?".$post_string :$this->url;
  60. $ch = curl_init(); // 启动⼀个CURL会话
  61. curl_setopt($ch, CURLOPT_URL, $URL); // 要访问的地址
  62. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查 // https请求不验证证书和hosts
  63. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 // 模拟⽤户使⽤的浏览器
  64. if(strtolower($this->method)=="post"){
  65. curl_setopt($ch, CURLOPT_POST, true); // 发送⼀个常规的Post请求
  66. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); // Post提交的数据包
  67. }
  68. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout); // 设置超时限制防⽌死循环
  69. curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
  70. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 获取的信息以⽂件流的形式返回
  71. curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //模拟的header头
  72. $result = curl_exec($ch);
  73. curl_close($ch);
  74. return $result;
  75. }
  76. public function checkHeader(){
  77. if (!empty($this->header)){
  78. $temp=[];
  79. foreach ($this->header as $key=>$value){
  80. $temp[]=$key.":".$value;
  81. }
  82. return $temp;
  83. }
  84. return[];
  85. }
  86. public function checkBody(){
  87. if (!empty($this->body)){
  88. $body = http_build_query($this->body);
  89. if(key_exists("Content-Type",$this->header) && $this->header['Content-Type']=="application/json"){
  90. $body =json_encode($this->body);
  91. }
  92. return $body;
  93. }
  94. return'';
  95. }
  96. }
  97. class TaxInvoice {
  98. protected $appKey;
  99. protected $appSecret;
  100. protected $request;
  101. protected $entCode;//企业税号
  102. protected $zipCode;//压缩标识
  103. protected $encryptCode;//加密标识 0 base64 1 3DES
  104. // protected $domain='https://openapi.ele-cloud.com';//正式域名
  105. protected $domain='https://sandbox.ele-cloud.com';//测试域名
  106. public function __construct(string $appKey,string $appSecret,string $entCode='',$zipCode=0,$encryptCode=0){
  107. $this->appKey=$appKey;
  108. $this->appSecret=$appSecret;
  109. $this->entCode=$entCode;
  110. $this->zipCode=$zipCode;
  111. $this->encryptCode=$encryptCode;
  112. $this->request=new Rmethod();
  113. }
  114. /** * 年月日、时分秒 + 3位毫秒数
  115. * @param string $format
  116. * @param null $utimestamp
  117. * @return false|string */
  118. public function ts_time($format = 'u', $utimestamp = null)
  119. { if (is_null($utimestamp)){ $utimestamp = microtime(true); }
  120. $timestamp = floor($utimestamp);
  121. $milliseconds = round(($utimestamp - $timestamp) * 1000);
  122. return str_pad(date("YmdHis").$milliseconds,17,"0",STR_PAD_RIGHT);
  123. }
  124. /**
  125. * @param string $buyer_id
  126. * @param string $batchNum
  127. * @param string $start
  128. * @param string $end
  129. * @param string $status
  130. * @return array|bool|float|int|mixed|stdClass|string|null
  131. */
  132. public function getMainInvoice(string $buyer_id='',string $batchNum='',string $start='',string
  133. $end='',string $status=''){
  134. $url=$this->domain."/api/dxhy-open-income/v1/getMainInvoice?access_token=".$this->GetToken();
  135. $param = [
  136. "GMFSBH"=>$buyer_id,
  137. "PCH"=>$batchNum,
  138. "CJKSRQ"=>$start,
  139. "CJJSRQ"=>$end,
  140. "ZTBZ"=>$status,
  141. ];
  142. $data=$this->request->request($url,$this->GetParam($param));
  143. return $this->ReturnData($data);
  144. }
  145. /**
  146. * @param int $refresh
  147. * @return mixed|string
  148. */public function GetToken($refresh=0){
  149. $token = Cache::get("TAXToken");
  150. if($token==false || $refresh==1){
  151. $result=$this->auth();
  152. \think\facade\Log::info("参数:".json_encode($result,JSON_UNESCAPED_UNICODE));
  153. if(key_exists("access_token",$result) && $result['access_token']!=''){
  154. Cache::set("TAXToken",$result['access_token'],$result['expires_in']);
  155. $token=$result['access_token'];
  156. }
  157. }
  158. return $token;
  159. }
  160. /**
  161. * @return bool|string
  162. */public function auth(){
  163. $uri=$this->domain."/api/authen/token";
  164. $param=["appKey"=>$this->appKey,"appSecret"=>$this->appSecret];
  165. $result=$this->request->request($url=$uri,$body=$param,$method="post");
  166. return $result;
  167. }
  168. /**
  169. * @param $data
  170. * @return array
  171. */public function GetParam($data){
  172. $param=[
  173. "zipCode"=>$this->zipCode,
  174. "entCode"=>$this->entCode,
  175. "encryptCode"=>$this->encryptCode,
  176. "dataExchangeId"=>$this->ts_time().rand(pow(10,14),pow(10,15)-1),
  177. "content"=>base64_encode(json_encode($data,JSON_UNESCAPED_UNICODE))
  178. ];
  179. \think\facade\Log::info("参数:".json_encode($data,JSON_UNESCAPED_UNICODE));
  180. return $param;
  181. }
  182. /**
  183. * @param $data
  184. * @return array|bool|float|int|mixed|stdClass|string|null
  185. */public function ReturnData($data){
  186. $return =["code"=>0,"message"=>"fail"];
  187. if(key_exists("returnCode",$data['returnStateInfo'])){
  188. if ($data['returnStateInfo']['returnCode']=='0000'){
  189. $result= base64_decode($data['content']);
  190. $return = json_decode($result,true);
  191. }else{
  192. $returnMessage= base64_decode($data['returnStateInfo']['returnMessage']);
  193. $return =["code"=>$data['returnStateInfo']['returnCode'],"message"=>$returnMessage];
  194. }
  195. }
  196. \think\facade\Log::info("返回值:".json_encode($return,JSON_UNESCAPED_UNICODE));
  197. return $return;
  198. }
  199. /**
  200. * @param string $buyer_id
  201. * @param string $batchNum
  202. * @param string $start
  203. * @param string $end
  204. * @param string $status
  205. * @param int $num
  206. * @return array|bool|float|int|mixed|stdClass|string|null
  207. */
  208. public function getInvoiceState(string $buyer_id='',string $batchNum='',string $start='',string
  209. $end='',string $status='',int $num=1){
  210. $url=$this->domain."/api/dxhy-open-income/v1/getInvoiceState?access_token=".$this->GetToken();
  211. $param = [
  212. "GMFSBH"=>$buyer_id,
  213. "PCH"=>$batchNum,
  214. "ZTBGKSRQ"=>$start,
  215. "ZTBGJSRQ"=>$end,
  216. "ZTBZ"=>$status,
  217. "KSHS"=>$num,
  218. ];
  219. $data=$this->request->request($url,$this->GetParam($param));
  220. return $this->ReturnData($data);
  221. }
  222. /**
  223. * @param string $buyer_id
  224. * @param int $total
  225. * @param string $batchNum
  226. * @param array $invArr [{invoiceCode:'',invoiceNumber:'',invoiceType:'',inv_subtotal_amount:'',opentime:'',
  227. * buyer_id:'',reason:''}]
  228. * @return array|bool|float|int|mixed|stdClass|string|null
  229. */
  230. public function applyLegalize(string $buyer_id='',int $total=0,string $batchNum='',array $invArr=[]){
  231. $url=$this->domain."/api/dxhy-open-income/v1/applyLegalize?access_token=".$this->GetToken();
  232. $temp=[];
  233. if(!empty($invArr)){
  234. foreach ($invArr as $value){
  235. $data=[];
  236. $data['FPDM']=$value['invoiceCode'];
  237. $data['FPHM']=$value['invoiceNumber'];
  238. $data['YXSE']=$value['inv_subtotal_amount'];
  239. $data['SQSKSSQ']=$value['opentime'];
  240. $data['GMFSBH']=$value['buyer_id'];
  241. $data['FPLXDM']=$value['invoiceType'];
  242. $data['BDKYY']=$value['reason']??'';
  243. $temp[]=$data;
  244. }
  245. }
  246. $param = [
  247. "GMFSBH"=>$buyer_id,
  248. "PCH"=>$batchNum,
  249. "FHHS"=>$total,
  250. "FPZHXX"=>$temp,
  251. ];
  252. // "FPDM":"3100174130", "FPHM":"08975555", "GMFSBH":"91110104444324CP321", "SQRZLX":"1", "FPLXDM":"01",
  253. // "SQSKSSQ":"202005", "YXSE":"200", "BDKYY":
  254. $data=$this->request->request($url,$this->GetParam($param));
  255. return $this->ReturnData($data);
  256. }
  257. /**
  258. * @param string $batchNum
  259. * @return array|bool|float|int|mixed|stdClass|string|null
  260. */
  261. public function applyLegalizeResult(string $batchNum=''){
  262. $url=$this->domain."/api/dxhy-open-income/v1/applyLegalizeResult?access_token=".$this->GetToken();
  263. $param = ["PCH"=>$batchNum];
  264. $data=$this->request->request($url,$this->GetParam($param));
  265. return $this->ReturnData($data);
  266. }
  267. /**
  268. * @param string $buyer_id
  269. * @param string $period
  270. * @return array|bool|float|int|mixed|stdClass|string|null
  271. */public function getCountInfo(string $buyer_id='',string $period=''){
  272. $url=$this->domain."/api/dxhy-open-income/v1/getCountInfo?access_token=".$this->GetToken();
  273. $param = [
  274. "GMFSBH"=>$buyer_id,
  275. "RZSKSSQ"=>$period,
  276. ];
  277. $data=$this->request->request($url,$this->GetParam($param));
  278. return $this->ReturnData($data);
  279. }
  280. /**
  281. * @param string $buyer_id
  282. * @param string $period
  283. * @param string $batchNum
  284. * @param string $statisFlag
  285. * @return array|bool|float|int|mixed|stdClass|string|null
  286. */public function applyCount(string $buyer_id='',string $period='',string $batchNum='',string $statisFlag=''){
  287. $url=$this->domain."/api/dxhy-open-income/v1/applyCount?access_token=".$this->GetToken();
  288. $param = [
  289. "GMFSBH"=>$buyer_id,
  290. "RZSKSSQ"=>$period,
  291. "TJBZ"=>$statisFlag,
  292. "PCH"=>$batchNum
  293. ];
  294. $data=$this->request->request($url,$this->GetParam($param));
  295. return $this->ReturnData($data);
  296. }
  297. /**
  298. * @param string $buyer_id
  299. * @param string $batchNum
  300. * @return array|bool|float|int|mixed|stdClass|string|null
  301. */
  302. public function applyCountResult(string $buyer_id='',string $batchNum=''){
  303. $url=$this->domain."/api/dxhy-open-income/v1/applyCountResult?access_token=".$this->GetToken();
  304. $param = [
  305. "GMFSBH"=>$buyer_id,
  306. "PCH"=>$batchNum
  307. ];
  308. $data=$this->request->request($url,$this->GetParam($param));
  309. return $this->ReturnData($data);
  310. }
  311. /**
  312. * @param string $buyer_id
  313. * @param string $batchNum
  314. * @param string $ack
  315. * @param string $statisTime
  316. * @param string $period
  317. * @param string $confirm_passwd
  318. * @return array|bool|float|int|mixed|stdClass|string|null
  319. */
  320. public function applyConfirm(string $buyer_id='',string $batchNum='',string $ack='',string $statisTime='',string
  321. $period='',string $confirm_passwd=''){
  322. $url=$this->domain."/api/dxhy-open-income/v1/applyConfirm?access_token=".$this->GetToken();
  323. $param = [
  324. "GMFSBH"=>$buyer_id,
  325. "PCH"=>$batchNum,
  326. "QRBZ"=>$ack,
  327. "TJSJ"=>$statisTime,
  328. "RZSKSSQ"=>$period,
  329. "QRMM"=>$confirm_passwd,
  330. ];
  331. $data=$this->request->request($url,$this->GetParam($param));
  332. return $this->ReturnData($data);
  333. }
  334. /**
  335. * @param string $buyer_id
  336. * @param string $batchNum
  337. * @param string $ack
  338. * @param string $statisTime
  339. * @return array|bool|float|int|mixed|stdClass|string|null
  340. */
  341. public function applyConfirmResult(string $buyer_id='',string $batchNum='',string $ack='',string $statisTime=''){
  342. $url=$this->domain."/api/dxhy-open-income/v1/applyConfirmResult?access_token=".$this->GetToken();
  343. $param = [
  344. "GMFSBH"=>$buyer_id,
  345. "PCH"=>$batchNum,
  346. "QRBZ"=>$ack,
  347. "TJSJ"=>$statisTime,
  348. ];
  349. $data=$this->request->request($url,$this->GetParam($param));
  350. return $this->ReturnData($data);
  351. }
  352. /**
  353. * @param string $idCard
  354. * @return array|bool|float|int|mixed|stdClass|string|null
  355. */
  356. public function getCompanyInfo(string $idCard=''){
  357. $url=$this->domain."/api/dxhy-open-income/v1/getCompanyInfo?access_token=".$this->GetToken();
  358. $param = [
  359. "SBH"=>$idCard,
  360. ];
  361. $data=$this->request->request($url,$this->GetParam($param));
  362. return $this->ReturnData($data);
  363. }
  364. /**
  365. * @param string $idCard
  366. * @param string $confirm_passwd
  367. * @param string $new_passwd
  368. * @return array|bool|float|int|mixed|stdClass|string|null
  369. */
  370. public function setPassword(string $idCard='',string $confirm_passwd='',string $new_passwd=''){
  371. $url=$this->domain."/api/dxhy-open-income/v1/setPassword?access_token=".$this->GetToken();
  372. $param = [
  373. "SBH"=>$idCard,
  374. "YWMM"=>$confirm_passwd,
  375. "NEWYWMM"=>$new_passwd,
  376. ];
  377. $data=$this->request->request($url,$this->GetParam($param));
  378. return $this->ReturnData($data);
  379. }
  380. /**
  381. * @param string $idCard
  382. * @return array|bool|float|int|mixed|stdClass|string|null
  383. */
  384. public function resetPassword(string $idCard=''){
  385. $url=$this->domain."/api/dxhy-open-income/v1/resetPassword?access_token=".$this->GetToken();
  386. $param = [
  387. "SBH"=>$idCard
  388. ];
  389. $data=$this->request->request($url,$this->GetParam($param));
  390. return $this->ReturnData($data);
  391. }
  392. /**
  393. * @param array $OrderBatchArr
  394. * @param array $OrderInvList
  395. * @return array|bool|float|int|mixed|\stdClass|string|null
  396. */public function GenerateInvoice(array $OrderBatchArr=[], array $OrderInvList=[]){
  397. $url=$this->domain."/api/order-api/order-api/v5/GenerateInvoice?access_token=".$this->GetToken();
  398. $param = [
  399. "DDPCXX"=>$OrderBatchArr,
  400. "DDZXX"=>$OrderInvList
  401. ];
  402. $data=$this->request->request($url,$this->GetParam($param));
  403. return $this->ReturnData($data);
  404. }
  405. //{"HZSQDSCPC":{"SQBSCQQPCH":"申请表上传请求批次号","NSRSBH":"申请方纳税人识别号","KPZD":"开票终端","FPLXDM":"发票类型代码","KZZD":"扩展字段"},
  406. //"HZSQDSCZXX":[
  407. //{"HZSQDTXX":{"SQBSCQQLSH":"申请表上传请求流水号","YYSBZ":"营业税标志","XXBLX":"信息表类型","YFPDM":"原蓝字发票代码","YFPHM":"原蓝字发票号码","YFPKPRQ":"原蓝字发票开票日期","TKSJ":"填开时间",
  408. //"XHFSBH":"销货方纳税人识别","XHFMC":"销货方纳税人名称","GMFSBH":"购买方纳税人识别号","GMFMC":"购买方纳税人名称","HJJE":"合计金额(带负号,不含税) ","HJSE":"合计税额(带负号)","SQSM":"申请说明",
  409. //"XXBTSBS":"信息表特殊标识","KZZD1":"扩展字段 1","KZZD2":"扩展字段 2"},"DDMXXX":[{"XH":"项目序号","FPHXZ":"发票行性质","SPBM":"商品编码","ZXBM":"自行编码","YHZCBS":"优惠政策标识",
  410. //"LSLBS":"零税率标识","ZZSTSGL":"增值税特殊管理","XMMC":"项目名称","GGXH":"规格型号","DW":"单位","SPSL":"商品数量","DJ":"单价","JE":"金额","HSBZ":"含税标志,固定不含税","SL":"税率","SE":"税额",
  411. //"KCE":"扣除额"}]}]}
  412. /**
  413. * @param string $idCard 纳税人识别号
  414. * @param string $OrderBatchNum 开票申请批次号
  415. * @return array|bool|float|int|mixed|\stdClass|string|null
  416. */
  417. public function GetAllocatedInvoices(string $idCard='',string $OrderBatchNum=''){
  418. $url=$this->domain."/api/order-api/order-api/v5/GetAllocatedInvoices?access_token=".$this->GetToken();
  419. $param = [
  420. "NSRSBH"=>$idCard,
  421. "DDQQPCH"=>$OrderBatchNum
  422. ];
  423. $data=$this->request->request($url,$this->GetParam($param));
  424. return $this->ReturnData($data);
  425. }
  426. /**
  427. * @param string $idCard 纳税人识别号
  428. * @param string $OrderSerialNum 流水号
  429. * @param string $extraCode 提取码
  430. * @param string $orderCode 订单号
  431. * @param string $isFile 是否版式文件 0需要1 不需要
  432. * @param string $orderStart 订单日期起始
  433. * @param string $orderEnd 订单日期终止
  434. * @return array|bool|float|int|mixed|\stdClass|string|null
  435. */public function GetOrderInfoAndInvoiceInfo(string $idCard='',string $OrderSerialNum='',string $extraCode='',string
  436. $orderCode='',string $isFile="",string $orderStart='',string $orderEnd=''){
  437. $url=$this->domain."/api/order-api/order-api/v5/GetOrderInfoAndInvoiceInfo?access_token=".$this->GetToken();
  438. $param = [
  439. "NSRSBH"=>$idCard,
  440. "DDQQLSH"=>$OrderSerialNum,
  441. "TQM"=>$extraCode,
  442. "DDH"=>$orderCode,
  443. "BSWJ"=>$isFile,
  444. "DDRQQ"=>$orderStart,
  445. "DDRQZ"=>$orderEnd,
  446. ];
  447. $data=$this->request->request($url,$this->GetParam($param));
  448. return $this->ReturnData($data);
  449. }
  450. //同步商品信息接口
  451. /**
  452. * @param string $seller_id
  453. * @param string $invoiceType
  454. * @param string $invoiceCode
  455. * @param string $invoiceNumber
  456. * @param string $cancelType
  457. * @param string $cancelText
  458. * @return array|bool|float|int|mixed|\stdClass|string|null
  459. */public function DeprecateInvoices(string $seller_id='',string $invoiceType='',string $invoiceCode='',string
  460. $invoiceNumber='',string $cancelType='',string $cancelText=''){
  461. $url=$this->domain."/api/order-api/order-api/v5/DeprecateInvoices?access_token=".$this->GetToken();
  462. $param=[
  463. "XHFSBH"=>$seller_id,
  464. "FPLXDM"=>$invoiceType,
  465. "FPDM"=>$invoiceCode,
  466. "FPHM"=>$invoiceNumber,
  467. "ZFLX"=>$cancelType,
  468. "ZFYY"=>$cancelText,
  469. ];
  470. $data=$this->request->request($url,$this->GetParam($param));
  471. return $this->ReturnData($data);
  472. }
  473. //查询企业购买方信息接口
  474. /**
  475. * @param string $seller_id
  476. * @param string $invoiceNumber
  477. * @param string $invoiceCode
  478. * @return array|bool|float|int|mixed|\stdClass|string|null
  479. */public function QueryInvalidInvoice(string $seller_id='',string $invoiceNumber='',string $invoiceCode=''){
  480. $url=$this->domain."/api/order-api/order-api/v5/QueryInvalidInvoice?access_token=".$this->GetToken();
  481. $param=[
  482. "XHFSBH"=>$seller_id,
  483. "FPDM"=>$invoiceCode,
  484. "FPHM"=>$invoiceNumber,
  485. ];
  486. $data=$this->request->request($url,$this->GetParam($param));
  487. return $this->ReturnData($data);
  488. }
  489. //企业购买方信息接口
  490. /**
  491. * @param array $redTicketArr
  492. * @param array $redTicketList
  493. * @return array|bool|float|int|mixed|\stdClass|string|null
  494. */public function AllocateRedInvoiceApplication(array $redTicketArr=[],array $redTicketList=[]){
  495. $url=$this->domain."/api/order-api/order-api/v5/AllocateRedInvoiceApplication?access_token=".$this->GetToken();
  496. $param=[
  497. "HZSQDSCPC"=>$redTicketArr,
  498. "HZSQDSCZXX"=>$redTicketList,
  499. ];
  500. $data=$this->request->request($url,$this->GetParam($param));
  501. return $this->ReturnData($data);
  502. }
  503. //红字发票申请表审核结果下载(增专专用)
  504. /**
  505. * @param string $goodId
  506. * @param string $seller_id
  507. * @param string $seller_name
  508. * @param string $projectName
  509. * @param string $page
  510. * @param string $size
  511. * @return array|bool|float|int|mixed|\stdClass|string|null
  512. */public function QueryCommodityInfo(string $goodId='',string $seller_id='',string $seller_name='',string
  513. $projectName='',string $page="1",string $size=''){
  514. $url=$this->domain."/api/order-api/order-api/v5/QueryCommodityInfo?access_token=".$this->GetToken();
  515. $param=[
  516. "SPID"=>$goodId,
  517. "XHFSBH"=>$seller_id,
  518. "XHFMC"=>$seller_name,
  519. "XMMC"=>$projectName,
  520. "YS"=>$page,
  521. "GS"=>$size
  522. ];
  523. $data=$this->request->request($url,$this->GetParam($param));
  524. return $this->ReturnData($data);
  525. }
  526. //为生成动态二维码接口,用于扫码开票二维码生成,暂时只支持蓝字发 票,暂时只支持电子普通发票,普通发票
  527. /**
  528. * @param string $goodId
  529. * @param string $seller_id
  530. * @param string $seller_name
  531. * @param string $catCode
  532. * @param string $goodCode
  533. * @param string $discountFlag
  534. * @param string $zeroRateFlag
  535. * @param string $addTaxM
  536. * @param string $projectName
  537. * @param string $spec
  538. * @param string $unit
  539. * @param string $price
  540. * @return array|bool|float|int|mixed|\stdClass|string|null
  541. */public function SyncCommodityInfo(string $goodId='',string $seller_id='',string $seller_name='',string
  542. $catCode='',string $goodCode="",string $discountFlag='', string $zeroRateFlag='',string $addTaxM='',string
  543. $projectName='',string $spec='',string $unit='',string $price=''){
  544. $url=$this->domain."/api/order-api/order-api/v5/SyncCommodityInfo?access_token=".$this->GetToken();
  545. $param=[
  546. "SPID"=>$goodId,
  547. "XHFSBH"=>$seller_id,
  548. "XHFMC"=>$seller_name,
  549. "XMMC"=>$projectName,
  550. "SPBM"=>$catCode,
  551. "ZXBM"=>$goodCode,
  552. "YHZCBS"=>$discountFlag,
  553. "LSLBS"=>$zeroRateFlag,
  554. "ZZSTSGL"=>$addTaxM,
  555. "GGXH"=>$spec,
  556. "DW"=>$unit,
  557. "DJ"=>$price,
  558. ];
  559. $data=$this->request->request($url,$this->GetParam($param));
  560. return $this->ReturnData($data);
  561. }
  562. //f发票信息查验
  563. /**
  564. * @param string $buyerCode
  565. * @param string $buyer_id
  566. * @param string $seller_id
  567. * @param string $buyer_name
  568. * @param string $seller_name
  569. * @param string $page
  570. * @param string $size
  571. * @return array|bool|float|int|mixed|\stdClass|string|null
  572. */public function queryBuyerInfo(string $buyerCode='',string $buyer_id='',string $seller_id='',string $buyer_name='',
  573. string $seller_name='',string $page='',string $size=''){
  574. $url=$this->domain."/api/order-api/order-api/v5/queryBuyerInfo?access_token=".$this->GetToken();
  575. $param=[
  576. "XHFSBH"=>$seller_id,
  577. "XHFMC"=>$seller_name,
  578. "GMFBM"=>$buyerCode,
  579. "GMFSBH"=>$buyer_id,
  580. "GMFMC"=>$buyer_name,
  581. "YS"=>$page,
  582. "GS"=>$size,
  583. ];
  584. $data=$this->request->request($url,$this->GetParam($param));
  585. return $this->ReturnData($data);
  586. }
  587. //异步批量发票查验
  588. /**
  589. * @param string $buyerCode
  590. * @param string $buyer_id
  591. * @param string $seller_id
  592. * @param string $buyer_name
  593. * @param string $seller_name
  594. * @param string $buyer_type
  595. * @param string $buyer_addr
  596. * @param string $buyer_tel
  597. * @param string $buyer_bank
  598. * @param string $buyer_bankNo
  599. * @param string $buyer_email
  600. * @param string $buyer_mobile
  601. * @param string $actionType
  602. * @param string $remark
  603. * @return array|bool|float|int|mixed|\stdClass|string|null
  604. */public function SyncBuyerInfo(string $buyerCode='',string $buyer_id='',string $seller_id='',string $buyer_name='',
  605. string $seller_name='',string $buyer_type='',string $buyer_addr='',string $buyer_tel='',string $buyer_bank='',
  606. string $buyer_bankNo='',string $buyer_email='',string $buyer_mobile='',string $actionType='',string $remark=''){
  607. $url=$this->domain."/api/order-api/order-api/v5/SyncBuyerInfo?access_token=".$this->GetToken();
  608. $param=[
  609. "XHFSBH"=>$seller_id,
  610. "XHFMC"=>$seller_name,
  611. "GMFBM"=>$buyerCode,
  612. "GMFSBH"=>$buyer_id,
  613. "GMFMC"=>$buyer_name,
  614. "GMFLX"=>$buyer_type,
  615. "GMFDZ"=>$buyer_addr,
  616. "GMFDH"=>$buyer_tel,
  617. "GMFYH"=>$buyer_bank,
  618. "GMFZH"=>$buyer_bankNo,
  619. "GMFYX"=>$buyer_email,
  620. "GMFSJH"=>$buyer_mobile,
  621. "CZLX"=>$actionType,
  622. "BZ"=>$remark,
  623. ];
  624. $data=$this->request->request($url,$this->GetParam($param));
  625. return $this->ReturnData($data);
  626. }
  627. //批量发票查验结果
  628. /**
  629. * @param string $resultBatchNum
  630. * @param string $idCard
  631. * @param string $invoiceType
  632. * @param string $start
  633. * @param string $end
  634. * @param string $buyer_id
  635. * @param string $seller_id
  636. * @param string $infoCode
  637. * @param string $downScope
  638. * @param string $page
  639. * @param string $size
  640. * @return array|bool|float|int|mixed|\stdClass|string|null
  641. */public function DownloadRedInvoiceApplicationResult(string $resultBatchNum='',string $idCard='',string
  642. $invoiceType='',string $start='',string $end='',string $buyer_id='',string $seller_id='',string $infoCode='',
  643. string $downScope='0',string $page='1',string $size='10'){
  644. $url=$this->domain."/api/order-api/order-api/v5/DownloadRedInvoiceApplicationResult?access_token=".$this->GetToken();
  645. $param=[
  646. "SQBXZQQPCH"=>$resultBatchNum,
  647. "NSRSBH"=>$idCard,
  648. "FPLXDM"=>$invoiceType,
  649. "TKRQQ"=>$start,
  650. "TKRQZ"=>$end,
  651. "GMFSBH"=>$buyer_id,
  652. "XHFSBH"=>$seller_id,
  653. "XXBBH"=>$infoCode,
  654. "XXBFW"=>$downScope,
  655. "YS"=>$page,
  656. "GS"=>$size
  657. ];
  658. $data=$this->request->request($url,$this->GetParam($param));
  659. return $this->ReturnData($data);
  660. }
  661. /**
  662. * @param array $invInfo
  663. * @param array $invGoodList
  664. * @return array|bool|float|int|mixed|\stdClass|string|null
  665. */public function GenerateDynamicCode(array $invInfo=[],array $invGoodList=[]){
  666. $url=$this->domain."/api/order-api/order-api/v5/GenerateDynamicCode?access_token=".$this->GetToken();
  667. $param=[
  668. "DDTXX"=>$invInfo,
  669. "DDMXXX"=>$invGoodList
  670. ];
  671. $data=$this->request->request($url,$this->GetParam($param));
  672. return $this->ReturnData($data);
  673. }
  674. /**
  675. * @param string $checkCode
  676. * @param string $invSubtotal
  677. * @param string $invoiceCode
  678. * @param string $invoiceNumber
  679. * @param string $issueDate
  680. * @param string $invType
  681. * @return array|bool|float|int|mixed|\stdClass|string|null
  682. */public function CheckInvoiceSingle(string $checkCode='',string $invSubtotal='',string $invoiceCode='',string
  683. $invoiceNumber='',string $issueDate='',string $invType=''){
  684. $url=$this->domain."/api/open-recipt/V1/CheckInvoiceSingle?access_token=".$this->GetToken();
  685. $param=[
  686. "jym"=>$checkCode,
  687. "fpje"=>$invSubtotal,
  688. "fpdm"=>$invoiceCode,
  689. "kprq"=>$issueDate,
  690. "fphm"=>$invoiceNumber,
  691. "fpzl"=>$invType,
  692. ];
  693. $data=$this->request->request($url,$this->GetParam($param));
  694. return $this->ReturnData($data);
  695. }
  696. /**
  697. * @param string $batchNum
  698. * @param array $invoiceList
  699. * @return array|bool|float|int|mixed|\stdClass|string|null
  700. */public function MultilCheckInvoice(string $batchNum='',array $invoiceList=[]){
  701. $url=$this->domain."/api/open-recipt/V1/MultilCheckInvoice?access_token=".$this->GetToken();
  702. $param=[
  703. "pch"=>$batchNum,
  704. "invoiceList"=>$invoiceList
  705. ];
  706. $data=$this->request->request($url,$this->GetParam($param));
  707. return $this->ReturnData($data);
  708. }
  709. /**
  710. * @param string $batchNum
  711. * @return array|bool|float|int|mixed|\stdClass|string|null
  712. */public function BatchGetInvoice(string $batchNum=''){
  713. $url=$this->domain."/api/open-recipt/V1/BatchGetInvoice?access_token=".$this->GetToken();
  714. $param=[
  715. "pch"=>$batchNum
  716. ];
  717. $data=$this->request->request($url,$this->GetParam($param));
  718. return $this->ReturnData($data);
  719. }
  720. //全票面采集
  721. /**
  722. * @param string $entCode
  723. */public function setentCode($entCode=''){
  724. $this->entCode=$entCode;
  725. }
  726. /**
  727. * @param string $buyer_id 购方税号
  728. * @param string $invtype 发票类型 增值税专用发票:01 机动车销售统一发票:03 增值税电子专用发票:08 通行费电子发票:14 电子发票(增值税专用发票): 31
  729. * @param string $batchNum 批次号 32 位.代表一次请求,每次请 求批次号不重复。如果数据一 次性获取完成,批次号需要更 换。如果一次性数据获取不完, 批次号需保持一致。
  730. * @param string $start 发票采集开始时间 20170101140245
  731. * @param string $end 发票采集结束时间 20170101140245
  732. * @param int $page 开始行数
  733. * @param string $status 状态 1继续请求 0结束请求
  734. * @param string $size 每次请求数量
  735. */
  736. public function getInvoice(string $buyer_id='',string $invtype="",string $batchNum='',string $start='',string
  737. $end='',int $page=1,string $status='',string $size=''){
  738. $url=$this->domain."/api/dxhy-open-income/v1/getInvoice?access_token=".$this->GetToken();
  739. $param = [
  740. "GMFSBH"=>$buyer_id,
  741. "FPLXDM"=>$invtype,
  742. "PCH"=>$batchNum,
  743. "CJKSRQ"=>$start,
  744. "CJJSRQ"=>$end,
  745. "KSHS"=>$page,
  746. "ZTBZ"=>$status,
  747. "FHHS"=>$size
  748. ];
  749. $data=$this->request->request($url,$this->GetParam($param));
  750. return $this->ReturnData($data);
  751. }}