load->library('session'); $this->load->_model('Model_api','api'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $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_ups','ups'); $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_emaildata','emaildata'); $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_apismt','apismt'); $this->load->_model('Model_cne','cne'); $this->load->_model('Model_specialstock','specialstock'); $this->load->_model('Model_whlabellabel','whlabellabel'); $this->load->_model('Model_allocation','allocation'); $this->load->_model('Model_yswaybill','yswaybill'); $this->load->_model('Model_paypal','paypal'); $this->load->_model('Model_17track','17track'); $this->load->_model('Model_ck','ck'); $this->load->_model('Model_weight','weight'); $this->load->_model('Model_pay','pay'); $this->load->_model('Model_setting','setting'); $this->load->_model('Model_classid','classid'); $this->load->_model('Model_apitt','apitt'); $this->load->_model('Model_customertt','customertt'); $this->load->_model('Model_als','als'); $this->load->_model('Model_apiyy','apiyy'); $this->load->_model('Model_whlabel_fc','whlabel_fc'); $this->load->_model('Model_excel','excel'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'c') { $this->_c(); } else if($arg == 'excel') { $this->_excel($arg_array); } else if($arg == 'rz') { $this->_rz($arg_array); } } public function _excel($arg_array) { $filePath = './data/yyexcel/'.$arg_array[0].'/excel.txt'; $fileContent = file_get_contents($filePath); if ($fileContent !== false) { header( 'Content-Type: application/vnd.ms-excel; name=excel' ); header( 'Content-type: application/octet-stream' ); header( 'Content-Disposition: attachment; filename='.$arg_array[0].'.xls'); header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ); header( 'Pragma: no-cache' ); header( 'Expires: 0' ); echo $fileContent; } else { echo "文件无法读取"; } } public function _rz($arg_array) { $a = './data/yylog/RK-'.$arg_array[0].'.txt'; if(is_file($a)) { $myfile = fopen($a, "r") or die("Unable to open file!"); $bc = fread($myfile,filesize($a)); fclose($myfile); $zt = explode('\n',trim($bc,'\n')); //$bc = json_decode($bc,true); $nr = array(); foreach($zt as $k=>$val) { $xx = explode(' = ',trim($val,' = ')); if(stripos($xx[0],'RK-F') !== false) { $nr[$k][][0] = '入库发送'; } else if(stripos($xx[0],'RK-J') !== false) { $nr[$k][][0] = '入库接收'; } else if(stripos($xx[0],'SH-F') !== false) { $nr[$k][][0] = '审核发送'; } else if(stripos($xx[0],'SH-J') !== false) { $nr[$k][][0] = '审核接收'; } else if(stripos($xx[0],'DC-F') !== false) { $nr[$k][][0] = '调出发送'; } else if(stripos($xx[0],'DC-J') !== false) { $nr[$k][][0] = '调出接收'; } $nr[$k][][1] = $xx[1]; } echo "
";
			print_r($nr);
		}
		else
		{
			echo '无';
		}
	}
	
	
	
	public function _c()
	{
		$asd = array();
		$f = array('fullordersmt','fullordertt','fullorder');
		foreach($f as $v)
		{
		    $d = $this->$v->find_all("librarytime > '".(time()-(5*24*3600))."' and (type = '13' or type = '16') and dbapi < 99");
			if($d)
			{
		        $h = $this->_list($d,$v);
			    foreach($h as $vv)
			    {
				    $x = 0;$c = 0;
				    $xs = $this->apiyy->_cxxsdd($vv['0']);
				    $chd = $this->apiyy->_cxchd($vv['0']);
				    if(isset($xs['Data'][0]))
				    {
					    $vv[] = '成功';
					    $x = 1;
				    }
				    else
				    {
				    	$vv[] = '无';
				    }
				    if(isset($chd['Data'][0]))
				    {
				    	$vv[] = '成功';
					    $c = 1;
				    }
				    else
				    {
				    	$vv[] = '无';
				    }
				    if($x==1 && $c==1)
				    {
					    $this->$v->save(array('dbapi'=>99),$vv[4]);
				    }
				    $asd[] = $vv;
				}
			}
		}
		
		$title = "表 ".date("Y-m-d"); 
            $titlename = "

".$title."

编号 销售订单发送 销售订单接收 出货单发送 出货单接收 销售订单验证 出货单验证
"; $filename = $title.".xls"; $tail = "\n"; $data = $this->excel->get_fz2_bc($asd,$titlename,$filename,$tail); $orderinfo = time(); $pdtime = date('Y-m-d',time()); $folderPath = './data/yyexcel/'.$pdtime; // 文件夹路径 $permissions = 0777; // 权限设置 if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹 file_exists($folderPath); if(!is_file($folderPath."/".$orderinfo.".txt")) { $myfile = fopen($folderPath."/excel.txt", "w") or die("Unable to open file!"); fwrite($myfile, $data); fclose($myfile); } else { $myfile = fopen($folderPath."/exce.txt", "a+") or die("Unable to open file!"); fwrite($myfile, $data); fclose($myfile); } } public function _list($d,$fullorder)//获取订单列表 { $xx = array(); foreach($d as $k=>$data) { $xx[$k] = array(0=>$data['number'],'xsf'=>'','xss'=>'','fhf'=>'','fhs'=>'',4=>$data['id']); $kh = $this->shop->read($data['shop']); $classid = $this->classid->sku(); $tcall = $this->typeclass->find_all(); $typeclass = array(); foreach ($tcall as $v) { $tcjm[$v['id']] = array($v['jm'],$v['classid']); $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']); } $bm = '03'; $xysc = array(); $data['lh'] = array(); $scid = '';$cw = '';$lc = 0; $sku = explode(';',trim($data['fpdata'],';')); $whlabelsc = explode('|',trim($data['whlabel'],'|')); foreach($sku as $key=>$val) { if(stripos($val,'-131-') !== false) { continue; } $pm = $classid; $jm = $classid; $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>''); $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val); $ts = explode('|',trim($features,'|')); if(stripos($ts[0],',') !== false) { $ft = explode(',',$ts[0]); $features = explode('-',trim($ft[1],'-')); $features[] = $ft[0]; } else { $features = explode('-',trim($ts[0],'-')); } foreach($features as $k=>$v) { if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']])) { if($typeclass[$v]['bm'] != '') { $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm']; } } if($v != 0) { if(isset($pm[$typeclass[$v]['classid']])) { if($typeclass[$v]['title'] == '9A') { $pm[$typeclass[$v]['classid']] = '9A'; } else if($typeclass[$v]['title'] == '10A') { $pm[$typeclass[$v]['classid']] = '10A'; } else { $clzh = $typeclass[$v]['zh']; if(stripos($typeclass[$v]['zh'],'|') !== false) { $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|')); $clzh = $clzh[0]; } $pm[$typeclass[$v]['classid']] = $clzh; } } if(isset($jm[$typeclass[$v]['classid']])) { if($typeclass[$v]['jm']) { $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm']; } } } } $jm = array_filter($jm);//去除空值 $jm = implode("-",$jm); $pm = array_filter($pm);//去除空值 $zh = implode(" ",$pm); $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' ')); $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$ts[1],'zh'=>$zh,'bm'=>$bm.implode("",$bmpx))); if(isset($lh['Data'][0])) { if($lh['Data'][0]['m_isSucess'] != 1) { if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!') { $xx[$k][1] = $lh; $this->apiyy->insert(array('number'=>$data['number'],'error'=>$lh['Data'][0]['m_errorMsg'],'type'=>'料号','cs'=>$fullorder)); continue; } } } else { $this->apiyy->insert(array('number'=>$data['number'],'error'=>json_encode($lh),'type'=>'料号','cs'=>$fullorder)); continue; } $data['lh'][] = array('sku'=>$jm,'ts'=>$ts[2]); if(stripos($val,'-131-') !== false) { continue; } if(stripos($val,'-126-') !== false) { $drck = '12003';//进入发条库 } else if(stripos($val,'-127-') !== false) { $drck = '12004';//进入发块库 } else { $drck = '12006';//其它进入完成库 } } $data['yyid'] = $kh['yyid']; @$ay = $this->apiyy->_neworder($data,$classid,$tcall); $xx[$k]['xsf'] = $ay['fs']; $xx[$k]['xss'] = $ay['fh']; if($ay['c'] != 0) { $this->$fullorder->save(array('dbapi'=>0),$data['id']); $this->apiyy->insert(array('number'=>$data['number'],'type'=>'销售订单','error'=>$ay['error'],'cs'=>$fullorder)); } else { $this->$fullorder->save(array('dbapi'=>99),$data['id']); $chdfs = '';$chdjs = '';$chdcg = 0; foreach($data['lh'] as $k=>$v) { $chd = array('number'=>$data['number'],'i'=>$k+1,'ts'=>$v['ts']); $c = $this->apiyy->get_chd($chd); $chdfs = $c['1']; $chdjs = json_encode($c['0']); if($c['Data'][0]['m_isSucess'] == 1) { $chdcg += 1; } } $xx[$k]['fhf'] = $chdfs; $xx[$k]['fhs'] = $chdjs; if($chdcg == count($data['lh'])) { $cs = $this->$fullorder->save(array('dbapi'=>100),$data['id']); } } } return $xx; } }