|
@@ -16,6 +16,8 @@ use App\Models\Product\CategoryRelated; |
|
@@ -16,6 +16,8 @@ use App\Models\Product\CategoryRelated; |
|
16
|
use App\Models\Product\Detail;
|
16
|
use App\Models\Product\Detail;
|
|
17
|
use App\Models\Product\Product;
|
17
|
use App\Models\Product\Product;
|
|
18
|
use App\Models\RouteMap\RouteMap;
|
18
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
19
|
+use App\Models\Visit\Visit;
|
|
|
|
20
|
+use App\Models\Visit\VisitItem;
|
|
19
|
use App\Services\ProjectServer;
|
21
|
use App\Services\ProjectServer;
|
|
20
|
use Illuminate\Console\Command;
|
22
|
use Illuminate\Console\Command;
|
|
21
|
use Illuminate\Support\Facades\DB;
|
23
|
use Illuminate\Support\Facades\DB;
|
|
@@ -40,6 +42,7 @@ class DownloadProject extends Command |
|
@@ -40,6 +42,7 @@ class DownloadProject extends Command |
|
40
|
|
42
|
|
|
41
|
public function handle(){
|
43
|
public function handle(){
|
|
42
|
ProjectServer::useProject(1225);
|
44
|
ProjectServer::useProject(1225);
|
|
|
|
45
|
+ echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
|
|
43
|
$data = $this->downloadProduct();
|
46
|
$data = $this->downloadProduct();
|
|
44
|
DB::disconnect('custom_mysql');
|
47
|
DB::disconnect('custom_mysql');
|
|
45
|
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
|
48
|
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
|
|
@@ -50,12 +53,13 @@ class DownloadProject extends Command |
|
@@ -50,12 +53,13 @@ class DownloadProject extends Command |
|
50
|
{
|
53
|
{
|
|
51
|
$product = new Product();
|
54
|
$product = new Product();
|
|
52
|
$filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content',
|
55
|
$filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content',
|
|
53
|
- 'category_id', 'status'];
|
56
|
+ 'category_id', 'status','seo_mate'];
|
|
54
|
$this->order = 'sort';
|
57
|
$this->order = 'sort';
|
|
55
|
$lists = $product->list(['status'=>1],'id',$filed);
|
58
|
$lists = $product->list(['status'=>1],'id',$filed);
|
|
56
|
if(!empty($lists)){
|
59
|
if(!empty($lists)){
|
|
57
|
$cate_data = $this->getCategoryList();//分类
|
60
|
$cate_data = $this->getCategoryList();//分类
|
|
58
|
foreach ($lists as $k => $v){
|
61
|
foreach ($lists as $k => $v){
|
|
|
|
62
|
+ echo date('Y-m-d H:i:s') . '产品id:'.$v['id'] . PHP_EOL;
|
|
59
|
$v['url'] = 'https://www.autsikinta.com/' . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);
|
63
|
$v['url'] = 'https://www.autsikinta.com/' . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);
|
|
60
|
$v['category_id_text'] = $this->categoryName($v['id'],$cate_data);
|
64
|
$v['category_id_text'] = $this->categoryName($v['id'],$cate_data);
|
|
61
|
//ToDo::处理图片及文件
|
65
|
//ToDo::处理图片及文件
|
|
@@ -64,10 +68,10 @@ class DownloadProject extends Command |
|
@@ -64,10 +68,10 @@ class DownloadProject extends Command |
|
64
|
}else{
|
68
|
}else{
|
|
65
|
$v['images'] = '';
|
69
|
$v['images'] = '';
|
|
66
|
}
|
70
|
}
|
|
|
|
71
|
+ $v['seo_mate'] = json_encode($v['seo_mate']);
|
|
67
|
$lists[$k] = $v;
|
72
|
$lists[$k] = $v;
|
|
68
|
}
|
73
|
}
|
|
69
|
}
|
74
|
}
|
|
70
|
- echo date('Y-m-d H:i:s') . '数据详情$v:'. json_encode($lists) . PHP_EOL;
|
|
|
|
71
|
return $lists;
|
75
|
return $lists;
|
|
72
|
}
|
76
|
}
|
|
73
|
public function categoryName($product_id,$data){
|
77
|
public function categoryName($product_id,$data){
|
|
@@ -106,6 +110,39 @@ class DownloadProject extends Command |
|
@@ -106,6 +110,39 @@ class DownloadProject extends Command |
|
106
|
}
|
110
|
}
|
|
107
|
return $data;
|
111
|
return $data;
|
|
108
|
}
|
112
|
}
|
|
|
|
113
|
+// public function exportData($data){
|
|
|
|
114
|
+// // 创建一个新的 Excel 电子表格实例
|
|
|
|
115
|
+// $spreadsheet = new Spreadsheet();
|
|
|
|
116
|
+// $sheet = $spreadsheet->getActiveSheet();
|
|
|
|
117
|
+// // 添加表头
|
|
|
|
118
|
+// $sheet->setCellValue('A1', '浏览时间');
|
|
|
|
119
|
+// $sheet->setCellValue('B1', '访客来源');
|
|
|
|
120
|
+// $sheet->setCellValue('C1', '访客入路页面');
|
|
|
|
121
|
+// $sheet->setCellValue('D1', '终端');
|
|
|
|
122
|
+// $sheet->setCellValue('E1', '国家ip');
|
|
|
|
123
|
+// $sheet->setCellValue('F1', '深度访问页数');
|
|
|
|
124
|
+// $rowCount = 2;
|
|
|
|
125
|
+// foreach ($data as $v) {
|
|
|
|
126
|
+// $sheet->setCellValue('A' . $rowCount, $v['created_at']);
|
|
|
|
127
|
+// $sheet->setCellValue('B' . $rowCount, $v['referrer_url']);
|
|
|
|
128
|
+// $sheet->setCellValue('C' . $rowCount, $v['url']);
|
|
|
|
129
|
+// $sheet->setCellValue('D' . $rowCount, $v['device_text']);
|
|
|
|
130
|
+// $sheet->setCellValue('E' . $rowCount, $v['ip']);
|
|
|
|
131
|
+// $sheet->setCellValue('F' . $rowCount, $v['depth']);
|
|
|
|
132
|
+// $rowCount++;
|
|
|
|
133
|
+// }
|
|
|
|
134
|
+// // 创建一个新的 Excel Writer 对象
|
|
|
|
135
|
+// $writer = new Xlsx($spreadsheet);
|
|
|
|
136
|
+// $filename = time().'.xlsx';
|
|
|
|
137
|
+// // 设置导出文件的保存路径和文件名
|
|
|
|
138
|
+// $filePath = public_path('upload/excel/'.$filename);
|
|
|
|
139
|
+// // 导出 Excel 文件
|
|
|
|
140
|
+// $writer->save($filePath);
|
|
|
|
141
|
+// echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL;
|
|
|
|
142
|
+// // 返回导出文件的响应
|
|
|
|
143
|
+// return ['file_link'=>url('upload/excel/'.$filename)];
|
|
|
|
144
|
+// }
|
|
|
|
145
|
+
|
|
109
|
public function exportData($data){
|
146
|
public function exportData($data){
|
|
110
|
// 创建一个新的 Excel 电子表格实例
|
147
|
// 创建一个新的 Excel 电子表格实例
|
|
111
|
$spreadsheet = new Spreadsheet();
|
148
|
$spreadsheet = new Spreadsheet();
|
|
@@ -118,6 +155,7 @@ class DownloadProject extends Command |
|
@@ -118,6 +155,7 @@ class DownloadProject extends Command |
|
118
|
$sheet->setCellValue('E1', '产品分类');
|
155
|
$sheet->setCellValue('E1', '产品分类');
|
|
119
|
$sheet->setCellValue('F1', '产品状态');
|
156
|
$sheet->setCellValue('F1', '产品状态');
|
|
120
|
$sheet->setCellValue('G1', '产品主图');
|
157
|
$sheet->setCellValue('G1', '产品主图');
|
|
|
|
158
|
+ $sheet->setCellValue('H1', '产品TDK');
|
|
121
|
$rowCount = 2;
|
159
|
$rowCount = 2;
|
|
122
|
foreach ($data as $v) {
|
160
|
foreach ($data as $v) {
|
|
123
|
$sheet->setCellValue('A' . $rowCount, $v['title']);
|
161
|
$sheet->setCellValue('A' . $rowCount, $v['title']);
|
|
@@ -127,6 +165,7 @@ class DownloadProject extends Command |
|
@@ -127,6 +165,7 @@ class DownloadProject extends Command |
|
127
|
$sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
|
165
|
$sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
|
|
128
|
$sheet->setCellValue('F' . $rowCount, '发布中');
|
166
|
$sheet->setCellValue('F' . $rowCount, '发布中');
|
|
129
|
$sheet->setCellValue('G' . $rowCount, $v['images']);
|
167
|
$sheet->setCellValue('G' . $rowCount, $v['images']);
|
|
|
|
168
|
+ $sheet->setCellValue('H' . $rowCount, $v['seo_mate']);
|
|
130
|
$rowCount++;
|
169
|
$rowCount++;
|
|
131
|
}
|
170
|
}
|
|
132
|
// 创建一个新的 Excel Writer 对象
|
171
|
// 创建一个新的 Excel Writer 对象
|
|
@@ -140,4 +179,27 @@ class DownloadProject extends Command |
|
@@ -140,4 +179,27 @@ class DownloadProject extends Command |
|
140
|
// 返回导出文件的响应
|
179
|
// 返回导出文件的响应
|
|
141
|
return ['file_link'=>url('upload/excel/'.$filename)];
|
180
|
return ['file_link'=>url('upload/excel/'.$filename)];
|
|
142
|
}
|
181
|
}
|
|
|
|
182
|
+
|
|
|
|
183
|
+// public function downloadItem($filed = ['id','depth','created_at','referrer_url','url','device_port','country','ip']){
|
|
|
|
184
|
+// $visitModel = new Visit();
|
|
|
|
185
|
+// $page = 1;
|
|
|
|
186
|
+// $pageSize = 3000;
|
|
|
|
187
|
+// $lists = $visitModel->lists(['updated_date'=>['between',['2025-02-01','2025-02-31']]],$page,$pageSize,'id',$filed);
|
|
|
|
188
|
+// foreach ($lists as $v){
|
|
|
|
189
|
+// $customer_visit_id[] = $v['id'];
|
|
|
|
190
|
+// }
|
|
|
|
191
|
+// $itemModel = new VisitItem();
|
|
|
|
192
|
+// $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']);
|
|
|
|
193
|
+// foreach ($lists as $key => $value){
|
|
|
|
194
|
+// $sub = [];
|
|
|
|
195
|
+// foreach ($itemList as $sonValue){
|
|
|
|
196
|
+// if($value['id'] == $sonValue['customer_visit_id']){
|
|
|
|
197
|
+// $sub[] = $sonValue;
|
|
|
|
198
|
+// }
|
|
|
|
199
|
+// }
|
|
|
|
200
|
+// $value['sub'] = $sub;
|
|
|
|
201
|
+// $lists[$key] = $value;
|
|
|
|
202
|
+// }
|
|
|
|
203
|
+// return $lists;
|
|
|
|
204
|
+// }
|
|
143
|
} |
205
|
} |