| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 | <?phpclass Model_Hualeixw extends Lin_Model {function __construct(){		parent::__construct();}//渠道http://123.207.33.169:8082/getProductList.htm    public function get_data($data)	{		if($data['printcode'] == "HUALEIXW-FEDEX")		{			$product_id = 6021;			$link = 'param=';			$ys = 0;//非延时获取运单		}		else if($data['printcode'] == "HUALEIXW-FEDEX-EUROPE")		{			$product_id = 2801;			$link = 'getTrackingNumber=2¶m=';			$ys = 1;//延时获取运单		}		else if($data['printcode'] == "HUALEIXW-DHL")		{			$product_id = 7141;			$link = 'param=';			$ys = 0;//非延时获取运单		}		else if($data['printcode'] == "HUALEIXW-ARAMEX")		{			$product_id = 3361;			$link = 'param=';			$ys = 0;//非延时获取运单		}		else if($data['printcode'] == "HUALEIXW-GES-GB-A")		{			//$product_id = 4461;			$product_id = 4461;			$link = 'param=';			$ys = 0;		}		else if ($data['printcode'] == "HUALEIXW-GES-EU9610")		{			$product_id = 4301;//7301;			$link = 'getTrackingNumber=2¶m=';			$ys = 1;		}		else if ($data['printcode'] == "HUALEIXW-TNT")		{			$product_id = 2641;			$link = 'getTrackingNumber=2¶m=';			$ys = 1;		}		else if ($data['printcode'] == "HUALEIXW-UPS")		{			$product_id = 6321;			$link = 'getTrackingNumber=2¶m=';			$ys = 1;		}		else if ($data['printcode'] == "HUALEIXW-USPS")		{			$product_id = 5921;			$link = 'param=';			$ys = 0;		}		else if ($data['printcode'] == "HUALEIXW-HC-FEDEX")		{			$product_id =  8441;			$link = 'param=';			$ys = 0;		}				$rs = $this->curlRequest('http://123.207.33.169:8082/selectAuth.htm',"username=XW&password=292321");		$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_taxnocountry' => 'CN',		'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'=>'',//保险金额		);		}		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'=>'',//保险金额		);		}				 if ($data['printcode'] == "HUALEIXW-GES-EU9610")		{			$count['order_cargoamount'] = $data['shouldmoney'];		}				$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)				{					$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
 |