作者 李宇航

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

gx创建作者



查看合并请求 !1198
@@ -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;
@@ -39,8 +41,8 @@ class DownloadProject extends Command @@ -39,8 +41,8 @@ class DownloadProject extends Command
39 protected $description = '导出项目数据'; 41 protected $description = '导出项目数据';
40 42
41 public function handle(){ 43 public function handle(){
42 - ProjectServer::useProject(1225);  
43 - $data = $this->downloadProduct(); 44 + ProjectServer::useProject(1646);
  45 + $data = $this->downloadItem();
44 DB::disconnect('custom_mysql'); 46 DB::disconnect('custom_mysql');
45 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 47 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
46 return $this->exportData($data); 48 return $this->exportData($data);
@@ -111,22 +113,20 @@ class DownloadProject extends Command @@ -111,22 +113,20 @@ class DownloadProject extends Command
111 $spreadsheet = new Spreadsheet(); 113 $spreadsheet = new Spreadsheet();
112 $sheet = $spreadsheet->getActiveSheet(); 114 $sheet = $spreadsheet->getActiveSheet();
113 // 添加表头 115 // 添加表头
114 - $sheet->setCellValue('A1', '产品名称');  
115 - $sheet->setCellValue('B1', '产品短描述');  
116 - $sheet->setCellValue('C1', '产品内容');  
117 - $sheet->setCellValue('D1', '产品路由');  
118 - $sheet->setCellValue('E1', '产品分类');  
119 - $sheet->setCellValue('F1', '产品状态');  
120 - $sheet->setCellValue('G1', '产品主图'); 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', '深度访问页数');
121 $rowCount = 2; 122 $rowCount = 2;
122 foreach ($data as $v) { 123 foreach ($data as $v) {
123 - $sheet->setCellValue('A' . $rowCount, $v['title']);  
124 - $sheet->setCellValue('B' . $rowCount, $v['intro']);  
125 - $sheet->setCellValue('C' . $rowCount, $v['content']);  
126 - $sheet->setCellValue('D' . $rowCount, $v['url']);  
127 - $sheet->setCellValue('E' . $rowCount, $v['category_id_text']);  
128 - $sheet->setCellValue('F' . $rowCount, '发布中');  
129 - $sheet->setCellValue('G' . $rowCount, $v['images']); 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++; 130 $rowCount++;
131 } 131 }
132 // 创建一个新的 Excel Writer 对象 132 // 创建一个新的 Excel Writer 对象
@@ -140,4 +140,25 @@ class DownloadProject extends Command @@ -140,4 +140,25 @@ class DownloadProject extends Command
140 // 返回导出文件的响应 140 // 返回导出文件的响应
141 return ['file_link'=>url('upload/excel/'.$filename)]; 141 return ['file_link'=>url('upload/excel/'.$filename)];
142 } 142 }
  143 +
  144 + public function downloadItem($filed = ['id','depth','created_at','referrer_url','url','device_port','country','ip']){
  145 + $visitModel = new Visit();
  146 + $lists = $visitModel->list(['updated_date'=>['between',['025-02-01','2025-02-31']]]);
  147 + foreach ($lists as $v){
  148 + $customer_visit_id[] = $v['id'];
  149 + }
  150 + $itemModel = new VisitItem();
  151 + $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']);
  152 + foreach ($lists as $key => $value){
  153 + $sub = [];
  154 + foreach ($itemList as $sonValue){
  155 + if($value['id'] == $sonValue['customer_visit_id']){
  156 + $sub[] = $sonValue;
  157 + }
  158 + }
  159 + $value['sub'] = $sub;
  160 + $lists[$key] = $value;
  161 + }
  162 + return $this->success($lists);
  163 + }
143 } 164 }