作者 李宇航

合并分支 'master-server' 到 'master'

gx创建作者



查看合并请求 !1200
@@ -41,8 +41,8 @@ class DownloadProject extends Command @@ -41,8 +41,8 @@ class DownloadProject extends Command
41 protected $description = '导出项目数据'; 41 protected $description = '导出项目数据';
42 42
43 public function handle(){ 43 public function handle(){
44 - ProjectServer::useProject(1646);  
45 - $data = $this->downloadItem(); 44 + ProjectServer::useProject(1225);
  45 + $data = $this->downloadProduct();
46 DB::disconnect('custom_mysql'); 46 DB::disconnect('custom_mysql');
47 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 47 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
48 return $this->exportData($data); 48 return $this->exportData($data);
@@ -52,7 +52,7 @@ class DownloadProject extends Command @@ -52,7 +52,7 @@ class DownloadProject extends Command
52 { 52 {
53 $product = new Product(); 53 $product = new Product();
54 $filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content', 54 $filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content',
55 - 'category_id', 'status']; 55 + 'category_id', 'status','seo_mate'];
56 $this->order = 'sort'; 56 $this->order = 'sort';
57 $lists = $product->list(['status'=>1],'id',$filed); 57 $lists = $product->list(['status'=>1],'id',$filed);
58 if(!empty($lists)){ 58 if(!empty($lists)){
@@ -108,25 +108,62 @@ class DownloadProject extends Command @@ -108,25 +108,62 @@ class DownloadProject extends Command
108 } 108 }
109 return $data; 109 return $data;
110 } 110 }
  111 +// public function exportData($data){
  112 +// // 创建一个新的 Excel 电子表格实例
  113 +// $spreadsheet = new Spreadsheet();
  114 +// $sheet = $spreadsheet->getActiveSheet();
  115 +// // 添加表头
  116 +// $sheet->setCellValue('A1', '浏览时间');
  117 +// $sheet->setCellValue('B1', '访客来源');
  118 +// $sheet->setCellValue('C1', '访客入路页面');
  119 +// $sheet->setCellValue('D1', '终端');
  120 +// $sheet->setCellValue('E1', '国家ip');
  121 +// $sheet->setCellValue('F1', '深度访问页数');
  122 +// $rowCount = 2;
  123 +// foreach ($data as $v) {
  124 +// $sheet->setCellValue('A' . $rowCount, $v['created_at']);
  125 +// $sheet->setCellValue('B' . $rowCount, $v['referrer_url']);
  126 +// $sheet->setCellValue('C' . $rowCount, $v['url']);
  127 +// $sheet->setCellValue('D' . $rowCount, $v['device_text']);
  128 +// $sheet->setCellValue('E' . $rowCount, $v['ip']);
  129 +// $sheet->setCellValue('F' . $rowCount, $v['depth']);
  130 +// $rowCount++;
  131 +// }
  132 +// // 创建一个新的 Excel Writer 对象
  133 +// $writer = new Xlsx($spreadsheet);
  134 +// $filename = time().'.xlsx';
  135 +// // 设置导出文件的保存路径和文件名
  136 +// $filePath = public_path('upload/excel/'.$filename);
  137 +// // 导出 Excel 文件
  138 +// $writer->save($filePath);
  139 +// echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL;
  140 +// // 返回导出文件的响应
  141 +// return ['file_link'=>url('upload/excel/'.$filename)];
  142 +// }
  143 +
111 public function exportData($data){ 144 public function exportData($data){
112 // 创建一个新的 Excel 电子表格实例 145 // 创建一个新的 Excel 电子表格实例
113 $spreadsheet = new Spreadsheet(); 146 $spreadsheet = new Spreadsheet();
114 $sheet = $spreadsheet->getActiveSheet(); 147 $sheet = $spreadsheet->getActiveSheet();
115 // 添加表头 148 // 添加表头
116 - $sheet->setCellValue('A1', '浏览时间');  
117 - $sheet->setCellValue('B1', '访客来源');  
118 - $sheet->setCellValue('C1', '访客入路页面');  
119 - $sheet->setCellValue('D1', '终端');  
120 - $sheet->setCellValue('E1', '国家ip');  
121 - $sheet->setCellValue('F1', '深度访问页数'); 149 + $sheet->setCellValue('A1', '产品名称');
  150 + $sheet->setCellValue('B1', '产品短描述');
  151 + $sheet->setCellValue('C1', '产品内容');
  152 + $sheet->setCellValue('D1', '产品路由');
  153 + $sheet->setCellValue('E1', '产品分类');
  154 + $sheet->setCellValue('F1', '产品状态');
  155 + $sheet->setCellValue('G1', '产品主图');
  156 + $sheet->setCellValue('H1', '产品TDK');
122 $rowCount = 2; 157 $rowCount = 2;
123 foreach ($data as $v) { 158 foreach ($data as $v) {
124 - $sheet->setCellValue('A' . $rowCount, $v['created_at']);  
125 - $sheet->setCellValue('B' . $rowCount, $v['referrer_url']);  
126 - $sheet->setCellValue('C' . $rowCount, $v['url']);  
127 - $sheet->setCellValue('D' . $rowCount, $v['device_text']);  
128 - $sheet->setCellValue('E' . $rowCount, $v['ip']);  
129 - $sheet->setCellValue('F' . $rowCount, $v['depth']); 159 + $sheet->setCellValue('A' . $rowCount, $v['title']);
  160 + $sheet->setCellValue('B' . $rowCount, $v['intro']);
  161 + $sheet->setCellValue('C' . $rowCount, $v['content']);
  162 + $sheet->setCellValue('D' . $rowCount, $v['url']);
  163 + $sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
  164 + $sheet->setCellValue('F' . $rowCount, '发布中');
  165 + $sheet->setCellValue('G' . $rowCount, $v['images']);
  166 + $sheet->setCellValue('H' . $rowCount, $v['seo_mate']);
130 $rowCount++; 167 $rowCount++;
131 } 168 }
132 // 创建一个新的 Excel Writer 对象 169 // 创建一个新的 Excel Writer 对象
@@ -141,26 +178,26 @@ class DownloadProject extends Command @@ -141,26 +178,26 @@ class DownloadProject extends Command
141 return ['file_link'=>url('upload/excel/'.$filename)]; 178 return ['file_link'=>url('upload/excel/'.$filename)];
142 } 179 }
143 180
144 - public function downloadItem($filed = ['id','depth','created_at','referrer_url','url','device_port','country','ip']){  
145 - $visitModel = new Visit();  
146 - $page = 1;  
147 - $pageSize = 3000;  
148 - $lists = $visitModel->lists(['updated_date'=>['between',['2025-02-01','2025-02-31']]],$page,$pageSize,'id',$filed);  
149 - foreach ($lists as $v){  
150 - $customer_visit_id[] = $v['id'];  
151 - }  
152 - $itemModel = new VisitItem();  
153 - $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']);  
154 - foreach ($lists as $key => $value){  
155 - $sub = [];  
156 - foreach ($itemList as $sonValue){  
157 - if($value['id'] == $sonValue['customer_visit_id']){  
158 - $sub[] = $sonValue;  
159 - }  
160 - }  
161 - $value['sub'] = $sub;  
162 - $lists[$key] = $value;  
163 - }  
164 - return $lists;  
165 - } 181 +// public function downloadItem($filed = ['id','depth','created_at','referrer_url','url','device_port','country','ip']){
  182 +// $visitModel = new Visit();
  183 +// $page = 1;
  184 +// $pageSize = 3000;
  185 +// $lists = $visitModel->lists(['updated_date'=>['between',['2025-02-01','2025-02-31']]],$page,$pageSize,'id',$filed);
  186 +// foreach ($lists as $v){
  187 +// $customer_visit_id[] = $v['id'];
  188 +// }
  189 +// $itemModel = new VisitItem();
  190 +// $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']);
  191 +// foreach ($lists as $key => $value){
  192 +// $sub = [];
  193 +// foreach ($itemList as $sonValue){
  194 +// if($value['id'] == $sonValue['customer_visit_id']){
  195 +// $sub[] = $sonValue;
  196 +// }
  197 +// }
  198 +// $value['sub'] = $sub;
  199 +// $lists[$key] = $value;
  200 +// }
  201 +// return $lists;
  202 +// }
166 } 203 }