| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Ahc extends Start_Controller {	public function __construct(){		parent::__construct();		$this->load->library('session');		$this->load->_model('Model_fullorder_smt','fullorder_smt');		$this->load->_model('Model_fullorder','fullorder');		$this->load->_model('Model_fullordertt','fullordertt');		$this->load->_model('Model_fullorderexcel','fullorderexcel');		$this->load->_model('Model_shop','shop');		$this->load->_model('Model_typeclass','typeclass');		$this->load->_model('Model_express','express');		$this->load->_model('Model_country','country');		$this->load->_model('Model_productdescribe','productdescribe');		$this->load->_model('Model_customs','customs');		$this->load->_model('Model_detailed','detailed');		$this->load->_model('Model_productdescription','productdescription');		$this->load->_model('Model_logistics','logistics');		$this->load->_model('Model_hl','hl');		$this->load->_model('Model_excel','excel');		$this->load->_model('Model_warehouse','warehouse');		$this->load->_model('Model_customer','customer');		$this->load->_model('Model_user','user');		$this->load->_model('Model_dhl','dhl');		$this->load->_model('Model_notice','notice');		$this->load->_model('Model_api','api');	}	//定义方法的调用规则 获取URI第二段值    public function _remap($arg,$arg_array)    {		if($arg == 'hcd')        {             $this->_hcd();        }		else		{			 $this->_index();		}    }	//管理	public function _index()	{		$dt = 0;		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$usp = $user;		    $fgshop = "";$sid = "";		    $user = explode('|',trim($user['shop'],'|'));			foreach ($user as $value) 		    {				$fgshop .= " shop = ".$value." or";				$sid .= " id = ".$value." or";			}		}		$post = $this->input->post(NULL, TRUE);		if(isset($post['page']))		{		    $page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$timetk = $this->input->post('timetk',true);			$timetj = $this->input->post('timetj',true);			$timetk = strtotime($timetk)+12*3600;			$timetj = strtotime($timetj)+12*3600;			$data = $this->input->post('data',true);			$where = "mergeid = 0 and (".rtrim($fgshop,'or').")";			if($data == 1)			{				$where .= " and print = 2 and state = 207";			}			else if($data == 2)			{				$where .= " and print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'";			}			else if($data == 3)			{				$where .= " and print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'";			}			else if($data == 4)			{				$where .= " and print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'";			}            //数据排序            $order_str = "dtime desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            $info_list = $this->fullorder_smt->find_all($where,'id,shop,type,orderinfo,number,client,state,buytime,libraryconfirm,express,waybill,orderremarks,reviewremarks,printnumber,black,clientremarks',$order_str,$start,$perpage);			 //格式化数据            foreach ($info_list as $key=>$value) 		    {				$ud = $this->fullorder_smt->read($value['id']);				$ud['address'] = str_replace("'","’",$ud['address']);				$ud['name'] = str_replace("'","’",$ud['name']);				$customer = $this->customer->get_email($ud['email'],$value['shop']);				$customerb = $this->customer->get_shopdata($ud['name'],$ud['email'],$ud['address'],$value['shop']);				//$a = array_column($customer, 'email'); //三维找其中健的数组			    //$a = array_flip($a); //键和值调换				$shop = $this->shop->read($value['shop']);				$info_list[$key]['shop'] = $shop['shopname'];				//$info_list[$key]['user'] = $shop['shopuser'];				$warehouse = $this->warehouse->read($value['type']);				$warehousetitle = $warehouse['title'];				if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}				$info_list[$key]['type'] = $warehousetitle;				$typeclass = $this->typeclass->read($value['state']);				$info_list[$key]['state'] = $typeclass['spare'];				if($ud['source'] == 1) //线下单用订单时间,其他用付款时间				{					$info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';				}				else				{				    $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']+$dt).'</p><p>'.date('H:i:s',$value['buytime']+$dt).'</p>';				}				if($value['waybill'] != "")				{					$info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>";				}				if($value['express'] != 0)				{				    $express = $this->express->read($value['express']);					$expressservicename = $express['servicename'];				if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}				    $info_list[$key]['express'] = $expressservicename;				}				else				{					$info_list[$key]['express'] = "无";				}				$x = "";				if($value['libraryconfirm'] == 2 && $ud['review'] > 4 && $ud['library'] == 1)				{				    $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";				}				else if(($ud['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)				{					$x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";				}				if(($ud['review'] > 4) && $ud['print'] == 2)				{				    $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";				}				else if($ud['review'] >4 && $ud['print'] == 1)				{				    $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";				}				if($value['waybill'] == "" && $ud['review'] > 4)				{					$x = $x."<p><b class='kn' data-type='2'>填写运单</b></p>";				}				else if($value['waybill'] != "" && $ud['review'] > 4)				{					$x = $x."<p><b class='kn' data-type='2'>修改运单</b></p>";				}				if(($ud['review'] == 1 || $ud['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)				{					$x = $x."<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";				}				if($value['black'] == 0)				{					$x = $x."<p><b class='black' data-type='4' data-id='".$value['id']."'>加黑名单</b></p>";				}				$info_list[$key]['black'] = $x;				$tly = "";				if($value['clientremarks'] != "")				{					$tly = "<p style='color:#FF3333'>有客户留言</p>";				}								$info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder_smt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";				            }			$xx1 = $this->fullorder_smt->find_count("print = 2 and state = 207");			$xx2 = $this->fullorder_smt->find_count("print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'");			$xx3 = $this->fullorder_smt->find_count("print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'");			$xx4 = $this->fullorder_smt->find_count("print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'");		    $total = $this->fullorder_smt->find_count($where);		    $pagenum = ceil($total/$perpage);		    $over = $total-($start+$perpage);		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'xx'=>(array('1'=>$xx1,'2'=>$xx2,'3'=>$xx3,'4'=>$xx4)));		    echo json_encode($rows);exit;		}		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));		$this->data['wlshop'] = $wlshop;		$this->data['express'] = $this->express->find_all();		$fullorderexcel = $this->fullorderexcel->find_all('type=1','*','idorder desc');//导出模板		$this->data['fullorderexcel'] = $fullorderexcel;		$error = $this->fullorder_smt->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and (".rtrim($fgshop,'or').")");		$this->data['error'] = $error;		$this->_Template('ahc_smt',$this->data);	}		//管理	public function _hcd()	{		$dt = 0;		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$usp = $user;		    $fgshop = "";$sid = "";		    $user = explode('|',trim($user['shop'],'|'));			foreach ($user as $value) 		    {				$fgshop .= " shop = ".$value." or";				$sid .= " id = ".$value." or";			}		}		$post = $this->input->post(NULL, TRUE);		if(isset($post['page']))		{		    $page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$timetk = $this->input->post('timetk',true);			$timetj = $this->input->post('timetj',true);			$timetk = strtotime($timetk)+12*3600;			$timetj = strtotime($timetj)+12*3600;			$data = $this->input->post('data',true);			$where = "mergeid = 0 and type = 5 and review = 6 and (".rtrim($fgshop,'or').")";			if($data == 1)			{				$where .= " and print = 2 and state = 207 and dtime > 1557244800";			}			else if($data == 2)			{				$where .= " and print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'";			}			else if($data == 3)			{				$where .= " and print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'";			}			else if($data == 4)			{				$where .= " and print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'";			}            //数据排序            $order_str = "dtime desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,client,state,buytime,libraryconfirm,express,waybill,orderremarks,reviewremarks,printnumber,black,clientremarks',$order_str,$start,$perpage);			 //格式化数据            foreach ($info_list as $key=>$value) 		    {				$ud = $this->fullorder->read($value['id']);				$ud['address'] = str_replace("'","’",$ud['address']);				$ud['name'] = str_replace("'","’",$ud['name']);				$customer = $this->customer->get_email($ud['email'],$value['shop']);				$customerb = $this->customer->get_shopdata($ud['name'],$ud['email'],$ud['address'],$value['shop']);				//$a = array_column($customer, 'email'); //三维找其中健的数组			    //$a = array_flip($a); //键和值调换				$shop = $this->shop->read($value['shop']);				$info_list[$key]['shop'] = $shop['shopname'];				//$info_list[$key]['user'] = $shop['shopuser'];				$warehouse = $this->warehouse->read($value['type']);				$warehousetitle = $warehouse['title'];				if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}				$info_list[$key]['type'] = $warehousetitle;				$typeclass = $this->typeclass->read($value['state']);				$info_list[$key]['state'] = $typeclass['spare'];				if($ud['source'] == 1) //线下单用订单时间,其他用付款时间				{					$info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';				}				else				{				    $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']+$dt).'</p><p>'.date('H:i:s',$value['buytime']+$dt).'</p>';				}				if($value['waybill'] != "")				{					$info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>";				}				if($value['express'] != 0)				{				    $express = $this->express->read($value['express']);					$expressservicename = $express['servicename'];				if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}				    $info_list[$key]['express'] = $expressservicename;				}				else				{					$info_list[$key]['express'] = "无";				}				$x = "";				if($value['libraryconfirm'] == 2 && $ud['review'] > 4 && $ud['library'] == 1)				{				    $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";				}				else if(($ud['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)				{					$x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";				}				if(($ud['review'] > 4) && $ud['print'] == 2)				{				    $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";				}				else if($ud['review'] >4 && $ud['print'] == 1)				{				    $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";				}				if($value['waybill'] == "" && $ud['review'] > 4)				{					$x = $x."<p><b class='kn' data-type='2'>填写运单</b></p>";				}				else if($value['waybill'] != "" && $ud['review'] > 4)				{					$x = $x."<p><b class='kn' data-type='2'>修改运单</b></p>";				}				if(($ud['review'] == 1 || $ud['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)				{					$x = $x."<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";				}				if($value['black'] == 0)				{					$x = $x."<p><b class='black' data-type='4' data-id='".$value['id']."'>加黑名单</b></p>";				}				$info_list[$key]['black'] = $x;				$tly = "";				if($value['clientremarks'] != "")				{					$tly = "<p style='color:#FF3333'>有客户留言</p>";				}								$info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";				            }			$xx1 = $this->fullorder->find_count("print = 2 and dtime > 1557244800 and state = 207 and type = 5");			$xx2 = $this->fullorder->find_count("print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj' and type = 5");			$xx3 = $this->fullorder->find_count("print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj' and type = 5");			$xx4 = $this->fullorder->find_count("print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj' and type = 5");		    $total = $this->fullorder->find_count($where);		    $pagenum = ceil($total/$perpage);		    $over = $total-($start+$perpage);		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'xx'=>(array('1'=>$xx1,'2'=>$xx2,'3'=>$xx3,'4'=>$xx4)));		    echo json_encode($rows);exit;		}		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));		$this->data['wlshop'] = $wlshop;		$this->data['express'] = $this->express->find_all();		$fullorderexcel = $this->fullorderexcel->find_all('type=1','*','idorder desc');//导出模板		$this->data['fullorderexcel'] = $fullorderexcel;		$error = $this->fullorder->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and type = 5 and (".rtrim($fgshop,'or').")");		$this->data['error'] = $error;		$this->_Template('ahc_dlz',$this->data);	}}
 |