load->library('session'); $this->load->_model('Model_api','api'); $this->load->_model('Model_apismt','apismt'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullorder_smt','fullorder_smt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_customersmt','customersmt'); $this->load->_model('Model_country','country'); $this->load->_model('Model_hl','hl'); $this->load->_model('Model_is','is'); $this->load->_model('Model_kdniao','kdniao'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_fullorderexcel','fullorderexcel'); $this->load->_model('Model_dhl','dhl'); $this->load->_model('Model_usps','usps'); $this->load->_model('Model_dhltest','dhltest'); $this->load->_model('Model_customer','customer'); $this->load->_model('Model_express','express'); $this->load->_model('Model_notice','notice'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_productdescribe','productdescribe'); $this->load->_model('Model_ljg','ljg'); $this->load->_model('Model_commodityread','commodityread'); $this->load->_model('Model_service','service'); $this->load->_model('Model_fedex','fedex'); $this->load->_model('Model_commodity','commodity'); $this->load->_model('Model_fullordersmtorder','fullordersmtorder'); $this->load->_model('Model_fullordersmthb','fullordersmthb'); $this->load->_model('Model_allocation','allocation'); $this->load->_model('Model_excel','excel'); $this->load->_model('Model_reset','reset'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'jsf') { $this->_jsf($arg_array); } else if($arg == 'jsm') { $this->_jsm($arg_array); } else if($arg == 'sku') { $this->_sku($arg_array); } else if($arg == 'order') { $this->_order($arg_array);//查询获取到fullordersmtorder的单 } else if($arg == 'data') { $this->_data($arg_array);//查询获取到fullordersmtorder的单 } else if($arg == 'dataxr') { $this->_dataxr($arg_array);//查询获取到fullordersmtorder的单写入 } else if($arg == 'cf') { $this->_cf($arg_array);//查询获取到fullordersmtorder的单 } else if($arg == 'khjz') { $this->_khjz($arg_array); } else if($arg == 'khjzfs') { $this->_khjzfs($arg_array); } else if($arg == 'tbsmt') { $this->_tbsmt($arg_array); } else if($arg == 'xqcx') { $this->_xqcx($arg_array); } else if($arg == 'dpex') { $this->_dpex($arg_array); } else if($arg == 'fedexhz') { $this->_fedexhz($arg_array); } else if($arg == 'smtck') { $this->_smtck($arg_array); } else if($arg == 'xxfs') { $this->_xxfs($arg_array);//消息发送测试 } else if($arg == 'smtprintout') { $this->_smtprintout($arg_array);//速卖通亚马逊操作出库 } else if($arg == 'feite') { $this->_feite($arg_array);//飞特提取内容下载 } else if($arg == 'rl') { $this->_rl($arg_array);//return label信息查找 } else if($arg == 'cz') { $this->_cz($arg_array);//重置恢复打印、出库 } else if($arg == 'paypal') { $this->_paypal($arg_array);//重置恢复打印、出库 } else if($arg == 'qcfs') { $this->_qcfs($arg_array);//清除邮件发送信息 } else if($arg == 'yd') { $this->_yd($arg_array);//测试运单 } else if($arg == 'jzw') { $this->_jzw($arg_array);//矫正whlabel } else if($arg == 'qlzd') { $this->_qlzd($arg_array);//清除无效占单 } } public function _qcfs($arg_array) { $a = $this->fullorder->get_number($arg_array[0]); $this->fullorder->save(array('zdstate'=>'','wltype'=>0,'wlcontent'=>'','wlfstime'=>''),$a['id']); } public function _jzw($arg_array)//矫正number和features不一致 { $d = $this->whlabel->find_pc("1=1",'sku,features,warehouse','*'); foreach ($d as $val) { $xd = $this->whlabel->find_all("sku = '".$val['sku']."' and features = '".$val['features']."' and warehouse = '".$val['warehouse']."'",'id,number,features,title,warehouse'); foreach ($xd as $v) { $f = str_replace('-','',$v['features']); if($v['number'] != $f) { $this->whlabel->save(array("number"=>$f),$v['id']); } } } } public function _qlzd()//清除无效占单 { $cw = array();$s = array(); $wh = $this->whlabel->find_all("state = '0' and zd != ''"); foreach ($wh as $v) { $d = $this->fullorder->get_number($v['zd']); if(!$d) { $d = $this->fullordersmt->get_number($v['zd']); if(!$d) { $d = $this->fullordertt->get_number($v['zd']); if(!$d) { $cw[] = $v['id']; continue; } } } if($d['state'] != 207 && $d['state'] != 209) { $s[] = $v['zd']; $this->whlabel->save(array("zd"=>''),$v['id']); } } echo "
";
		print_r($s);
	}
	
	
	public function _smtprintout($arg_array)
	{
		$time = time();
		$a = $this->fullordersmt->get_number($arg_array[0]);
		if($a)
		{
			if($a['zsbjz'] < 1)
			{
				echo "9610要求必须要申报价值!";exit;
			}
			if($a['waybill'] != '' && $a['printtime'] == '0' && $a['librarytime'] == '0' && $a['warehouse'] == '3')
			{
				if($this->fullordersmt->save(array('review'=>5,'reviewtime'=>$time,'print'=>3,'printtime'=>$time,'printnumber'=>1,'library'=>2,'librarytime'=>$time,'libraryconfirm'=>2),$a['id']))
				{
					echo "操作已完成";
				}
				else
				{
					echo "操作失败,请重试";
				}
			}
			else
			{
				echo "操作失败,订单已操作完成或不符合条件";
			}
		}
		else
		{
			echo "找不到此编号";
		}
	}
	
	public function _smtck($arg_array)//测试SKU
	{
		$notice = $this->notice->read($arg_array[1]);
		$v = $this->fullorder->get_number($arg_array[0]);
		$shop = $this->shop->read($v['shop']);
		$express = $this->express->read($v['express']);
		$fs = $this->notice->get_god($v,$shop,$express,$notice['content'],$notice['message'],$notice['emailtitle']);
	}
	public function _sku($arg_array)//测试SKU
	{
		$gethl = $this->hl->get_hl();//获取即时汇率
		$dictionaries = $this->typeclass->find_all('ae!= "" and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)'); //产品人发类型颜色
		$dtc = array();
		foreach ($dictionaries as $v) 
		{
			if(stripos($v['spare'],'|') !== false)//如果有多个值
			{
				$v['spare'] = explode('|',$v['spare']);
				foreach ($v['spare'] as $k=>$vs) 
		        {
					if(stripos($v['zh'],'|') !== false)
					{
						$vzh = explode('|',$v['zh']);
						$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id']);
					}
					else
					{
					    $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
					}
				}
			}
			else if(stripos($v['spare'],'|') !== false)//如果有多个值
			{
				$v['spare'] = explode('|',$v['spare']);
				foreach ($v['spare'] as $k=>$vs) 
		        {
					if(stripos($v['zh'],'|') !== false)
					{
						$vzh = explode('|',$v['zh']);
						$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id']);
					}
					else
					{
					    $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
					}
				}
			}
			else
			{
				$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
			}
			
		}
		$dictionaries2 = $this->typeclass->find_all();
		foreach ($dictionaries2 as $v)
		{
			$dtctitle[$v['id']] = $v['title'];
		}
		$dtc['Clip'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
		$dtc['Clip--D'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
		$dtc['Clip--L'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
		$dtc['with bangs'] = array('classid'=>999,'zh'=>'(带齐刘海)','id'=>0);
		$dtc['no bangs'] = array('classid'=>999,'zh'=>'(无刘海)','id'=>0);
		$dtc['right'] = array('classid'=>999,'zh'=>'右偏分(戴上后U型部分在右边)','id'=>0);
		$dtc['middle'] = array('classid'=>999,'zh'=>'中分(戴上后U型部分在中间)','id'=>0);
		$dtc['left'] = array('classid'=>999,'zh'=>'左偏分(戴上后U型部分在左边)','id'=>0);
		$dtc['freeeyelash'] = array('classid'=>999,'zh'=>'(送假睫毛)','id'=>0);
		$dtc['stwbob10'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 10寸','id'=>0);
		$dtc['stwbob12'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 12寸','id'=>0);
		$dtc['stwbob14'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 14寸','id'=>0);
		$dtc['HDTransparent'] = array('classid'=>9,'zh'=>'(HD透明蕾丝)','id'=>0);
		$dtc['HDLight Brown'] = array('classid'=>9,'zh'=>'(HD透明蕾丝)','id'=>0);
		$dtc['nwb'] = array('classid'=>15,'zh'=>'扁头 自然曲','id'=>111);//中文词不一样,ID一样
		$dtctitle[126] = 'Hair Weaving';
		$dtctitle[127] = 'Closure';
		$dtctitle[128] = 'Wigs';
		$dtctitle[130] = 'Clip-in Full Head';
		/*  匹配结束  */    
		/*  价格加入  */  
		$money = array();
		$productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
		foreach ($productdescribe as $v) 
		{
			$money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
		}
		/*  价格加入  */
		/*  匹配ID加入  */
		$int = array();
		$intdata = $this->typeclass->find_all('classid=14','id,ae');
		foreach ($intdata as $v) 
		{
			$v['spare'] = explode('|',$v['spare']);
			$int[$v['id']] = $v['spare'][0];
		}
		/*  匹配ID结束  */
		/*  匹配状态加入  */
		$zt = array();$ste = array();
		$ztdata = $this->typeclass->find_all('classid=29','id,classtitle');
		foreach ($ztdata as $v) 
		{
			$zt[$v['classtitle']] = $v['id'];
			$ste[$v['id']] = $v['classtitle'];
		}
		/*  匹配状态结束  */
		/*  国家加入键值-k  */
		$cuy = array();
		$cuydata = $this->country->find_all('1=1','al,lb,id');
		foreach ($cuydata as $v) 
		{
			$cuy[$v['al']] = array('id'=>$v['id'],'lb'=>$v['lb']);//获取到国家ID
		}
		/*  国家加入键值-j  */
		/*  币种加入键值-k  */
		$typeclass = array();
		$tdata = $this->typeclass->find_all('classid=30','id,title');
		foreach ($tdata as $v) 
		{
			$typeclass[$v['title']] = $v['id'];
		}
		/*  币种加入键值-j  */
		$is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
		
		$r = $this->api->matching('1;1','BW--3+13*6F-24 26 28-20',$dtc,$money,$int,$dtctitle);
		echo "
";
		print_r($r);
	}
	
	public function _cf($arg_array) //速卖通订单拆分
	{
		$b = $this->fullordersmt->get_orderinfo($arg_array[0]);
			if($b['merge'] == $b['id'])
			{
				$data = $this->fullordersmt->find_all("merge = '".$b['merge']."'");
			    foreach ($data as $v) 
			    {
				    $a = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
					if($a)
					{
					    $this->fullordersmt->save($a,$v['id']);
					}
			    }
			}
	}
	
	public function _khjzfs($arg_array)//独立站客户下单数量矫正
	{
		//@$this->allocation->insert(array('title'=>'khfs - '.date('Y-m-d H:i:s',time())));
		$customer = $this->customer->find_all("1=1",'id,email,shop','id asc',$arg_array[0],$arg_array[1]);
		foreach ($customer as $k=>$v) 
        {
			$num =  $this->fullorder->find_all("email = '".$v['email']."' and shop = '".$v['shop']."' and mergeid = 0","*","dtime desc");
			$money = sprintf("%01.2f",array_sum(array_column($num,'shouldmoney')));
			$n = count($num);
			if($n > 0)
			{
			    $this->customer->save(array('num'=>$n,'money'=>$money,'time'=>$num[0]['dtime']),$v['id']);
			}
			else
			{
				$this->customer->save(array('num'=>$n),$v['id']);
			}
		}
	}
	
	public function _khjz($arg_array)//独立站客户下单数量矫正
	{
		$customer = $this->customer->find_count();
		$customer = ceil($customer/20000);
		for($i=0;$i<$customer;$i++) 
        {
			$a = ($i=='0')?0:$i*20000;
			$b = ($i+1)*20000;
		$ch = curl_init();
		$url = 'http://a'.($i+10).'.wepolicy.cn/ab/khjzfs/'.$a.'/'.$b;
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_HEADER,0);
		curl_setopt($ch,CURLOPT_POST, 1);
		curl_setopt($ch,CURLOPT_TIMEOUT,20);
        //设置post数据
		$post = array();
		$post['data'] = 1;
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
		$res = curl_exec($ch);
		curl_close($ch);
		}
	}
	
	public function _tbsmt($arg_array)//同步速卖通新店
	{
		$ch = curl_init();
		$url = 'http://39.100.97.180/start/order';
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_HEADER,0);
		curl_setopt($ch,CURLOPT_POST, 1);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
        //设置post数据
		$post = array();
		$post['starttime'] = 1393606800;
		$post['endtime'] = 1590021229;
		$post['page'] = $arg_array[0];
		$post['size'] = 50;
		$post['state'] = '["IN_CANCEL","WAIT_SELLER_SEND_GOODS","SELLER_PART_SEND_GOODS","WAIT_BUYER_ACCEPT_GOODS","FUND_PROCESSING","IN_ISSUE","IN_FROZEN","WAIT_SELLER_EXAMINE_MONEY","RISK_CONTROL"]';
		$post['code'] = '50002100d409LZqwnvDc1iVenS9ysG7EbP4LuxhnfuHykTwEciGd1129c3d57tI3Sin';
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
		$res = curl_exec($ch);
		curl_close($ch);
		$res = json_decode($res,true);
   	    echo "
";
		print_r($res);
	}
	
	public function _xqcx($arg_array)
	{
		$cw = array();
		 $class = array();$classdata = array();$lx = array();$pm = array();
		 $a = $this->typeclass->find_all('classid=6 or classid=7 or classid=8 or classid=10 or classid=12 or classid=13 or classid=15 or classid=19 or classid=20 or classid=21 or classid=22 or classid=23 or classid=24'); 
		 foreach ($a as $val)
		{
			$class[] = '-'.$val['id'].'-';
		}
		 $b = $this->typeclass->find_all(); 
		 foreach ($b as $val)
		{
			$classdata[$val['id']] = $val['title'];
			$lx[$val['id']] = $val['classid'];
			$pm[$val['id']] = $val['zh'];
		}
		//Closure  wigs
		 $dataa = $this->fullorder->find_all("librarytime > '1598889600' and librarytime < '1601395200' and (fpdata like '%Closure%' or fpdata like '%Wigs%')",'number,fpdata','id desc');
		 $datab = $this->fullordersmt->find_all("librarytime > '1598889600' and librarytime < '1601395200' and (fpdata like '%Closure%' or fpdata like '%Wigs%')",'number,fpdata','id desc');
		 $data = array_merge($dataa,$datab);
		 
		 $p = $class;
  $resdata = array();
  foreach ($data as $val)
  {
	  $f = explode(';',trim($val['fpdata'],';'));
	   foreach ($f as $v)
       {
		   if((stripos($v,'-127-') !== false || stripos($v,'-128-') !== false) && stripos($v,'-57-') !== false)
		   {
		    $e = explode('|',$v);
			$d = str_replace($p,'-',$e[0]);
			$q = str_replace(array('-163-','-164-','-165-','-166-'),'-',$e[0]);
			$q = explode('-',trim($q,'-'));
			$c = explode(',',$e[0]);
			if(!isset($resdata[$d]))
			{
			   if(stripos($v,'-127-') !== false)
			   {
			       if(isset($q[9]))
				   {
					   $s = ($q[9] != 68 && $q[9] != 69)?1:2; 
				   }
				   else
				   {
					   $s = 1;
				   }
				   $bt = (!isset($q[8]))?$q[5]:$q[8];//360类型的蕾丝尺寸直接显示为类型名称
				   if($lx[$q[5]] == '27')//如果是发块类型
				   {
				       $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$bt,$s);//数量、尺寸、类型、蕾丝尺寸、蕾丝颜色
				   }
			   }
			   else
			   {
				   if(isset($q[8]))
				   {
					   $s = ($q[8] != 68 && $q[8] != 69)?1:2; 
				   }
				   else
				   {
					   $s = 1;
				   }
				   if($lx[$q[5]] == '18')//如果是头套种类
				   {
				       $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$s);//数量、尺寸、头套种类、蕾丝颜色
				   }
			   }
			}
			else
			{
				if(is_array($e[2]) || !is_numeric($e[2]))
				{
					$cw[] = $v;
					continue;
				}
				else
				{
                $resdata[$d][0] += $e[2];
				}
				
			}
		   }
	   }
  }
  
$data =  array();
foreach ($resdata as $v)
{
	if(isset($v[4]))
	{
		if(!isset($data[$v[1].$v[2].$v[3].$v[4]]))
		{
			$data[$v[1].$v[2].$v[3].$v[4]] = array($v[0],$v[1],$pm[$v[2]],$classdata[$v[3]],$v[4]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
		}
		else
		{
			$data[$v[1].$v[2].$v[3].$v[4]][0] += $v[0];
		}
	}
	else
	{
		if(!isset($data[$v[1].$v[2].$v[3]]))
		{
			$data[$v[1].$v[2].$v[3]] = array($v[0],$v[1],$pm[$v[2]],$v[3]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
		}
		else
		{
			$data[$v[1].$v[2].$v[3]][0] += $v[0];
		}
	}
}
$list = array();
foreach ($data as $v)
{
	$x = (isset($v[4]))?$v[3]:$v[2];
	    if(!isset($list[$v[2]]))
		{
			$list[$v[2]] = array();
			if(!isset($list[$v[2]][$x]))
		    {
				$list[$v[2]][$x] = array();
				$list[$v[2]][$x][] = $v;
			}
			else
			{
				$list[$v[2]][$x][] = $v;
			}
		}
		else
		{
			if(!isset($list[$v[2]][$x]))
		    {
				$list[$v[2]][$x] = array();
				$list[$v[2]][$x][] = $v;
			}
			else
			{
				$list[$v[2]][$x][] = $v;
			}
		}
}

foreach ($list as $key=>$val)
{
	foreach ($val as $k=>$va)
    {
		$dd = array();
		foreach ($va as $v)
        {
		    $ss = (!isset($v[4]))?$v[3]:$v[4];
		    if(!isset($dd[$v['1']]))
		    {
			    $dd[$v['1']] = array();
				$dd[$v['1']][$ss] = $v;
		    }
		    else
		    {
			    $dd[$v['1']][$ss] = $v;
		    }
		}
		ksort($dd);
		$list[$key][$k] = $dd;
    }
}
//echo count($list);
//echo "
";
//print_r($list);

		$str = "
        
        
        ";
		foreach ($list as $key=>$val)
{
	$btnum = count($val);
		$str .= "";
			foreach ($val as $k=>$v)
            {
            $str .="";
			}
           $str .=  "

".$key."

".$k." 中棕 透明
"; $str .= ""; foreach ($val as $k=>$v) { $str .= ""; } $str .= "
"; foreach ($v as $sk=>$s) { $xk1 = (isset($s[1]))?$s[1][0]:0; $xk2 = (isset($s[2]))?$s[2][0]:0; $str .=""; } $str .= "
".$sk."".$xk1."".$xk2."
"; } $str .= ""; header( "Content-Type: application/vnd.ms-excel; name='excel'" ); header( "Content-type: application/octet-stream" ); header( "Content-Disposition: attachment; filename=".time().'.xls' ); header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); header( "Pragma: no-cache" ); header( "Expires: 0" ); exit($str); } public function _fedexhz($arg_array) { $fullorder = $this->fullorder->get_number($arg_array[0]); if(!$fullorder) { $fullorder = $this->fullordersmt->get_number($arg_array[0]); } $fullorder = $this->_text($fullorder); $data = $fullorder; $ToState = array('alabama'=>'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'],' '); $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])]; $data['province'] = $dataprovince; //your account details here /**许昌联邦账号 $key = 'L7Vtg0uUP0BxgNfp'; $password = 'iOqmHwfjx12sxszdEZstGtRYs'; $AccountNumber = '644155250'; $MeterNumber = '250140772'; **/ //杭州联邦账号 $key = 'Jx8Rq9QL34sMKJTK'; $password = 'lmnYVRVcOISI0D1i48CEiXpYh'; $AccountNumber = '692362136'; $MeterNumber = '250759448'; $xml = ''; $xml.=''; $xml.=''; $xml.=''; $xml.=''; $xml.=''; $xml.=''; $xml.=''.$key.''; $xml.=''.$password.''; $xml.=''; $xml.=''; $xml.=''.$key.''; $xml.=''.$password.''; $xml.=''; $xml.=''; $xml.=''; $xml.=''.$AccountNumber.''; $xml.=''.$MeterNumber.''; $xml.=''; $xml.=''; //$xml.='Ship_International_basic'; $xml.=''; $xml.=''; $xml.='ship'; $xml.='26'; $xml.='0'; $xml.='0'; $xml.=''; $xml.=''; $xml.=''.date('Y-m-d',time()).'T'.date('H:i:s',time()).'-12:00'.''; $xml.='REGULAR_PICKUP'; $xml.='FEDEX_INTERNATIONAL_PRIORITY';//FEDEX_INTERNATIONAL_PRIORITY、FEDEX_INTERNATIONAL_PRIORITY_EXPRESS也是优先。INTERNATIONAL_ECONOMY经济 //超过重量需要换包装,现在不设置,超出也按0.4走 if($data['zzl'] < '9999999')//现在限制死,只有0.4 实际应填写 $data['zzl'] < 0.5 { $xml.='FEDEX_PAK'; } else { $xml.='FEDEX_BOX'; } $xml.='';//发货人信息开始 $xml.=''.$AccountNumber.''; $xml.=''; $xml.='LONGYI';//$data['warehouse']['company'] $xml.='LONGYI';//$data['warehouse']['company'] $xml.='18539006340';//$data['warehouse']['phone'] //$xml.=''.$data['warehouse']['name'].''; $xml.=''; $xml.=''; $xml.='4703,building C,bodi center,ningwei street';//$data['warehouse']['address'] $xml.='Hang Zhou';//$data['warehouse']['city'] //$xml.='TN'; $xml.='310000';//$data['warehouse']['zipcode'] //许昌联邦要求使用郑州邮编:450016 $xml.=''.$data['warehouse']['lb'].''; $xml.=''; $xml.=''; $xml.='';//收货人信息开始 $xml.=''.$AccountNumber.''; $xml.=''; $xml.=''.$data['name'].''; $xml.=''.$data['client'].''; $xml.=''.$data['phone'].''; //$xml.=''.$data['name'].''; $xml.=''; $xml.=''; $xml.=''.$data['address'].''; $xml.=''.$data['address2'].''; $xml.=''.$data['city'].''; $xml.=''.$data['province'].''; $xml.=''.$data['zipcode'].''; $xml.=''.$data['lb'].''; $xml.=''; $xml.=''; $xml.=''; $xml.='SENDER'; $xml.=''; $xml.=''; $xml.=''.$AccountNumber.''; $xml.=''; $xml.='He Cong'; //$xml.=''; $xml.=''; $xml.=''; $xml.=''; $xml.=''; //ETD开始 $xml.=''; $xml.='ELECTRONIC_TRADE_DOCUMENTS'; $xml.=''; $xml.='COMMERCIAL_INVOICE'; $xml.=''; $xml.=''; //ETD结束 $xml.=''; $xml.=''; $xml.='RECIPIENT'; $xml.=''; $xml.=''; $xml.=''; //$xml.=''; //$xml.='BUSINESS_STATE';//雇主识别代码BUSINESS_NATIONAL、BUSINESS_STATE、BUSINESS_UNION、PERSONAL_NATIONAL、PERSONAL_STATE //$xml.='213456';//这里填税号 //$xml.=''; //$xml.=''; //$xml.='12345'; //$xml.='INPUT YOUR INFORMATION'; //$xml.=''; $xml.=''; $xml.=''; $xml.=''; $xml.='DOCUMENTS_ONLY'; $xml.=''; $xml.='USD'; $xml.=''.$data['zsbjz'].''; $xml.=''; //DESC1---:Commodities循环 $xml.=''; $xml.='1';//件数 $xml.='satin bags-100PCS';//品名和数量 $xml.='CN'; $xml.='4202320000';//海关编码 $xml.=''; $xml.='KG';//重量:磅 $xml.='0.1';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4 $xml.=''; $xml.='100';//需要填写数量 $xml.='cm'; $xml.=''; $xml.='USD'; $xml.='0.2';//单条申报价值 $xml.=''; $xml.=''; //DESC2 $xml.=''; $xml.='1';//件数 $xml.='hair accessories-100PCS';//品名和数量 $xml.='CN'; $xml.='9615110000';//海关编码 $xml.=''; $xml.='KG';//重量:磅 $xml.='0.1';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4 $xml.=''; $xml.='100';//需要填写数量 $xml.='cm'; $xml.=''; $xml.='USD'; $xml.='0.3';//单条申报价值 $xml.=''; $xml.=''; //DESC3 $xml.=''; $xml.='1';//件数 $xml.='woven label-1000PCS';//品名和数量 $xml.='CN'; $xml.='5901101090';//海关编码 $xml.=''; $xml.='KG';//重量:磅 $xml.='0.2';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4 $xml.=''; $xml.='1000';//需要填写数量 $xml.='cm'; $xml.=''; $xml.='USD'; $xml.='0.05';//单条申报价值 $xml.=''; $xml.=''; /** //DESC4 $xml.=''; $xml.='1';//件数 $xml.='satin bags-100PCS';//品名和数量 $xml.='CN'; $xml.='4202320000';//海关编码 $xml.=''; $xml.='KG';//重量:磅 $xml.='0.2';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4 $xml.=''; $xml.='100';//需要填写数量 $xml.='cm'; $xml.=''; $xml.='USD'; $xml.='0.2';//单条申报价值 $xml.=''; $xml.=''; **/ $xml.=''; $xml.='30.37(f)'; $xml.=''; $xml.=''; $xml.=''; $xml.='COMMON2D'; $xml.='PDF'; $xml.='STOCK_4X6.75'; $xml.=''; //发票参数开始 $xml.=''; $xml.='COMMERCIAL_INVOICE'; //ETD $xml.=''; $xml.=''; $xml.='PDF'; $xml.='PAPER_LETTER'; $xml.='true'; $xml.=''; $xml.=''; $xml.='LETTER_HEAD'; $xml.='IMAGE_1'; $xml.=''; $xml.=''; $xml.='SIGNATURE'; $xml.='IMAGE_2'; $xml.=''; //ETD $xml.=''; $xml.=''; //发票参数结束 $xml.='LIST';//费率请求类型 $xml.=''.$data['zjs'].'';//包装数量 $xml.=''; $xml.='1'; //$xml.='USD120.00';//保险金额 $xml.=''; $xml.='KG'; $xml.='0.4';//现在限制死,只有0.4 '.$data['zzl'].' $xml.=''; //超过重量需要填尺寸,现在不设置,超出也按0.4走 if($data['zzl'] > '99999')//这个正常设置应该是$data['zzl'] > '0.4' { $xml.=''; $xml.='4'; $xml.='20'; $xml.='30'; $xml.='CM'; $xml.=''; } //$xml.='Book';//阿联酋需要选择 $xml.=''; $xml.='CUSTOMER_REFERENCE'; $xml.=''.$data['number'].''; $xml.=''; //签名开始 if($data['qm'] > 0) { $qm = ($data['qm']=='1')?'ADULT':'INDIRECT';//DIRECT直接签名 ADULT成人签名 INDIRECT间接签名 $xml.=''; $xml.='SIGNATURE_OPTION'; $xml.=''; $xml.=''.$qm.''; $xml.=''; $xml.=''; } //签名结束 $xml.=''; $xml.=''; $xml.=''; $xml.=''; $xml.=''; /** $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services/ship'); 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); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35); $result_xml = curl_exec($ch); $result_xml = str_replace(array(':','-'), '', $result_xml); @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); **/ $ch = curl_init(); $url = 'http://z.wepolicy.cn/fedexhz.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35); //设置post数据 $post = array(); $post['data'] = $xml; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $values = json_decode($res,true); if(isset($values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber'])) { $g = array('x'=>'1','waybill'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber'],'label'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['CompletedPackageDetails']['Label']['Parts']['Image'],'invoice'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['ShipmentDocuments']['Parts']['Image']); } else if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'])) { $a = ''; if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage'])) { $a = $values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage']; } else { foreach ($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'] as $v) { $a .= $v['LocalizedMessage'].'--'; } } $g = array('x'=>'0','Description'=>$a); } else { $g = array('x'=>'0','Description'=>'未知错误'); } echo "
";
		print_r($g);
	}
	
	public function _text($fullorder)
    {
		/** 发票地址信息暂时无用 
		$fullorder['baddress'] = explode(',',$fullorder['baddress']);
		$fullorder['baddress'] = array_reverse($fullorder['baddress']);
		$fullorder['baddress'][1] = $country['ename'];
		**/
		//获取所用相关信息
		$warehouse = $this->warehouse->read($fullorder['type']);
		$country = $this->country->read($fullorder['country']);//订单国家信息
		$fcountry = $this->country->read($warehouse['country']);//仓库国家信息
		$warehouse['country'] = $fcountry['ename'];//仓库国家名
		$warehouse['lb'] = $fcountry['lb'];//仓库国家编码
		$fullorder['warehouse'] = $warehouse;//仓库数据加入订单
		$fullorder['lb'] = $country['lb'];//订单国家编码加入
		$fullorder['country'] = $country['ename'];//订单国家名
		$fullorder['zhou'] = $country['continent'];//所属州
		$express = $this->express->read($fullorder['express']);
		$fullorder['express'] = $express['servicename'];
		$fullorder['account'] = $express['account'];
		$fullorder['printcode'] = $express['printcode'];
		$fullorder['time'] = date('Y-m-d',time());
		$fullorder['times'] = date('Y-m-d H:i',time());
		$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
		$fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']);
		$fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']);
		$fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('<','>',';
',';
'),$fullorder['shipremarks']); $shop = $this->shop->read($fullorder['shop']); $fullorder['shop'] = $shop['shopname']; if(is_numeric($fullorder['pay'])) { $pay = $this->typeclass->read($fullorder['pay']); if($pay['classid'] == '4') { $fullorder['pay'] = $pay['title']; } } if($fullorder['printcode'] != "USPS") { $fullorder['client'] = htmlspecialchars($fullorder['client']); $fullorder['name'] = htmlspecialchars($fullorder['name']); } //增加退货单所需信息 $pt = ''; $fpdata = explode(';',trim($fullorder['fpdata'],';')); foreach ($fpdata as $v) { $p = explode('|',trim($v,'|')); $pt .= '

'.$p[1].' * '.$p[2].'

'; } $fullorder['pt'] = $pt; return $fullorder; } public function _dpex($arg_array) { $fullorder = $this->fullorder->get_number($arg_array[0]); if(!$fullorder) { $fullorder = $this->fullordersmt->get_number($arg_array[0]); } $fullorder = $this->_text($fullorder); /** $warehouse = $this->warehouse->read($fullorder['type']); $country = $this->country->read($fullorder['country']);//订单国家信息 $fcountry = $this->country->read($warehouse['country']);//仓库国家信息 $warehouse['country'] = $fcountry['ename'];//仓库国家名 $warehouse['lb'] = $fcountry['lb'];//仓库国家编码 $fullorder['warehouse'] = $warehouse;//仓库数据加入订单 $fullorder['lb'] = $country['lb'];//订单国家编码加入 $fullorder['country'] = $country['ename'];//订单国家名 $fullorder['zhou'] = $country['continent'];//所属州 $express = $this->express->read($fullorder['express']); $fullorder['express'] = $express['servicename']; $fullorder['account'] = $express['account']; $fullorder['printcode'] = $express['printcode']; $fullorder['time'] = date('Y-m-d',time()); $fullorder['times'] = date('Y-m-d H:i',time()); $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100; $fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']); $fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']); $shop = $this->shop->read($fullorder['shop']); $fullorder['shop'] = $shop['shopname']; **/ $fullorder['number'] = $fullorder['number'].'-1';//订单号重复修改新订单好 $data = $fullorder; $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=createOrder"; $Clientid = 'LYFZP'; $Token = 'NGkJSDx3bAxojl1YN232'; $code = array('DPEX'=>array('11','DPEX','1'),'ARAMEX'=>array('002','安迈世',0),'FEDEX'=>array('FEDEX_1CC','FEDEX_1CC',';lab10_10'),'UPS'=>array('04','UPS',0),'DHL'=>array('06','DHL',';lab10_10'),'FED-SN-IP'=>array('07','FED-SN-IP',';lab10_10'),'WML-FEDEX-ZZ'=>array('05','WML-FEDEX-ZZ',';lab10_10'),'FED-XS-F'=>array('03','FED-XS-F',';lab10_10'),'CNE'=>array('08','全球优先CNE','label10x10;0'),'TCNE'=>array('09','E速宝特惠','label10x10;0')); $printcode = $code[$data['printcode']]; //创建并预报订单 $count = array( 'Verify' => array( 'Clientid'=>$Clientid, 'Token'=>$Token ), 'OrderType' => '1',//1:快件订单 2:快递制单-非实时返回单号 3:仓储订单 4:快递制单-实时返回单号(等待时间较 长)。此方法选择 4,后续如需调用其他 方法,例如调用删除接口,其他方法 OrderType 请选择 2。 'OrderDatas' => array(0=>array( 'CustomerNumber' => $data['number'],//订单号 'ChannelCode' => $printcode[0],//渠道代码 'CountryCode' => $data['lb'],//国家二字码 'TotalWeight' => $data['zzl'],//订单重量 'TotalValue' => $data['zsbjz'],//申报价值 'Number' => $data['zjs'],//件数 'Note' => $data['number'],//备注 /** 'Insurance' => array(//是否购买保险 'Code' => '',//保险类型 'Value' => '',//保险金额 ), **/ 'FeePayData' => array(//运费支付信息 'FeePayType' => 'PP',//支付方式 [ PP:预付,CC:到付, TP:第三方] 'FeePayAccountNumber' => '',//支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传 'FeePayCountryCode' => '',//支付账号对应国家 支付方式为 TP 时必传 'FeePayPostCode' => '',//支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传 ), 'TaxPayData' => array(//税金/关税支付信息 OrderType 为 [快递制单] 时必传字段 'TaxPayType' => 'PP',//支付方式 [ PP:预付,CC:到付, TP:第三方] 'TaxPayAccountNumber' => '',//支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传 'TaxPayCountryCode' => '',//支付账号对应国家 支付方式为 TP 时必传 'TaxPayPostCode' => '',//支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传 ), 'Recipient' => array(//收件人信息 'Name' => $data['name'],//姓名 'Addres1' => $data['address'],//地址1 'Addres2' => $data['address2'],//地址2 'Mobile' => preg_replace('/\D/s','',$data['phone']),//手机 'Province' => $data['province'],//省/州 'City' => $data['city'],//城市 'Post' => trim($data['zipcode'],' '),//邮编 ), 'OrderItems' => array( 0=>array(//订单明细 'Money' => 'USD',//货币单位 //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传) 'Cnname' => '化纤发',//产品中文名 'Enname' => 'synthetic hair*1',//产品英文名 'Price' => '10',//单价 'Weight' => '0.1',//重量 'Num' => 1,//数量 'CustomsCode'=>6704190000//海关编码 ), 1=>array(//订单明细 'Money' => 'USD',//货币单位 //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传) 'Cnname' => '头饰',//产品中文名 'Enname' => 'hair accessories*1',//产品英文名 'Price' => '0.5',//单价 'Weight' => '0.1',//重量 'Num' => '1',//数量 'CustomsCode'=>9615110000//海关编码 ), 2=>array(//订单明细 'Money' => 'USD',//货币单位 //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传) 'Cnname' => '小发刷',//产品中文名 'Enname' => 'Hairbrush*1',//产品英文名 'Price' => '0.5',//单价 'Weight' => '0.1',//重量 'Num' => '1',//数量 'CustomsCode'=>9603290090//海关编码 ), 3=>array(//订单明细 'Money' => 'USD',//货币单位 //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传) 'Cnname' => '袋子',//产品中文名 'Enname' => 'Satin Bag*1',//产品英文名 'Price' => '0.5',//单价 'Weight' => '0.1',//重量 'Num' => '1',//数量 'CustomsCode'=>4202320000//海关编码 ), 4=>array(//订单明细 'Money' => 'USD',//货币单位 //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传) 'Cnname' => '假睫毛',//产品中文名 'Enname' => 'Eyelashes*1',//产品英文名 'Price' => '0.5',//单价 'Weight' => '0.1',//重量 'Num' => '1',//数量 'CustomsCode'=>6704200000//海关编码 ), /** 2=>array(//订单明细 'Money' => 'USD',//货币单位 //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传) 'Cnname' => '假睫毛',//产品中文名 'Enname' => 'Eyelashes*1',//产品英文名 'Price' => '0.5',//单价 'Weight' => '0.1',//重量 'Num' => '1',//数量 'CustomsCode'=>6704200000//海关编码 ), 3=>array(//订单明细 'Money' => 'USD',//货币单位 //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传) 'Cnname' => '袋子',//产品中文名 'Enname' => 'Satin Bag*1',//产品英文名 'Price' => '0.5',//单价 'Weight' => '0.1',//重量 'Num' => '1',//数量 'CustomsCode'=>4202320000//海关编码 ) **/ )) ) /**, 'Volumes' => array(//材积明细 (OrderType 为快递制单必传) 'Weight' => '123123',//实重 'Number' => '123123',//件数 'Length' => '123123',//长 'Width' => '123123',//宽 'Height' => '123123',//高 ), **/ ); $count = json_encode($count,true); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count))); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(!isset($res['returnDatas'][0]['corpBillid'])) { $g = array('x'=>'0','Description'=>$res['returnDatas'][0]['message']); } else { $yd = $this->get_dpex_yd($res['returnDatas'][0]['corpBillid'],$printcode[2]); $fp = $this->get_dpex_fp($res['returnDatas'][0]['corpBillid'],$count); if($yd != 'c' && $fp != 'c') { $g = array('x'=>'1','waybillid'=>$res['returnDatas'][0]['corpBillid'],'waybill'=>$res['returnDatas'][0]['trackNumber'],'yd'=>''.$yd.'','fp'=>''.$fp.''); } else { $g = array('x'=>'0','Description'=>'换取运单失败,请重试'); } } echo "
";
		print_r($g);
	}
	
	public function get_dpex_yd($waybill,$PrintPaper)
	{
		$url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderLabel";
		$Clientid = 'LYFZP';
		$Token = 'NGkJSDx3bAxojl1YN232';
		
		$count = array(
		'Verify' => array(
		'Clientid'=>$Clientid,
		'Token'=>$Token
		),
		'CorpBillidDatas'=> array(0=>array('CorpBillid'=>$waybill)),
		'OrderType'=> "1",//1:快件订单 2:快递制单 3:仓库订单
		'PrintPaper'=> $PrintPaper,//打印纸张 快递制单只固定为:label 和 A4
		'PrintContent'=> "1"//打印内容 1:地址标签 2:报关单 3:配货信息 可自由组合用“,”号隔开 如:1,2,3
		);
	    
		$count = json_encode($count,true);
        
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_HEADER,0);
		curl_setopt($ch,CURLOPT_POST, 1);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
		$res = curl_exec($ch);
		curl_close($ch);
		$res = json_decode($res,true);
		if($res['statusCode'] == 'success')
		{
		    return $res['url'];
		}
		else
		{
			return 'c';
		}
	}
	
	public function get_dpex_fp($waybill)
	{
		$url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderInvoice";
		$Clientid = 'LYFZP';
		$Token = 'NGkJSDx3bAxojl1YN232';
		
		$count = array(
		'Verify' => array(
		'Clientid'=>$Clientid,
		'Token'=>$Token
		),
		'CorpBillidDatas'=> array(0=>array('CorpBillid'=>$waybill))
		);
	    
		$count = json_encode($count,true);
        
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_HEADER,0);
		curl_setopt($ch,CURLOPT_POST, 1);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
		$res = curl_exec($ch);
		curl_close($ch);
		$res = json_decode($res,true);
		if($res['statusCode'] == 'success')
		{
		    return $res['url'];
		}
		else
		{
			return 'c';
		}
	}
	
	
	public function _feite($waybill)//飞特提取内容下载
	{
	    $a = '{"data":{"items":[{"orderId":"F370142205310002","traceId":"1Z88F19Y0396934797","remark":"LY-Supernova-0531-FBA16QRN39JPU-4","importTime":"2022-05-31 15:57:25","sentTime":"2022-06-02 22:40:19","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205300001","traceId":"1Z287F0E6705824870","remark":"LY-AP-2022053009-FBA16QQ0TC4N","importTime":"2022-05-30 15:45:42","sentTime":"2022-05-31 19:10:01","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270006","traceId":"1Z88F19Y0303244340","remark":"LY-WK- 2022052701-FBA16QJXYP99","importTime":"2022-05-27 15:24:16","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270005","traceId":"1Z88F19Y0302468708","remark":"LY-SN-2022052701","importTime":"2022-05-27 15:23:16","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270001","traceId":"1Z88F19Y0301362654","remark":"LY-Wiggins-2022052705-FBA16QJHKJ5R","importTime":"2022-05-27 11:58:23","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205120001","traceId":"1Z88F19Y0312674270","remark":"LY-H-2022051203-FBA16PSVQ9YF","importTime":"2022-05-12 09:51:55","sentTime":"2022-05-13 15:40:37","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220511000A","traceId":"1Z88F19Y0315997229","remark":"LY-Wiggins-2022051105-FBA16PRXMZ5L","importTime":"2022-05-11 15:01:31","sentTime":"2022-05-13 15:40:37","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000M","traceId":"1Z88F19Y0399360286","remark":"LY-XCLY-20220510-024-FBA00001","importTime":"2022-05-10 14:55:18","sentTime":"2022-05-10 20:19:19","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000J","traceId":"1Z88F19Y0397487868","remark":"LY-WK-2022050703-","importTime":"2022-05-10 12:22:22","sentTime":"2022-05-10 12:52:17","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000I","traceId":"1Z88F19Y0395774837","remark":"LY-Wiggins-2022050703-","importTime":"2022-05-10 12:22:23","sentTime":"2022-05-10 12:52:17","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000H","traceId":"1Z88F19Y0397543547","remark":"LY-AP-22050711-","importTime":"2022-05-10 12:22:19","sentTime":"2022-05-10 12:52:17","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205090002","traceId":"1Z88F19Y0397647720","remark":"LY-YMS-22050901-FBA16PNXD0GM","importTime":"2022-05-09 09:56:49","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205090001","traceId":"1Z88F19Y0397194737","remark":"LY-AS-22050902-FBA16PNSGL89","importTime":"2022-05-09 08:39:18","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205080005","traceId":"1Z88F19Y0399894754","remark":"LY-YMS-22050805","importTime":"2022-05-08 12:19:57","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220427000I","traceId":"272474117028","remark":"SUPER-20426-004","importTime":"2022-04-27 16:01:08","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000H","traceId":"272474116466","remark":"QQS-20426-052","importTime":"2022-04-27 15:59:38","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000G","traceId":"272474117109","remark":"QQS-20426-001","importTime":"2022-04-27 15:59:34","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000F","traceId":"272474116352","remark":"QQS-20425-102","importTime":"2022-04-27 15:59:29","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220427000D","traceId":"272474117337","remark":"Y-20426-058","importTime":"2022-04-27 14:07:57","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F37014220427000B","traceId":"272474117017","remark":"KISS-20426-021","importTime":"2022-04-27 14:07:50","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"芬兰"},{"orderId":"F37014220427000A","traceId":"272474116341","remark":"ALIP-20423-217","importTime":"2022-04-27 14:07:36","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204270009","traceId":"272474117532","remark":"Y-20427-011","importTime":"2022-04-27 14:03:31","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"葡萄牙"},{"orderId":"F370142204270008","traceId":"272474116569","remark":"AAP-20426-030","importTime":"2022-04-27 14:03:20","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204270004","traceId":"272467942761","remark":"ALIP-20425-072","importTime":"2022-04-27 11:10:19","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204270003","traceId":"272467945153","remark":"ALIP-20426-015","importTime":"2022-04-27 10:13:06","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"瑞典"},{"orderId":"F370142204270002","traceId":"272467947649","remark":"KISS-20425-019","importTime":"2022-04-27 10:13:03","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204270001","traceId":"272467946860","remark":"AAP-20425-002","importTime":"2022-04-27 10:12:51","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260009","traceId":"272419119163","remark":"KISS-20423-033","importTime":"2022-04-26 14:17:33","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204260008","traceId":"272419119185","remark":"Y-20426-006","importTime":"2022-04-26 13:12:56","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260007","traceId":"272419119060","remark":"ALIP-20425-067","importTime":"2022-04-26 13:12:48","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260006","traceId":"272419118970","remark":"KISS-20425-023","importTime":"2022-04-26 13:12:39","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260005","traceId":"272467947351","remark":"ALIP-20424-090","importTime":"2022-04-26 13:12:30","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"丹麦"},{"orderId":"F370142204260004","traceId":"272419118671","remark":"ALIP-20424-074","importTime":"2022-04-26 13:12:22","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"爱尔兰"},{"orderId":"F370142204260003","traceId":"272419119233","remark":"ALIP-20423-157","importTime":"2022-04-26 13:12:13","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260002","traceId":"272419118248","remark":"AAP-20425-016","importTime":"2022-04-26 13:12:05","sentTime":"2022-04-26 23:54:20","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204260001","traceId":"272419118947","remark":"AAP-20425-023","importTime":"2022-04-26 10:59:31","sentTime":"2022-04-26 23:54:20","iossNumber":"FR76880693544","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000H","traceId":"272362120808","remark":"KISS-20423-063","importTime":"2022-04-25 14:12:43","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220425000G","traceId":"272362120896","remark":"ALIP-20423-111","importTime":"2022-04-25 14:12:39","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220425000F","traceId":"272362120234","remark":"KISS-20422-051","importTime":"2022-04-25 14:12:34","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000E","traceId":"272362120040","remark":"KISS-20417-041","importTime":"2022-04-25 14:12:27","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"爱尔兰"},{"orderId":"F37014220425000D","traceId":"272362119918","remark":"AAP-20424-006","importTime":"2022-04-25 14:12:22","sentTime":"2022-04-26 23:54:20","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000C","traceId":"272362121285","remark":"Y-20423-049","importTime":"2022-04-25 11:54:54","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000B","traceId":"272362120223","remark":"ALIP-20419-117","importTime":"2022-04-25 11:48:14","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000A","traceId":"272362119540","remark":"ALIP-20422-137","importTime":"2022-04-25 11:42:36","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204250009","traceId":"272362119653","remark":"ALIP-20423-100","importTime":"2022-04-25 11:42:23","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250008","traceId":"272362120061","remark":"ALIP-20422-191","importTime":"2022-04-25 11:42:20","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204250006","traceId":"272362120495","remark":"AAP-20424-016","importTime":"2022-04-25 11:19:23","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250005","traceId":"272362119355","remark":"AAP-20424-025","importTime":"2022-04-25 11:02:10","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"瑞典"},{"orderId":"F370142204250004","traceId":"272362120407","remark":"AAP-20423-017","importTime":"2022-04-25 10:55:58","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204250003","traceId":"272362120392","remark":"AAP-20423-006","importTime":"2022-04-25 10:55:42","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250002","traceId":"272362121171","remark":"Y-20423-003","importTime":"2022-04-25 09:21:30","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"}],"pageInfo":{"pageIndex":1,"pageSize":1000,"totalCount":51,"totalPage":1}},"status":1,"msg":"","datas":null,"errCode":0}';
		//发货页面当前页数量拉满
	    //格式:{"data":{"items":[{"orderId":"F37014220102000D","traceId":"288335360044","remark":"ALIP-11230-109","importTime":"2022-01-02 13:48:27","sentTime":"2022-01-05 07:57:00","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"}],"pageInfo":{"pageIndex":1,"pageSize":1000,"totalCount":563,"totalPage":1}},"status":1,"msg":"","datas":null,"errCode":0}
		$a = json_decode($a,true);$b = array();
		foreach ($a['data']['items'] as $v)
		{
			//if($v['iossNumber'] == 'IM3800007691')
			//{
				$b[] = $v;
			//}
		}
		$title = "飞特"; 
            $titlename = "
订单号 跟踪号 编号 导入时间 发货时间 IOSS 快递方式 国家
"; $filename = $title.".xls"; $tail = "\n"; $this->excel->get_fz2($b,$titlename,$filename,$tail); } public function _rl($arg_array) { $t = (1646064000-1635696000)/(24*3600); $list = array(); for($i=0;$i<$t;$i++) { $time = ($i>0)?1635696000+($i*24*3600):1646064000; $time = date('Ymd',$time); $d = $this->fullorder->find_all("returndata like '%$time%'",'number,returndata,js,zzl'); foreach ($d as $v) { $list[] = $v; } $s = $this->fullordersmt->find_all("returndata like '%$time%'",'number,returndata,js,zzl'); foreach ($s as $v) { $list[] = $v; } } $data = array(); foreach ($list as $k=>$v) { $js = ($v['js'] == '0')?'FIRST CLASS':'PRIORITY'; $return = explode('/t-',$v['returndata']); $time = explode('/pdf/',$return[0]); $time = strtotime($time[1]); $return = explode('.pdf"',$return[1]); $data[] = array($v['number'],$return[0],$js,$v['zzl'],date('Y-m-d',$time)); } $title = 'return'; $titlename = "
编号 return label 运单号 服务类型 重量 return label 时间
"; $filename = $title.".xls"; $tail = "\n"; $this->excel->get_fz2($data,$titlename,$filename,$tail); echo "
";
		 print_r($data);
	}
	
	public function _cz($arg_array)
    {
		$f = 'fullorder';
		$d = $this->fullorder->get_number($arg_array[0]);
		if(!$d)
		{
			$f = 'fullordersmt';
			$d = $this->fullordersmt->get_number($arg_array[0]);
			if(!$d)
			{
				$f = 'fullordertt';
				$d = $this->fullordertt->get_number($arg_array[0]);
			}
		}
		if(!$d)
		{
			echo '找不到此编号';exit;
		}
		$cz = 'reset';
		$c = $this->$cz->find_all("number = '".$arg_array[0]."'",'*','id desc');
		if(!$c)
		{
			echo '找不到此编号';exit;
		}
		$c = $c[0];
		if($c['printtime'] != '无' && $c['librarytime'] != '无')
		{
			$this->$f->save(array('printtime'=>strtotime($c['printtime']),'print'=>3,'printnumber'=>1,'librarytime'=>strtotime($c['librarytime']),'library'=>2,'reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
		}
		else if($c['printtime'] != '无' && $c['librarytime'] == '无')
		{
			$this->$f->save(array('printtime'=>strtotime($c['printtime']),'print'=>3,'printnumber'=>1,'reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
		}
		else if($c['printtime'] == '无' && $c['librarytime'] == '无' && $c['reviewtime'] != '无')
		{
			$this->$f->save(array('reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
		}
		else
		{
			echo '没有可恢复的状态';exit;
		}
	}
	
	public function _paypal($arg_array)//paypal用 返回头部数据
    {
		$f = $this->fullorder->get_number($arg_array[0]);
		$s = $this->shop->read($f['shop']);
		$client_id = $s['paypalname'];
        $secret_id = $s['paypalpass'];
		
		$url = 'https://api-m.paypal.com/v1/reporting/transactions?start_date='.date('Y-m-d',time()-26*24*3600).'T00:00:00-0700&end_date='.date('Y-m-d',time()+24*3600).'T23:59:59-0700&transaction_id='.$f['paypal'].'&fields=all&page_size=100&page=1';
		$ToState = array('alabama'=>'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');
		$ToState = array_flip($ToState);
		$header[] = "Content-Type: application/json";
        $header[] = "Authorization: Basic ".base64_encode($client_id.":".$secret_id);
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_HTTPGET, true);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //TRUE 将curl_exec()获取的信息以字符串返回,而不是直接输出。
		curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
		curl_setopt($ch, CURLOPT_HEADER, true); //返回response头部信息
        curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
        curl_setopt($ch, CURLOPT_URL, $url);
        $result = curl_exec($ch);
		curl_getinfo($ch, CURLINFO_HEADER_OUT);
		curl_close($ch);
        echo "
";
        echo $result;exit;
	}
	
	public function _yd($arg_array)
	{
		$fullorder = $this->fullorder->get_number($arg_array[0]);
		if(!$fullorder)
		{
			$fullorder = $this->fullordersmt->get_number($arg_array[0]);
		}
		if(!$fullorder)
		{
			echo "编号错误";exit;
		}
		/** 发票地址信息暂时无用 
		$fullorder['baddress'] = explode(',',$fullorder['baddress']);
		$fullorder['baddress'] = array_reverse($fullorder['baddress']);
		$fullorder['baddress'][1] = $country['ename'];
		**/
		//获取所用相关信息
		$warehouse = $this->warehouse->read($fullorder['type']);
		$country = $this->country->read($fullorder['country']);//订单国家信息
		$fcountry = $this->country->read($warehouse['country']);//仓库国家信息
		$warehouse['country'] = $fcountry['ename'];//仓库国家名
		$warehouse['lb'] = $fcountry['lb'];//仓库国家编码
		$fullorder['warehouse'] = $warehouse;//仓库数据加入订单
		$fullorder['lb'] = $country['lb'];//订单国家编码加入
		$fullorder['country'] = $country['ename'];//订单国家名
		$fullorder['zhou'] = $country['continent'];//所属州
		$express = $this->express->read($fullorder['express']);
		$fullorder['express'] = $express['servicename'];
		$fullorder['account'] = $express['account'];
		$fullorder['printcode'] = $express['printcode'];
		$fullorder['time'] = date('Y-m-d',time());
		$fullorder['times'] = date('Y-m-d H:i',time());
		$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
		$fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']);
		$fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']);
		$fullorder['shipremarks'] = str_replace(array('<','>'),array('<','>'),$fullorder['shipremarks']);
		$fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('<','>',';
',';
'),$fullorder['shipremarks']); $shop = $this->shop->read($fullorder['shop']); $fullorder['shop'] = $shop['shopname']; $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']); $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']); if(is_numeric($fullorder['pay'])) { $pay = $this->typeclass->read($fullorder['pay']); if($pay['classid'] == '4') { $fullorder['pay'] = $pay['title']; } } if($fullorder['printcode'] != "USPS") { $fullorder['client'] = htmlspecialchars($fullorder['client']); $fullorder['name'] = htmlspecialchars($fullorder['name']); } //增加退货单所需信息 $pt = ''; $fpdata = explode(';',trim($fullorder['fpdata'],';')); foreach ($fpdata as $v) { $p = explode('|',trim($v,'|')); $pt .= '

'.$p[1].' * '.$p[2].'

'; } $fullorder['pt'] = $pt; //$fullorder['printcode'] = 'HUALEIXW-FEDEX'; //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100; //$fullorder['sbbm']= 4202320000;//($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100; //$fullorder['sbpm']= 'eyelashes'; //$fullorder['zwpm']= '假睫毛'; //$fullorder['sbpm']= 'Satin Bag'; //$fullorder['zwpm']= '袋子'; //$fullorder['hgbm']= 4202320000; //$fullorder['address'] = '1653 Treutlan Place'; //$fullorder['address2'] = ''; //$fullorder['qm'] = 2; //$notice = $this->notice->read(6); //$fcountry['warehouse']['name'] = 'Hair Me Please LLC'; //$fullorder['cxcode'] = strtolower($express['cxcode']); //$barcode = $this->fedex->get_logistics($fullorder);//获取联邦快递信息 //echo $fullorder['name']; //$b = $this->ups->get_data($fullorder); $barcode = $this->get_data($fullorder); //$b = $this->usps->get_logistics($fullorder); echo "
";
		print_r($barcode);
		//echo "
";
		
		//echo $barcode['Postage'];
		
		
		
		//$b = $this->_pdf($barcode['yd'],$barcode['waybill'],time());
		
		//header("Content-type: text/xml");
		
		//echo $barcode;
		
		//echo $Hyd;
		//echo "
";
		//print_r($barcode);
		//print_r($barcode);
		/**
		$time = '1586232000';
		$bctime = date('Ymd',$time);
						$Hwaybill = $barcode['waybill'];
						$Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
						$Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);
		//header("Content-type:text/xml");
echo 'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
		//echo "
";
		//print_r($barcode);
		//$a = $this->whlabel->find_all(array('zd'=>'ASTE-00212-025'));//专属
		**/
	}
	
	  public function get_data($data)
	{
		if($data['pay'] == 1)
		{
			$data['pay'] == 'PayPal';
		}
		else if($data['pay'] == 2)
		{
			$data['pay'] == 'Western Union';
		}
		else if($data['pay'] == 3)
		{
			$data['pay'] == '微信';
		}
		else if($data['pay'] == 4)
		{
			$data['pay'] == '支付宝';
		}
		else if($data['pay'] == 5)
		{
			$data['pay'] == '银行转账';
		}
		else if($data['pay'] == 6)
		{
			$data['pay'] == '现金收款';
		}
		else if($data['pay'] == 7)
		{
			$data['pay'] == 'PingPong金融';
		}
		$id = 'XUCHANGLONGY';
		$pass = 'dJ84as3ELr';
		//$sid = '603521441';//官方DHL
		$sid = '605062090';//官方DHL美国
		$xmend = "\n";
		$Pieces = '';
		for($i=0;$i<$data['zjs'];$i++)
		{
		    $Pieces .= "".$xmend;
		    $Pieces .= "".($i+1)."".$xmend;
		    $Pieces .= "EE".$xmend;
			$Pieces .= "".$data['zzl']."".$xmend;
			$Pieces .= "15".$xmend;
			$Pieces .= "3".$xmend;
			$Pieces .= "5".$xmend;
			$Pieces .= "".$xmend;
		}
		/**  此内容是添加发票信息
		$dataadress = array();$baddress = '';$ba1 = '';$ba2 = '';
		for($i=5;$i 1)
		{
			for($i=0;$i".$xmend;
				$baddress .= "".rtrim($ba2,',')."".$xmend;
		}
		else
		{
			for($i=0;$i".$xmend;
		}
		**/
		$hgbm = $data['sbbm'];
		if(isset($data['hgbm']))
		{
			if($data['hgbm'] != '')
			{
				$hgbm = $data['hgbm'];
			}
		}
		$xml = "";
		$xml .= "".$xmend;
        $xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "".date('c')."".$xmend;
		//$rand = (strlen($data['orderinfo']) < 15)?rand(10000000,99999999):rand(100000,999999);
		//$xml .= "".time().$data['orderinfo'].$rand."".$xmend;
		$xml .= "".time().time().rand(10000000,99999999)."".$xmend;
		$xml .= "".$id."".$xmend;//DHL账号
		$xml .= "".$pass."".$xmend;//DHL密码
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "LongYi ERP".$xmend;
		$xml .= "V1.0.0".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "AP".$xmend;//地区代码
		$xml .= "en".$xmend;//语言
		///$xml .= "Y".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$sid."".$xmend;
		$xml .= "S".$xmend;
		$xml .= "".$sid."".$xmend;
		///$xml .= "R".$xmend;//R为收件人付关税 S发件人付关税
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$data['name']."".$xmend;//收货人名称
		/**
		if(strlen($data['address'].$data['address2']) > 44)
		{
			$adl = $data['address'].$data['address2'];
			$adl1 = substr($adl,0,44);//截取44字符前内容
			$adlnum = strripos($adl1," ");//查找最后一次出现空格位置
			$adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
			$adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
			$xml .= "".$adl1."".$xmend;//收货人地址1
			$xml .= "".$adl2."".$xmend;//收货人地址2
		}
		**/
		if($data['address2'])
		{
			//$adl = $data['address'].$data['address2'];
			//$adl1 = substr($adl,0,44);//截取44字符前内容
			//$adlnum = strripos($adl1," ");//查找最后一次出现空格位置
			//$adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
			//$adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
			$xml .= "".$data['address']."".$xmend;//收货人地址1
			$xml .= "".$data['address2']."".$xmend;//收货人地址2
		}
		else
		{
		    $xml .= "".$data['address'].$data['address2']."".$xmend;//收货人地址
		}
		if($data['street'] != '')
		{
		    $xml .= "".$data['street']."".$xmend;//收货人街道
		}
		$xml .= "".$data['city']."".$xmend;//城市
		if($data['lb'] == 'US')
		{
			$xml .= "".$data['province']."".$xmend;//州代码,仅美国
		}
		$xml .= "".trim($data['zipcode'],' ')."".$xmend;//邮编
		$xml .= "".$data['lb']."".$xmend;//国家代码
		$xml .= "".$data['country']."".$xmend;//国家名称
		$xml .= "".$xmend;
		$xml .= "".$data['client']."".$xmend;//名称
		$xml .= "".preg_replace('/\D/s','',$data['phone'])."".$xmend;//联系方式
		//$xml .= "".$data['email']."".$xmend;//联系邮箱
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$xmend;//多商品循环此外层标签及内层标签
		$xml .= "".$hgbm."".$xmend;//商品编码
		$xml .= "".$data['sbpm']."".$xmend;//商品名称
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$data['zsbjz']."".$xmend;//申报价值
		$xml .= "".$data['currencytitle']."".$xmend;//货币代码
		$xml .= "DAP".$xmend;//贸易条款
		$xml .= "".$xmend;
		/** 发票信息开始 **/
		$xml .= "Y".$xmend;
	    $xml .= "en".$xmend;
	    $xml .= "CMI".$xmend;
	    $xml .= "".$xmend;
		$xml .= "P".$xmend;
		if(strlen($data['paypal']) > 30)
		{
		    $xml .= "".str_replace(array('-'),array(''),$data['paypal'])."".$xmend;
		}
		else
		{
			$xml .= "".$data['paypal'].' '.$data['pay']."".$xmend;
		}
		$xml .= "".date('Y-m-d',time())."".$xmend;
		/**
		$xml .= "".$data['client']."".$xmend;
		$xml .= "".$data['client']."".$xmend;//账单名称
		$xml .= "";//地址1
		$xml .= "";//地址2
		$xml .= "".$data['baddress'][4]."".$xmend;//城市
		$xml .= "".$data['baddress'][2]."".$xmend;//邮编
		$xml .= "".$xmend;//所在郊区
		if($data['baddress'][1] == 'United States')
		{
			$xml .= "".$data['baddress'][3]."".$xmend;//省、州
		}
		$xml .= "".$data['baddress'][1]."".$xmend;//国家
		$xml .= "".preg_replace('/\D/s','',$data['baddress'][0])."".$xmend;//号码
		**/
		$xml .= "".$xmend;
		$xml .= "1".$xmend;//顺序号
		$xml .= "".$data['ts']."".$xmend;//数量
		$xml .= "PCS".$xmend;//单位
		$xml .= "".$data['sbpm']."".$xmend;//品名
		$xml .= "".$data['dtsbjz']."".$xmend;//单价
		$xml .= "Y".$xmend;//是否国产,Y本国,N国外
		$xml .= "".$hgbm."".$xmend;//品名编码
		$xml .= "".$xmend;
		$xml .= "".$data['zzl']."".$xmend;//净重
		$xml .= "K".$xmend;//重量单位,K千克
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$data['zzl']."".$xmend;//毛重
		$xml .= "K".$xmend;//毛重单位,K千克
		$xml .= "".$xmend;
		$xml .= "CN".$xmend;//原产国国家代码
		$xml .= "CHINA".$xmend;//原产国名称
		$xml .= "".$xmend;
		$xml .= "PEK PORT".$xmend;//适用港口
	    $xml .= "".$xmend;
		/** 发票信息结束 **/
		$xml .= "".$xmend;
		$xml .= "".$data['number']."".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		///$xml .= "".$data['zjs']."".$xmend;
		$xml .= "".$xmend;
		$xml .= $Pieces;
		$xml .= "".$xmend;
		///$xml .= "".$data['zzl']."".$xmend;
		$xml .= "K".$xmend;
		$xml .= "P".$xmend;
		$xml .= "P".$xmend;
		$xml .= "".date('Y-m-d',time())."".$xmend;
		$xml .= "".$data['sbpm']."".$xmend;//内容
		///$xml .= "DD".$xmend;
		$xml .= "C".$xmend;
		///$xml .= "".$data['bx']."".$xmend;//保险金额
		$xml .= "EE".$xmend;
		$xml .= "Y".$xmend;
		$xml .= "".$data['currencytitle']."".$xmend;//货币代码
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= "".$sid."".$xmend;
		$xml .= "LongYing".$xmend;//发货公司名称
		$xml .= "LongYingShiYe, Yinghao Rd.".$xmend;//发货地址
		$xml .= "Shangji Economic Development Zone".$xmend;//发货地址
		$xml .= "".$data['warehouse']['city']."".$xmend;//发货城市
		$xml .= "".$data['warehouse']['zipcode']."".$xmend;
		$xml .= "CN".$xmend;//发货国家代码
		$xml .= "CHINA".$xmend;//发货国家名称
		$xml .= "".$xmend;
		$xml .= 'GeMengTi'.$xmend;//发货人 '.$data['warehouse']['company'].'
		$xml .= '15939964739'.$xmend;
		$xml .= "".$xmend;
		
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		$xml .= '91411002MA3X46XC9K'.$xmend;
		$xml .= 'VAT'.$xmend;
		$xml .= 'CN'.$xmend;
		$xml .= "".$xmend;
		$xml .= "".$xmend;
		
	    $xml .= "".$xmend;
		/** 无纸化 PLT 开始 **/
		$xml .= "".$xmend;
		$xml .= "WY".$xmend;
		$xml .= "".$xmend;
		/** 无纸化 PLT 结束 **/
		if($data['bx'] > 0)
		{
		    $xml .= "".$xmend;
		    $xml .= "II".$xmend;
			$xml .= "".$data['bx']."".$xmend;
			$xml .= "USD".$xmend;
		    $xml .= "".$xmend;
		}
	    $xml .= "PDF".$xmend;
		/** 无纸化 PLT 启用这个 **/
		$xml .= "N".$xmend;
		/** 无纸化 PLT 启用这个 **/
		/** 无纸化 PLT 关闭这个 **/
		//$xml .= "Y".$xmend;
        //$xml .= "1".$xmend;
		/** 无纸化 PLT 关闭这个 **/
		$xml .= "".$xmend;
        $xml .= "".$xmend;
		echo "
";
		echo $xml;
		exit;
		
		$ch = curl_init(); 
		curl_setopt($ch, CURLOPT_URL,'https://xml-api.dhl.com/XMLShippingServlet'); 
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,15);
		$data = curl_exec($ch);
		curl_close($ch);
		$data = utf8_encode($data);
        libxml_disable_entity_loader(true);
        @$values = json_decode(json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
	}
	
	
	public function _xx()
	{
		$shop = $this->shop->read(57);
		if($shop['apitoken_time'] > time())
			{
				$token = $shop['apitoken'];
			}
			else
			{
				$res = $this->shop->hq_token($shop);
				$token = $res;
			}
           $data = '?';
		   //$data .= '&searchCriteria[filterGroups][0][filters][0][conditionType]=ConditionType';//字段类型
		   $data .= 'searchCriteria[sortOrders][0][field]=created_at';
		   $data .= '&searchCriteria[sortOrders][0][direction]=DESC';
		   $data .= '&searchCriteria[pageSize]=200';
		   $data .= '&searchCriteria[currentPage]=1';
		   $data .= '&searchCriteria[filterGroups][0][filters][0][field]=status';//字段名称
		   $data .= '&searchCriteria[filterGroups][0][filters][0][value]=processing';//字段内容
		   $url = 'https://pc.bilisar.com/rest/V1/orders'.$data;//订单
		   $res = $this->su_curl('',$url,$header=array("Authorization: Bearer ".$token,"Content-Type: application/json"),$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
		   $res = json_decode($res,true);
		   foreach ($res['items'] as $read) 
		   {
			   $productNames = '';//产品名称
			   $sku = '';
			   $parameters = '';
			   $quantity = '';
			   $orderid = '';
			   $link = '';
			   foreach ($read['items'] as $list) 
		       {
				    $productNames .= $list['name'].',';
					$sku .= $list['sku'].',';
					$link .= $list['extension_attributes']['product_url'].',';
					if(isset($list['extension_attributes']['select_options']))
					{
						foreach ($list['extension_attributes']['select_options'] as $s) 
		            	{
							$p = json_decode($s,true);
							$parameters .= $p['label'].':'.$p['value'].'---';
						}
					}
					$parameters = trim($parameters,'---').';';
					$quantity .= $list['qty_ordered'].';';
					$orderid = $list['order_id'];
			   }
			   $sku = str_replace(array('<','>'),array('<','>'),$sku);
			   $bill_street = '';//街道地址
			   foreach ($read['billing_address']['street'] as $s) 
		       {
				    $bill_street .= $s.' ';
			   }
			   $ship_street = '';//街道地址
			   foreach ($read['billing_address']['street'] as $s) 
		       {
				    $ship_street .= $s.' ';
			   }
			    $ly = isset($read['extension_attributes']['osc_order_comment'])?addslashes($read['extension_attributes']['osc_order_comment']):'';//留言
			   $thatDayOrder[] = array
			   (
			    'orderid' => $orderid,
    		    'order_id' => $read['increment_id'],
			    'insurance' => $read['extension_attributes']['amextrafee_base_fee_amount'],//运费险
    		    'product_name' => trim($productNames,','),
    		    'purchased_on' => $read['created_at'],
    		    'name' => (isset($read['customer_firstname'])?$read['customer_firstname']:'').' '.(isset($read['customer_lastname'])?$read['customer_lastname']:''),
    		    'bill_to_name' => $read['billing_address']['firstname'].' '.$read['billing_address']['lastname'],
    		    'ship_to_name' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['firstname'].' '.$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['lastname'],
				'billing_address' =>  trim($bill_street,' '). ',' .$read['billing_address']['city']. ',' .(isset($read['billing_address']['region'])?$read['billing_address']['region']. ',':'') .$read['billing_address']['postcode']. ',' .$read['billing_address']['country_id']. ',' .$read['billing_address']['telephone'],
    		    'shipping_address' => trim($ship_street,' '). ',' . $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['city']. ',' .(isset($read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'])?$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'].',':'').$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['postcode']. ',' .$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['country_id']. ',' .$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['telephone'],
    		    'country' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['country_id'],
    		    'region' => isset($read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'])?$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region']:'',
    		    'city' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['city'],
    		    'street' => $ship_street,
     		   'telephone' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['telephone'],
     		   'postcode' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['postcode'],
     		   'email' =>$read['billing_address']['email'],
     		   'global_currency_code' => $read['global_currency_code'],
     		   'base_grand_total' => $read['base_grand_total'],
     		   'grand_total' => $read['order_currency_code'].$read['grand_total'],
     		   'isstatus' => $read['status'],
     		   'isparameter' => trim($parameters,';'),
     		   'sku' => trim($sku,','),
     		   'order_quantity' => trim($quantity,';'),
     		   'order_comment' => $ly,
     		   'paypal_num' => isset($read['payment']['last_trans_id'])?$read['payment']['last_trans_id']:'',
	 		   'pay' => $read['payment']['method'],
     		   'paypal_protection_eligibility' => isset($read['payment']['additional_information']['9'])?$read['payment']['additional_information']['9']:'',
	 		   'shippingmethod'=> ($read['base_shipping_amount'] > 0 || $read['tax_amount'] > 0)?$read['shipping_description'].' '.$read['base_shipping_amount'].'  Tax:'.$read['tax_amount'].';':$read['shipping_description'].' '.$read['base_shipping_amount'].'  Tax:'.$read['tax_amount'],
	 		  'link'=>trim($link,','),
	 		   'author_id' => '',
	 		   'source_content_id' => '',
                );
			}
			echo "
";
		print_r($thatDayOrder);
		exit;
	}
	public function _a()
	{
		$where = "dlz < '1' and state = '207' and (express = '2' or express = '63' or express = '64') and librarytime > '".strtotime(date("Y-m-d 7:00:0",strtotime("-20 day")))."' and librarytime < '".strtotime(date("Y-m-d 7:00:0",time()))."'";
		$fdata = $this->fullorder->find_count($where);
		
		echo "
";
		echo $fdata;
		//print_r($fdata);
		exit;
		
		
		
		
		
		
		$sid = '';$sd = array();
		if(isset($_SESSION['api']))
		{
			$user = $this->user->get_api($_SESSION['api']);
		    $user = explode('|',trim($user['shop'],'|'));
			foreach ($user as $value) 
		    {
				$sid .= " id = '$value' or";
			}
			$sid = " and (".rtrim($sid,'or').")";
		}
		$post = $this->input->post(NULL, TRUE);
		$api = $this->input->get('api',true);
		$dshop = $this->input->get('dshop',true);
		//@$gethl = $this->hl->get_hl();//获取即时汇率
		$gethl = array();
		/*  订单号加入键值-k  */
		/**
		$dataorder = array();
		$fdata = $this->fullorder->find_all('dtime > "'.(time()-96*3600).'"','orderinfo');
		foreach ($fdata as $v) 
		{
			$dataorder[$v['orderinfo']] = "";//获取到单号
		}
		**/
		/*  订单号加入键值-j  */
		/*  匹配加入  */
		$dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
		// and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)
		$dtc = array();
		foreach ($dictionaries as $v) 
		{
			if(stripos($v['spare'],'|') !== false)//如果有多个值
			{
				$v['spare'] = explode('|',$v['spare']);
				foreach ($v['spare'] as $k=>$vs) 
		        {
					if(stripos($v['zh'],'|') !== false)
					{
						$vzh = explode('|',$v['zh']);
						$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
					}
					else
					{
					    $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
					}
				}
			}
			else
			{
				$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
			}
			
		}
		$dictionaries2 = $this->typeclass->find_all();
		foreach ($dictionaries2 as $v)
		{
			$dtctitle[$v['id']] = $v['title'];
		}
		/*  匹配结束  */    
		/*  价格加入  */ 
		/** 
		$money = array();
		$productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
		foreach ($productdescribe as $v) 
		{
			$money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
		}
		**/
		/*  价格加入  */
		/*  匹配ID加入  */
		$int = array();
		$intdata = $this->typeclass->find_all('classid=14','id,spare');
		foreach ($intdata as $v) 
		{
			$v['spare'] = explode('|',$v['spare']);
			$int[$v['id']] = $v['spare'][0];
		}
		/*  匹配ID结束  */
		/*  国家加入键值-k  */
		$cuy = array();
		$cuydata = $this->country->find_all('1=1','lb,id');
		foreach ($cuydata as $v) 
		{
			$cuy[$v['lb']] = $v['id'];//获取到国家ID
		}
		/*  国家加入键值-j  */
		/*  币种加入键值-k  */
		$typeclass = array();
		$tdata = $this->typeclass->find_all('classid=30','id,title');
		foreach ($tdata as $v) 
		{
			$typeclass[$v['title']] = $v['id'];
		}
		/*  币种加入键值-j  */
		/*  支付方式-k  */
		$pay = array();
		$tdata = $this->typeclass->find_all('classid=4','id,spare');
		foreach ($tdata as $v) 
		{
			$paytype = $this->pay->get_typeclass($v['id']);
			if(isset($paytype['estimaterate']))
			{
				$estimaterate = $paytype['estimaterate'];
			}
			else
			{
				$estimaterate = 0;
			}
			if(stripos($v['spare'],'|') !== false)//如果有多个值
			{
				$v['spare'] = explode('|',$v['spare']);
				foreach ($v['spare'] as $k=>$vs) 
		        {
					$pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
				}
			}
			else
			{
				$pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
			}
		}
		$pay['stripeios'] = $pay['stripe_payments'];
		/*  支付方式-j  */
		/*  新增SKU-k  */
		$zjsku = array();
		$shopsku = $this->shopsku->find_all();
		foreach ($shopsku as $val) 
		{
			$ss = explode(',',trim($val['shop'],','));
			foreach ($ss as $v) 
			{
				if(isset($zjsku[$v]))
				{
					$zjsku[$v] .= ','.trim($val['sku'],',');
				}
				else
				{
					$zjsku[$v] = trim($val['sku'],',');
				}
			}
		}	
		/*  新增SKU-j  */
		$is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表

			 $value = $this->shop->read(57);
				$setting = $this->setting->get_settings();
				$this->db->trans_begin();
				$res = $this->_xx($value['brandname'],$value['shopadmin'],$value);
				$sd[] = $res;
				$sjc = $setting['sctime'];//时间差 之前是3600 现在为0
				if($res)
				{
					foreach ($res as $v) 
		        	{
						if($value['token'] == 'SU')
						{
							$time = $v['purchased_on']-7*3600-$sjc;//之前是+$sjc
						}
						else if($value['program'] == 'Shopify')
						{
							$time = $v['purchased_on'];
						}
						else
						{
							if($value['id'] == 1)
							{
								$time = strtotime($v['purchased_on'])-7*3600-$sjc;//-$sjc;//之前是+$sjc
							}
							else
							{
								$time = strtotime($v['purchased_on'])-7*3600-$sjc;//订单时间更为时间戳 //之前是+$sjc
							}
						}
						$num = $this->fullorder->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
						$order_id = $value['id'].$v['order_id'];
						$tc = isset($typeclass[$v['global_currency_code']])?$typeclass[$v['global_currency_code']]:0;
						$dataorder = $this->fullorder->get_orderinfo($order_id);
						$hmdid = '';
						if($value['program'] == 'Shopify' && isset($dataorder['id']))
						{
							if($v['order_comment'] != $dataorder['clientremarks'])
							{
								$this->fullorder->save(array('clientremarks'=>$v['order_comment']),$dataorder['id']);
							}
						}
						if(!isset($dataorder['id']))
//现在为所有订单都获取。!$ord && strcasecmp($v['isstatus'],'processing') == 0如果没有此订单并且订单状态为等待发货则继续
						{
							if(!isset($cuy[$v['country']]))
							{    
							    $cuy[$v['country']] = 1004;
							}
			          	    $post = $this->api->get_data($value,$v,$gethl,$time,$cuy[$v['country']],$is,$num,$v['country'],$tc,$dtc,array(),$int,$dtctitle,$pay,$zjsku);
							$kn = explode('-',$post['paypal']);
							if($post['pay'] == 23 && $value['klarnaname'] != '' && $value['klarnapass'] != '')
							{
							    $klarna = $this->_klarnadata($post['paypal'],$value['klarnaname'],$value['klarnapass']);
								if($klarna != '')
								{
								    $post['klarnadata'] = $klarna;
								}
								
							}
							if($post['pay'] == 26 && $value['afterpayname'] != '' && $value['afterpaypass'] != '')
							{
							    $afterpay = $this->_afterpay($post['paypal'],$value['afterpayname'],$value['afterpaypass']);
								if($afterpay != '')
								{
								    $post['klarnadata'] = $afterpay;
								}
								
							}
							if($post['pay'] == 27 && $value['clearpayname'] != '' && $value['clearpaypass'] != '')
							{
							    $clearpay = $this->_clearpay($post['paypal'],$value['clearpayname'],$value['clearpaypass']);
								if($clearpay != '')
								{
								    $post['klarnadata'] = $clearpay;
								}
								
							}
							if($post['pay'] == '28' && $post['state'] != '207')
							{
								continue;
							}
							if($post['state'] == '217' || $post['state'] == '203')
							{
								continue;
							}
							/**
							else if($post['pay'] == 22 && $value['paypalname'] != '' && $value['paypalpass'] != '')
							{
							    $paypal = $this->_paypaldata($post['paypal'],$value['paypalname'],$value['paypalpass']);
								if($paypal != '')
								{
								    $post['klarnadata'] = $paypal;
								}
								
							}
							**/
							
							/** 启用自动分配仓库 **/
							$warehouse = $this->warehouse->find_all("fpzd = '1'",'*','fpsx desc');
							foreach ($warehouse as $v) 
		        	        {
								if($v['bdcountry'] != 0 && $v['bdcountry'] != $post['country'])
								{
									continue;
								}
								$yx = 'get_yx_'.$v['bdck'];
								$post['express'] = 0;
								$kczd = $this->ck->$yx($post['state'],$v,$post['shop'],$post['number'],$post['whlabel'],$post['fpdata']);
								if($kczd['t'] == 0)
								{
									$country = $this->country->read($post['country']);//获取国家中配置物流
									if($country['express'] != 0)
									{
										$post['express'] = $country['express'];
									}
									if($v['express'] != 0)//优先使用仓库指定物流,替换掉上面的国家配置物流
									{
										$post['express'] = $v['express'];
									}
									$post['type'] = $v['id'];
									$post['whlabel'] = $kczd['whlabel'];
									$post['fpdata'] = $kczd['fpdata'];
									if(stripos($kczd['whlabel'],$v['hz']) !== false)
									{
									    break 1;
									}
								}
							}
							$qdw = $this->warehouse->read($post['type']);
							$fl = $this->ck->get_fl($qdw['hz'],$post['whlabel'],$post['fpdata']);
							$post['sfxh'] = $fl['sfxh'];
							$post['ckfl'] = $fl['ckfl'];
							$zipcode =  substr($post['zipcode'],0,1);
							if($post['type'] == 5 && $zipcode > 6)
							{
								$post['express'] = 63;
							}
							//自动写位置 开始
							$zclp = array();$pxsl = array();
							$slpx = explode('|',$post['slpx']);//排序
							foreach ($slpx as $k=>$v) 
							{
								$v = explode('-',$v);
								if(!isset($v[1]))
								{
									$v[1] == 1;
								}
								for($i=$v[0];$i<$v[1];$i++)
								{
			    					$pxsl[$i] = $k;
								}
							}
							$mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
							if($qdw['wz'] == 1)
							{
								$pm = explode(';',trim($post['shipremarks'],';'));
								foreach ($pm as $k=>$vv) 
		        				{
									$vv = trim($vv,' ');
									$lp = $this->typeclass->find_all("zh = '$vv'");
									if(isset($lp[0]['classid']))
									{
										$zclp[] = $vv;
										unset($pm[$k]);
									}
								}
								$pm = array_values($pm);
								$w = explode('|',trim($post['whlabel'],'|'));
								foreach ($w as $k=>$val) 
		        	    		{
									$hwm = '';
									if(stripos($val,$qdw['hz']) !== false)
									{
										$num = explode('-',trim($val,'-'));
										$xq = explode('~',trim($num[2],'~'));
										$pmxq = '(';
										foreach ($xq as $v) 
		        	           			{
											$zdidjl .= '('.trim($v,$qdw['hz']).')';
											$h = $this->$mc->read(trim($v,$qdw['hz']));
											if($h['details'] != '')
											{
									            $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
											}
								        }
										$xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
										if(isset($pxsl[$k]))
										{
											if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
											{
												$pm[$pxsl[$k]] .= trim($pmxq,',').')';
											}
										}
										$zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
							        }
						        }
								if($zclp)
								{
									$zclp = ';'.implode(";",$zclp);
								}
								else
								{
									$zclp = '';
								}
								$post['shipremarks'] = implode(";",$pm).$zclp;
								$post['contents'] = $zdidjl.' - '.$zdwzjl;
					        }
							//自动写位置 结束
							//条数及申报
							$ts = 0;
							$dtsbjz = 0;
							$zsbjz = 0;
							$w = explode('|',trim($post['whlabel'],'|'));
							foreach ($w as $k=>$val) 
		        	    	{
								$num = explode('-',trim($val,'-'));
								$ts += $num[1];
							}
							if($ts > 0 && $ts < 6 && $post['country'] == 192)
							{
								$dtsbjz = ($ts==3)?sprintf("%.1f",100/$ts):100/$ts;
								$zsbjz = sprintf("%.2f",$dtsbjz*$ts);
							}
							$post['ts'] = $ts;
							$post['dtsbjz'] = $dtsbjz;
							$post['zsbjz'] = $zsbjz;
							/** **/
							//合并重复项
							$hbcfw = explode('|',trim($post['whlabel'],'|'));
							$hbcff = explode(';',trim($post['fpdata'],';'));
							$c = 0;
							$hbw = array();
							$hbf = array();
							for($i=0;$i 0)
							{
								$post['fpdata'] = implode(";",$hbf).';';
								$post['whlabel'] = '|'.implode("|",$hbw).'|';
							}
							//合并重复项结束
							//非占单设置为禁止占单开始
							$hbw = explode('|',trim($post['whlabel'],'|'));
							$hbf = explode(';',trim($post['fpdata'],';'));
							foreach ($hbw as $k=>$val) 
		        	    	{
								$w = explode('-',$val);
								$f = explode('|',$hbf[$k]);
								if(!isset($w[2]) || $w[2] == 0)
								{
									$w[2] = "DNOTO";
								    $f[9] = "DNOTO";
								    $hbf[$k] =  implode("|",$f);
								    $hbw[$k] = implode("-",$w);
								}
							}
							$post['fpdata'] = implode(";",$hbf).';';
							$post['whlabel'] = '|'.implode("|",$hbw).'|';
							//非占单设置为禁止占单结束
							//查询净重开始
							$post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
							$post['zzl'] = ($post['jweight']+100)/1000;
							if($post['express'] == 2)
							{
								$post['zzl'] = intval(($post['jweight']+100)*0.035);
							}
							//查询净重结束
			   		   		$tjid = $this->fullorder->insert($post);
							
							/**
							if($post['shop'] == '1' || $post['shop'] == '2' || $post['shop'] == '6' || $post['shop'] == '5')
							{
								$this->_znxc($post,$order_id,$lkh);
							}
							else
							{
							    $this->_znx($post,$order_id,$lkh);
							}
							**/
						}//else{}如果有此订单
					}
				}
				if ($this->db->trans_status() === FALSE)
                {
				    $this->db->trans_commit();
                }
                else
                {
                    $this->db->trans_commit();
                }
			
			echo json_encode(array('msg'=>'OK!','success'=>true));exit;
		
	}

}