|
@@ -162,68 +162,51 @@ class DownloadProject extends Command |
|
@@ -162,68 +162,51 @@ class DownloadProject extends Command |
|
162
|
return ['file_link'=>url('upload/excel/'.$filename)];
|
162
|
return ['file_link'=>url('upload/excel/'.$filename)];
|
|
163
|
}
|
163
|
}
|
|
164
|
|
164
|
|
|
165
|
-// public function exportData($data){
|
|
|
|
166
|
-// // 创建一个新的 Excel 电子表格实例
|
|
|
|
167
|
-// $spreadsheet = new Spreadsheet();
|
|
|
|
168
|
-// $sheet = $spreadsheet->getActiveSheet();
|
|
|
|
169
|
-// // 添加表头
|
|
|
|
170
|
-// $sheet->setCellValue('A1', '产品名称');
|
|
|
|
171
|
-//// $sheet->setCellValue('B1', '产品短描述');
|
|
|
|
172
|
-//// $sheet->setCellValue('C1', '产品内容');
|
|
|
|
173
|
-//// $sheet->setCellValue('D1', '产品路由');
|
|
|
|
174
|
-//// $sheet->setCellValue('E1', '产品分类');
|
|
|
|
175
|
-//// $sheet->setCellValue('F1', '产品状态');
|
|
|
|
176
|
-//// $sheet->setCellValue('G1', '产品主图');
|
|
|
|
177
|
-//// $sheet->setCellValue('H1', '产品seo_title');
|
|
|
|
178
|
-//// $sheet->setCellValue('I1', '产品seo_keyword');
|
|
|
|
179
|
-//// $sheet->setCellValue('J1', '产品seo_title');
|
|
|
|
180
|
-// $rowCount = 2;
|
|
|
|
181
|
-// foreach ($data as $v) {
|
|
|
|
182
|
-// $sheet->setCellValue('A' . $rowCount, $v['title']);
|
|
|
|
183
|
-//// $sheet->setCellValue('B' . $rowCount, $v['intro']);
|
|
|
|
184
|
-//// $sheet->setCellValue('C' . $rowCount, $v['content']);
|
|
|
|
185
|
-//// $sheet->setCellValue('D' . $rowCount, $v['url']);
|
|
|
|
186
|
-//// $sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
|
|
|
|
187
|
-//// $sheet->setCellValue('F' . $rowCount, '发布中');
|
|
|
|
188
|
-//// $sheet->setCellValue('G' . $rowCount, $v['images']);
|
|
|
|
189
|
-//// $sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']);
|
|
|
|
190
|
-//// $sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']);
|
|
|
|
191
|
-//// $sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']);
|
|
|
|
192
|
-// $rowCount++;
|
|
|
|
193
|
-// }
|
|
|
|
194
|
-// // 创建一个新的 Excel Writer 对象
|
|
|
|
195
|
-// $writer = new Xlsx($spreadsheet);
|
|
|
|
196
|
-// $filename = time().'.xlsx';
|
|
|
|
197
|
-// // 设置导出文件的保存路径和文件名
|
|
|
|
198
|
-// $filePath = public_path('upload/excel/'.$filename);
|
|
|
|
199
|
-// // 导出 Excel 文件
|
|
|
|
200
|
-// $writer->save($filePath);
|
|
|
|
201
|
-// echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL;
|
|
|
|
202
|
-// // 返回导出文件的响应
|
|
|
|
203
|
-// return ['file_link'=>url('upload/excel/'.$filename)];
|
|
|
|
204
|
-// }
|
|
|
|
205
|
-//
|
|
|
|
206
|
-// public function downloadItem($filed = ['id','depth','created_at','referrer_url','url','device_port','country','ip']){
|
|
|
|
207
|
-// $visitModel = new Visit();
|
|
|
|
208
|
-// $page = 1;
|
|
|
|
209
|
-// $pageSize = 3000;
|
|
|
|
210
|
-// $lists = $visitModel->lists(['updated_date'=>['between',['2025-02-01','2025-02-31']]],$page,$pageSize,'id',$filed);
|
|
|
|
211
|
-// foreach ($lists as $v){
|
|
|
|
212
|
-// $customer_visit_id[] = $v['id'];
|
|
|
|
213
|
-// }
|
|
|
|
214
|
-// $itemModel = new VisitItem();
|
|
|
|
215
|
-// $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']);
|
|
|
|
216
|
-// foreach ($lists as $key => $value){
|
|
|
|
217
|
-// $sub = [];
|
|
|
|
218
|
-// foreach ($itemList as $sonValue){
|
|
|
|
219
|
-// if($value['id'] == $sonValue['customer_visit_id']){
|
|
|
|
220
|
-// $sub[] = $sonValue;
|
|
|
|
221
|
-// }
|
|
|
|
222
|
-// }
|
|
|
|
223
|
-// $value['sub'] = $sub;
|
|
|
|
224
|
-// $lists[$key] = $value;
|
|
|
|
225
|
-// }
|
|
|
|
226
|
-// return $lists;
|
|
|
|
227
|
-// }
|
|
|
|
228
|
-
|
165
|
+ /**
|
|
|
|
166
|
+ * @remark :导入产品
|
|
|
|
167
|
+ * @name :exportProductData
|
|
|
|
168
|
+ * @author :lyh
|
|
|
|
169
|
+ * @method :post
|
|
|
|
170
|
+ * @time :2025/6/30 16:46
|
|
|
|
171
|
+ */
|
|
|
|
172
|
+ public function exportProductData($data){
|
|
|
|
173
|
+ // 创建一个新的 Excel 电子表格实例
|
|
|
|
174
|
+ $spreadsheet = new Spreadsheet();
|
|
|
|
175
|
+ $sheet = $spreadsheet->getActiveSheet();
|
|
|
|
176
|
+ // 添加表头
|
|
|
|
177
|
+ $sheet->setCellValue('A1', '产品名称');
|
|
|
|
178
|
+ $sheet->setCellValue('B1', '产品短描述');
|
|
|
|
179
|
+ $sheet->setCellValue('C1', '产品内容');
|
|
|
|
180
|
+ $sheet->setCellValue('D1', '产品路由');
|
|
|
|
181
|
+ $sheet->setCellValue('E1', '产品分类');
|
|
|
|
182
|
+ $sheet->setCellValue('F1', '产品状态');
|
|
|
|
183
|
+ $sheet->setCellValue('G1', '产品主图');
|
|
|
|
184
|
+ $sheet->setCellValue('H1', '产品seo_title');
|
|
|
|
185
|
+ $sheet->setCellValue('I1', '产品seo_keyword');
|
|
|
|
186
|
+ $sheet->setCellValue('J1', '产品seo_title');
|
|
|
|
187
|
+ $rowCount = 2;
|
|
|
|
188
|
+ foreach ($data as $v) {
|
|
|
|
189
|
+ $sheet->setCellValue('A' . $rowCount, $v['title']);
|
|
|
|
190
|
+ $sheet->setCellValue('B' . $rowCount, $v['intro']);
|
|
|
|
191
|
+ $sheet->setCellValue('C' . $rowCount, $v['content']);
|
|
|
|
192
|
+ $sheet->setCellValue('D' . $rowCount, $v['url']);
|
|
|
|
193
|
+ $sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
|
|
|
|
194
|
+ $sheet->setCellValue('F' . $rowCount, '发布中');
|
|
|
|
195
|
+ $sheet->setCellValue('G' . $rowCount, $v['images']);
|
|
|
|
196
|
+ $sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']);
|
|
|
|
197
|
+ $sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']);
|
|
|
|
198
|
+ $sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']);
|
|
|
|
199
|
+ $rowCount++;
|
|
|
|
200
|
+ }
|
|
|
|
201
|
+ // 创建一个新的 Excel Writer 对象
|
|
|
|
202
|
+ $writer = new Xlsx($spreadsheet);
|
|
|
|
203
|
+ $filename = time().'.xlsx';
|
|
|
|
204
|
+ // 设置导出文件的保存路径和文件名
|
|
|
|
205
|
+ $filePath = public_path('upload/excel/'.$filename);
|
|
|
|
206
|
+ // 导出 Excel 文件
|
|
|
|
207
|
+ $writer->save($filePath);
|
|
|
|
208
|
+ echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL;
|
|
|
|
209
|
+ // 返回导出文件的响应
|
|
|
|
210
|
+ return ['file_link'=>url('upload/excel/'.$filename)];
|
|
|
|
211
|
+ }
|
|
229
|
} |
212
|
} |