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

字段导出、订单导出修改

@@ -114,6 +114,9 @@ class OrderController extends AdminBaseController @@ -114,6 +114,9 @@ class OrderController extends AdminBaseController
114 if(isset($param['status']) && $param['status'] >= 0) { 114 if(isset($param['status']) && $param['status'] >= 0) {
115 $where['status'] = $param['status']; 115 $where['status'] = $param['status'];
116 } 116 }
  117 + if(!empty($param['pay_type'])) {
  118 + $where['pay_type'] = $param['pay_type'];
  119 + }
117 if(isset($param['is_excel']) && $param['is_excel'] >= 0) { 120 if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
118 $where['is_excel'] = $param['is_excel']; 121 $where['is_excel'] = $param['is_excel'];
119 } 122 }
@@ -323,6 +326,9 @@ class OrderController extends AdminBaseController @@ -323,6 +326,9 @@ class OrderController extends AdminBaseController
323 if(isset($param['status']) && $param['status'] >= 0) { 326 if(isset($param['status']) && $param['status'] >= 0) {
324 $where['status'] = $param['status']; 327 $where['status'] = $param['status'];
325 } 328 }
  329 + if(!empty($param['pay_type'])) {
  330 + $where['pay_type'] = $param['pay_type'];
  331 + }
326 if(isset($param['is_excel']) && $param['is_excel'] >= 0) { 332 if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
327 $where['is_excel'] = $param['is_excel']; 333 $where['is_excel'] = $param['is_excel'];
328 } 334 }
@@ -400,6 +406,7 @@ class OrderController extends AdminBaseController @@ -400,6 +406,7 @@ class OrderController extends AdminBaseController
400 $objPHPExcel->getActiveSheet()->getColumnDimension('AO')->setWidth(20); 406 $objPHPExcel->getActiveSheet()->getColumnDimension('AO')->setWidth(20);
401 $objPHPExcel->getActiveSheet()->getColumnDimension('AP')->setWidth(20); 407 $objPHPExcel->getActiveSheet()->getColumnDimension('AP')->setWidth(20);
402 $objPHPExcel->getActiveSheet()->getColumnDimension('AQ')->setWidth(20); 408 $objPHPExcel->getActiveSheet()->getColumnDimension('AQ')->setWidth(20);
  409 + $objPHPExcel->getActiveSheet()->getColumnDimension('AR')->setWidth(20);
403 // 设置水平居中 410 // 设置水平居中
404 $objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); 411 $objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
405 // 设置垂直居中 412 // 设置垂直居中
@@ -412,43 +419,44 @@ class OrderController extends AdminBaseController @@ -412,43 +419,44 @@ class OrderController extends AdminBaseController
412 ->setCellValue('D1', '销售用户名') 419 ->setCellValue('D1', '销售用户名')
413 ->setCellValue('E1', '订单确认码') 420 ->setCellValue('E1', '订单确认码')
414 ->setCellValue('F1', '订单状态') 421 ->setCellValue('F1', '订单状态')
415 - ->setCellValue('G1', '收集状态')  
416 - ->setCellValue('H1', '发布时间')  
417 - ->setCellValue('I1', '失效时间')  
418 - ->setCellValue('J1', '订购方式')  
419 - ->setCellValue('K1', '来源渠道')  
420 - ->setCellValue('L1', '销售人员')  
421 - ->setCellValue('M1', '小朋友姓名')  
422 - ->setCellValue('N1', '小朋友性别')  
423 - ->setCellValue('O1', '小朋友生日')  
424 - ->setCellValue('P1', '家长姓名')  
425 - ->setCellValue('Q1', '家长身份')  
426 - ->setCellValue('R1', '其他身份')  
427 - ->setCellValue('S1', '家长电话')  
428 - ->setCellValue('T1', '手机备用电话')  
429 - ->setCellValue('U1', '座机备用电话')  
430 - ->setCellValue('V1', '地址')  
431 - ->setCellValue('W1', '收货地址')  
432 - ->setCellValue('X1', '详细收货地址')  
433 - ->setCellValue('Y1', '收货人姓名')  
434 - ->setCellValue('Z1', '收货人电话')  
435 - ->setCellValue('AA1', '收货区域')  
436 - ->setCellValue('AB1', '商品选择')  
437 - ->setCellValue('AC1', '具体版本')  
438 - ->setCellValue('AD1', '其他版本')  
439 - ->setCellValue('AE1', '订购长度')  
440 - ->setCellValue('AF1', '其他订购长度')  
441 - ->setCellValue('AG1', '订购起始月')  
442 - ->setCellValue('AH1', '订购价格')  
443 - ->setCellValue('AI1', '礼物选择')  
444 - ->setCellValue('AJ1', '加赠礼物')  
445 - ->setCellValue('AK1', '加赠礼物名称')  
446 - ->setCellValue('AL1', '是否适龄')  
447 - ->setCellValue('AM1', '不适龄备注')  
448 - ->setCellValue('AN1', '图片')  
449 - ->setCellValue('AO1', '月龄版升级年份')  
450 - ->setCellValue('AP1', '备注')  
451 - ->setCellValue('AQ1', '客户编号'); 422 + ->setCellValue('G1', '支付方式')
  423 + ->setCellValue('H1', '收集状态')
  424 + ->setCellValue('I1', '发布时间')
  425 + ->setCellValue('J1', '失效时间')
  426 + ->setCellValue('K1', '订购方式')
  427 + ->setCellValue('L1', '来源渠道')
  428 + ->setCellValue('M1', '销售人员')
  429 + ->setCellValue('N1', '小朋友姓名')
  430 + ->setCellValue('O1', '小朋友性别')
  431 + ->setCellValue('P1', '小朋友生日')
  432 + ->setCellValue('Q1', '家长姓名')
  433 + ->setCellValue('R1', '家长身份')
  434 + ->setCellValue('S1', '其他身份')
  435 + ->setCellValue('R1', '家长电话')
  436 + ->setCellValue('U1', '手机备用电话')
  437 + ->setCellValue('V1', '座机备用电话')
  438 + ->setCellValue('W1', '地址')
  439 + ->setCellValue('X1', '收货地址')
  440 + ->setCellValue('Y1', '详细收货地址')
  441 + ->setCellValue('Z1', '收货人姓名')
  442 + ->setCellValue('AA1', '收货人电话')
  443 + ->setCellValue('AB1', '收货区域')
  444 + ->setCellValue('AC1', '商品选择')
  445 + ->setCellValue('AD1', '具体版本')
  446 + ->setCellValue('AE1', '其他版本')
  447 + ->setCellValue('AF1', '订购长度')
  448 + ->setCellValue('AG1', '其他订购长度')
  449 + ->setCellValue('AH1', '订购起始月')
  450 + ->setCellValue('AI1', '订购价格')
  451 + ->setCellValue('AJ1', '礼物选择')
  452 + ->setCellValue('AK1', '加赠礼物')
  453 + ->setCellValue('AL1', '加赠礼物名称')
  454 + ->setCellValue('AM1', '是否适龄')
  455 + ->setCellValue('AN1', '不适龄备注')
  456 + ->setCellValue('AO1', '图片')
  457 + ->setCellValue('AP1', '月龄版升级年份')
  458 + ->setCellValue('AQ1', '备注')
  459 + ->setCellValue('AR1', '客户编号');
452 460
453 $i = 2; 461 $i = 2;
454 462
@@ -462,6 +470,13 @@ class OrderController extends AdminBaseController @@ -462,6 +470,13 @@ class OrderController extends AdminBaseController
462 if($v['is_stop'] == 1) { 470 if($v['is_stop'] == 1) {
463 $is_stop = '已停止'; 471 $is_stop = '已停止';
464 } 472 }
  473 + $pay_type = '';
  474 + if($v['pay_type'] == 1) {
  475 + $pay_type = '微信';
  476 + }
  477 + if($v['pay_type'] == 2) {
  478 + $pay_type = '支付宝';
  479 + }
465 $objPHPExcel->setActiveSheetIndex(0) 480 $objPHPExcel->setActiveSheetIndex(0)
466 ->setCellValue('A' . $i, $v['id']) 481 ->setCellValue('A' . $i, $v['id'])
467 ->setCellValueExplicit('B' . $i, $v['order_sn'],\PHPExcel_Cell_DataType::TYPE_STRING) 482 ->setCellValueExplicit('B' . $i, $v['order_sn'],\PHPExcel_Cell_DataType::TYPE_STRING)
@@ -470,9 +485,10 @@ class OrderController extends AdminBaseController @@ -470,9 +485,10 @@ class OrderController extends AdminBaseController
470 ->setCellValue('D' . $i, $v['user_login']) 485 ->setCellValue('D' . $i, $v['user_login'])
471 ->setCellValue('E' . $i, $v['number']) 486 ->setCellValue('E' . $i, $v['number'])
472 ->setCellValue('F' . $i, $status) 487 ->setCellValue('F' . $i, $status)
473 - ->setCellValue('G' . $i, $is_stop)  
474 - ->setCellValue('H' . $i, date('Y-m-d H:i',$v['create_time']))  
475 - ->setCellValue('I' . $i, date('Y-m-d H:i',$v['over_time'])); 488 + ->setCellValue('G' . $i, $pay_type)
  489 + ->setCellValue('H' . $i, $is_stop)
  490 + ->setCellValue('I' . $i, date('Y-m-d H:i',$v['create_time']))
  491 + ->setCellValue('J' . $i, date('Y-m-d H:i',$v['over_time']));
476 $v['options'] = json_decode($v['options'],true); 492 $v['options'] = json_decode($v['options'],true);
477 foreach ($v['options'] as $ks=>$vs) { 493 foreach ($v['options'] as $ks=>$vs) {
478 $where = [ 494 $where = [
@@ -242,4 +242,91 @@ class OrderOptionController extends AdminBaseController @@ -242,4 +242,91 @@ class OrderOptionController extends AdminBaseController
242 $this->success('成功','',explode(',',$values)); 242 $this->success('成功','',explode(',',$values));
243 } 243 }
244 } 244 }
  245 +
  246 + /**
  247 + * 字段数据导出
  248 + * @adminMenu(
  249 + * 'name' => '字段数据导出',
  250 + * 'parent' => 'index',
  251 + * 'display'=> false,
  252 + * 'hasView'=> false,
  253 + * 'order' => 6,
  254 + * 'icon' => '',
  255 + * 'remark' => '字段数据导出',
  256 + * 'param' => ''
  257 + * )
  258 + */
  259 + public function excel()
  260 + {
  261 + $param = $this->request->param();
  262 + // 进行查询条件的处理
  263 + $where = [
  264 + 'delete_time'=>0
  265 + ];
  266 + if(isset($param['keyword'])) {
  267 + $where['name|values'] = ['like','%'.$param['keyword'].'%'];
  268 + }
  269 + if(!empty($param['sort'])) {
  270 + $where['sort'] = $param['sort'];
  271 + }
  272 + // 查询数据并导出
  273 + $list = $this->singleData($this->table,$where,1,['create_time'=>'DESC']);
  274 + $this->expList($list);
  275 + }
  276 +
  277 + // 数据导出
  278 + private function expList($array)
  279 + {
  280 + //导出Excel
  281 + $objPHPExcel = new \PHPExcel();
  282 +
  283 + // 设置单元格宽度
  284 + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
  285 + $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
  286 + $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
  287 + $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
  288 + $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
  289 + $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
  290 + // 设置水平居中
  291 + $objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  292 + // 设置垂直居中
  293 + $objPHPExcel->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
  294 + //Add some data
  295 + $objPHPExcel->setActiveSheetIndex(0)
  296 + ->setCellValue('A1', 'ID')
  297 + ->setCellValue('B1', '字段名称')
  298 + ->setCellValue('C1', '字段类型')
  299 + ->setCellValue('D1', '取值范围')
  300 + ->setCellValue('E1', '用户是否可见')
  301 + ->setCellValue('F1', '更新时间')
  302 + ->setCellValue('G1', '发布时间');
  303 +
  304 + $i = 2;
  305 +
  306 + // 循环到导出数据
  307 + foreach ($array as $v) {
  308 + $is_show = '否';
  309 + if($v['is_show'] == 1) {
  310 + $is_show = '是';
  311 + }
  312 + $objPHPExcel->setActiveSheetIndex(0)
  313 + ->setCellValue('A' . $i, $v['id'])
  314 + ->setCellValue('B' . $i, $v['name'])
  315 + ->setCellValue('C' . $i, $this->type[$v['sort']])
  316 + ->setCellValue('D' . $i, $v['values'])
  317 + ->setCellValue('E' . $i, $is_show)
  318 + ->setCellValue('F' . $i, date('Y-m-d H:i',$v['update_time']))
  319 + ->setCellValue('G' . $i, date('Y-m-d H:i',$v['create_time']));
  320 + $i++;
  321 + }
  322 +
  323 + $filename = '字段数据导出'. date('Y-m-d').'.xls';
  324 + ob_end_clean();
  325 + header("Content-type:application/vnd.ms-excel;charset=UTF-8");
  326 + header('Content-Type: application/vnd.ms-excel');
  327 + header('Content-Disposition: attachment;filename="' . $filename . '"');
  328 + header('Cache-Control: max-age=0');
  329 + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  330 + $objWriter->save('php://output');
  331 + }
245 } 332 }
@@ -245,7 +245,7 @@ class OrderController extends HomeBaseController @@ -245,7 +245,7 @@ class OrderController extends HomeBaseController
245 $orderInfo['options'] = json_decode($orderInfo['options'],true); 245 $orderInfo['options'] = json_decode($orderInfo['options'],true);
246 $order_price = 0; 246 $order_price = 0;
247 foreach ($orderInfo['options'] as $k=>$v) { 247 foreach ($orderInfo['options'] as $k=>$v) {
248 - if($v['id'] == 25) { 248 + if($v['id'] == 64) {
249 $order_price = $v['user_choose']; 249 $order_price = $v['user_choose'];
250 } 250 }
251 } 251 }
@@ -30,6 +30,12 @@ @@ -30,6 +30,12 @@
30 <option value="0" <eq name="is_over" value="0">selected</eq>>否</option> 30 <option value="0" <eq name="is_over" value="0">selected</eq>>否</option>
31 <option value="1" <eq name="is_over" value="1">selected</eq>>是</option> 31 <option value="1" <eq name="is_over" value="1">selected</eq>>是</option>
32 </select>&nbsp; &nbsp; 32 </select>&nbsp; &nbsp;
  33 + 支付类型:
  34 + <select class="form-control" name="pay_type" style="width: 140px;">
  35 + <option value="0">请选择</option>
  36 + <option value="1" <eq name="pay_type" value="0">selected</eq>>微信</option>
  37 + <option value="2" <eq name="pay_type" value="1">selected</eq>>支付宝</option>
  38 + </select>&nbsp; &nbsp;
33 导出状态: 39 导出状态:
34 <select class="form-control" name="is_excel" style="width: 140px;"> 40 <select class="form-control" name="is_excel" style="width: 140px;">
35 <option value="-1">请选择</option> 41 <option value="-1">请选择</option>
@@ -146,6 +152,7 @@ @@ -146,6 +152,7 @@
146 var url2 = url1.split('.',5); 152 var url2 = url1.split('.',5);
147 var sort_id = $('select[name=sort_id]').val(); 153 var sort_id = $('select[name=sort_id]').val();
148 var status = $('select[name=status]').val(); 154 var status = $('select[name=status]').val();
  155 + var pay_type = $('select[name=pay_type]').val();
149 var is_over = $('select[name=is_over]').val(); 156 var is_over = $('select[name=is_over]').val();
150 var is_excel = $('select[name=is_excel]').val(); 157 var is_excel = $('select[name=is_excel]').val();
151 var keyword = $('input[name=keyword]').val(); 158 var keyword = $('input[name=keyword]').val();
@@ -169,6 +176,9 @@ @@ -169,6 +176,9 @@
169 if(status.length > 0) { 176 if(status.length > 0) {
170 param += '/status/'+status; 177 param += '/status/'+status;
171 } 178 }
  179 + if(pay_type.length > 0) {
  180 + param += '/pay_type/'+pay_type;
  181 + }
172 if(is_over.length > 0) { 182 if(is_over.length > 0) {
173 param += '/is_over/'+is_over; 183 param += '/is_over/'+is_over;
174 } 184 }
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <div class="wrap js-check-wrap"> 4 <div class="wrap js-check-wrap">
5 <ul class="nav nav-tabs"> 5 <ul class="nav nav-tabs">
6 <li class="active"><a href="javascript:;">所有字段</a></li> 6 <li class="active"><a href="javascript:;">所有字段</a></li>
7 - <li><a href="{:url('OrderOption/add')}">添加字段</a></li> 7 + <!--<li><a href="{:url('OrderOption/add')}">添加字段</a></li>-->
8 </ul> 8 </ul>
9 <form class="well form-inline margin-top-20" method="post" action="{:url('OrderOption/index')}"> 9 <form class="well form-inline margin-top-20" method="post" action="{:url('OrderOption/index')}">
10 字段类型: 10 字段类型:
@@ -19,14 +19,15 @@ @@ -19,14 +19,15 @@
19 value="{$keyword|default=''}" placeholder="请输入关键字..."> 19 value="{$keyword|default=''}" placeholder="请输入关键字...">
20 <input type="submit" class="btn btn-primary" value="搜索"/> 20 <input type="submit" class="btn btn-primary" value="搜索"/>
21 <a class="btn btn-danger" href="{:url('OrderOption/index')}">清空</a> 21 <a class="btn btn-danger" href="{:url('OrderOption/index')}">清空</a>
  22 + <input type="button" class="btn btn-primary" id="excel" value="导出"/>
22 </form> 23 </form>
23 <form class="js-ajax-form" action="" method="post"> 24 <form class="js-ajax-form" action="" method="post">
24 - <div class="table-actions">  
25 - <button class="btn btn-danger btn-sm js-ajax-submit" type="submit"  
26 - data-action="{:url('OrderOption/delete')}" data-subcheck="true" data-msg="您确定删除吗?">  
27 - {:lang('DELETE')}  
28 - </button>  
29 - </div> 25 + <!--<div class="table-actions">-->
  26 + <!--<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"-->
  27 + <!--data-action="{:url('OrderOption/delete')}" data-subcheck="true" data-msg="您确定删除吗?">-->
  28 + <!--{:lang('DELETE')}-->
  29 + <!--</button>-->
  30 + <!--</div>-->
30 <table class="table table-hover table-bordered table-list"> 31 <table class="table table-hover table-bordered table-list">
31 <thead> 32 <thead>
32 <tr> 33 <tr>
@@ -63,7 +64,7 @@ @@ -63,7 +64,7 @@
63 <td>{:date('Y-m-d H:i',$vo.update_time)}</td> 64 <td>{:date('Y-m-d H:i',$vo.update_time)}</td>
64 <td> 65 <td>
65 <a href="{:url('OrderOption/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a> 66 <a href="{:url('OrderOption/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a>
66 - <a href="{:url('OrderOption/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a> 67 + <!--<a href="{:url('OrderOption/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a>-->
67 </td> 68 </td>
68 </tr> 69 </tr>
69 </foreach> 70 </foreach>
@@ -82,17 +83,43 @@ @@ -82,17 +83,43 @@
82 </tr> 83 </tr>
83 </tfoot> 84 </tfoot>
84 </table> 85 </table>
85 - <div class="table-actions">  
86 - <button class="btn btn-danger btn-sm js-ajax-submit" type="submit"  
87 - data-action="{:url('OrderOption/delete')}" data-subcheck="true" data-msg="您确定删除吗?">  
88 - {:lang('DELETE')}  
89 - </button>  
90 - </div> 86 + <!--<div class="table-actions">-->
  87 + <!--<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"-->
  88 + <!--data-action="{:url('OrderOption/delete')}" data-subcheck="true" data-msg="您确定删除吗?">-->
  89 + <!--{:lang('DELETE')}-->
  90 + <!--</button>-->
  91 + <!--</div>-->
91 <ul class="pagination">{$page|default=''}</ul> 92 <ul class="pagination">{$page|default=''}</ul>
92 </form> 93 </form>
93 </div> 94 </div>
94 <script src="__STATIC__/js/admin.js"></script> 95 <script src="__STATIC__/js/admin.js"></script>
95 <script> 96 <script>
  97 + $('#excel').click(function () {
  98 + var url1 = "{:url('OrderOption/excel')}";
  99 + var url2 = url1.split('.',5);
  100 + var sort = $('select[name=sort]').val();
  101 + var keyword = $('input[name=keyword]').val();
  102 + var param = '/excel/1';
  103 + var ids = [];
  104 + $('.js-check').each(function(index,element) {
  105 + if($(this).prop('checked') == true) {
  106 + ids.push($(this).val());
  107 + }
  108 + });
  109 + console.log(ids);
  110 + if(ids.length>0) {
  111 + ids = ids.join(',');
  112 + param += '/ids/' + ids;
  113 + }
  114 + if(sort.length > 0) {
  115 + param += '/sort/'+sort;
  116 + }
  117 + if(keyword.length > 0) {
  118 + param += '/keyword/'+keyword;
  119 + }
  120 + var url = url2[0]+param+'.html';
  121 + window.open(url);
  122 + });
96 function reloadPage(win) { 123 function reloadPage(win) {
97 win.location.reload(); 124 win.location.reload();
98 } 125 }