| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 | <?phpclass Model_Dpdold extends Lin_Model {function __construct(){		parent::__construct();}    public function get_data($data)	{		$rs = $this->curlRequest('http://123.207.33.169:8082/selectAuth.htm',"username=XW&password=123456");		$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, 预报订单		 */		//预报数据		$count = Array(		'buyerid' => '',//买家ID		'consignee_address' => $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'].'-1',//原单号		'product_id' => $product_id,		'weight' => 0,		'product_imagepath' => '',		'consignee_email'=>isset($data['email'])?$data['email']:'',		'consignee_companyname'=>$data['client'],//收件公司		//'order_cargoamount'=>'',//订单实际金额		//'order_insurance'=>'',//保险金额		);		$result = $this->curlRequest('http://123.207.33.169:8082/createOrderApi.htm', "param=" . json_encode($count));		$resultData = json_decode($result['result'], true);		if($resultData['ack'] == 'true')		{			$g = array('x'=>'1','waybill'=>$resultData['tracking_number']);		}		else		{			$resultData['message'] = urldecode($resultData['message']);			$g = array('x'=>'0','Description'=>$resultData['message']);		}		return array($g,$resultData);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_manifest($fullorder) //生成发货清单	{	   	}		public function get_logistics($number)//追踪快递	{			}	}  //end class
 |