作者 刘朕
1 个管道 的构建 通过 耗费 1 秒

订单导出、销售订单列表筛选问题修复

@@ -19,11 +19,13 @@ class OrderController extends AdminBaseController @@ -19,11 +19,13 @@ class OrderController extends AdminBaseController
19 protected $order_model; 19 protected $order_model;
20 protected $option_table; 20 protected $option_table;
21 protected $sort_model; 21 protected $sort_model;
  22 + protected $order_sort_table;
22 public function _initialize() 23 public function _initialize()
23 { 24 {
24 $this->table = 'Order'; 25 $this->table = 'Order';
25 $this->order_model = new OrderModel(); 26 $this->order_model = new OrderModel();
26 $this->option_table = 'OrderOption'; 27 $this->option_table = 'OrderOption';
  28 + $this->order_sort_table = 'OrderSort';
27 29
28 // 订单字段类型定义 30 // 订单字段类型定义
29 $this->sort_model[1] = '<div class="text_item form_options" data-validate="{validate}"> 31 $this->sort_model[1] = '<div class="text_item form_options" data-validate="{validate}">
@@ -83,6 +85,7 @@ class OrderController extends AdminBaseController @@ -83,6 +85,7 @@ class OrderController extends AdminBaseController
83 </div>'; 85 </div>';
84 } 86 }
85 87
  88 +
86 /** 89 /**
87 * 电子订单列表 90 * 电子订单列表
88 * @adminMenu( 91 * @adminMenu(
@@ -134,7 +137,7 @@ class OrderController extends AdminBaseController @@ -134,7 +137,7 @@ class OrderController extends AdminBaseController
134 $where['create_time'] = ['<= time', $endTime]; 137 $where['create_time'] = ['<= time', $endTime];
135 } 138 }
136 } 139 }
137 - $list = Db::name('order_view')->where($where)->paginate(10); 140 + $list = $this->singleData('order_view',$where,2,[],10);
138 $list->appends($param); 141 $list->appends($param);
139 $this->assign('list',$list->items()); 142 $this->assign('list',$list->items());
140 $this->assign('page',$list->render()); 143 $this->assign('page',$list->render());
@@ -146,7 +149,7 @@ class OrderController extends AdminBaseController @@ -146,7 +149,7 @@ class OrderController extends AdminBaseController
146 $this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : ''); 149 $this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : '');
147 $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : ''); 150 $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
148 // 订单类型查询 151 // 订单类型查询
149 - $sortList = Db::name('OrderSort')->where(['delete_time'=>0])->select()->toArray(); 152 + $sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
150 $this->assign('sortList',$sortList); 153 $this->assign('sortList',$sortList);
151 return $this->fetch(); 154 return $this->fetch();
152 } 155 }
@@ -199,7 +202,7 @@ class OrderController extends AdminBaseController @@ -199,7 +202,7 @@ class OrderController extends AdminBaseController
199 $where['create_time'] = ['<= time', $endTime]; 202 $where['create_time'] = ['<= time', $endTime];
200 } 203 }
201 } 204 }
202 - $list = Db::name('order_view')->where($where)->paginate(10); 205 + $list = $this->singleData('order_view',$where,2,[],10);
203 $list->appends($param); 206 $list->appends($param);
204 $this->assign('list',$list->items()); 207 $this->assign('list',$list->items());
205 $this->assign('page',$list->render()); 208 $this->assign('page',$list->render());
@@ -211,7 +214,7 @@ class OrderController extends AdminBaseController @@ -211,7 +214,7 @@ class OrderController extends AdminBaseController
211 $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : ''); 214 $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
212 $this->assign('sort_id',$param['sort_id']); 215 $this->assign('sort_id',$param['sort_id']);
213 // 订单类型 216 // 订单类型
214 - $sortList = Db::name('OrderSort')->where(['delete_time'=>0])->select()->toArray(); 217 + $sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
215 $this->assign('sortList',$sortList); 218 $this->assign('sortList',$sortList);
216 return $this->fetch(); 219 return $this->fetch();
217 } 220 }
@@ -270,7 +273,7 @@ class OrderController extends AdminBaseController @@ -270,7 +273,7 @@ class OrderController extends AdminBaseController
270 $where['create_time'] = ['<= time', $endTime]; 273 $where['create_time'] = ['<= time', $endTime];
271 } 274 }
272 } 275 }
273 - $list = Db::name('order_view')->where($where)->paginate(10); 276 + $list = $this->singleData('order_view',$where,2,[],10);
274 $list->appends($param); 277 $list->appends($param);
275 $this->assign('list',$list->items()); 278 $this->assign('list',$list->items());
276 $this->assign('page',$list->render()); 279 $this->assign('page',$list->render());
@@ -283,7 +286,7 @@ class OrderController extends AdminBaseController @@ -283,7 +286,7 @@ class OrderController extends AdminBaseController
283 $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : ''); 286 $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
284 $this->assign('user_id',$param['user_id']); 287 $this->assign('user_id',$param['user_id']);
285 // 订单类型 288 // 订单类型
286 - $sortList = Db::name('OrderSort')->where(['delete_time'=>0])->select()->toArray(); 289 + $sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
287 $this->assign('sortList',$sortList); 290 $this->assign('sortList',$sortList);
288 return $this->fetch(); 291 return $this->fetch();
289 } 292 }
@@ -344,14 +347,13 @@ class OrderController extends AdminBaseController @@ -344,14 +347,13 @@ class OrderController extends AdminBaseController
344 } 347 }
345 } 348 }
346 // 查询数据并导出 349 // 查询数据并导出
347 - $list = Db::name('order_view')->where($where)->select()->toArray(); 350 + $list = $this->singleData('order_view',$where,1);
348 $this->expList($list); 351 $this->expList($list);
349 } 352 }
350 353
351 // 数据导出 354 // 数据导出
352 private function expList($array) 355 private function expList($array)
353 { 356 {
354 -  
355 //导出Excel 357 //导出Excel
356 $objPHPExcel = new \PHPExcel(); 358 $objPHPExcel = new \PHPExcel();
357 359
@@ -397,6 +399,7 @@ class OrderController extends AdminBaseController @@ -397,6 +399,7 @@ class OrderController extends AdminBaseController
397 $objPHPExcel->getActiveSheet()->getColumnDimension('AN')->setWidth(20); 399 $objPHPExcel->getActiveSheet()->getColumnDimension('AN')->setWidth(20);
398 $objPHPExcel->getActiveSheet()->getColumnDimension('AO')->setWidth(20); 400 $objPHPExcel->getActiveSheet()->getColumnDimension('AO')->setWidth(20);
399 $objPHPExcel->getActiveSheet()->getColumnDimension('AP')->setWidth(20); 401 $objPHPExcel->getActiveSheet()->getColumnDimension('AP')->setWidth(20);
  402 + $objPHPExcel->getActiveSheet()->getColumnDimension('AQ')->setWidth(20);
400 // 设置水平居中 403 // 设置水平居中
401 $objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); 404 $objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
402 // 设置垂直居中 405 // 设置垂直居中
@@ -444,7 +447,8 @@ class OrderController extends AdminBaseController @@ -444,7 +447,8 @@ class OrderController extends AdminBaseController
444 ->setCellValue('AM1', '不适龄备注') 447 ->setCellValue('AM1', '不适龄备注')
445 ->setCellValue('AN1', '图片') 448 ->setCellValue('AN1', '图片')
446 ->setCellValue('AO1', '月龄版升级年份') 449 ->setCellValue('AO1', '月龄版升级年份')
447 - ->setCellValue('AP1', '备注'); 450 + ->setCellValue('AP1', '备注')
  451 + ->setCellValue('AQ1', '客户编号');
448 452
449 $i = 2; 453 $i = 2;
450 454
@@ -475,37 +479,39 @@ class OrderController extends AdminBaseController @@ -475,37 +479,39 @@ class OrderController extends AdminBaseController
475 'id' => $vs['id'] 479 'id' => $vs['id']
476 ]; 480 ];
477 $vs['cell'] = Db::name('OrderOption')->where($where)->value('cell'); 481 $vs['cell'] = Db::name('OrderOption')->where($where)->value('cell');
478 - if($vs['type'] == 3) {  
479 - // 纯数字字段转化为字符串格式,防止以科学计数法进行显示  
480 - $objPHPExcel->setActiveSheetIndex(0)  
481 - ->setCellValueExplicit($vs['cell'] . $i, $vs['user_choose'],\PHPExcel_Cell_DataType::TYPE_STRING);  
482 - } elseif($vs['type'] == 8) {  
483 - // 导出图片格式,高度自适应  
484 - $filePath = './upload/'.$vs['user_choose'];  
485 - if(!empty($vs['user_choose']) && file_exists($filePath)) {  
486 - $image = \think\Image::open('./upload/'.$vs['user_choose']);  
487 - // 返回图片的宽度  
488 - $width = $image->width();  
489 - // 返回图片的高度  
490 - $height = $image->height();  
491 - $default = $height/($width/100);  
492 - //设置默认行高(通过图片缩放比例计算高度)  
493 - $objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight($default);  
494 - // 图片生成  
495 - $objDrawing[$i] = new \PHPExcel_Worksheet_Drawing();  
496 - $objDrawing[$i]->setPath($filePath);  
497 - // 设置宽度  
498 - $objDrawing[$i]->setWidth(100); //照片宽度  
499 - /*设置图片要插入的单元格*/  
500 - $objDrawing[$i]->setCoordinates($vs['cell'].$i);  
501 - // 图片偏移距离  
502 - $objDrawing[$i]->setOffsetX(12);  
503 - $objDrawing[$i]->setOffsetY(12);  
504 - $objDrawing[$i]->setWorksheet($objPHPExcel->getActiveSheet()); 482 + if(!empty($vs['cell'])) {
  483 + if($vs['type'] == 3) {
  484 + // 纯数字字段转化为字符串格式,防止以科学计数法进行显示
  485 + $objPHPExcel->setActiveSheetIndex(0)
  486 + ->setCellValueExplicit($vs['cell'] . $i, $vs['user_choose'],\PHPExcel_Cell_DataType::TYPE_STRING);
  487 + } elseif($vs['type'] == 8) {
  488 + // 导出图片格式,高度自适应
  489 + $filePath = './upload/'.$vs['user_choose'];
  490 + if(!empty($vs['user_choose']) && file_exists($filePath)) {
  491 + $image = \think\Image::open('./upload/'.$vs['user_choose']);
  492 + // 返回图片的宽度
  493 + $width = $image->width();
  494 + // 返回图片的高度
  495 + $height = $image->height();
  496 + $default = $height/($width/100);
  497 + //设置默认行高(通过图片缩放比例计算高度)
  498 + $objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight($default);
  499 + // 图片生成
  500 + $objDrawing[$i] = new \PHPExcel_Worksheet_Drawing();
  501 + $objDrawing[$i]->setPath($filePath);
  502 + // 设置宽度
  503 + $objDrawing[$i]->setWidth(100); //照片宽度
  504 + /*设置图片要插入的单元格*/
  505 + $objDrawing[$i]->setCoordinates($vs['cell'].$i);
  506 + // 图片偏移距离
  507 + $objDrawing[$i]->setOffsetX(12);
  508 + $objDrawing[$i]->setOffsetY(12);
  509 + $objDrawing[$i]->setWorksheet($objPHPExcel->getActiveSheet());
  510 + }
  511 + } else {
  512 + $objPHPExcel->setActiveSheetIndex(0)
  513 + ->setCellValue($vs['cell'] . $i, $vs['user_choose']);
505 } 514 }
506 - } else {  
507 - $objPHPExcel->setActiveSheetIndex(0)  
508 - ->setCellValue($vs['cell'] . $i, $vs['user_choose']);  
509 } 515 }
510 } 516 }
511 $i++; 517 $i++;
@@ -147,12 +147,14 @@ @@ -147,12 +147,14 @@
147 html += `<div class="list_style" data-href="${element.detail_url}"> 147 html += `<div class="list_style" data-href="${element.detail_url}">
148 <div class="style_one"> 148 <div class="style_one">
149 <p class="style_text"> 149 <p class="style_text">
150 - 订单类型:<span class="font_weight">${element.name}</span> 150 + 订单类型:<span class="font_weight">${element.sort_name}</span>
151 </p> 151 </p>
152 ${status} 152 ${status}
153 </div> 153 </div>
154 <p class="order_num">订单编号:${element.order_sn}</p> 154 <p class="order_num">订单编号:${element.order_sn}</p>
155 <p class="order_data" id="change_time">提交时间:${element.create_time}</p> 155 <p class="order_data" id="change_time">提交时间:${element.create_time}</p>
  156 + <p class="order_data">订单确认码:${element.number}</p>
  157 + <p class="order_data">联系电话:${element.mobile}</p>
156 ${change} 158 ${change}
157 </div>`; 159 </div>`;
158 }); 160 });