Explorar el Código

测试一下u9

lvhao hace 6 meses
padre
commit
082482c00f
Se han modificado 1 ficheros con 683 adiciones y 0 borrados
  1. 683 0
      core/CoreApp/controllers/Aayytest.php

+ 683 - 0
core/CoreApp/controllers/Aayytest.php

@@ -0,0 +1,683 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Aayytest extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->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 == 'cs')
+        {
+             $this->_cs($arg_array);
+        }
+		else if($arg == 'excel')
+        {
+             $this->_excel($arg_array);
+        }
+		else if($arg == 'xxpl')
+        {
+             $this->_xxpl();
+        }
+		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 "<pre>";
+			print_r($nr);
+		}
+		else
+		{
+			echo '无';
+		}
+	}
+	
+	
+	
+	public function _c()
+	{
+		$asd = array();
+		
+		$v = "fullorder";
+        $d = $this->$v->find_all(" number = QQS-50124-091 and librarytime > '".(time()-(12*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;
+                if(!isset($vv[0]))
+                {
+                    continue;
+                }
+                $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 = "<table border=1>
+            <tr><th colspan='6' align='left'><h3>".$title."<h3></th></tr>
+            <tr>
+            <td>编号</td>
+			<td>销售订单发送</td>
+			<td>销售订单接收</td>
+            <td>出货单发送</td>
+			<td>出货单接收</td>
+			<td>销售订单验证</td>
+            <td>出货单验证</td>
+            </tr>
+            </table>"; 
+            $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,' '));
+				if(!isset($ts[1]))
+				{
+					$ts[1] = '无';
+				}
+				$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(isset($c['Data']))
+					{
+					    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;
+	}
+	
+	
+	
+	public function _cs($arg_array)
+	{
+		$asd = array();
+		$data = $this->fullorder->get_number($arg_array[0]);
+		$fullorder = 'fullorder';
+		$xx = array();
+
+			$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,' '));
+				if(!isset($ts[1]))
+				{
+					$ts[1] = '无';
+				}
+				$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);
+			echo "<pre>";
+			print_r(array($data,$classid,$tcall));
+			echo "<pre>";
+			print_r($ay);
+			exit;
+			
+			$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(isset($c['Data']))
+					{
+					    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']);
+			    }
+		    }
+		}
+		
+		
+		
+		public function _xxpl()
+	{
+		
+		$dir = '/data/excel/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'xls|xlsx|csv';
+        $config['max_size'] = 10240;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+			$fileName = '.' . $full_path;
+            if (!file_exists($fileName)) 
+			{
+				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
+            }
+			else
+			{
+				require_once "./data/excel/PHPExcel/IOFactory.php";
+				@$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
+				@$phpExcel->setActiveSheetIndex(0);// 设置为默认表
+				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量
+				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
+				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
+				++$column;//如果列数大于26行
+				$list = array();
+				for ($i = 2; $i <= $row; $i++) // 行数循环
+				{
+					$data = array();
+                    for ($c = 'A'; $c != $column; $c++)  // 列数循环
+	                {
+						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
+                    }
+					$list[] = $data;
+                }
+			}
+			$cw = [];$d = [];
+			foreach ($list as $v)
+		    {
+				$v = $v[0];
+				$fullorder_name = 'fullorder';
+				$y = $this->fullorder->get_number($v);
+				if(!$y)
+				{
+					$fullorder_name = 'fullordersmt';
+					$y = $this->fullordersmt->get_number($v);
+					if(!$y)
+					{
+						$fullorder_name = 'fullordertt';
+						$y = $this->fullordertt->get_number($v);
+						if(!$y)
+				    	{
+							$cw[] = [$v,'无数据'];
+						}
+						
+					}
+				}
+				$d[$fullorder_name][] = $y;
+			}
+			foreach($d as $key=>$val)
+			{
+				$h = $this->_list($val,$key);
+			    foreach($h as $vv)
+			    {
+				    $x = 0;$c = 0;
+					if(!isset($vv[0]))
+					{
+						continue;
+					}
+				    $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;
+				}
+			}
+			echo "<pre>";
+				print_r($cw);
+				echo "<pre>";
+				print_r($asd);
+        }
+		else
+		{
+			echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
+		}
+    }
+	
+}