| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 | 
							- <?php 
 
- function name($name)
 
- {
 
-     $userKey = array(
 
- 	'Alipearl' => array('username'=>'huchunmei','api_key'=>'huchunmei126_alipearl_erp888','url'=>'https://www.alipearlhair.com'),
 
- 	'Asteria'  => array('username'=>'huchunmei','api_key'=>'huchunmei126_asteria_erp888','url'=>'https://www.asteriahair.com'),
 
- 	'WestKiss' => array('username'=>'huchunmei','api_key'=>'huchunmei126_westkiss_erp868','url'=>'https://www.westkiss.com'),
 
- 	'SuperNova' => array('username'=>'huchunmei','api_key'=>'huchunmei126_supernova_erp6898','url'=>'https://www.supernovahair.com'),
 
- 	'Wiggins' => array('username'=>'huchunmei','api_key'=>'huchunmei126_wiggins_erp652','url'=>'https://www.wigginshair.com'),
 
- 	'Yolissa' => array('username'=>'huchunmei','api_key'=>'huchunmei126_yolissa_688','url'=>'https://www.yolissahair.com'),
 
-     );
 
-     if(array_key_exists($name,$userKey))
 
- 	{
 
- 	    $proxy = new SoapClient($userKey[$name]['url'].'/api/soap/?wsdl');
 
-         try {$sessionId = $proxy->login($userKey[$name]['username'], $userKey[$name]['api_key']);} catch (Exception $e) {
 
-     echo $e->getMessage();
 
- }
 
- 		return array('proxy'=>$proxy,'sessionId'=>$sessionId,'url'=>$userKey[$name]['url']);
 
-     }
 
- 	else
 
- 	{
 
- 		 return 2;exit;
 
- 	}
 
- }
 
- function synchronization($name,$from,$to)
 
- {
 
- 	$data = name($name);
 
- 	$fromTime = date('Y-m-d H:i:s',$from);
 
- 	$toTime = date('Y-m-d H:i:s',$to);
 
- 	$filters = array(array('created_at'=>array('from'=>$fromTime,'to'=>$toTime)));
 
- 	$result = $data['proxy']->call($data['sessionId'],'sales_order.list',$filters);
 
- 	$thatDayOrder = array();
 
- 	foreach($result as $item)
 
- 	{
 
- 		$iteminfo = $data['proxy']->call($data['sessionId'], 'sales_order.info', $item['increment_id']);
 
- 		$productNames = '';
 
- 		$parameters = array();
 
- 		$skus = '';
 
- 		$quantity = '';
 
- 		$thislink = '';
 
- 		foreach($iteminfo['items'] as $index=>$products)
 
- 		{
 
- 		    $quantity .= floor($products['qty_ordered']).';';
 
- 		    $productNames .= ($index > 0)?','.$products['name']:$products['name'];
 
- 		    $skus .= ($index > 0)?','.$products['sku']:$products['sku'];
 
- 		    $options = unserialize($products['product_options']);
 
- 		    $para = '';
 
- 		    if(isset($options['options']))
 
- 			{
 
- 		        foreach($options['options'] as $i=>$op)
 
- 		        {
 
- 			        $parameter = $op['label'].':'.$op['value'];
 
- 		            $para .= ($i>0)?','.$parameter:$parameter;
 
- 	            }
 
- 			}
 
- 			else
 
- 			{
 
- 				$para = '';
 
- 			}
 
- 	        $parameters[] = $para;
 
- 			try
 
- 			{
 
- 			    $plink = $data['proxy']->call($data['sessionId'], 'catalog_product.info',$products['product_id']);
 
- 			    $thislink .= ($index > 0)?','.$data['url'].'/'.$plink['url_path']:$data['url'].'/'.$plink['url_path'];
 
- 			}catch (Exception $e) 
 
- 			{
 
-                 continue;
 
-             }
 
- 	     }
 
- 		 if($item['status'] == 'pending')
 
- 		 {
 
- 			 continue;
 
- 		 }
 
- 	 $iteminfo['shipping_address']['street'] = preg_replace('/( | | |\s)+/',' ',$iteminfo['shipping_address']['street']);
 
- 	 $iteminfo['billing_address']['street'] = preg_replace('/( | | |\s)+/',' ',$iteminfo['billing_address']['street']);
 
-      $shipping_address = $iteminfo['shipping_address']['street'] . ',' . $iteminfo['shipping_address']['city'] . ',' . $iteminfo['shipping_address']['region'] . ',' . $iteminfo['shipping_address']['postcode'] . ',' . $iteminfo['shipping_address']['country_id'] . ',' . $iteminfo['shipping_address']['telephone'];
 
-      $billing_address = $iteminfo['billing_address']['street'] . ',' . $iteminfo['billing_address']['city'] . ',' . $iteminfo['billing_address']['region'] . ',' . $iteminfo['billing_address']['postcode'] . ',' . $iteminfo['billing_address']['country_id'] . ',' . $iteminfo['billing_address']['telephone'];
 
- 	 $shippingmethod = $item['shipping_description'];
 
-      $thatDayOrder[] = array(
 
-      'order_id' => $item['increment_id'],
 
- 	 'insurance' => $item['base_amcheckoutfees_amount'],
 
-      'product_name' => $productNames,
 
-      'purchased_on' => $item['created_at'],
 
-      'name' => $iteminfo['customer_firstname'].' '.$iteminfo['customer_lastname'],
 
-      'bill_to_name' => $item['billing_firstname'].' '.$item['billing_lastname'],
 
-      'ship_to_name' => $item['shipping_firstname'].' '.$item['shipping_lastname'],
 
-      'shipping_address' => $shipping_address,
 
-      'billing_address' => $billing_address,
 
-      'country' => $iteminfo['shipping_address']['country_id'],
 
-      'region' => $iteminfo['shipping_address']['region'],
 
-      'city' => $iteminfo['shipping_address']['city'],
 
-      'street' => $iteminfo['shipping_address']['street'],
 
-      'telephone' => $item['telephone'],
 
-      'postcode' => $item['postcode'],
 
-      'email' => $item['customer_email'],
 
-      'global_currency_code' => $item['global_currency_code'],
 
-      'base_grand_total' => $item['base_grand_total'],
 
-      'grand_total' => $item['order_currency_code'].$item['grand_total'],
 
-      'isstatus' => $item['status'],
 
-      'isparameter' => implode(';',$parameters),
 
-      'sku' => str_replace(array('<','>'),array('<','>'),$skus),
 
-      'order_quantity' => $quantity,
 
-      'order_comment' => addslashes($item['firecheckout_customer_comment']),
 
-      'paypal_num' => ($iteminfo['payment']['oceanpay_order_id'] != '')?$iteminfo['payment']['oceanpay_order_id']:$iteminfo['payment']['last_trans_id'],
 
- 	 'pay' => $iteminfo['payment']['method'],
 
-      'paypal_protection_eligibility' => $iteminfo['payment']['additional_information']['paypal_protection_eligibility'],
 
- 	 'shippingmethod'=>($item['base_shipping_amount'] > 0 || $iteminfo['tax_amount'] > 0)?$shippingmethod.' '.$item['base_shipping_amount'].'  Tax:'.$iteminfo['tax_amount'].';':$shippingmethod.' '.$item['base_shipping_amount'].'  Tax:'.$iteminfo['tax_amount'],
 
- 	 'link'=>$thislink,
 
- 	  'wjauthorid' => isset($iteminfo['author_id'])?$iteminfo['author_id']:'',
 
- 	  'sourcecontentid' => isset($iteminfo['source_content_id'])?$iteminfo['source_content_id']:'',
 
- 	  'authorid' => ''
 
-      );
 
- 	 //sleep(1);
 
- 	 }
 
- 	 return $thatDayOrder;exit;
 
- }
 
- function g($name,$from,$to)
 
- {
 
- 	$data = name($name);
 
- 	$fromTime = date('Y-m-d H:i:s',$from);
 
- 	$toTime = date('Y-m-d H:i:s',$to);
 
- 	$filters = array(array('created_at'=>array('from'=>$fromTime,'to'=>$toTime)));
 
- 	$result = $data['proxy']->call($data['sessionId'],'sales_order.list',$filters);
 
- 	$thatDayOrder = array();
 
- 	foreach($result as $item)
 
- 	{
 
- 		$iteminfo = $data['proxy']->call($data['sessionId'], 'sales_order.info', $item['increment_id']);
 
- 		$productNames = '';
 
- 		$parameters = array();
 
- 		$skus = '';
 
- 		$quantity = '';
 
- 		$thislink = '';
 
- 		foreach($iteminfo['items'] as $index=>$products)
 
- 		{
 
- 		    $quantity .= floor($products['qty_ordered']).';';
 
- 		    $productNames .= ($index > 0)?','.$products['name']:$products['name'];
 
- 		    $skus .= ($index > 0)?','.$products['sku']:$products['sku'];
 
- 		    $options = unserialize($products['product_options']);
 
- 		    $para = '';
 
- 		    if(isset($options['options']))
 
- 			{
 
- 		        foreach($options['options'] as $i=>$op)
 
- 		        {
 
- 			        $parameter = $op['label'].':'.$op['value'];
 
- 		            $para .= ($i>0)?','.$parameter:$parameter;
 
- 	            }
 
- 			}
 
- 			else
 
- 			{
 
- 				$para = '';
 
- 			}
 
- 	        $parameters[] = $para;
 
- 			try
 
- 			{
 
- 			    $plink = $data['proxy']->call($data['sessionId'], 'catalog_product.info',$products['product_id']);
 
- 			    $thislink .= ($index > 0)?','.$data['url'].'/'.$plink['url_path']:$data['url'].'/'.$plink['url_path'];
 
- 			}catch (Exception $e) 
 
- 			{
 
-                 continue;
 
-             }
 
- 	     }
 
- 	
 
- 	 $iteminfo['shipping_address']['street'] = preg_replace('/( | | |\s)+/',' ',$iteminfo['shipping_address']['street']);
 
- 	 $iteminfo['billing_address']['street'] = preg_replace('/( | | |\s)+/',' ',$iteminfo['billing_address']['street']);
 
-      $shipping_address = $iteminfo['shipping_address']['street'] . ',' . $iteminfo['shipping_address']['city'] . ',' . $iteminfo['shipping_address']['region'] . ',' . $iteminfo['shipping_address']['postcode'] . ',' . $iteminfo['shipping_address']['country_id'] . ',' . $iteminfo['shipping_address']['telephone'];
 
-      $billing_address = $iteminfo['billing_address']['street'] . ',' . $iteminfo['billing_address']['city'] . ',' . $iteminfo['billing_address']['region'] . ',' . $iteminfo['billing_address']['postcode'] . ',' . $iteminfo['billing_address']['country_id'] . ',' . $iteminfo['billing_address']['telephone'];
 
- 	 $shippingmethod = $item['shipping_description'];
 
-      $thatDayOrder[] = array(
 
-      'order_id' => $item['increment_id'],
 
- 	 'insurance' => $item['base_amcheckoutfees_amount'],
 
-      'product_name' => $productNames,
 
-      'purchased_on' => $item['created_at'],
 
-      'name' => $iteminfo['customer_firstname'].' '.$iteminfo['customer_lastname'],
 
-      'bill_to_name' => $item['billing_firstname'].' '.$item['billing_lastname'],
 
-      'ship_to_name' => $item['shipping_firstname'].' '.$item['shipping_lastname'],
 
-      'shipping_address' => $shipping_address,
 
-      'billing_address' => $billing_address,
 
-      'country' => $iteminfo['shipping_address']['country_id'],
 
-      'region' => $iteminfo['shipping_address']['region'],
 
-      'city' => $iteminfo['shipping_address']['city'],
 
-      'street' => $iteminfo['shipping_address']['street'],
 
-      'telephone' => $item['telephone'],
 
-      'postcode' => $item['postcode'],
 
-      'email' => $item['customer_email'],
 
-      'global_currency_code' => $item['global_currency_code'],
 
-      'base_grand_total' => $item['base_grand_total'],
 
-      'grand_total' => $item['order_currency_code'].$item['grand_total'],
 
-      'isstatus' => $item['status'],
 
-      'isparameter' => implode(';',$parameters),
 
-      'sku' => str_replace(array('<','>'),array('<','>'),$skus),
 
-      'order_quantity' => $quantity,
 
-      'order_comment' => addslashes($item['firecheckout_customer_comment']),
 
-      'paypal_num' => ($iteminfo['payment']['oceanpay_order_id'] != '')?$iteminfo['payment']['oceanpay_order_id']:$iteminfo['payment']['last_trans_id'],
 
- 	 'pay' => $iteminfo['payment']['method'],
 
-      'paypal_protection_eligibility' => $iteminfo['payment']['additional_information']['paypal_protection_eligibility'],
 
- 	 'shippingmethod'=>($item['base_shipping_amount'] > 0 || $iteminfo['tax_amount'] > 0)?$shippingmethod.' '.$item['base_shipping_amount'].'  Tax:'.$iteminfo['tax_amount'].';':$shippingmethod.' '.$item['base_shipping_amount'].'  Tax:'.$iteminfo['tax_amount'],
 
- 	 'link'=>$thislink,
 
- 	  'wjauthorid' => isset($iteminfo['author_id'])?$iteminfo['author_id']:'',
 
- 	  'sourcecontentid' => isset($iteminfo['source_content_id'])?$iteminfo['source_content_id']:'',
 
- 	  'authorid' => ''
 
-      );
 
- 	 //sleep(1);
 
- 	 }
 
- 	 return $thatDayOrder;exit;
 
- }
 
- function cs($name,$from,$to)//查看该订单所有信息
 
- {
 
- 	$data = name($name);
 
- 	$fromTime = date('Y-m-d H:i:s',$from);
 
- 	$toTime = date('Y-m-d H:i:s',$to);
 
- 	$filters = array(array('created_at'=>array('from'=>$fromTime,'to'=>$toTime)));
 
- 	$result = $data['proxy']->call($data['sessionId'],'sales_order.list',$filters);
 
- 	$thatDayOrder = array();
 
- 	foreach($result as $item)
 
- 	{
 
- 		$iteminfo = $data['proxy']->call($data['sessionId'], 'sales_order.info', $item['increment_id']);
 
- 		$productNames = '';
 
- 		$parameters = array();
 
- 		$skus = '';
 
- 		$quantity = '';
 
- 		$thislink = '';
 
- 		$link = array();
 
- 		foreach($iteminfo['items'] as $index=>$products)
 
- 		{
 
- 		    $quantity .= floor($products['qty_ordered']).';';
 
- 		    $productNames .= ($index > 0)?','.$products['name']:$products['name'];
 
- 		    $skus .= ($index > 0)?','.$products['sku']:$products['sku'];
 
- 		    $options = unserialize($products['product_options']);
 
- 		    $para = '';
 
- 		    if(isset($options['options']))
 
- 			{
 
- 		        foreach($options['options'] as $i=>$op)
 
- 		        {
 
- 			        $parameter = $op['label'].':'.$op['value'];
 
- 		            $para .= ($i>0)?','.$parameter:$parameter;
 
- 	            }
 
- 			}
 
- 			else
 
- 			{
 
- 				$para = '';
 
- 			}
 
- 	        $parameters[] = $para;
 
- 			try
 
- 			{
 
- 			    $plink = $data['proxy']->call($data['sessionId'], 'catalog_product.info',$products['product_id']);
 
- 				$link[] = $plink;
 
- 			    $thislink .= ($index > 0)?','.$data['url'].'/'.$plink['url_path']:$data['url'].'/'.$plink['url_path'];
 
- 			}catch (Exception $e) 
 
- 			{
 
-                 continue;
 
-             }
 
- 	     }
 
- 		 if($item['status'] == 'pending')
 
- 		 {
 
- 			 continue;
 
- 		 }
 
- 		 $thatDayOrder[] = array($iteminfo,$link);
 
- 	 
 
- 	 }
 
- 	 return $thatDayOrder;exit;
 
- }
 
- function cs2()//查看该订单所有信息
 
- {
 
- 	$name = 'Alipearl';
 
- 	$jqtime = 9*3600;
 
- 	$from = strtotime('yesterday')-$jqtime;//昨日0点+1小时保险无漏单
 
- 	$to = time();
 
- 	$data = name($name);
 
- 	$fromTime = date('Y-m-d H:i:s',$from);
 
- 	$toTime = date('Y-m-d H:i:s',$to);
 
- 	$filters = array(array('created_at'=>array('from'=>$fromTime,'to'=>$toTime)));
 
- 	$result = $data['proxy']->call($data['sessionId'],'sales_order.list',$filters);
 
- 	$thatDayOrder = array();
 
- 	foreach($result as $item)
 
- 	{
 
- 		$iteminfo = $data['proxy']->call($data['sessionId'], 'sales_order.info', $item['increment_id']);
 
- 		$productNames = '';
 
- 		$parameters = array();
 
- 		$skus = '';
 
- 		$quantity = '';
 
- 		$thislink = '';
 
- 		foreach($iteminfo['items'] as $index=>$products)
 
- 		{
 
- 		    $quantity .= floor($products['qty_ordered']).';';
 
- 		    $productNames .= ($index > 0)?','.$products['name']:$products['name'];
 
- 		    $skus .= ($index > 0)?','.$products['sku']:$products['sku'];
 
- 		    $options = unserialize($products['product_options']);
 
- 		    $para = '';
 
- 		    foreach($options['options'] as $i=>$op)
 
- 		    {
 
- 			    $parameter = $op['label'].':'.$op['value'];
 
- 		        $para .= ($i>0)?','.$parameter:$parameter;
 
- 	        }
 
- 	        $parameters[] = $para;
 
- 			try
 
- 			{
 
- 			    $plink = $data['proxy']->call($data['sessionId'], 'catalog_product.info',$products['product_id']);
 
- 			    $thislink .= ($index > 0)?','.$data['url'].'/'.$plink['url_path']:$data['url'].'/'.$plink['url_path'];
 
- 			}catch (Exception $e) 
 
- 			{
 
-                 continue;
 
-             }
 
- 	     }
 
- 		 $thatDayOrder[] = $iteminfo;
 
- 	 
 
- 	 }
 
- 	 return $thatDayOrder;
 
- 	 
 
- }
 
- function update($ddh,$ydh,$xg,$shop,$ex,$msg)
 
- {
 
- 	$data = name($shop['brandname']);
 
- 	if($data == 2)
 
- 	{
 
- 		return;exit;
 
- 	}
 
- 	$carrier = strtolower($ex['iscode']);
 
- 	$id = $ddh; //订单号
 
- 	$shopname = $shop['brandname'];  //店铺名
 
- 	$buyername = $xg['bname'];   //Bill Name
 
- 	$email_call = $shop['shopid']; //发货人邮箱;
 
- 	$phone = $shop['shopphone'];   //发货人电话
 
- 	$track_type = $ex['title'];   //快递名称
 
- 	$service = $ex['title'];   //快递追踪名称
 
- 	$track_link = $ex['url'];   //快递查询网址
 
- 	$logistics_number = $ydh;    //运单号
 
- 	$remark = $msg;
 
- 	try 
 
- 	{
 
- 	    $create_result = $data['proxy']->call($data['sessionId'],'order_shipment.create',array($id,array(),$remark,true,true));
 
- 	}
 
- 	catch (Exception $e)
 
- 	{ 
 
- 	    return $e;exit;
 
- 	}
 
- 	if(isset($create_result))
 
- 	{
 
- 		$status_array = array('orderIncrementId'=>$id,'status'=>'complete');
 
- 		$track_array = array(
 
- 		'shipmentIncrementId' =>$create_result,//ID
 
- 		'carrier' =>  $carrier,//物流商
 
- 		'title' => $track_type,//标题同上
 
- 		'trackNumber' => $logistics_number//运单
 
- 		);
 
- 		$track_result = $data['proxy']->call($data['sessionId'],'sales_order_shipment.addTrack',$track_array);
 
- 		$status_result = $data['proxy']->call($data['sessionId'], 'sales_order.addComment',$status_array);
 
- 	}
 
- 	else
 
- 	{
 
- 		$status_result = "";
 
- 	}
 
- 	if($status_result)
 
- 	{
 
- 		return 1;exit;
 
- 	}
 
- 	else
 
- 	{
 
- 		return;exit;
 
- 	}
 
- }
 
- if($_POST['synchronization'])
 
- {
 
- 	$synchronization = synchronization($_POST['name'],$_POST['from'],$_POST['to']);
 
- 	echo json_encode($synchronization);exit;
 
- }
 
- if($_POST['update'])
 
- {
 
- 	$update = update($_POST['ddh'],$_POST['ydh'],$_POST['xg'],$_POST['shop'],$_POST['ex'],$_POST['msg']);
 
- 	echo json_encode($update);exit;
 
- }
 
- if($_POST['cs'])
 
- {
 
- 	$synchronization = cs($_POST['name'],$_POST['from'],$_POST['to']);
 
- 	echo json_encode($synchronization);exit;
 
- }
 
- if($_POST['g'])
 
- {
 
- 	$synchronization = g($_POST['name'],$_POST['from'],$_POST['to']);
 
- 	echo json_encode($synchronization);exit;
 
- }
 
- if($_GET['a'])
 
- {
 
- 	$synchronization = cs2();
 
- 	 echo "<pre>";
 
- 	 print_r($synchronization); 
 
- }
 
- if($_POST['shopify'])
 
- {
 
- 	$shopify = shopify($_POST['shopify']);
 
- 	echo $shopify;exit;
 
- }
 
- function shopify($shopify)
 
- {
 
- 	$ch = curl_init();
 
-     curl_setopt($ch, CURLOPT_URL,$shopify);//?status=any所有订单 &limit=200每页多少单
 
-     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
 
-     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
 
-     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
-     $res = curl_exec($ch);
 
-     curl_close($ch);
 
- 	return $res;
 
- }
 
- //echo "<pre>";
 
- //print_r(array($item,$iteminfo));
 
- //echo "</pre>";
 
 
  |