|
@@ -1,309 +1,311 @@
|
|
-<?php
|
|
|
|
-class Model_hualei extends Lin_Model {
|
|
|
|
-function __construct(){
|
|
|
|
- parent::__construct();
|
|
|
|
-}
|
|
|
|
-//渠道 http://123.207.33.169:8082/getProductList.htm
|
|
|
|
-//$ys = 1;//延时获取运单
|
|
|
|
- public function get_data($data)
|
|
|
|
- {
|
|
|
|
- $duty_type = '';//区分快递承担税费人的选项 DDU或DDP ddp好像是收件人承担税费
|
|
|
|
- if($data['printcode'] == "HUALEI-FEDEX")
|
|
|
|
- {
|
|
|
|
- $product_id = 6021;
|
|
|
|
- $link = 'param=';
|
|
|
|
- $ys = 0;//非延时获取运单
|
|
|
|
- }
|
|
|
|
- else if($data['printcode'] == "HUALEI-ARAMEX-G")
|
|
|
|
- {
|
|
|
|
- $product_id = 3361;
|
|
|
|
- $link = 'param=';
|
|
|
|
- $ys = 0;//非延时获取运单
|
|
|
|
- }
|
|
|
|
- else if($data['printcode'] == "HUALEI-ARAMEX-S")
|
|
|
|
- {
|
|
|
|
- $product_id = 8161;//南非
|
|
|
|
- $link = 'param=';
|
|
|
|
- $ys = 0;//非延时获取运单
|
|
|
|
- }
|
|
|
|
- else if ($data['printcode'] == "HUALEI-GES-EU")
|
|
|
|
- {
|
|
|
|
- $product_id = 4301;
|
|
|
|
- $link = 'param=';
|
|
|
|
- $ys = 0;//非延时获取运单
|
|
|
|
- if($data['printnumber'] > 0)
|
|
|
|
- {
|
|
|
|
- $data['number'] = $data['number'].'-'.($data['printnumber']+1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else if ($data['printcode'] == "HUALEI-WMS")//DPEX
|
|
|
|
- {
|
|
|
|
- $product_id = 5781;
|
|
|
|
- $link = 'param=';
|
|
|
|
- $ys = 0;//非延时获取运单
|
|
|
|
- }
|
|
|
|
- else if ($data['printcode'] == "HUALEI-DHL-A1")//TNT
|
|
|
|
- {
|
|
|
|
- $product_id = 7281;
|
|
|
|
- $link = 'param=';
|
|
|
|
- $ys = 0;//非延时获取运单
|
|
|
|
- }
|
|
|
|
- else if ($data['printcode'] == "HUALEI-DHL")//TNT
|
|
|
|
- {
|
|
|
|
- $product_id = 7141;
|
|
|
|
- $link = 'param=';
|
|
|
|
- $ys = 0;//
|
|
|
|
- $duty_type = "DDP";
|
|
|
|
- }
|
|
|
|
- else if($data['printcode'] == 'HUALEI-MLXY'){
|
|
|
|
- $product_id = 7581;
|
|
|
|
- $link = 'param=';
|
|
|
|
- $ys = 0;//
|
|
|
|
- //$duty_type = "DDP";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $rs = $this->curlRequest('http://123.207.33.169:8082/selectAuth.htm',"username=LY&password=ly999");
|
|
|
|
- $reData = json_decode(str_replace("'", "\"", $rs['result']));
|
|
|
|
- $customer_id = $reData->customer_id;
|
|
|
|
- $customer_userid = $reData->customer_userid;
|
|
|
|
-
|
|
|
|
- //$product_id = 4461; //产品id 运输方式由APT给出
|
|
|
|
- $format = 'lbl_NL_XIN.frx'; //打印类型
|
|
|
|
- $printType = 1; //打印类型
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 2, 预报订单
|
|
|
|
- */
|
|
|
|
- if($data['ioss'] != '')//如果有IOSS
|
|
|
|
- {
|
|
|
|
- //预报数据
|
|
|
|
- $count = Array(
|
|
|
|
- 'buyerid' => '',//买家ID
|
|
|
|
- 'consignee_address' => ($data['address2'] != '')?$data['address'].' '.$data['address2']:$data['address'],//地址
|
|
|
|
- 'consignee_city' => $data['city'],//城市
|
|
|
|
- 'consignee_mobile' => '',//收货人手机号 选填
|
|
|
|
- 'consignee_name' => $data['name'],//收件人
|
|
|
|
- 'trade_type' => 'ZYXT',//交易类型
|
|
|
|
- 'consignee_postcode' => $data['zipcode'],//邮编
|
|
|
|
- 'consignee_state' => $data['province'],//省/州
|
|
|
|
- 'consignee_telephone' => $data['phone'],//收货人电话 必填
|
|
|
|
- 'country' => $data['lb'],//收货人国家二字码
|
|
|
|
- 'shipper_taxno' => $data['ioss'],
|
|
|
|
- 'shipper_taxnotype'=>'IOSS',
|
|
|
|
- 'shipper_taxnocountry' => 'NL',
|
|
|
|
- 'customer_id' => $customer_id,
|
|
|
|
- 'customer_userid' => $customer_userid,
|
|
|
|
- 'orderInvoiceParam' => Array(
|
|
|
|
- '0' => Array
|
|
|
|
- (
|
|
|
|
- 'invoice_amount' => $data['zsbjz'],
|
|
|
|
- 'invoice_pcs' => $data['ts'],
|
|
|
|
- 'invoice_title' => $data['sbpm'],
|
|
|
|
- 'invoice_weight' => sprintf("%.3f",$data['zzl']/$data['ts']),//单条重量
|
|
|
|
- 'item_id' => '',
|
|
|
|
- 'item_transactionid' => '',
|
|
|
|
- 'sku' => $data['zwpm'],
|
|
|
|
- 'sku_code' => $data['zwpm'],
|
|
|
|
- 'hs_code'=> $data['hgbm'],//海关编码
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- 'order_customerinvoicecode' => $data['number'],//原单号
|
|
|
|
- 'product_id' => $product_id,
|
|
|
|
- 'weight' => 0,
|
|
|
|
- 'product_imagepath' => '',
|
|
|
|
- 'consignee_email'=>isset($data['email'])?$data['email']:'',
|
|
|
|
- 'consignee_companyname'=>$data['client'],//收件公司
|
|
|
|
- //'order_cargoamount'=>'',//订单实际金额
|
|
|
|
- //'order_insurance'=>'',//保险金额
|
|
|
|
- 'duty_type'=>$duty_type,
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- //预报数据
|
|
|
|
- $count = Array(
|
|
|
|
- 'buyerid' => '',//买家ID
|
|
|
|
- 'consignee_address' => ($data['address2'] != '')?$data['address'].' '.$data['address2']:$data['address'],//地址
|
|
|
|
- 'consignee_city' => $data['city'],//城市
|
|
|
|
- 'consignee_mobile' => '',//收货人手机号 选填
|
|
|
|
- 'consignee_name' => $data['name'],//收件人
|
|
|
|
- 'trade_type' => 'ZYXT',//交易类型
|
|
|
|
- 'consignee_postcode' => $data['zipcode'],//邮编
|
|
|
|
- 'consignee_state' => $data['province'],//省/州
|
|
|
|
- 'consignee_telephone' => $data['phone'],//收货人电话 必填
|
|
|
|
- 'country' => $data['lb'],//收货人国家二字码
|
|
|
|
- 'customer_id' => $customer_id,
|
|
|
|
- 'customer_userid' => $customer_userid,
|
|
|
|
- 'orderInvoiceParam' => Array(
|
|
|
|
- '0' => Array
|
|
|
|
- (
|
|
|
|
- 'invoice_amount' => $data['zsbjz'],
|
|
|
|
- 'invoice_pcs' => $data['ts'],
|
|
|
|
- 'invoice_title' => $data['sbpm'],
|
|
|
|
- 'invoice_weight' => sprintf("%.3f",$data['zzl']/$data['ts']),//单条重量
|
|
|
|
- 'item_id' => '',
|
|
|
|
- 'item_transactionid' => '',
|
|
|
|
- 'sku' => $data['zwpm'],
|
|
|
|
- 'sku_code' => $data['zwpm'],
|
|
|
|
- 'hs_code'=> $data['hgbm'],//海关编码
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- 'order_customerinvoicecode' => $data['number'],//原单号
|
|
|
|
- 'product_id' => $product_id,
|
|
|
|
- 'weight' => 0,
|
|
|
|
- 'product_imagepath' => '',
|
|
|
|
- 'consignee_email'=>isset($data['email'])?$data['email']:'',
|
|
|
|
- 'consignee_companyname'=>$data['client'],//收件公司
|
|
|
|
- //'order_cargoamount'=>'',//订单实际金额
|
|
|
|
- //'order_insurance'=>'',//保险金额
|
|
|
|
- 'duty_type'=>$duty_type,
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- $result = $this->curlRequest('http://123.207.33.169:8082/createOrderApi.htm',$link.json_encode($count));
|
|
|
|
- $resultData = json_decode($result['result'], true);
|
|
|
|
- if($resultData['ack'] == 'true')
|
|
|
|
- {
|
|
|
|
- //if($resultData['tracking_number'] == $resultData['reference_number'])
|
|
|
|
- if($ys == 1)
|
|
|
|
- {
|
|
|
|
- $g = array('x'=>'1','ys'=>1,'waybill'=>'');
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- $pdf = $this->get_pdf($resultData['order_id']);
|
|
|
|
- if($pdf['x'] == 1)
|
|
|
|
- {
|
|
|
|
- if($product_id == 4361)
|
|
|
|
- {
|
|
|
|
- $g = array('x'=>'1','ys'=>0,'waybill'=>$resultData['order_privatecode'],'waybill2'=>$resultData['tracking_number'],'label'=>$pdf['label']);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- $g = array('x'=>'1','ys'=>0,'waybill'=>$resultData['tracking_number'],'label'=>$pdf['label']);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- $g = array('x'=>'0','Description'=>$pdf['Description']);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- $resultData['message'] = urldecode($resultData['message']);
|
|
|
|
- $g = array('x'=>'0','Description'=>$resultData['message']);
|
|
|
|
- }
|
|
|
|
- return $g;exit;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function curlRequest($url,$czdata = '')
|
|
|
|
- {
|
|
|
|
- $return = array('state' => 0, 'message' => '', 'result' => '', 'errNo' => 0);
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- $ch = curl_init($url);
|
|
|
|
- curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
- curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
|
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
|
|
- 'Accept-Language: zh-cn',
|
|
|
|
- 'Connection: Keep-Alive',
|
|
|
|
- 'Cache-Control: no-cache',
|
|
|
|
- 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'));
|
|
|
|
- curl_setopt($ch, CURLOPT_POSTFIELDS, $czdata);
|
|
|
|
- //设置超时时间
|
|
|
|
- curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
|
|
|
- //API返回数据
|
|
|
|
- $apiResult = curl_exec($ch);
|
|
|
|
-
|
|
|
|
- $errNo = curl_errno($ch);
|
|
|
|
- if ($errNo)
|
|
|
|
- {
|
|
|
|
- //返回错误码
|
|
|
|
- $return['errNo'] = $errNo;
|
|
|
|
- $errorStr = curl_error($ch);
|
|
|
|
- switch ((int)$errNo)
|
|
|
|
- {
|
|
|
|
- case 6: //避免一直发邮件 URL报错
|
|
|
|
- break;
|
|
|
|
- case 7: //无法通过 connect() 连接至主机或代理服务器
|
|
|
|
- break;
|
|
|
|
- case 28: //超时
|
|
|
|
- break;
|
|
|
|
- case 56: //接收网络数据失败
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- throw new Exception($errorStr);
|
|
|
|
- }
|
|
|
|
- curl_close($ch);
|
|
|
|
- $return['state'] = 1;
|
|
|
|
- //返回数据
|
|
|
|
- $return['result'] = $apiResult;
|
|
|
|
- }
|
|
|
|
- catch (Exception $e)
|
|
|
|
- {
|
|
|
|
- $return['state'] = 0;
|
|
|
|
- $return['message'] = $e->getMessage();
|
|
|
|
- }
|
|
|
|
- return $return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function get_hqwaybill($number)
|
|
|
|
- {
|
|
|
|
- $ch = curl_init();
|
|
|
|
- curl_setopt($ch, CURLOPT_URL, 'http://123.207.33.169:8082/getOrderTrackingNumber.htm?documentCode='.$number);
|
|
|
|
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
- curl_setopt($ch, CURLOPT_HTTPGET, true);
|
|
|
|
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
|
|
|
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
|
- $res = curl_exec($ch);
|
|
|
|
- curl_close($ch);
|
|
|
|
- $res = json_decode($res,true);
|
|
|
|
- if(isset($res['childno'][0]))
|
|
|
|
- {
|
|
|
|
- $g = array('x'=>'1','ys'=>0,'waybill'=>$res['order_serveinvoicecode']);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- $g = array('x'=>'0','Description'=>$res['msg']);
|
|
|
|
- }
|
|
|
|
- return $g;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function get_pdf($orderid)
|
|
|
|
- {
|
|
|
|
- $ch = curl_init("http://123.207.33.169:8089/order/FastRpt/PDF_NEW.aspx?PrintType=lab10_10&order_id=".$orderid);
|
|
|
|
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
|
- curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
|
|
|
|
- curl_setopt($ch, CURLOPT_NOBODY, 1);
|
|
|
|
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
- curl_setopt($ch, CURLOPT_HEADER, 1);
|
|
|
|
- curl_exec($ch);
|
|
|
|
- $res = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
|
|
|
- curl_close($ch);
|
|
|
|
- if(stripos($res,'.pdf') !== false)
|
|
|
|
- {
|
|
|
|
- $g = array('x'=>'1','label'=>$res);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- $g = array('x'=>'0','Description'=>"获取运单失败,请重试");
|
|
|
|
- }
|
|
|
|
- return $g;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function get_manifest($fullorder) //生成发货清单
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function get_logistics($number)//追踪快递
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- //http://123.207.33.169:8089/order/FastRpt/PDF_NEW.aspx?Format=lbl_NL_XIN.frx&PrintType=lab10_10&order_id=5456516打印
|
|
|
|
-
|
|
|
|
|
|
+<?php
|
|
|
|
+class Model_hualei extends Lin_Model {
|
|
|
|
+function __construct(){
|
|
|
|
+ parent::__construct();
|
|
|
|
+}
|
|
|
|
+//渠道 http://123.207.33.169:8082/getProductList.htm
|
|
|
|
+//$ys = 1;//延时获取运单
|
|
|
|
+ public function get_data($data)
|
|
|
|
+ {
|
|
|
|
+ $duty_type = '';//区分快递承担税费人的选项 DDU或DDP ddp好像是收件人承担税费
|
|
|
|
+ if($data['printcode'] == "HUALEI-FEDEX")
|
|
|
|
+ {
|
|
|
|
+ $product_id = 6021;
|
|
|
|
+ $link = 'param=';
|
|
|
|
+ $ys = 0;//非延时获取运单
|
|
|
|
+ }
|
|
|
|
+ else if($data['printcode'] == "HUALEI-ARAMEX-G")
|
|
|
|
+ {
|
|
|
|
+ $product_id = 3361;
|
|
|
|
+ $link = 'param=';
|
|
|
|
+ $ys = 0;//非延时获取运单
|
|
|
|
+ }
|
|
|
|
+ else if($data['printcode'] == "HUALEI-ARAMEX-S")
|
|
|
|
+ {
|
|
|
|
+ $product_id = 8161;//南非
|
|
|
|
+ $link = 'param=';
|
|
|
|
+ $ys = 0;//非延时获取运单
|
|
|
|
+ }
|
|
|
|
+ else if ($data['printcode'] == "HUALEI-GES-EU")
|
|
|
|
+ {
|
|
|
|
+ $product_id = 4301;
|
|
|
|
+ $link = 'param=';
|
|
|
|
+ $ys = 0;//非延时获取运单
|
|
|
|
+ if($data['printnumber'] > 0)
|
|
|
|
+ {
|
|
|
|
+ $data['number'] = $data['number'].'-'.($data['printnumber']+1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if ($data['printcode'] == "HUALEI-WMS")//DPEX
|
|
|
|
+ {
|
|
|
|
+ $product_id = 5781;
|
|
|
|
+ $link = 'param=';
|
|
|
|
+ $ys = 0;//非延时获取运单
|
|
|
|
+ }
|
|
|
|
+ else if ($data['printcode'] == "HUALEI-DHL-A1")//TNT
|
|
|
|
+ {
|
|
|
|
+ $product_id = 7281;
|
|
|
|
+ $link = 'param=';
|
|
|
|
+ $ys = 0;//非延时获取运单
|
|
|
|
+ }
|
|
|
|
+ else if ($data['printcode'] == "HUALEI-DHL")//TNT
|
|
|
|
+ {
|
|
|
|
+ $product_id = 7141;
|
|
|
|
+ $link = 'param=';
|
|
|
|
+ $ys = 0;//
|
|
|
|
+ $duty_type = "DDP";
|
|
|
|
+ }
|
|
|
|
+ else if($data['printcode'] == 'HUALEI-MLXY'){
|
|
|
|
+ $product_id = 7581;
|
|
|
|
+ $link = 'param=';
|
|
|
|
+ $ys = 0;//
|
|
|
|
+ //$duty_type = "DDP";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $rs = $this->curlRequest('http://123.207.33.169:8082/selectAuth.htm',"username=LY&password=ly999");
|
|
|
|
+ $reData = json_decode(str_replace("'", "\"", $rs['result']));
|
|
|
|
+ $customer_id = $reData->customer_id;
|
|
|
|
+ $customer_userid = $reData->customer_userid;
|
|
|
|
+
|
|
|
|
+ //$product_id = 4461; //产品id 运输方式由APT给出
|
|
|
|
+ $format = 'lbl_NL_XIN.frx'; //打印类型
|
|
|
|
+ $printType = 1; //打印类型
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 2, 预报订单
|
|
|
|
+ */
|
|
|
|
+ if($data['ioss'] != '')//如果有IOSS
|
|
|
|
+ {
|
|
|
|
+ //预报数据
|
|
|
|
+ $count = Array(
|
|
|
|
+ 'buyerid' => '',//买家ID
|
|
|
|
+ 'consignee_address' => ($data['address2'] != '')?$data['address'].' '.$data['address2']:$data['address'],//地址
|
|
|
|
+ 'consignee_city' => $data['city'],//城市
|
|
|
|
+ 'consignee_mobile' => '',//收货人手机号 选填
|
|
|
|
+ 'consignee_name' => $data['name'],//收件人
|
|
|
|
+ 'trade_type' => 'ZYXT',//交易类型
|
|
|
|
+ 'consignee_postcode' => $data['zipcode'],//邮编
|
|
|
|
+ 'consignee_state' => $data['province'],//省/州
|
|
|
|
+ 'consignee_telephone' => $data['phone'],//收货人电话 必填
|
|
|
|
+ 'country' => $data['lb'],//收货人国家二字码
|
|
|
|
+ 'shipper_taxno' => $data['ioss'],
|
|
|
|
+ 'shipper_taxnotype'=>'IOSS',
|
|
|
|
+ 'shipper_taxnocountry' => 'NL',
|
|
|
|
+ 'customer_id' => $customer_id,
|
|
|
|
+ 'customer_userid' => $customer_userid,
|
|
|
|
+ 'orderInvoiceParam' => Array(
|
|
|
|
+ '0' => Array
|
|
|
|
+ (
|
|
|
|
+ 'invoice_amount' => $data['zsbjz'],
|
|
|
|
+ 'invoice_pcs' => $data['ts'],
|
|
|
|
+ 'invoice_title' => $data['sbpm'],
|
|
|
|
+ 'invoice_weight' => sprintf("%.3f",$data['zzl']/$data['ts']),//单条重量
|
|
|
|
+ 'item_id' => '',
|
|
|
|
+ 'item_transactionid' => '',
|
|
|
|
+ 'sku' => $data['zwpm'],
|
|
|
|
+ 'sku_code' => $data['zwpm'],
|
|
|
|
+ 'hs_code'=> $data['hgbm'],//海关编码
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ 'order_customerinvoicecode' => $data['number'],//原单号
|
|
|
|
+ 'product_id' => $product_id,
|
|
|
|
+ 'weight' => 0,
|
|
|
|
+ 'product_imagepath' => '',
|
|
|
|
+ 'consignee_email'=>isset($data['email'])?$data['email']:'',
|
|
|
|
+ 'consignee_companyname'=>$data['client'],//收件公司
|
|
|
|
+ //'order_cargoamount'=>'',//订单实际金额
|
|
|
|
+ //'order_insurance'=>'',//保险金额
|
|
|
|
+ 'duty_type'=>$duty_type,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //预报数据
|
|
|
|
+ $count = Array(
|
|
|
|
+ 'buyerid' => '',//买家ID
|
|
|
|
+ 'consignee_address' => ($data['address2'] != '')?$data['address'].' '.$data['address2']:$data['address'],//地址
|
|
|
|
+ 'consignee_city' => $data['city'],//城市
|
|
|
|
+ 'consignee_mobile' => '',//收货人手机号 选填
|
|
|
|
+ 'consignee_name' => $data['name'],//收件人
|
|
|
|
+ 'trade_type' => 'ZYXT',//交易类型
|
|
|
|
+ 'consignee_postcode' => $data['zipcode'],//邮编
|
|
|
|
+ 'consignee_state' => $data['province'],//省/州
|
|
|
|
+ 'consignee_telephone' => $data['phone'],//收货人电话 必填
|
|
|
|
+ 'country' => $data['lb'],//收货人国家二字码
|
|
|
|
+ 'customer_id' => $customer_id,
|
|
|
|
+ 'customer_userid' => $customer_userid,
|
|
|
|
+ 'orderInvoiceParam' => Array(
|
|
|
|
+ '0' => Array
|
|
|
|
+ (
|
|
|
|
+ 'invoice_amount' => $data['zsbjz'],
|
|
|
|
+ 'invoice_pcs' => $data['ts'],
|
|
|
|
+ 'invoice_title' => $data['sbpm'],
|
|
|
|
+ 'invoice_weight' => sprintf("%.3f",$data['zzl']/$data['ts']),//单条重量
|
|
|
|
+ 'item_id' => '',
|
|
|
|
+ 'item_transactionid' => '',
|
|
|
|
+ 'sku' => $data['zwpm'],
|
|
|
|
+ 'sku_code' => $data['zwpm'],
|
|
|
|
+ 'hs_code'=> $data['hgbm'],//海关编码
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ 'order_customerinvoicecode' => $data['number'],//原单号
|
|
|
|
+ 'product_id' => $product_id,
|
|
|
|
+ 'weight' => 0,
|
|
|
|
+ 'product_imagepath' => '',
|
|
|
|
+ 'consignee_email'=>isset($data['email'])?$data['email']:'',
|
|
|
|
+ 'consignee_companyname'=>$data['client'],//收件公司
|
|
|
|
+ //'order_cargoamount'=>'',//订单实际金额
|
|
|
|
+ //'order_insurance'=>'',//保险金额
|
|
|
|
+ 'duty_type'=>$duty_type,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+// var_dump($link);
|
|
|
|
+// var_dump(json_encode($count));
|
|
|
|
+ $result = $this->curlRequest('http://123.207.33.169:8082/createOrderApi.htm',$link.json_encode($count));
|
|
|
|
+ $resultData = json_decode($result['result'], true);
|
|
|
|
+ if($resultData['ack'] == 'true')
|
|
|
|
+ {
|
|
|
|
+ //if($resultData['tracking_number'] == $resultData['reference_number'])
|
|
|
|
+ if($ys == 1)
|
|
|
|
+ {
|
|
|
|
+ $g = array('x'=>'1','ys'=>1,'waybill'=>'');
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $pdf = $this->get_pdf($resultData['order_id']);
|
|
|
|
+ if($pdf['x'] == 1)
|
|
|
|
+ {
|
|
|
|
+ if($product_id == 4361)
|
|
|
|
+ {
|
|
|
|
+ $g = array('x'=>'1','ys'=>0,'waybill'=>$resultData['order_privatecode'],'waybill2'=>$resultData['tracking_number'],'label'=>$pdf['label']);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $g = array('x'=>'1','ys'=>0,'waybill'=>$resultData['tracking_number'],'label'=>$pdf['label']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $g = array('x'=>'0','Description'=>$pdf['Description']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $resultData['message'] = urldecode($resultData['message']);
|
|
|
|
+ $g = array('x'=>'0','Description'=>$resultData['message']);
|
|
|
|
+ }
|
|
|
|
+ return $g;exit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function curlRequest($url,$czdata = '')
|
|
|
|
+ {
|
|
|
|
+ $return = array('state' => 0, 'message' => '', 'result' => '', 'errNo' => 0);
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ $ch = curl_init($url);
|
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
+ curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
|
|
+ 'Accept-Language: zh-cn',
|
|
|
|
+ 'Connection: Keep-Alive',
|
|
|
|
+ 'Cache-Control: no-cache',
|
|
|
|
+ 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'));
|
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $czdata);
|
|
|
|
+ //设置超时时间
|
|
|
|
+ curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
|
|
|
+ //API返回数据
|
|
|
|
+ $apiResult = curl_exec($ch);
|
|
|
|
+
|
|
|
|
+ $errNo = curl_errno($ch);
|
|
|
|
+ if ($errNo)
|
|
|
|
+ {
|
|
|
|
+ //返回错误码
|
|
|
|
+ $return['errNo'] = $errNo;
|
|
|
|
+ $errorStr = curl_error($ch);
|
|
|
|
+ switch ((int)$errNo)
|
|
|
|
+ {
|
|
|
|
+ case 6: //避免一直发邮件 URL报错
|
|
|
|
+ break;
|
|
|
|
+ case 7: //无法通过 connect() 连接至主机或代理服务器
|
|
|
|
+ break;
|
|
|
|
+ case 28: //超时
|
|
|
|
+ break;
|
|
|
|
+ case 56: //接收网络数据失败
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ throw new Exception($errorStr);
|
|
|
|
+ }
|
|
|
|
+ curl_close($ch);
|
|
|
|
+ $return['state'] = 1;
|
|
|
|
+ //返回数据
|
|
|
|
+ $return['result'] = $apiResult;
|
|
|
|
+ }
|
|
|
|
+ catch (Exception $e)
|
|
|
|
+ {
|
|
|
|
+ $return['state'] = 0;
|
|
|
|
+ $return['message'] = $e->getMessage();
|
|
|
|
+ }
|
|
|
|
+ return $return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function get_hqwaybill($number)
|
|
|
|
+ {
|
|
|
|
+ $ch = curl_init();
|
|
|
|
+ curl_setopt($ch, CURLOPT_URL, 'http://123.207.33.169:8082/getOrderTrackingNumber.htm?documentCode='.$number);
|
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPGET, true);
|
|
|
|
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
|
+ $res = curl_exec($ch);
|
|
|
|
+ curl_close($ch);
|
|
|
|
+ $res = json_decode($res,true);
|
|
|
|
+ if(isset($res['childno'][0]))
|
|
|
|
+ {
|
|
|
|
+ $g = array('x'=>'1','ys'=>0,'waybill'=>$res['order_serveinvoicecode']);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $g = array('x'=>'0','Description'=>$res['msg']);
|
|
|
|
+ }
|
|
|
|
+ return $g;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function get_pdf($orderid)
|
|
|
|
+ {
|
|
|
|
+ $ch = curl_init("http://123.207.33.169:8089/order/FastRpt/PDF_NEW.aspx?PrintType=lab10_10&order_id=".$orderid);
|
|
|
|
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
|
+ curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
|
|
|
|
+ curl_setopt($ch, CURLOPT_NOBODY, 1);
|
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
+ curl_setopt($ch, CURLOPT_HEADER, 1);
|
|
|
|
+ curl_exec($ch);
|
|
|
|
+ $res = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
|
|
|
+ curl_close($ch);
|
|
|
|
+ if(stripos($res,'.pdf') !== false)
|
|
|
|
+ {
|
|
|
|
+ $g = array('x'=>'1','label'=>$res);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $g = array('x'=>'0','Description'=>"获取运单失败,请重试");
|
|
|
|
+ }
|
|
|
|
+ return $g;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function get_manifest($fullorder) //生成发货清单
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function get_logistics($number)//追踪快递
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ //http://123.207.33.169:8089/order/FastRpt/PDF_NEW.aspx?Format=lbl_NL_XIN.frx&PrintType=lab10_10&order_id=5456516打印
|
|
|
|
+
|
|
} //end class
|
|
} //end class
|