瀏覽代碼

添加tiktok的异常取消导出

lvhao 1 周之前
父節點
當前提交
6fd71838f4
共有 2 個文件被更改,包括 122 次插入0 次删除
  1. 116 0
      core/CoreApp/controllers/Fullordertt.php
  2. 6 0
      template/erp/fullordertt.html

+ 116 - 0
core/CoreApp/controllers/Fullordertt.php

@@ -161,6 +161,10 @@ class Fullordertt extends Start_Controller {
 		else if($arg == 'yc')
         {
              $this->_yc();
+        }
+		else if($arg == 'ycexcel')
+        {
+             $this->_ycexcel();
         }
 		else if($arg == 'yzaddress')
         {
@@ -4627,6 +4631,118 @@ class Fullordertt extends Start_Controller {
 		$this->data['fullorderexcel'] = $fullorderexcel;
 		$this->_Template('fullordertt_yc',$this->data);
 	}
+	//导出异常取消列表
+	public function _ycexcel(){
+		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";
+			}
+		}
+		$query = $this->input->get(NULL, TRUE);
+		if(empty($query['is_excel'])){
+			exit;
+		}
+		
+		$where = "library = 2 and state = 214 and (".rtrim($fgshop,'or').")";
+		
+		$info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,state,dtime,express,waybill,library,operation,librarytime,retreattime,printtype');
+		$shop_list = $this->shop->find_all('id > 0');
+		$shop_list = array_column($shop_list,'shopname','id');
+		$warehouse_list = $this->warehouse->find_all('id > 0');
+		$warehouse_list = array_column($warehouse_list,'title','id');
+		$express_list = $this->express->find_all('id > 0');
+		$express_list = array_column($express_list,'servicename','id');
+		$typeclass_list = $this->typeclass->find_all('classid = 29');
+		$typeclass_list = array_column($typeclass_list,'spare','classid');
+		//格式化数据
+	
+		foreach ($info_list as $key=>$value) 
+		{
+			$ud = $this->fullordertt->read($value['id']);
+			$info_list[$key]['shop'] = isset($shop_list[$value['shop']])? $shop_list[$value['shop']] : ''; 
+			$info_list[$key]['type'] = isset($warehouse_list[$value['type']])? $warehouse_list[$value['type']] : '';
+			if($value['express'] != 0)
+			{
+				$info_list[$key]['express'] = isset($express_list[$value['express']])? $express_list[$value['express']] : '';
+			}
+			else
+			{
+				$info_list[$key]['express'] = "无";
+			}
+			$info_list[$key]['state'] =  isset($typeclass_list[$value['state']])? $typeclass_list[$value['state']] : ''; 
+			$info_list[$key]['dtime'] = date('Y-m-d H:i:s',$ud['dtime']);
+			if($value['library'] == 1 && $ud['printtype'] == 3)
+			{
+				$info_list[$key]['library'] = "不需要";
+			}
+			else if($value['library'] == 1 && $ud['printtype'] != 3)
+			{
+				$info_list[$key]['library'] = "未出库";
+			}
+			else if($value['library'] == 2)
+			{
+				$info_list[$key]['library'] = date('Y-m-d H:i:s',$value['librarytime'])." 出库";
+			}
+			else if($value['library'] == 3)
+			{
+				$info_list[$key]['library'] = date('Y-m-d H:i:s',$value['retreattime'])." 退库";
+			}
+		}
+		
+		//生成excel
+		$filename = 'tiktok异常取消导出-'.date('Ymd',time()).".xlsx";
+		$str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
+		<head>
+		<!--[if gte mso 9]><xml>
+		<x:ExcelWorkbook>
+		<x:ExcelWorksheets>
+		<x:ExcelWorksheet>
+		<x:Name>EXCEL</x:Name>
+		<x:WorksheetOptions>
+		<x:Print>
+		<x:ValidPrinterInfo />
+		</x:Print>
+		</x:WorksheetOptions>
+		</x:ExcelWorksheet>
+		</x:ExcelWorksheets>
+		</x:ExcelWorkbook>
+		</xml>
+		<![endif]-->
+		</head><body>";
+		$str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>"; 
+		$str .= "<tr><td>店铺名称</td><td>发货仓库</td><td>订单号</td><td>编号</td><td>订单状态</td><td>订单时间</td><td>物流方式</td><td>运单号</td><td>发货状态</td></tr>";
+		foreach ($info_list as $key=>$v) 
+		{ 
+			
+			$str .= "<tr>";
+			$str .= "<td>". $v['shop']. "</td>";
+			$str .= "<td>". $v['type']. "</td>";
+			$str .= "<td>`". $v['orderinfo']. "</td>";
+			$str .= "<td>". $v['number']. "</td>";
+			$str .= "<td>". $v['state']. "</td>";
+			$str .= "<td>". $v['dtime']. "</td>";
+			$str .= "<td>". $v['express']. "</td>";
+			$str .= "<td>`". $v['waybill']. "</td>";
+			$str .= "<td>". $v['library']. "</td>";
+			$str .= "</tr>";
+		}
+		$str .= "</table></body></html>"; 
+		header( "Content-Type: application/vnd.ms-excel; name='excel'" ); 
+		header( "Content-type: application/octet-stream" ); 
+		header( "Content-Disposition: attachment; filename=".$filename ); 
+		header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); 
+		header( "Pragma: no-cache" ); 
+		header( "Expires: 0" ); 
+		exit($str); 
+		
+	}
 	//验证地址
 	public function _yzaddress()
 	{

+ 6 - 0
template/erp/fullordertt.html

@@ -142,6 +142,7 @@
 {/if}
 {if $yc > 0}
 <a href="/fullordertt/yc/" style="background-color:#F00">异常取消订单({$yc})</a>
+<a href="javascript:void(0);" onclick="ycqxdc()" style="background-color:#D2691E">导出异常取消订单</a>
 {/if}
 <a href="javascript:void(0);" class="dcdxyz">导出多运单号订单</a>
 <a href="javascript:void(0);" class="thxz">导出退货订单</a>
@@ -388,6 +389,11 @@ $(".datatext").on('click',".create_label",function() {
 
     })
 })
+
+function ycqxdc(){
+   
+    window.location.href = "/fullordertt/ycexcel?is_excel=1";
+}
 </script>
 <script type="text/javascript" src="{$theme}js/laydate.js"></script>