'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU');
$data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
$data['province'] = trim($data['province'],' ');
$data['province'] = (strlen($data['province'])==2 || $data['lb'] != 'US')?$data['province']:$ToState[strtolower($data['province'])];
$data['city'] = preg_replace('/( | |\s)/',' ',$data['city']);
if($data['printcode'] == 'FEDEX')
{
$code = 'YB0004';
}
else if($data['printcode'] == 'TOLL')
{
$code = 'DPEX';
}
else if($data['printcode'] == 'ARAMEX')
{
$code = 'YB0001';
}
else
{
$code = $data['printcode'];
}
$list = array();
$list['reference_no'] = $data['number'];//客户参考号
//$list['shipper_hawbcode'] = 'YT'.$data['orderinfo'];//运单号,必须YT开头
$list['shipping_method'] = $code;//配送方式
$list['order_weight'] = '0.400';//订单重量
$list['country_code'] = $data['lb'];//收件人国家二字码
if($data['bx'] > 0)
{
$list['insurance_value'] = $data['bx'];//投保金额,默认RMB
}
$list['order_pieces'] = $data['zjs'];//外包装件数,默认
$list['Consignee'] = array();//收件人信息
$list['Consignee']['consignee_company'] = $data['client'];
$list['Consignee']['consignee_province'] = $data['province'];
$list['Consignee']['consignee_city'] = $data['city'];
$list['Consignee']['consignee_street'] = $data['address'];
if($data['address2'])
{
$list['Consignee']['consignee_street2'] = $data['address2'];
}
$list['Consignee']['consignee_postcode'] = trim($data['zipcode'],' ');
$list['Consignee']['consignee_name'] = $data['name'];
$list['Consignee']['consignee_telephone'] = $data['phone'];
$list['Shipper'] = array();//发件人信息
$list['Shipper']['shipper_company'] = $data['warehouse']['company'];
$list['Shipper']['shipper_countrycode'] = $data['warehouse']['lb'];
$list['Shipper']['shipper_province'] = $data['warehouse']['province'];
$list['Shipper']['shipper_city'] = $data['warehouse']['city'];
$list['Shipper']['shipper_street'] = $data['warehouse']['address'].$data['warehouse']['address2'];
$list['Shipper']['shipper_postcode'] = $data['warehouse']['zipcode'];
$list['Shipper']['shipper_name'] = $data['warehouse']['company'];
$list['Shipper']['shipper_telephone'] = preg_replace('/\D/s','',$data['warehouse']['phone']);
$list['Shipper']['shipper_mobile'] = '03747050111';
$list['Shipper']['shipper_email'] = '3002735981@qq.com';
$list['ItemArr'] = array();
$list['ItemArr'][0]['invoice_enname'] = $data['sbpm'];
$list['ItemArr'][0]['invoice_cnname'] = $data['zwpm'];
//$zzl = sprintf("%.2f",0.4/($data['ts']+1));
$list['ItemArr'][0]['invoice_weight'] = '0.005';
$list['ItemArr'][0]['invoice_quantity'] = $data['ts'];
$list['ItemArr'][0]['invoice_unitcharge'] = $data['dtsbjz'];
//$list['ItemArr']['invoice_currencycode'] = 'USD';
$xml = '';
$xml.='';
$xml.='';
$xml.='';
$xml.=''.json_encode($list).'';
$xml.=''.$appToken.'';
$xml.=''.$appKey.'';
$xml.='createOrder';
$xml.='';
$xml.='';
$xml.='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://120.78.181.120/default/svc/web-service');
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result_xml = curl_exec($ch);
$result_xml = $response = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $result_xml);
$xml = new SimpleXMLElement($result_xml);
$body = $xml->xpath('//ns1callServiceResponse');
$array = json_decode(json_encode((array)$body),true);
$result_xml = json_decode($array[0]['response'],true);
if($result_xml['ask'] == 'Failure')
{
return array('a'=>1,'m'=>$result_xml['message'].':'.$result_xml['Error']['errMessage']);
}
else
{
return array('a'=>2,'number'=>$result_xml['shipping_method_no']);
}
}
public function get_label($number,$type)
{
$appToken = '070c4a24fdeb23fa3e0270858cd2ceda';
$appKey = '070c4a24fdeb23fa3e0270858cd2cedabfd75d1f2e461ee13e69646d3437a302';
$list = array();
$list['reference_no'] = $number;
$list['label_type'] = $type;
$xml = '';
$xml.='';
$xml.='';
$xml.='';
$xml.=''.json_encode($list).'';
$xml.=''.$appToken.'';
$xml.=''.$appKey.'';
$xml.='getLabelUrl';
$xml.='';
$xml.='';
$xml.='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://120.78.181.120/default/svc/web-service');
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result_xml = curl_exec($ch);
$result_xml = $response = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $result_xml);
$xml = new SimpleXMLElement($result_xml);
$body = $xml->xpath('//ns1callServiceResponse');
$array = json_decode(json_encode((array)$body),true);
$result_xml = json_decode($array[0]['response'],true);
if($result_xml['ask'] == 'Failure')
{
return array('a'=>1,'m'=>$result_xml['Error']['errMessage']);
}
else
{
return array('a'=>2,'pdf'=>$result_xml['url']);
}
}
public function get_ps()//配送方式 getShippingMethod
{
$appToken = '070c4a24fdeb23fa3e0270858cd2ceda';
$appKey = '070c4a24fdeb23fa3e0270858cd2cedabfd75d1f2e461ee13e69646d3437a302';
$xml = '';
$xml.='';
$xml.='';
$xml.='';
$xml.=''.json_encode(array('true')).'';
$xml.=''.$appToken.'';
$xml.=''.$appKey.'';
$xml.='getShippingMethod';
$xml.='';
$xml.='';
$xml.='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://120.78.181.120/default/svc/web-service');
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result_xml = curl_exec($ch);
$result_xml = str_replace(array(':','-'), '', $result_xml);
@$result_xml = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
$result_xml = str_replace(array('""','"[','time_cost(s)"','err_code"','"{'),array('":"','":[','time_cost(s)":','err_code":','":{'),$result_xml['SOAPENVBody']['ns1callServiceResponse']['response']);
$result_xml = json_decode($result_xml,true);
return $result_xml;
}
public function get_lj($number,$type)//取消
{
$appToken = '070c4a24fdeb23fa3e0270858cd2ceda';
$appKey = '070c4a24fdeb23fa3e0270858cd2cedabfd75d1f2e461ee13e69646d3437a302';
$list = array();
$list['reference_no'] = $number;
$list['type'] = $type;
$xml = '';
$xml.='';
$xml.='';
$xml.='';
$xml.=''.json_encode($list).'';
$xml.=''.$appToken.'';
$xml.=''.$appKey.'';
$xml.='cancelOrder';
$xml.='';
$xml.='';
$xml.='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://120.78.181.120/default/svc/web-service');
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result_xml = curl_exec($ch);
$result_xml = $response = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $result_xml);
$xml = new SimpleXMLElement($result_xml);
$body = $xml->xpath('//ns1callServiceResponse');
$array = json_decode(json_encode((array)$body),true);
$result_xml = json_decode($array[0]['response'],true);
if($result_xml['ask'] == 'Success')
{
return 1;
}
else
{
return $result_xml['Error']['errMessage'];
}
}
} //end class