load->library('session'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_productprice','productprice'); $this->load->_model('Model_excel','excel'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_outbound','outbound'); $this->load->_model('Model_express','express'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_country','country'); $this->load->_model('Model_kdniao','kdniao'); $this->load->_model('Model_notice','notice'); $this->load->_model('Model_dhl','dhl'); $this->load->_model('Model_dhlhz','dhlhz'); $this->load->_model('Model_usps','usps'); $this->load->_model('Model_fedex','fedex'); $this->load->_model('Model_fedex_cby','fedex_cby'); $this->load->_model('Model_ups','ups'); $this->load->_model('Model_ali','ali'); $this->load->_model('Model_dpd','dpd'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_user','user'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_specialstock','specialstock'); $this->load->_model('Model_ck','ck'); $this->load->_model('Model_whlabellabel','whlabellabel'); $this->load->_model('Model_apiyy','apiyy'); $this->load->helper('url'); $this->load->_model('Model_whlabel_fc','whlabel_fc'); $this->load->_model('Model_systemtransfer','systemtransfer'); $this->load->_model('Model_classid','classid'); $this->load->_model('Model_allocation','allocation'); $this->load->_model('Model_fullorderxw','fullorderxw'); $this->load->_model('Model_fullorderpaypal','fullorderpaypal'); $this->load->_model('Model_fedexv1','fedexv1'); $this->load->_model('Model_logic_crm','logic_crm'); $this->load->_model("Model_fullorder","fullorder"); $this->load->_model("Model_express","express"); $this->load->_model("Model_logic_ding","logic_ding"); $this->load->_model("Model_api",'api'); $this->load->_model("Model_usps",'usps'); $this->load->_model('Model_emaildata','emaildata'); $this->load->_model('Model_logic_tools','logic_tools'); $this->load->_model('Model_logic_order','logic_order'); $this->load->_model('Model_returngoods','returngoods'); $this->load->_model('Model_returnlogs','returnlogs'); $this->load->_model('Model_productdescribe','productdescribe'); $this->load->_model('Model_logic_u9tools','logic_u9tools'); $this->load->_model('Model_17track','17track'); $this->load->_model('Model_customer','customer'); $this->load->_model('Model_express','express'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'fout') { $this->_fout(); }else if($arg == 'waybillemail'){ $this->_waybillemail(); }else if($arg == 'getorder'){ $this->_getorder(); }elseif($arg == 'logistic'){ $this->_logistic(); }elseif($arg == 'th'){ $this->_th($arg_array); }else{ //$this->_a($arg_array); $this->_mdedit($arg_array); } } public function _th($arg_array){ die; if(empty($arg_array)){ die(1); } $order_no = $arg_array[0]; var_dump($order_no); $data = $this->fullorder->get_number($order_no); if(empty($data)){ echo 2; exit(2); } $r = $this->usps->get_return($data); echo "
";
        var_dump($r);
    }

	//物流轨迹
	public function  _logistic(){
	    
		echo "
";
	
		// $list = $this->fullorder->find_all("waybill = 284280923614");
		// var_dump($list);
		// die;
		// $v = $list[0];
		// $v = [
		// 	'waybill'=>'285250961332'
		// ];
		// $fs = $this->fedexv1->get_logistics($v);
		// var_dump($fs);
		// die;
		die;
		
		$list = $this->fullorder->get_waybill("9205890251001335261703");
 		$v = $list;
  		@$fs = $this->usps->get_logistics_new($v);
// 		$csck[] = array($v['number'],$fs['f'],$fs['content']);
// 		if(!isset($fs['f']))
// 		{
// 			$fs = $this->usps->get_logistics($v);
// 		}
 		var_dump($fs);
        //$fs = $this->usps->get_logistics($v);
		die;
	}


	public function _getorder(){
		
		$name = 'SuperNova';
		$userKey = array(
			'Alipearl' => array('username'=>'huchunmei','api_key'=>'huchunmei126_alipearl_erp888','url'=>'https://www.alipearlhair.com'),
			'Asteria'  => array('username'=>'huchunmei','api_key'=>'huchunmei126_asteria_erp888','url'=>'https://www.asteriahair.com'),
			'WestKiss' => array('username'=>'huchunmei','api_key'=>'huchunmei126_westkiss_erp868','url'=>'https://www.westkiss.com'),
			'SuperNova' => array('username'=>'huchunmei','api_key'=>'huchunmei126_supernova_erp6898','url'=>'https://www.supernovahair.com'),
			'Wiggins' => array('username'=>'huchunmei','api_key'=>'huchunmei126_wiggins_erp652','url'=>'https://www.wigginshair.com'),
			'Yolissa' => array('username'=>'huchunmei','api_key'=>'huchunmei126_yolissa_688','url'=>'https://www.yolissahair.com'),
			);
			
			$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();
			}
			
			$data =	array('proxy'=>$proxy,'sessionId'=>$sessionId,'url'=>$userKey[$name]['url']);
			
			$fromTime = date('Y-m-d H:i:s',time()- 3600*24*6);
			$toTime = date('Y-m-d H:i:s',time());
			$filters = array(array('created_at'=>array('from'=>$fromTime,'to'=>$toTime)));
			$result = $data['proxy']->call($data['sessionId'],'sales_order.list',$filters);
			echo "
";

			// print_r($result[0]);
			foreach($result as $item)
			{
				// print_r($item);exit;
				$iteminfo= $data['proxy']->call($data['sessionId'], 'sales_order.info', $item['increment_id']);
				print_r($iteminfo['items']);
				die;
			}	
	}

	public function getDtc(){
		$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');
		$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']);
			}
			
		}
		$dtctitle = [];
		$dictionaries2 = $this->typeclass->find_all();
		foreach ($dictionaries2 as $v)
		{
			$dtctitle[$v['id']] = $v['title'];
		}
		return [
			'dtc'=>$dtc,
			'dtctitle'=>$dtctitle
		];
	}
    public function _a($arg_array){
		$str = 'sourcetype=2&warehouse=13¤cy=219&capital=3&shop=52&pay=22&country=192&sbpm=Human Hair Wigs&zwpm=人发制假发*头套&hgbm=6704200000&express=1&printtype=1&msg=1&ioss=&qm=0&js=0&yc=0&orderinfo=&shouldmoney=1431.29&freight=0&expressmoney=0&insurance=0&paypal=0KE88673623148406&guarantee=无&quantity=1&buytime=2025-02-22&bname=Deidre Brown&sname=Deidre Brown&baddress=3854 Wordsworth Ave,Memphis,Tennessee,38128,US,9012890773&saddress=3854 Wordsworth Ave,Memphis,Tennessee,38128,US,9012890773&email=deidreb89.db@gmail.com&phone=9012890773&province=Tennessee&client=Deidre Brown&city=Memphis&name=Deidre Brown&zipcode=38128&address2=&address=3854 Wordsworth Ave&ts=8&dtsbjz=25&zsbjz=200.00&zzl=0.4&zjs=1&bx=0.00&freight=0&expressmoney=0&id=&purchase=0.00&cost=0.00&et=0&jgyc=1&customerid=1083429&shop=52&mdedit=&product=All+HD+lace+180%25density,+cap+size+21.5inch,+pre+plucked+and+pre+bleached.%0Acustom+black+mesh+cap,+only+1+comb+in+the+back,+no+tags%0A1.+16in+BW+5x5%0A2.+18IN+BW+6X6%0A3.+20in+BW+5x5%0A4.+24IN+BW+5x5%0A5.+24IN+BW+6x6%0A6.+22in+BW+5x5%0A7.+22in+BW+6x6%0A8.+20in+613+BW+5x5+%0AGifts:++HD+wig+cap,+Pink+Edge+Brushes&orderremarks=+%E6%89%B9%E5%8F%91%E5%AE%A2%E6%88%B7%EF%BC%88%E5%A4%A9%E5%AE%87%EF%BC%89&shipremarks=wig&jweight=0&whlabel=|12824698680571035402921382028-1-0|128246987805710321712921382028-1-0|12824698880571035402921382028-1-0|12824699080571035402921382028-1-0|128246990805710321712921382028-1-0|12824698980571035403021382028-1-0|128246989805710321712921382028-1-0|12824698881441035402921382028-1-0|&fpdata=86,-128-2469-80-57-103-540-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+5*5+Closure+Wig+Small+CustomizedDensity+HKK+16inch+%7C1%7C0.00%7C0.00%7C16%7C0.00%7C0.00%7C0%7C0;87,-128-2469-80-57-103-2171-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+6*6+Closure+Wig+Small+CustomizedDensity+HKK+18inch+%7C1%7C0.00%7C0.00%7C18%7C0.00%7C0.00%7C0%7C0;88,-128-2469-80-57-103-540-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+5*5+Closure+Wig+Small+CustomizedDensity+HKK+20inch+%7C1%7C0.00%7C0.00%7C20%7C0.00%7C0.00%7C0%7C0;90,-128-2469-80-57-103-540-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+5*5+Closure+Wig+Small+CustomizedDensity+HKK+24inch+%7C1%7C0.00%7C0.00%7C24%7C0.00%7C0.00%7C0%7C0;90,-128-2469-80-57-103-2171-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+6*6+Closure+Wig+Small+CustomizedDensity+HKK+24inch+%7C1%7C0.00%7C0.00%7C24%7C0.00%7C0.00%7C0%7C0;89,-128-2469-80-57-103-540-30-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+5*5+Closure+Wig+Medium+CustomizedDensity+HKK+22inch+%7C1%7C0.00%7C0.00%7C22%7C0.00%7C0.00%7C0%7C0;89,-128-2469-80-57-103-2171-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+6*6+Closure+Wig+Small+CustomizedDensity+HKK+22inch+%7C1%7C0.00%7C0.00%7C22%7C0.00%7C0.00%7C0%7C0;88,-128-2469-81-44-103-540-29-2138-2028-%7CWigs+BenDang+10A+#613+Body+Wave+HD+5*5+Closure+Wig+Small+CustomizedDensity+HKK+20inch+%7C1%7C0.00%7C0.00%7C20%7C0.00%7C0.00%7C0%7C0;&fpcount=-128-2469-86-80-57-103-540-29-2138-2028-|-128-2469-87-80-57-103-2171-29-2138-2028-|-128-2469-88-80-57-103-540-29-2138-2028-|-128-2469-90-80-57-103-540-29-2138-2028-|-128-2469-90-80-57-103-2171-29-2138-2028-|-128-2469-89-80-57-103-540-30-2138-2028-|-128-2469-89-80-57-103-2171-29-2138-2028-|-128-2469-88-81-44-103-540-29-2138-2028-|&budget=&
';
		echo "
";
		parse_str($str, $output);
 
		print_r($output);
		echo json_encode($output);
		// $list = [
		// 	[
		// 		'sku2'=>'-128-80-89-57-106-341-30-72-',
		// 	],
		// 	[
		// 		'sku2'=>'-128-80-88-57-2248-2096-30-72-2071-1645-',
		// 	]
		// ];
		// $r = $this->logic_u9tools->getU9bm($list,'sku2');
		// echo "
";
		// var_dump($r);
		die;
		$data = $this->getDtc();
		$dtc = $data['dtc'];
		$dtctitle = $data['dtctitle'];
		$quantity = 'Loose Body--HDWig-26-HD5*5Wig-180%,WKPack';
		$issku = '1;1';
		$money = array();
			$productdescribe = $this->productdescribe->find_all('1=1');
			foreach ($productdescribe as $v) 
			{
				$money[$v['number']] = array();
			}
			/*  价格加入  */
			/*  匹配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];
			}	
		var_dump($dtc);
		var_dump($dtctitle);
		$r = $this->api->matching($quantity,$issku,$dtc,$money,$int,$dtctitle,[1],[
			
		]);
		echo "
";
		var_dump($r);
		
		die;
	
        $time = time();
        $jiami = "alipearlhair+".(string)$time;
        echo json_encode([
			'shop'=>3,
			'waybill'=>'283786008019',
			'time'=>$time,
			'key'=>$this->logic_tools->toolsjiami($jiami,"6amg!pnfrlbpnjgirv", "6ook4k!2w94m6jtm"),
		]);
        die;

		$dtc = array();
		/*  订单号加入键值-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)
		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']);
			}
			
		}
		$dtctitle = [];
		$dictionaries2 = $this->typeclass->find_all();
		foreach ($dictionaries2 as $v)
		{
			$dtctitle[$v['id']] = $v['title'];
		}
		echo "
";
		$sku = "Free,Gift--PackQQS,NW--3+Ori6*6C-22 24 26-20-6*6C";
		$sl = "1;1;1;";
		$r = $this->api->matching($sl,$sku,$dtc,"","",$dtctitle,$shop=[],$extra = [
			"price"=>"565.7700",
			"row_total"=>"565.7700"
		]);
		var_dump($r['title']);
		$r = $r['product'];
		$rr = explode(";",$r);
		print_r($rr);
	
	    
    }
	public function _fout()
	{
		$waybill = $this->input->get('waybill');
		$info = $this->fullorder->get_waybill($waybill);
			
		//$r = $this->usps->get_new_logistics($info);
		$r = $this->fedexv1->get_logistics(123);
		echo "
";
		var_dump($r);
        //$this->fedexv1->makeAccessToken();
		
	}
	
	public function _waybillemail()
	{
		$urls = array();$sl = 0;$time = time();
		$wid = 2;
		// if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单
		// {
		// 	$wid = 1;
		// }
		// else if(date("H",time()) == '20' && date("i",time()) > '20' && date("i",time()) < '39')//其他快递
		// {
		// 	$wid = 2;
		// }
		// else
		// {
		// 	exit;
		// }
		$notice = $this->notice->find_all("message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
		foreach ($notice as $key=>$var)
		{
			$this->_waybillfs([
				'var'=>$var,
				'wid'=>$wid
			]);
		}
	
	}

	public function upadtel(){
		
		$returngoods_id = 150;
		$insert_flag = 1217819;
		$number = 'KISS-50206-004';

		$returngoods_info = $this->returngoods->read($returngoods_id);
		$this->returngoods->save([
			'status'=>80,
			'back_no'=>$number,
			'back_id'=>$insert_flag,
			'update_time'=>date('Y-m-d H:i:s'),
		],$returngoods_id);
		$this->returnlogs->insert([
			'rg_id'=>(int)$returngoods_id,
			'operat_id'=>10,
			'operat_name'=>'admin',
			'remark'=>"订单号:".$returngoods_info['orderinfo']."重新换货-换货新订单编码".$number,
			'create_time'=>date('Y-m-d H:i:s'),
		]);
	}
	
	
	public function _waybillfs($data)
	{
		if($data)
		{
		    $notice = $data['var'];
			$notice['email'] = $this->emaildata->read($notice['email']);
			$wid = $data['wid'];
			$fsjs = "";
			if($wid == 1 && (stripos($notice['express'],',2,') !== false || stripos($notice['express'],',63,') !== false || stripos($notice['express'],',64,') !== false))
			{
				$js = explode(',',trim($notice['js'],','));
				if(count($js) > 1)
				{
					$fsjs = " and (";
				    foreach ($js as $v)
				    {
					    $fsjs .= "js = '$v' or ";
				    }
					$fsjs = trim($fsjs,' or ').")" ;
				}
				else if(count($js) == 1)
				{
					$fsjs = " and js = '$js[0]'";
				}
				$where = "(express = '2' or express = '63' or express = '64') and librarytime > '".strtotime(date("Y-m-d 8:30:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 8:30:0",time()))."'".$fsjs;//3
			}
			
			else if($wid == 2 && stripos($notice['express'],',1,') !== false)
			{
			 	$where = "express != '2' and express != '63' and  express != '64' and printtype = '1' and waybill != '' and librarytime > '".strtotime(date("Y-m-d 20:00:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 20:00:0",time()))."'";//4
			}
			else
			{
				exit;
			}
			$this->logic_ding->sendToDing("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
// 		    $wlfs = array();
// 		    $dd = $this->fullorder->find_all("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
// 			foreach($dd as $v){
// 				$this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】");
// 			}
		    // foreach ($dd as $v)
		    // {
			//     $shop = $this->shop->read($v['shop']);
			//     $express = $this->express->read($v['express']);
			//     $fs = $this->notice->get_god($v,$shop,$express,$notice);
			//     $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】获取快递信息【".json_encode($notice,JSON_UNESCAPED_UNICODE)."】返回的信息".json_encode($fs));
			//     if($fs == 1)
			//     {
			// 	    $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$v['id']);
				    
			// 	    //给crm发送信息 先存储数据 后续定时任务执行
			// 		if($v['shop'] < 10){
						
			// 			$this->zztmpdata->insert([
			// 				'type'=>2,
			// 				'act_name'=>'crm_order',
			// 				'content'=>json_encode($v),
			// 				'create_time'=>time()
			// 			]);
						
			// 		}

				    
				    
			//     }
			//     else
			//     {
			// 		//$pdtime = date('Y-m-d',time());
			// 		//$folderPath = './data/dlzemail/'.$pdtime; // 文件夹路径
			// 		//$permissions = 0777; // 权限设置
			// 		//if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
			// 		//file_exists($folderPath);
			// 		if(!is_file("./data/dlzemail/".$v['number'].".txt"))
			// 		{
			// 			$myfile = fopen("./data/dlzemail/".$v['number'].".txt", "w") or die("Unable to open file!");
			// 			fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
			// 			fclose($myfile);
			// 		}
			// 		else
			// 		{
			// 			$myfile = fopen("./data/dlzemail/".$v['number'].".txt", "a+") or die("Unable to open file!");
			// 			fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
			// 			fclose($myfile);
			// 		}
			// 	    $this->fullorder->save(array('dlzemail'=>2,'dlzemailtime'=>time()),$v['id']);
			//     }
			//     sleep(50);
		    // }
		}
	}


	public function ll(){
		$str = 'sourcetype=2&warehouse=13¤cy=219&capital=3&shop=52&pay=22&country=192&sbpm=Human Hair Wigs&zwpm=人发制假发*头套&hgbm=6704200000&express=1&printtype=1&msg=1&ioss=&qm=0&js=0&yc=0&orderinfo=&shouldmoney=1431.29&freight=0&expressmoney=0&insurance=0&paypal=0KE88673623148406&guarantee=无&quantity=1&buytime=2025-02-22&bname=Deidre Brown&sname=Deidre Brown&baddress=3854 Wordsworth Ave,Memphis,Tennessee,38128,US,9012890773&saddress=3854 Wordsworth Ave,Memphis,Tennessee,38128,US,9012890773&email=deidreb89.db@gmail.com&phone=9012890773&province=Tennessee&client=Deidre Brown&city=Memphis&name=Deidre Brown&zipcode=38128&address2=&address=3854 Wordsworth Ave&ts=8&dtsbjz=25&zsbjz=200.00&zzl=0.4&zjs=1&bx=0.00&freight=0&expressmoney=0&id=&purchase=0.00&cost=0.00&et=0&jgyc=1&customerid=1083429&shop=52&mdedit=&product=All+HD+lace+180%25density,+cap+size+21.5inch,+pre+plucked+and+pre+bleached.%0Acustom+black+mesh+cap,+only+1+comb+in+the+back,+no+tags%0A1.+16in+BW+5x5%0A2.+18IN+BW+6X6%0A3.+20in+BW+5x5%0A4.+24IN+BW+5x5%0A5.+24IN+BW+6x6%0A6.+22in+BW+5x5%0A7.+22in+BW+6x6%0A8.+20in+613+BW+5x5+%0AGifts:++HD+wig+cap,+Pink+Edge+Brushes&orderremarks=+%E6%89%B9%E5%8F%91%E5%AE%A2%E6%88%B7%EF%BC%88%E5%A4%A9%E5%AE%87%EF%BC%89&shipremarks=wig&jweight=0&whlabel=|12824698680571035402921382028-1-0|128246987805710321712921382028-1-0|12824698880571035402921382028-1-0|12824699080571035402921382028-1-0|128246990805710321712921382028-1-0|12824698980571035403021382028-1-0|128246989805710321712921382028-1-0|12824698881441035402921382028-1-0|&fpdata=86,-128-2469-80-57-103-540-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+5*5+Closure+Wig+Small+CustomizedDensity+HKK+16inch+%7C1%7C0.00%7C0.00%7C16%7C0.00%7C0.00%7C0%7C0;87,-128-2469-80-57-103-2171-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+6*6+Closure+Wig+Small+CustomizedDensity+HKK+18inch+%7C1%7C0.00%7C0.00%7C18%7C0.00%7C0.00%7C0%7C0;88,-128-2469-80-57-103-540-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+5*5+Closure+Wig+Small+CustomizedDensity+HKK+20inch+%7C1%7C0.00%7C0.00%7C20%7C0.00%7C0.00%7C0%7C0;90,-128-2469-80-57-103-540-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+5*5+Closure+Wig+Small+CustomizedDensity+HKK+24inch+%7C1%7C0.00%7C0.00%7C24%7C0.00%7C0.00%7C0%7C0;90,-128-2469-80-57-103-2171-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+6*6+Closure+Wig+Small+CustomizedDensity+HKK+24inch+%7C1%7C0.00%7C0.00%7C24%7C0.00%7C0.00%7C0%7C0;89,-128-2469-80-57-103-540-30-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+5*5+Closure+Wig+Medium+CustomizedDensity+HKK+22inch+%7C1%7C0.00%7C0.00%7C22%7C0.00%7C0.00%7C0%7C0;89,-128-2469-80-57-103-2171-29-2138-2028-%7CWigs+BenDang+9A+Natural+Black+Body+Wave+HD+6*6+Closure+Wig+Small+CustomizedDensity+HKK+22inch+%7C1%7C0.00%7C0.00%7C22%7C0.00%7C0.00%7C0%7C0;88,-128-2469-81-44-103-540-29-2138-2028-%7CWigs+BenDang+10A+#613+Body+Wave+HD+5*5+Closure+Wig+Small+CustomizedDensity+HKK+20inch+%7C1%7C0.00%7C0.00%7C20%7C0.00%7C0.00%7C0%7C0;&fpcount=-128-2469-86-80-57-103-540-29-2138-2028-|-128-2469-87-80-57-103-2171-29-2138-2028-|-128-2469-88-80-57-103-540-29-2138-2028-|-128-2469-90-80-57-103-540-29-2138-2028-|-128-2469-90-80-57-103-2171-29-2138-2028-|-128-2469-89-80-57-103-540-30-2138-2028-|-128-2469-89-80-57-103-2171-29-2138-2028-|-128-2469-88-81-44-103-540-29-2138-2028-|&budget=&
';
		parse_str($str, $output);

		return  $output;
	}

	//修改客户分类
	public function _mdedit($arg_array)
	{
		$user = $this->user->read(10);
		
		$post = $this->ll();
		if(isset($post['shop']))
		{
			$fpcount = $post['fpcount'];
			if(!$fpcount)
			{
				echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit;
			}
			$customerid = $post['customerid'];
			$shop = $post['shop'];
			$sp = $this->shop->read($shop);
			$num = $this->fullorder->find_count('shop = "'.$sp['id'].'" and gtime = "'.date('Ymd',time()).'"');
			$post['source'] = 1;//订单类型:1.线下订单2.PC3.手机
			$post['state'] = 207;//订单状态:207等待发货
			$post['review'] = 2;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
			$post['print'] = 1;//打印状态:1.不可打印2.未打印3.已打印
			$post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
			$post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
			$post['link'] = $sp['link'];
			$post['issku'] = $sp['sku'];
			if($post['print'] != 3)
			{
			    $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因
			}
			$orderinfo = $post['orderinfo'];
			$post['shop'] = $sp['id'];
			$post['user'] = $sp['shopuser'];
			$post['number'] = $sp['shortname'].'-'.substr(date('ymd',time()),1).'-'.(substr(strval($num+1+1000),1,3));//编号 
			if($orderinfo != "")
			{
				$ordefin = $this->fullorder->get_orderinfo($orderinfo);
				if($ordefin)
				{
					echo json_encode(array('msg'=>'订单号重复!','success'=>false));exit;
				}
				else
				{
				    $post['orderinfo'] = $orderinfo;
				}
			}
			else
			{
			    $post['orderinfo'] = $sp['id'].date('ymdHis',time()).rand(0,1);//订单号
			}
			if($post['paypal'] != '')
			{
			    $pp = $this->fullorder->get_paypal($post['paypal']);	
			    if($pp)
			    {
				    echo json_encode(array('msg'=>'此交易号的订单已存在!','success'=>false));exit;
			    }
		    }
			$post['client'] = $post['client'];//客户名称
			$btime = $post['buytime'];//付款时间
			$post['buytime'] = strtotime($btime);//时间转UX
			$post['dtime'] = time();//订单时间
			$post['gtime'] = date('Ymd',time());//格式化时间
			$post['pay'] = $post['pay'];//支付方式
			$post['capital'] = $post['capital'];//资金状态
			$post['type'] = $post['warehouse'];//发货仓库
			$post['currency'] = $post['currency'];//币种
			$currency = $this->typeclass->read($post['currency']);
			$post['currencytitle'] = $currency['title'];//币种名称
			$post['freight'] = $post['freight'];//运费
			$post['expressmoney'] = $post['expressmoney'];//物流金额
			$post['shouldmoney'] = $post['shouldmoney'];//应收金额
			$post['skje'] = $post['shouldmoney'];//收款金额
			$product = $post['product'];//产品名称
			$product = str_replace(array('%26','%2B'),array('&','+'),$product);
			$post['product'] = preg_replace('/( | | |\s)/',' ',$product);
			$orderremarks = $post['orderremarks'];//订单备注
			$orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks);
			$post['orderremarks'] = preg_replace('/( | | |\s)/',' ',$orderremarks);
			$shipremarks = $post['shipremarks'];//仓库品名
			$shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);//仓库品名
			$post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
			$post['email'] = $post['email'];//邮箱
			$name = $post['name'];//名称
			$post['name'] = preg_replace('/( | | |\s)/',' ',$name);
			$post['phone'] = $post['phone'];//电话
			$post['phone'] = preg_replace('/\D/s','',$post['phone']);
			$post['country'] = $post['country'];//国家
			$ct = $this->country->read($post['country']);//国家
			$post['al'] = $ct['lb'];//国家二字码
			$post['province'] = $post['province'];//省、州
			$post['province'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['province']); //替换开头空字符
            $post['province'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['province']); //替换结尾空字符
			$post['city'] = $post['city'];//城市
			$post['city'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['city']); //替换开头空字符
            $post['city'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['city']); //替换结尾空字符
			$post['zipcode'] = $post['zipcode'];//邮编
			$post['zipcode'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['zipcode']); //替换开头空字符
            $post['zipcode'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['zipcode']); //替换结尾空字符
			$post['address'] = $post['address'];//地址
			$post['printtype'] = $post['printtype'];//打印类型
			$fpdata = $post['fpdata');//购买产品内容
			$fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
			$post['fpdata'] = $fpdata;
			$post['sbpm'] = $post['sbpm'];//申报品名
			$post['zwpm'] = $post['zwpm'];//中文品名
			$post['ts'] = $post['ts'];//条数
			$post['dtsbjz'] = $post['dtsbjz'];//单条申报价
			$post['zsbjz'] = $post['zsbjz'];//总申报价
			$post['zzl'] = $post['zzl'];//总重量
			$post['zjs'] = $post['zjs'];//总件数
			$post['express'] = $post['express'];//快递公司
			$post['printtype'] = $post['printtype'];//打印类型
			$post['quantity'] = $post['quantity'];//数量
			$post['paypal'] = $post['paypal'];//支付号
			$post['guarantee'] = $post['guarantee'];//卖家保障
			$post['msg'] = $post['msg'];//发送留言类型
			$post['ioss'] = $post['ioss'];
			$post['sbpm'] = $post['sbpm'];
			$pay = $this->pay->get_typeclass($post['pay']);
			$yga = $post['shouldmoney'];
			$post['budget'] = 0;
			if($pay)
			{
				$ygc = $pay['estimaterate'];//预估到账公式
				$ifbudget = eval("return $yga*1.$ygc;");
				$post['estimaterate'] = $pay['estimaterate'];
				if($ifbudget > 0)
				{
				    $post['budget'] = eval("return $yga*1.$ygc;");//预估到帐金额
				}
			}
			else
			{
				$ygb = $sp['estimaterate'];//店铺默认到账公式
				$ifbudget = eval("return $yga*1.$ygb;");
				$post['estimaterate'] = $sp['estimaterate'];
				if($ifbudget > 0)
				{
		    	    $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额
				}
			}
			$baddress = $post['baddress'];
			$saddress = $post['saddress'];
			$baddress = array_reverse(explode(',',$baddress));
			$saddress = array_reverse(explode(',',$saddress));
			$bar = '';$sar = '';
			$cr = $this->country->read($post['country']);
			$baddress[1] = $cr['lb'];
			$saddress[1] = $cr['lb'];
			$baddress = array_reverse($baddress);
			$saddress = array_reverse($saddress);
			for($i=0;$i'USPS收件人或公司名不可用特殊符号!','success'=>false));exit;
			}
			if(strlen($post['client']) > 35 || strlen($post['name']) > 35)//收件人姓名或公司名不允许超过35位
			{
				echo json_encode(array('msg'=>'收件人姓名或公司名不可超过35个字符!','success'=>false));exit;
			}
			if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $post['country'] != 192)
			{
				echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
			}
			if($post['express'] == '3' && $post['country'] != 192 && $post['country'] != 35)
			{
				echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
			}
			if($post['express'] == '3' && $post['country'] == 35 && $post['zsbjz'] > 20)
			{
				echo json_encode(array('msg'=>'UPS加拿大最高申报不可超过20','success'=>false));exit;
			}
			if($post['express'] == '2' && $post['warehouse'] != 5)
			{
				echo json_encode(array('msg'=>'非美国仓无法选择USPS!','success'=>false));exit;
			}
			if($post['express'] == '99' && $post['bx'] > 0)
			{
				echo json_encode(array('msg'=>'此物流不允许购买保险','success'=>false));exit;
			}
			if($post['express'] == 42 && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 || 
			{
				echo json_encode(array('msg'=>'此快递方式必须选择Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
			}
			if($post['express'] == 24 && $post['sbpm'] != 'Hair Sample' && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 || 
			{
				echo json_encode(array('msg'=>'此快递方式必须选择Hair Sample/Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
			}
			if($post['country'] != 192 && $post['express'] == 1 && $post['sbpm'] != 'Synthetic Hair Wigs' && $post['sbpm'] != 'Synthetic Hair Goods')//$post['express'] == 3 || 
			{
				echo json_encode(array('msg'=>'非美国选择官方DHL必须选择Synthetic Hair Wigs/Synthetic Hair Goods','success'=>false));exit;
			}
			if($post['pay'] == '22' && ($post['paypal'] == '' || $post['guarantee'] == ''))
			{
				echo json_encode(array('msg'=>'交易号和卖家保障必须填写','success'=>false));exit;
			}
			if($post['pay'] == '23' && $post['paypal'] == '')
			{
				echo json_encode(array('msg'=>'交易号必须填写','success'=>false));exit;
			}
			$express = $this->express->read($post['express']);
			if($post['zsbjz'] > $express['sbjz'])
			{
				echo json_encode(array('msg'=>'总申报价值不可超出'.$express['sbjz'],'success'=>false));exit;
			}
			if($post['shouldmoney'] > $express['shouldmoney'] && $express['shouldmoney'] != 0)
			{
				echo json_encode(array('msg'=>'订单金额不可超出'.$express['shouldmoney'],'success'=>false));exit;
			}
			if($express['ioss'] == 1 && $post['ioss'] == '')
			{
				 echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
			}
			if(strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize'])
			{
				echo json_encode(array('msg'=>'此快递方地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
			}
			if(strlen($post['address']) < 5)
			{
				echo json_encode(array('msg'=>'地址不可留空!','success'=>false));exit;
			}
			if($post['express'] == '2' && $post['zzl'] > '16' && $post['js'] == '0')
			{
				echo json_encode(array('msg'=>'重量大于16不可按Ground Advantage提交!','success'=>false));exit;
			}
			if($post['express'] == '2' && isset($post['js']) && $post['js'] == '0'&& $post['qm'] == '1')
			{
				echo json_encode(array('msg'=>'Ground Advantage不可使用签名服务!','success'=>false));exit;
			}
			if(($post['express'] == '3' || $post['express'] == '42' || $post['express'] == '24') && $post['shouldmoney'] < 1)
			{
				echo json_encode(array('msg'=>'零金额订单不可发 UPS/DHL官方-美国/Fedex(杭州)','success'=>false));exit;
			}
			if($post['express'] == '42' && $post['zsbjz'] < 1)
			{
				echo json_encode(array('msg'=>'零申报金额不可发 DHL官方-美国','success'=>false));exit;
			}
			if($post['express'] == '6' && $post['province'] == '')
			{
				echo json_encode(array('msg'=>'选择DPEX必须填写州信息','success'=>false));exit;
			}
			
			$dtctitle = array();
			$dictionaries = $this->typeclass->find_all();
			foreach ($dictionaries as $v)
			{
				$dtctitle[$v['id']] = array($v['title'],$v['bqsku']);
			}
			$fpdata = $post['fpdata'];
			if(stripos($fpdata,'-128-') !== false || stripos($fpdata,'-127-') !== false)
			{
			    $dfp =  explode(';',trim($fpdata,';'));
			    $fdata = '';
			    foreach ($dfp as $k=>$v)
			    {
				    $ptitleb = '';
				    $fp = explode('|',trim($v,'|'));
				    $fp0 = explode(',',$fp[0]);
					if(isset($fp0[1]))
					{
				        $fp1 = explode('-',trim($fp0[1],'-'));
					}
					else
					{
						$fp1 = explode('-',trim($fp[0],'-'));
					}
				    foreach ($fp1 as $vv)
				    {
					    $ptitleb .= isset($dtctitle[$vv])?$dtctitle[$vv][0].' ':'';
				    }
					if(isset($fp0[1]))
					{
				         $ptitleb .= $dtctitle[$fp0[0]][1].'inch ';
				         $fp[1] = $ptitleb;
					}
				    $fdata .= implode("|",$fp).";";
			    }
			    $fpdata = $fdata;
			}
			
			$warehouse = $this->warehouse->read($post['type']);
			if($warehouse['bdcountry'] != 0 && $post['country'] != $warehouse['bdcountry'])
			{
				echo json_encode(array('msg'=>'当前国家无法选择'.$warehouse['title'].'!','success'=>false));exit;
			}
			    // $kcyz = $this->ck->get_kc($post['state'],$warehouse,$post['shop'],$post['number'],$whlabel,$fpdata);
			    // if($kcyz['t'] > '0')
			    // {
				// 	echo $kcyz['m'];exit;
			    // }
			    // else if($kcyz['fpdata'] != '')
			    // {
				//     $post['whlabel'] = $kcyz['whlabel'];
				//     $post['fpdata'] = $kcyz['fpdata'];
			    // }
				// $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
				// $post['sfxh'] = $fl['sfxh'];
				// $post['ckfl'] = $fl['ckfl'];
				
				//查询净重开始
			$post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
			//查询净重结束
					$cusnum = $this->customer->read($customerid);
					// $this->customer->save(array('num'=>$cusnum['num']+1,'time'=>$post['buytime']),$customerid);
					// $this->fullorder->insert($post);
					echo json_encode(array('msg'=>'下单成功','success'=>true));exit;	
		}
		
		
		echo "1";
		die;
	}
	
	
}