'ID', 'value'=>function($model){ return $model['id']; }, ], [ 'name'=>'来源渠道', 'value'=>function($model){ return $model['s_id']; }, ], [ 'name'=>'产品编码', 'value'=>function($model){ return $model['mobile']?$model['mobile']['product_no']:''; }, ], [ 'name'=>'商品信息', 'value'=>function($model){ if($model['type']==1) { return $model['no']; }else{ return $model['info']['mobile']['name']; } }, ], [ 'name'=>'订单号', 'value'=>function($model){ return $model['order_no']; }, ], [ 'name'=>'姓名', 'value'=>function($model){ return $model['name']; }, ], [ 'name'=>'收货地址', 'value'=>function($model){ return $model['address']; }, ], [ 'name'=>'联系电话', 'value'=>function($model){ return $model['phone']; }, ], [ 'name'=>'身份证号码', 'value'=>function($model){ return $model['id_no']; }, ], /*[ 'name'=>'地区', 'value'=>function($model){ return Area::getNameString($model['city']); }, ],*/ [ 'name'=>'证件照片', 'value'=>function($model){ return $model['open_idcard_face_img']; }, 'image'=>1, ], [ 'name'=>'下单备注', 'value'=>function($model){ return $model['remark']; }, ], [ 'name'=>'下单时间', 'value'=>function($model){ return date('Y-m-d H:i:s',$model['create_time']); }, ], [ 'name'=>'供应商', 'value'=>function($model){ return $model['proxy']['nickname']??'-'; }, 'hidden'=>$admin['is_sub'], ], [ 'name'=>'底价', 'value'=>function($model){ return $model['amount_di']; }, ], [ 'name'=>'预存', 'value'=>function($model){ return $model['amount_charge']; }, ], [ 'name'=>'售价', 'value'=>function($model){ return $model['info']['mobile']['is_activity']?$model['info']['mobile']['amount_kill']:$model['amount_base']; }, ], [ 'name'=>'订单价格', 'value'=>function($model){ return $model['amount']; }, ], [ 'name'=>'付款状态', 'value'=>function($model){ // return $model['status']==0?'待付款':'已付款'; if($model['status'] == 50){ return '已关闭'; }elseif ($model['status'] == 0){ return '待付款'; }else{ return '已付款'; } }, ], [ 'name'=>'付款时间', 'value'=>function($model){ if(empty($model['pay_time'])){ return ''; } return date('Y-m-d H:i:s',$model['pay_time']); }, ], [ 'name'=>'付款方式', 'value'=>function($model){ return MobileOrder::$payTypes[$model['pay_type']]; }, ], [ 'name'=>'处理状态', 'value'=>function($model){ if($model['type']==1){ return MobileOrder::$status[$model['status']]; } return MobileOrder::flowStatus()[$model['status']]; }, ], /*[ 'name'=>'处理备注', 'value'=>function($model){ return $model['remark_sub']; }, ],*/ [ 'name'=>'快递公司', 'value'=>function($model){ return $model['trans_name']; }, ], [ 'name'=>'快递单号', 'value'=>function($model){ return $model['trans_no']; }, ], [ 'name'=>'下单域名', 'value'=>function($model){ if($model['s_id']){ return h5_link("home/{$model['s_id']}"); } return h5_link(); }, ], /*[ 'name'=>'号码归属地', 'value'=>function($model){ if(empty($model['info'])){ return ''; } return $model['info']['mobile']['province'].$model['info']['mobile']['city']; }, ],*/ /*[ 'name'=>'预存话费', 'value'=>function($model){ return $model['amount_charge']; }, ],*/ [ 'name'=>'运营商', 'value'=>function($model){ $brand = array_key_exists($model['brand'],Mobile::$flowBrand)?Mobile::$flowBrand[$model['brand']]:$model['brand']; return ($model['type']==2)?($model['brand']?$brand:''):$model['brand']; }, ], [ 'name'=>'详细介绍', 'value'=>function($model){ if(empty($model['info'])){ return ''; } return $model['info']['info']['describe']; }, ], /*[ 'name'=>'跟单员', 'value'=>function($model){ $names=[]; foreach ($model['admin'] as $admin){ $names[]=$admin['admin']['nickname']; } return implode(',',$names); }, ],*/ [ 'name'=>'主播', 'value'=>function($model){ return $model['anchor']['name']??''; }, 'hidden'=>$admin['is_sub'], ], [ 'name'=>$admin['is_sub']?'主播':'分站主播', 'value'=>function($model){ return $model['sub_anchor']['mobile_anchor']['name']??''; } ], [ 'name'=>'分站备注', 'value'=>function($model){ $arr=[]; foreach ($model['sub_remark']??[] as $remark){ $arr[]=sprintf("%s-%s:%s",$remark['create_time_format'],$remark['admin']['nickname']??'已删除',$remark['content']); } return implode(PHP_EOL,$arr); } ], [ 'name'=>'客服记录', 'value'=>function($model){ $arr=[]; foreach ($model['operation']??[] as $remark){ $arr[]=sprintf("%s-%s:%s",$remark['create_time_format'],$remark['admin']['nickname']??'已删除',$remark['content']); } return implode(PHP_EOL,$arr); } ], [ 'name'=>'敢探号结果', 'value'=>function($model){ $gantanhao = $model['gantanhao_data_notify'] && $model['status'] == 110 ? json_decode($model['gantanhao_data_notify'], true) : ''; return $gantanhao ? $gantanhao['reason'] : ''; }, ], [ 'name'=>'生产号码', 'value'=>function($model){ $gantanhao = $model['gantanhao_data_notify'] ? json_decode($model['gantanhao_data_notify'], true) : ''; return $gantanhao ? $gantanhao['plan_mobile_produced'] : ''; }, ], ]; $headers=[]; foreach ($header as $value){ if(is_callable($value['value']) && self::visible($value)){ $headers[]=$value; } } $sheet=$excel->getActiveSheet(); $headerPoint='A'; foreach ($headers as $key=>$value){ $sheet->setCellValue($cellKey=sprintf("%s%d",$headerPoint,1),$value['name']); $vk=2; foreach ($list as $_key=>$_value){ $val=$value['value']($_value); $sheet->setCellValueExplicit($cellKeyVal=sprintf("%s%d", $headerPoint, $vk), $val,DataType::TYPE_STRING); if(in_array($headerPoint,['AD','AE'])) { $sheet->getStyle($cellKeyVal)->getAlignment()->setWrapText(true); $sheet->getColumnDimension($headerPoint)->setWidth(50); } /* if(!empty($value['image'])){ $d=new Drawing(); $d->setName($value['name'])->setDescription($value['name'])->setPath($val)->setWidth(100)->setHeight(100); }else { $sheet->setCellValue(sprintf("%s%d", $row, $vk), $val); }*/ $vk++; } $headerPoint++; } $sheet->getColumnDimension('A')->setAutoSize(true); $xlsx=new Xlsx($excel); header('Content-Type: application/vnd.ms-excel;charset=UTF-8'); $xlsx->save('php://output'); return response() ->data('') ->contentType('application/vnd.ms-excel'); } protected static function visible($item){ return empty($item['hidden']) || !$item['hidden']; } }