public function export ( ) { $where = [ ] ; $user_name = $this -> request -> param ( "user_name" ) ; $status = $this -> request -> param ( "status" ) ; $user_name && $where [ 'subuser.user_name' ] = [ 'LIKE' , $user_name ] ; $status && $where [ 'feedback.status' ] = [ '=' , $status ] ; $fields = [ "subuser.user_name" , "feedback.feedback_id" , "feedback.text" , "feedback.files" , "feedback.status" , "feedback.create_time" , "feedback.reply_time" , "feedback.reply_text" , ] ; $lists = $this -> model -> alias ( "feedback" ) -> leftjoin ( "subuser subuser" , "feedback.subuser_id = subuser.subuser_id" ) -> where ( $where ) -> field ( $fields ) -> order ( 'feedback.feedback_id DESC' ) -> select ( ) -> toArray ( ) ; header ( 'Content-Type: application/vnd.ms-excel' ) ; header ( "Content-Disposition: attachment;filename=意见反馈.csv" ) ; header ( 'Cache-Control: max-age=0' ) ; $file = fopen ( 'php://output' , 'a' ) ; fprintf ( $file , chr ( 0xEF ) . chr ( 0xBB ) . chr ( 0xBF ) ) ; $arr = [ '序号' , '客户名称' , '提交人' , '意见反馈' , '创建时间' , '状态' , '回复内容' ] ; fputcsv ( $file , $arr ) ; foreach ( $lists as $k => $v ) { $k ++ ; $arr = [ $k , $v [ 'user_name' ] , $v [ 'user_name' ] , $v [ 'text' ] , $v [ 'create_time' ] , $v [ 'status_text' ] , $v [ 'reply_text' ] , ] ; fputcsv ( $file , $arr ) ; } exit ( ) ; }