123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803 |
- <?php
- use think\facade\Cache;
- class Rmethod{
- public $header;
- public $method;
- public $body;
- public $url;
- public $timeout=5;
- public function __construct(){
- $this->header=["Content-Type"=>"application/json"];
- }
- /**
- * @return mixed
- */
- public function getBody(){
- return $this->body;
- }
- /**
- * @param mixed $body
- */
- public function setBody($body){
- $this->body = $body;
- }
- /**
- * @param mixed $method
- */
- public function setMethod($method){
- $this->method = $method;
- }
- /**
- * @param mixed $url
- */
- public function setUrl($url){
- $this->url = $url;
- }
- /**
- * @param mixed $header
- */
- public function setHeader($header){
- $this->header = $header;
- }
- /**
- * @param string $url
- * @param array $body
- * @param string $method
- * @return bool|string
- */
- public function request($url='',$body=[],$method=""){
- !empty($body)?$this->body=$body:"";
- $url!=""?$this->url=$url:"";
- $this->method= $method!=""?$method:"post";
- $data=$this->curlmothod();
- return json_decode($data,true);
- }
- protected function curlmothod() {
- //⽀持json数据数据提交
- $post_string =$this->checkBody();
- $header=$this->checkHeader();
- $URL = strtolower($this->method)=="get" && !empty($post_data) ? $this->url."?".$post_string :$this->url;
- $ch = curl_init(); // 启动⼀个CURL会话
- curl_setopt($ch, CURLOPT_URL, $URL); // 要访问的地址
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查 // https请求不验证证书和hosts
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 // 模拟⽤户使⽤的浏览器
- if(strtolower($this->method)=="post"){
- curl_setopt($ch, CURLOPT_POST, true); // 发送⼀个常规的Post请求
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); // Post提交的数据包
- }
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout); // 设置超时限制防⽌死循环
- curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 获取的信息以⽂件流的形式返回
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //模拟的header头
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- public function checkHeader(){
- if (!empty($this->header)){
- $temp=[];
- foreach ($this->header as $key=>$value){
- $temp[]=$key.":".$value;
- }
- return $temp;
- }
- return[];
- }
- public function checkBody(){
- if (!empty($this->body)){
- $body = http_build_query($this->body);
- if(key_exists("Content-Type",$this->header) && $this->header['Content-Type']=="application/json"){
- $body =json_encode($this->body);
- }
- return $body;
- }
- return'';
- }
- }
- class TaxInvoice {
- protected $appKey;
- protected $appSecret;
- protected $request;
- protected $entCode;//企业税号
- protected $zipCode;//压缩标识
- protected $encryptCode;//加密标识 0 base64 1 3DES
- protected $domain='https://openapi.ele-cloud.com';//正式域名
- #protected $domain='https://sandbox.ele-cloud.com';//测试域名
- public function __construct(string $appKey,string $appSecret,string $entCode='',$zipCode=0,$encryptCode=0){
- $this->appKey=$appKey;
- $this->appSecret=$appSecret;
- $this->entCode=$entCode;
- $this->zipCode=$zipCode;
- $this->encryptCode=$encryptCode;
- \think\facade\Log::info("appkey:{$appKey} appSecret:{$appSecret} entCode:{$entCode} ");
- $this->request=new Rmethod();
- }
- /** * 年月日、时分秒 + 3位毫秒数
- * @param string $format
- * @param null $utimestamp
- * @return false|string */
- public function ts_time($format = 'u', $utimestamp = null)
- { if (is_null($utimestamp)){ $utimestamp = microtime(true); }
- $timestamp = floor($utimestamp);
- $milliseconds = round(($utimestamp - $timestamp) * 1000);
- return str_pad(date("YmdHis").$milliseconds,17,"0",STR_PAD_RIGHT);
- }
- /**
- * @param string $buyer_id
- * @param string $batchNum
- * @param string $start
- * @param string $end
- * @param string $status
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function getMainInvoice(string $buyer_id='',string $batchNum='',string $start='',string
- $end='',string $status=''){
- $url=$this->domain."/api/dxhy-open-income/v1/getMainInvoice?access_token=".$this->GetToken();
- $param = [
- "GMFSBH"=>$buyer_id,
- "PCH"=>$batchNum,
- "CJKSRQ"=>$start,
- "CJJSRQ"=>$end,
- "ZTBZ"=>$status,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param int $refresh
- * @return mixed|string
- */public function GetToken($refresh=0){
- $token = Cache::store("redis2")->get("TAXToken".$this->entCode);
- if($token==false || $refresh==1){
- $result=$this->auth();
- \think\facade\Log::info("参数:".json_encode($result,JSON_UNESCAPED_UNICODE));
- if(key_exists("access_token",$result) && $result['access_token']!=''){
- Cache::store('redis2')->set("TAXToken".$this->entCode,$result['access_token'],$result['expires_in']);
- $token=$result['access_token'];
- }
- }
- return $token;
- }
- /**
- * @return bool|string
- */public function auth(){
- $uri=$this->domain."/api/authen/token";
- $param=["appKey"=>$this->appKey,"appSecret"=>$this->appSecret];
- $result=$this->request->request($url=$uri,$body=$param,$method="post");
- return $result;
- }
- /**
- * @param $data
- * @return array
- */public function GetParam($data){
- $func=debug_backtrace();
- $dataEXchangeId =str_pad($this->ts_time().rand(pow(10,14),pow(10,15)-1),32,'0');
- while(strlen($dataEXchangeId)!=32){
- $dataEXchangeId =str_pad($this->ts_time().rand(pow(10,14),pow(10,15)-1),32,'0');
- }
- $param=[
- "zipCode"=>$this->zipCode,
- "entCode"=>$this->entCode,
- "encryptCode"=>$this->encryptCode,
- "dataExchangeId"=>$dataEXchangeId,
- "content"=>base64_encode(json_encode($data,JSON_UNESCAPED_UNICODE))
- ];
- \think\facade\Log::info("接口:".$func[1]['function']);
- \think\facade\Log::info("参数:".json_encode($data,JSON_UNESCAPED_UNICODE));
- \think\facade\Log::info("dataExchangeId:".$param['dataExchangeId']);
- return $param;
- }
- /**
- * @param $data
- * @return array|bool|float|int|mixed|stdClass|string|null
- */public function ReturnData($data){
- $return =["code"=>0,"message"=>"fail"];
- if(key_exists("returnCode",$data['returnStateInfo'])){
- if ($data['returnStateInfo']['returnCode']=='0000'){
- $result= base64_decode($data['content']);
- $return = json_decode($result,true);
- }else{
- if($data['returnStateInfo']['returnCode']=='9110'){
- $this->GetToken(1);
- }
- $returnMessage= base64_decode($data['returnStateInfo']['returnMessage']);
- $return =["code"=>$data['returnStateInfo']['returnCode'],"message"=>$returnMessage];
- }
- }
- \think\facade\Log::info("返回值:".json_encode($return,JSON_UNESCAPED_UNICODE));
- return $return;
- }
- /**
- * @param string $buyer_id
- * @param string $batchNum
- * @param string $start
- * @param string $end
- * @param string $status
- * @param int $num
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function getInvoiceState(string $buyer_id='',string $batchNum='',string $start='',string
- $end='',string $status='',int $num=1){
- $url=$this->domain."/api/dxhy-open-income/v1/getInvoiceState?access_token=".$this->GetToken();
- $param = [
- "GMFSBH"=>$buyer_id,
- "PCH"=>$batchNum,
- "ZTBGKSRQ"=>$start,
- "ZTBGJSRQ"=>$end,
- "ZTBZ"=>$status,
- "KSHS"=>$num,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $buyer_id
- * @param int $total
- * @param string $batchNum
- * @param array $invArr [{invoiceCode:'',invoiceNumber:'',invoiceType:'',inv_subtotal_amount:'',opentime:'',
- * buyer_id:'',reason:''}]
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function applyLegalize(string $buyer_id='',int $total=0,string $batchNum='',array $invArr=[]){
- $url=$this->domain."/api/dxhy-open-income/v1/applyLegalize?access_token=".$this->GetToken();
- $temp=[];
- if(!empty($invArr)){
- foreach ($invArr as $value){
- $data=[];
- $data['FPDM']=$value['invoiceCode'];
- $data['FPHM']=$value['invoiceNumber'];
- $data['YXSE']=$value['inv_subtotal_amount'];
- $data['SQSKSSQ']=$value['opentime'];
- $data['GMFSBH']=$value['buyer_id'];
- $data['FPLXDM']=$value['invoiceType'];
- $data['BDKYY']=$value['reason']??'';
- $temp[]=$data;
- }
- }
- $param = [
- "GMFSBH"=>$buyer_id,
- "PCH"=>$batchNum,
- "FHHS"=>$total,
- "FPZHXX"=>$temp,
- ];
- // "FPDM":"3100174130", "FPHM":"08975555", "GMFSBH":"91110104444324CP321", "SQRZLX":"1", "FPLXDM":"01",
- // "SQSKSSQ":"202005", "YXSE":"200", "BDKYY":
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $batchNum
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function applyLegalizeResult(string $batchNum=''){
- $url=$this->domain."/api/dxhy-open-income/v1/applyLegalizeResult?access_token=".$this->GetToken();
- $param = ["PCH"=>$batchNum];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $buyer_id
- * @param string $period
- * @return array|bool|float|int|mixed|stdClass|string|null
- */public function getCountInfo(string $buyer_id='',string $period=''){
- $url=$this->domain."/api/dxhy-open-income/v1/getCountInfo?access_token=".$this->GetToken();
- $param = [
- "GMFSBH"=>$buyer_id,
- "RZSKSSQ"=>$period,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $buyer_id
- * @param string $period
- * @param string $batchNum
- * @param string $statisFlag
- * @return array|bool|float|int|mixed|stdClass|string|null
- */public function applyCount(string $buyer_id='',string $period='',string $batchNum='',string $statisFlag=''){
- $url=$this->domain."/api/dxhy-open-income/v1/applyCount?access_token=".$this->GetToken();
- $param = [
- "GMFSBH"=>$buyer_id,
- "RZSKSSQ"=>$period,
- "TJBZ"=>$statisFlag,
- "PCH"=>$batchNum
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $buyer_id
- * @param string $batchNum
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function applyCountResult(string $buyer_id='',string $batchNum=''){
- $url=$this->domain."/api/dxhy-open-income/v1/applyCountResult?access_token=".$this->GetToken();
- $param = [
- "GMFSBH"=>$buyer_id,
- "PCH"=>$batchNum
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $buyer_id
- * @param string $batchNum
- * @param string $ack
- * @param string $statisTime
- * @param string $period
- * @param string $confirm_passwd
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function applyConfirm(string $buyer_id='',string $batchNum='',string $ack='',string $statisTime='',string
- $period='',string $confirm_passwd=''){
- $url=$this->domain."/api/dxhy-open-income/v1/applyConfirm?access_token=".$this->GetToken();
- $param = [
- "GMFSBH"=>$buyer_id,
- "PCH"=>$batchNum,
- "QRBZ"=>$ack,
- "TJSJ"=>$statisTime,
- "RZSKSSQ"=>$period,
- "QRMM"=>$confirm_passwd,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $buyer_id
- * @param string $batchNum
- * @param string $ack
- * @param string $statisTime
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function applyConfirmResult(string $buyer_id='',string $batchNum='',string $ack='',string $statisTime=''){
- $url=$this->domain."/api/dxhy-open-income/v1/applyConfirmResult?access_token=".$this->GetToken();
- $param = [
- "GMFSBH"=>$buyer_id,
- "PCH"=>$batchNum,
- "QRBZ"=>$ack,
- "TJSJ"=>$statisTime,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $idCard
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function getCompanyInfo(string $idCard=''){
- $url=$this->domain."/api/dxhy-open-income/v1/getCompanyInfo?access_token=".$this->GetToken();
- $param = [
- "SBH"=>$idCard,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $idCard
- * @param string $confirm_passwd
- * @param string $new_passwd
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function setPassword(string $idCard='',string $confirm_passwd='',string $new_passwd=''){
- $url=$this->domain."/api/dxhy-open-income/v1/setPassword?access_token=".$this->GetToken();
- $param = [
- "SBH"=>$idCard,
- "YWMM"=>$confirm_passwd,
- "NEWYWMM"=>$new_passwd,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $idCard
- * @return array|bool|float|int|mixed|stdClass|string|null
- */
- public function resetPassword(string $idCard=''){
- $url=$this->domain."/api/dxhy-open-income/v1/resetPassword?access_token=".$this->GetToken();
- $param = [
- "SBH"=>$idCard
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param array $OrderBatchArr
- * @param array $OrderInvList
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function GenerateInvoice(array $OrderBatchArr=[], array $OrderInvList=[]){
- $url=$this->domain."/api/order-api/order-api/v5/GenerateInvoice?access_token=".$this->GetToken();
- $param = [
- "DDPCXX"=>$OrderBatchArr,
- "DDZXX"=>$OrderInvList
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //{"HZSQDSCPC":{"SQBSCQQPCH":"申请表上传请求批次号","NSRSBH":"申请方纳税人识别号","KPZD":"开票终端","FPLXDM":"发票类型代码","KZZD":"扩展字段"},
- //"HZSQDSCZXX":[
- //{"HZSQDTXX":{"SQBSCQQLSH":"申请表上传请求流水号","YYSBZ":"营业税标志","XXBLX":"信息表类型","YFPDM":"原蓝字发票代码","YFPHM":"原蓝字发票号码","YFPKPRQ":"原蓝字发票开票日期","TKSJ":"填开时间",
- //"XHFSBH":"销货方纳税人识别","XHFMC":"销货方纳税人名称","GMFSBH":"购买方纳税人识别号","GMFMC":"购买方纳税人名称","HJJE":"合计金额(带负号,不含税) ","HJSE":"合计税额(带负号)","SQSM":"申请说明",
- //"XXBTSBS":"信息表特殊标识","KZZD1":"扩展字段 1","KZZD2":"扩展字段 2"},"DDMXXX":[{"XH":"项目序号","FPHXZ":"发票行性质","SPBM":"商品编码","ZXBM":"自行编码","YHZCBS":"优惠政策标识",
- //"LSLBS":"零税率标识","ZZSTSGL":"增值税特殊管理","XMMC":"项目名称","GGXH":"规格型号","DW":"单位","SPSL":"商品数量","DJ":"单价","JE":"金额","HSBZ":"含税标志,固定不含税","SL":"税率","SE":"税额",
- //"KCE":"扣除额"}]}]}
- /**
- * @param string $idCard 纳税人识别号
- * @param string $OrderBatchNum 开票申请批次号
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */
- public function GetAllocatedInvoices(string $idCard='',string $OrderBatchNum=''){
- $url=$this->domain."/api/order-api/order-api/v5/GetAllocatedInvoices?access_token=".$this->GetToken();
- $param = [
- "NSRSBH"=>$idCard,
- "DDQQPCH"=>$OrderBatchNum
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $idCard 纳税人识别号
- * @param string $OrderSerialNum 流水号
- * @param string $extraCode 提取码
- * @param string $orderCode 订单号
- * @param string $isFile 是否版式文件 0需要1 不需要
- * @param string $orderStart 订单日期起始
- * @param string $orderEnd 订单日期终止
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function GetOrderInfoAndInvoiceInfo(string $idCard='',string $OrderSerialNum='',string $extraCode='',string
- $orderCode='',string $isFile="",string $orderStart='',string $orderEnd=''){
- $url=$this->domain."/api/order-api/order-api/v5/GetOrderInfoAndInvoiceInfo?access_token=".$this->GetToken();
- $param = [
- "NSRSBH"=>$idCard,
- "DDQQLSH"=>$OrderSerialNum,
- "TQM"=>$extraCode,
- "DDH"=>$orderCode,
- "BSWJ"=>$isFile,
- "DDRQQ"=>$orderStart,
- "DDRQZ"=>$orderEnd,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //同步商品信息接口
- /**
- * @param string $seller_id
- * @param string $invoiceType
- * @param string $invoiceCode
- * @param string $invoiceNumber
- * @param string $cancelType
- * @param string $cancelText
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function DeprecateInvoices(string $seller_id='',string $invoiceType='',string $invoiceCode='',string
- $invoiceNumber='',string $cancelType='',string $cancelText=''){
- $url=$this->domain."/api/order-api/order-api/v5/DeprecateInvoices?access_token=".$this->GetToken();
- $param=[
- "XHFSBH"=>$seller_id,
- "FPLXDM"=>$invoiceType,
- "FPDM"=>$invoiceCode,
- "FPHM"=>$invoiceNumber,
- "ZFLX"=>$cancelType,
- "ZFYY"=>$cancelText,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //查询企业购买方信息接口
- /**
- * @param string $seller_id
- * @param string $invoiceNumber
- * @param string $invoiceCode
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function QueryInvalidInvoice(string $seller_id='',string $invoiceNumber='',string $invoiceCode=''){
- $url=$this->domain."/api/order-api/order-api/v5/QueryInvalidInvoice?access_token=".$this->GetToken();
- $param=[
- "XHFSBH"=>$seller_id,
- "FPDM"=>$invoiceCode,
- "FPHM"=>$invoiceNumber,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //企业购买方信息接口
- /**
- * @param array $redTicketArr
- * @param array $redTicketList
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function AllocateRedInvoiceApplication(array $redTicketArr=[],array $redTicketList=[]){
- $url=$this->domain."/api/order-api/order-api/v5/AllocateRedInvoiceApplication?access_token=".$this->GetToken();
- $param=[
- "HZSQDSCPC"=>$redTicketArr,
- "HZSQDSCZXX"=>$redTicketList,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //红字发票申请表审核结果下载(增专专用)
- /**
- * @param string $goodId
- * @param string $seller_id
- * @param string $seller_name
- * @param string $projectName
- * @param string $page
- * @param string $size
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function QueryCommodityInfo(string $goodId='',string $seller_id='',string $seller_name='',string
- $projectName='',string $page="1",string $size=''){
- $url=$this->domain."/api/order-api/order-api/v5/QueryCommodityInfo?access_token=".$this->GetToken();
- $param=[
- "SPID"=>$goodId,
- "XHFSBH"=>$seller_id,
- "XHFMC"=>$seller_name,
- "XMMC"=>$projectName,
- "YS"=>$page,
- "GS"=>$size
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //为生成动态二维码接口,用于扫码开票二维码生成,暂时只支持蓝字发 票,暂时只支持电子普通发票,普通发票
- /**
- * @param string $goodId
- * @param string $seller_id
- * @param string $seller_name
- * @param string $catCode
- * @param string $goodCode
- * @param string $discountFlag
- * @param string $zeroRateFlag
- * @param string $addTaxM
- * @param string $projectName
- * @param string $spec
- * @param string $unit
- * @param string $price
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function SyncCommodityInfo(string $goodId='',string $seller_id='',string $seller_name='',string
- $catCode='',string $goodCode="",string $discountFlag='', string $zeroRateFlag='',string $addTaxM='',string
- $projectName='',string $spec='',string $unit='',string $price=''){
- $url=$this->domain."/api/order-api/order-api/v5/SyncCommodityInfo?access_token=".$this->GetToken();
- $param=[
- "SPID"=>$goodId,
- "XHFSBH"=>$seller_id,
- "XHFMC"=>$seller_name,
- "XMMC"=>$projectName,
- "SPBM"=>$catCode,
- "ZXBM"=>$goodCode,
- "YHZCBS"=>$discountFlag,
- "LSLBS"=>$zeroRateFlag,
- "ZZSTSGL"=>$addTaxM,
- "GGXH"=>$spec,
- "DW"=>$unit,
- "DJ"=>$price,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //f发票信息查验
- /**
- * @param string $buyerCode
- * @param string $buyer_id
- * @param string $seller_id
- * @param string $buyer_name
- * @param string $seller_name
- * @param string $page
- * @param string $size
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function queryBuyerInfo(string $buyerCode='',string $buyer_id='',string $seller_id='',string $buyer_name='',
- string $seller_name='',string $page='',string $size=''){
- $url=$this->domain."/api/order-api/order-api/v5/queryBuyerInfo?access_token=".$this->GetToken();
- $param=[
- "XHFSBH"=>$seller_id,
- "XHFMC"=>$seller_name,
- "GMFBM"=>$buyerCode,
- "GMFSBH"=>$buyer_id,
- "GMFMC"=>$buyer_name,
- "YS"=>$page,
- "GS"=>$size,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //异步批量发票查验
- /**
- * @param string $buyerCode
- * @param string $buyer_id
- * @param string $seller_id
- * @param string $buyer_name
- * @param string $seller_name
- * @param string $buyer_type
- * @param string $buyer_addr
- * @param string $buyer_tel
- * @param string $buyer_bank
- * @param string $buyer_bankNo
- * @param string $buyer_email
- * @param string $buyer_mobile
- * @param string $actionType
- * @param string $remark
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function SyncBuyerInfo(string $buyerCode='',string $buyer_id='',string $seller_id='',string $buyer_name='',
- string $seller_name='',string $buyer_type='',string $buyer_addr='',string $buyer_tel='',string $buyer_bank='',
- string $buyer_bankNo='',string $buyer_email='',string $buyer_mobile='',string $actionType='',string $remark=''){
- $url=$this->domain."/api/order-api/order-api/v5/SyncBuyerInfo?access_token=".$this->GetToken();
- $param=[
- "XHFSBH"=>$seller_id,
- "XHFMC"=>$seller_name,
- "GMFBM"=>$buyerCode,
- "GMFSBH"=>$buyer_id,
- "GMFMC"=>$buyer_name,
- "GMFLX"=>$buyer_type,
- "GMFDZ"=>$buyer_addr,
- "GMFDH"=>$buyer_tel,
- "GMFYH"=>$buyer_bank,
- "GMFZH"=>$buyer_bankNo,
- "GMFYX"=>$buyer_email,
- "GMFSJH"=>$buyer_mobile,
- "CZLX"=>$actionType,
- "BZ"=>$remark,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //批量发票查验结果
- /**
- * @param string $resultBatchNum
- * @param string $idCard
- * @param string $invoiceType
- * @param string $start
- * @param string $end
- * @param string $buyer_id
- * @param string $seller_id
- * @param string $infoCode
- * @param string $downScope
- * @param string $page
- * @param string $size
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function DownloadRedInvoiceApplicationResult(string $resultBatchNum='',string $idCard='',string
- $invoiceType='',string $start='',string $end='',string $buyer_id='',string $seller_id='',string $infoCode='',
- string $downScope='0',string $page='1',int $size=10){
- $url=$this->domain."/api/order-api/order-api/v5/DownloadRedInvoiceApplicationResult?access_token=".$this->GetToken();
- $param=[
- "SQBXZQQPCH"=>$resultBatchNum,
- "NSRSBH"=>$idCard,
- "FPLXDM"=>$invoiceType,
- "TKRQQ"=>$start,
- "TKRQZ"=>$end,
- "GMFSBH"=>$buyer_id,
- "XHFSBH"=>$seller_id,
- "XXBBH"=>$infoCode,
- "XXBFW"=>$downScope,
- "YS"=>$page,
- "GS"=>$size
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param array $invInfo
- * @param array $invGoodList
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function GenerateDynamicCode(array $invInfo=[],array $invGoodList=[]){
- $url=$this->domain."/api/order-api/order-api/v5/GenerateDynamicCode?access_token=".$this->GetToken();
- $param=[
- "DDTXX"=>$invInfo,
- "DDMXXX"=>$invGoodList
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $checkCode
- * @param string $invSubtotal
- * @param string $invoiceCode
- * @param string $invoiceNumber
- * @param string $issueDate
- * @param string $invType
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function CheckInvoiceSingle(string $checkCode='',string $invSubtotal='',string $invoiceCode='',string
- $invoiceNumber='',string $issueDate='',string $invType=''){
- $url=$this->domain."/api/open-recipt/V1/CheckInvoiceSingle?access_token=".$this->GetToken();
- $param=[
- "jym"=>$checkCode,
- "fpje"=>$invSubtotal,
- "fpdm"=>$invoiceCode,
- "kprq"=>$issueDate,
- "fphm"=>$invoiceNumber,
- "fpzl"=>$invType,
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $batchNum
- * @param array $invoiceList
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function MultilCheckInvoice(string $batchNum='',array $invoiceList=[]){
- $url=$this->domain."/api/open-recipt/V1/MultilCheckInvoice?access_token=".$this->GetToken();
- $param=[
- "pch"=>$batchNum,
- "invoiceList"=>$invoiceList
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- /**
- * @param string $batchNum
- * @return array|bool|float|int|mixed|\stdClass|string|null
- */public function BatchGetInvoice(string $batchNum=''){
- $url=$this->domain."/api/open-recipt/V1/BatchGetInvoice?access_token=".$this->GetToken();
- $param=[
- "pch"=>$batchNum
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }
- //全票面采集
- /**
- * @param string $entCode
- */public function setentCode($entCode=''){
- $this->entCode=$entCode;
- }
-
- /**
- * @param string $buyer_id 购方税号
- * @param string $invtype 发票类型 增值税专用发票:01 机动车销售统一发票:03 增值税电子专用发票:08 通行费电子发票:14 电子发票(增值税专用发票): 31
- * @param string $batchNum 批次号 32 位.代表一次请求,每次请 求批次号不重复。如果数据一 次性获取完成,批次号需要更 换。如果一次性数据获取不完, 批次号需保持一致。
- * @param string $start 发票采集开始时间 20170101140245
- * @param string $end 发票采集结束时间 20170101140245
- * @param int $page 开始行数
- * @param string $status 状态 1继续请求 0结束请求
- * @param string $size 每次请求数量
- */
- public function getInvoice(string $buyer_id='',string $invtype="",string $batchNum='',string $start='',string
- $end='',int $page=1,string $status='',string $size=''){
- $url=$this->domain."/api/dxhy-open-income/v1/getInvoice?access_token=".$this->GetToken();
- $param = [
- "GMFSBH"=>$buyer_id,
- "FPLXDM"=>$invtype,
- "PCH"=>$batchNum,
- "CJKSRQ"=>$start,
- "CJJSRQ"=>$end,
- "KSHS"=>$page,
- "ZTBZ"=>$status,
- "FHHS"=>$size
- ];
- $data=$this->request->request($url,$this->GetParam($param));
- return $this->ReturnData($data);
- }}
|