setBatchId("100000100078"); $req->setGoods("1"); $req->setInvoiceContent("1"); $req->setInvoiceState("1"); $req->setInvoiceTo("1"); $req->setInvoiceType("1"); $req->setOrderType("1"); $req->setPayment("08"); $skuQuantityList = new SkuQuantityList(); $skuQuantityList->setNum("2"); $skuQuantityList->setSku("121347657"); $receiveInfoList = new ReceiveInfoList(); $receiveInfoList->setAddress("江苏省南京市雨花区软件大道舜天集团"); $receiveInfoList->setCityId("025"); $receiveInfoList->setCountryId("01"); $receiveInfoList->setEmail("xxx@xxx.com"); $receiveInfoList->setMobile("17856789012"); $receiveInfoList->setProvinceId("100"); $receiveInfoList->setReceiverName("张飞"); $receiveInfoList->setRemark("订单备注"); $receiveInfoList->setSkuQuantityList(array($skuQuantityList)); $receiveInfoList->setTelephone("010-84728989"); $receiveInfoList->setTownId("99"); $receiveInfoList->setTradeNo("1000001"); $receiveInfoList->setZip("210000"); $req->setReceiveInfoList(array($receiveInfoList)); $skuPriceList = new SkuPriceList(); $skuPriceList->setSkuId("121347746"); $skuPriceList->setUnitPrice("12.1"); $req->setSkuPriceList(array($skuPriceList)); $specialVatTicket = new SpecialVatTicket(); $specialVatTicket->setCompanyName("苏宁易购股份有限公司"); $specialVatTicket->setConsigneeAddress("江苏省南京市秦淮区法院"); $specialVatTicket->setConsigneeMobileNum("15822222200"); $specialVatTicket->setConsigneeName("张飞"); $specialVatTicket->setRegAccount("23235254664336"); $specialVatTicket->setRegAdd("江苏省南京市玄武区苏宁大道113号"); $specialVatTicket->setRegBank("苏宁银行"); $specialVatTicket->setRegTel("18767890345"); $specialVatTicket->setTaxNo("1234567890ABCDE"); $req->setSpecialVatTicket($specialVatTicket); $req->setSubmitType("1"); //api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $req -> setCheckParam('true'); $serverUrl = "http://openpre.cnsuning.com/api/http/sopRequest"; $appKey = "a13b8bd0efb06a770c57d1c370ce8ee7"; $appSecret = "f08ce9836c4bcfc708194594081f6690"; $client = new DefaultSuningClient($serverUrl,$appKey,$appSecret,'json'); $resp = $client -> execute($req); $reqJson = getReqJson($req); print_r("请求报文:\n".$reqJson); print_r("\n返回响应报文:\n".$resp); function getReqJson($req){ $paramsArray = $req -> getApiParams(); if(empty($paramsArray)){ $paramsArray = ''; } $paramsArray = array('sn_request' => array('sn_body' => array( "{$req -> getBizName()}" => $paramsArray ))); return json_encode($paramsArray); } ?>