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 "
";
	 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 "
";
//print_r(array($item,$iteminfo));
//echo "
";