瀏覽代碼

提交数据

lvhao 2 月之前
父節點
當前提交
554ac6f93e
共有 1 個文件被更改,包括 352 次插入0 次删除
  1. 352 0
      core/CoreApp/controllers/Systemfoutfz.php

+ 352 - 0
core/CoreApp/controllers/Systemfoutfz.php

@@ -0,0 +1,352 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+header("Access-Control-Allow-Origin: *");
+class Systemfoutfz extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->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_fullorderamz','fullorderamz');
+		$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_logic_ding","logic_ding");
+		$this->load->_model("Model_fedexv1",'fedexv1');
+		$this->load->_model("Model_zzquque_u9","zzquque_u9");
+		$this->load->_model("Model_customsdeclaration","customsdeclaration");
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'exceltwo')
+        {
+             $this->_exceltwo($arg_array);
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	public function _exceltwo($arg_array)
+    {
+		if(isset($_GET['fexcel']))  
+		{
+			$dowid = $this->input->get('a');
+			$wid = "";
+			if($dowid != "")
+			{
+				$id_arr =  explode(',',rtrim($dowid,','));
+				foreach ($id_arr as $v) 
+		        {
+                    $wid  .= " id = '$v' or";
+                }
+				$wid = " and".rtrim($wid,'or');
+			}
+		    $t = $this->input->get('t',true);
+			$timetk = $this->input->get('timetk',true);
+			$timetj = $this->input->get('timetj',true);
+			$shop = $this->input->get('shop',true);
+			$source = $this->input->get('source',true);
+			$orderinfo = $this->input->get('orderinfo',true);
+			$number = $this->input->get('number',true);
+			$library = $this->input->get('library',true);
+			$waybill = $this->input->get('waybill',true);
+			$express = $this->input->get('express',true);
+			$type = $this->input->get('type',true);
+			$so = $this->input->get('so',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
+			if($timetk && $timetj && $library == 1)
+            {
+				//$cxtime = 'reviewtime';
+                $where  .= "  and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
+				$where  .= " and state != 217";
+				
+            }
+			else if($timetk && $timetj && $library == 2)
+            {
+				$cxtime = 'librarytime';
+                $where  .= " and librarytime > '$timetk' and librarytime < '$timetj'";
+            }
+		
+			if(isset($_SESSION['api']))
+            {
+				if($type)
+            	{
+                	$where  .= " and type = '$type'";
+           		}
+				else
+				{
+					$uw = '';
+				    $u = $this->user->get_api($_SESSION['api']);
+				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));
+				    foreach ($u['warehouse'] as $v) 
+		            {
+					    $uw  .= " type = '$v' or";
+                    }
+				    $uw = rtrim($uw,'or');
+					$uw = " and (".ltrim($uw,' ').")";
+					$where  .= $uw;
+				}
+            }
+			else
+			{
+				echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
+			}
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($library)
+            {
+                $where  .= " and library = '$library'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			if($express)
+            {
+				$where  .= " and express = '$express'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($so)
+            {
+                $where  .= " and shipremarks like '%$so%'";
+            }
+            //数据排序
+			//$order_str = ($print != 3)?"id desc":"librarytime desc";
+			$order_str = "librarytime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$typeclass = array();
+			$tclass = $this->typeclass->find_all();
+			foreach ($tclass as $v) 
+			{
+				$typeclass[$v['id']] = $v;
+			}
+			$classid = $classid = $this->classid->sku();
+			$shop_list = $this->shop->find_all();
+			$shop_list = array_column($shop_list,'shopname','id');
+			$express_list = $this->express->find_all();
+			$express_list = array_column($express_list,'servicename','id');
+			$warehouse_list = $this->warehouse->find_all();
+			$warehouse_list = array_column($warehouse_list,'title','id');
+
+			$info_list = $this->_getAndTransfer('fullorder',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid);
+
+			$info_listsmt = $this->_getAndTransfer('fullordersmt',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid);
+
+			$info_listtt = $this->_getAndTransfer('fullordertt',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid);
+
+			$info_listamz = $this->_getAndTransfer('fullorderamz',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid);
+
+			$info_listxw = $this->_getAndTransfer('fullorderxw',$where.$wid,$order_str,$shop_list,$express_list,$warehouse_list,$classid);
+			
+			
+			
+			$list = [];
+			$list = array_merge($info_list,$info_listsmt,$info_listtt,$info_listamz,$info_listxw);
+			echo "<pre>";
+			print_r($list);
+			die;
+			
+			$final_list = [];
+			// foreach(){
+
+			// }
+			
+		
+            $title = '订单出库-'.date('Ymd',time());
+            $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
+			$tail = "\n";
+            $filename = $title.".xls";
+            $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt),$titlename,$filename,$tail);
+		}
+	}
+	
+	
+	/**
+	 * 对多个平台的数据进行循环处理
+	 */
+	private function _getAndTransfer($table,$where,$order_str,$shop_list,$express_list,$warehouse_list,$classid){
+		 //取得信息列表
+		 $info_list = $this->$table->find_all($where,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
+		 //格式化数据
+		foreach ($info_list as $key=>$value) 
+		{
+			$info_list[$key]['shop'] = isset($shop_list[$value['shop']])?$shop_list[$value['shop']]: "";
+			if($value['waybill'] == '0')
+			{
+				$info_list[$key]['waybill'] = "";
+			}
+			$info_list[$key]['express'] = isset($express_list[$value['express']])?$express_list[$value['express']]:"";
+		
+			$info_list[$key]['type'] = isset($warehouse_list[$value['type']])?$warehouse_list[$value['type']]: "";
+			if($value['print'] == 1)
+			{
+				$info_list[$key]['print'] = '不可打印';
+			}
+			else if($value['print'] == 2)
+			{
+				$info_list[$key]['print'] = '未打印';
+			}
+			else if($value['print'] == 3)
+			{
+				$info_list[$key]['print'] = '已打印';
+			}
+			if($value['library'] == 1)
+			{
+				$info_list[$key]['library'] = '<em class="c">未出库</em>';
+			}
+			else if($value['library'] == 2)
+			{
+				$info_list[$key]['library'] = '<em class="c">已出库</em>';
+			}
+			else if($value['library'] == 3)
+			{
+				$info_list[$key]['library'] = '<em class="c">已退库</em>';
+			}
+			if($value['librarytime'] == '0')
+			{
+				$info_list[$key]['librarytime'] = '<em class="t"></em>';
+			}
+			else
+			{
+				$info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
+			}
+			$dbapi = explode(';',trim($value['fpdata'],';'));
+			$tmp_jm = "";
+			$tmp_zh = "";
+			foreach ($dbapi as $va) 
+			{
+				$pm = $classid;
+				$jm = $classid;
+				$bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
+				$features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
+				$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 && isset($typeclass[$v]))
+					{
+						if($typeclass[$v]['classid'] == 13)
+						{
+							$dj = $typeclass[$v]['title'];
+						}
+						if($typeclass[$v]['classid'] == 8)
+						{
+							$ys = $typeclass[$v]['title'];
+						}
+						if($typeclass[$v]['classid'] == 15)
+						{
+							$hx = $typeclass[$v]['title'];
+						}
+						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);
+				$tmp_jm .= $jm.";";
+				$pm = array_filter($pm);//去除空值
+				$zh = implode(" ",$pm);
+				$zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
+				$tmp_zh .= $zh.";";
+			}
+			$info_list[$key]['jm'] = trim($tmp_jm,';');
+			$info_list[$key]['zh'] = trim($tmp_zh,';');
+		}
+
+		return $info_list;
+	}
+}