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'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'fout') { $this->_fout(); }else if($arg == 'waybillemail'){ $this->_waybillemail(); }else{ $this->_a($arg_array); } } public function _a($arg_array){ $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');
		$this->usps->get_new_logistics($waybill);
        //$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 _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);
		    // }
		}
	}
}