合并分支 'lyh-server' 到 'master'
gx 查看合并请求 !1752
正在显示
1 个修改的文件
包含
105 行增加
和
129 行删除
| @@ -16,6 +16,7 @@ use App\Models\Product\CategoryRelated; | @@ -16,6 +16,7 @@ use App\Models\Product\CategoryRelated; | ||
| 16 | use App\Models\Product\Product; | 16 | use App\Models\Product\Product; |
| 17 | use App\Models\ProjectAssociation\ProjectAssociation; | 17 | use App\Models\ProjectAssociation\ProjectAssociation; |
| 18 | use App\Models\RouteMap\RouteMap; | 18 | use App\Models\RouteMap\RouteMap; |
| 19 | +use App\Models\Visit\VisitItem; | ||
| 19 | use App\Models\Workchat\MessagePush; | 20 | use App\Models\Workchat\MessagePush; |
| 20 | use App\Services\ProjectServer; | 21 | use App\Services\ProjectServer; |
| 21 | use Illuminate\Console\Command; | 22 | use Illuminate\Console\Command; |
| @@ -40,96 +41,112 @@ class DownloadProject extends Command | @@ -40,96 +41,112 @@ class DownloadProject extends Command | ||
| 40 | protected $description = '导出项目数据'; | 41 | protected $description = '导出项目数据'; |
| 41 | 42 | ||
| 42 | public function handle(){ | 43 | public function handle(){ |
| 43 | - $v6WeekModel = new V6WeeklyReport(); | ||
| 44 | - $lists = $v6WeekModel->list([],'id',['*'],'desc',100); | ||
| 45 | echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; | 44 | echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; |
| 46 | - foreach ($lists as $data){ | ||
| 47 | - $this->workChatMessage($data,$data['project_id']); | ||
| 48 | - } | 45 | + ProjectServer::useProject(535); |
| 46 | + $data = $this->importVisit(); | ||
| 47 | + dd($data); | ||
| 48 | + DB::disconnect('custom_mysql'); | ||
| 49 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 49 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 50 | return true; | 50 | return true; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | - public function downloadProduct() | 53 | + /** |
| 54 | + * @remark :导出明细 | ||
| 55 | + * @name :importVisit | ||
| 56 | + * @author :lyh | ||
| 57 | + * @method :post | ||
| 58 | + * @time :2025/4/8 11:34 | ||
| 59 | + */ | ||
| 60 | + public function importVisit() | ||
| 54 | { | 61 | { |
| 55 | - $product = new Product(); | ||
| 56 | -// $filed = ['id', 'project_id', 'title' ,'thumb' , 'route' ,'intro','content', | ||
| 57 | -// 'category_id', 'status','seo_mate']; | ||
| 58 | - $filed = ['id','title']; | ||
| 59 | - $this->order = 'sort'; | ||
| 60 | - $lists = $product->list(['status'=>1],'id',$filed); | ||
| 61 | - if(!empty($lists)){ | ||
| 62 | -// $cate_data = $this->getCategoryList();//分类 | ||
| 63 | - foreach ($lists as $k => $v){ | ||
| 64 | - echo date('Y-m-d H:i:s') . '产品id:'.$v['id'] . PHP_EOL; | ||
| 65 | -// $v['url'] = 'https://www.autsikinta.com/' . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']); | ||
| 66 | -// $v['category_id_text'] = $this->categoryName($v['id'],$cate_data); | ||
| 67 | -// //ToDo::处理图片及文件 | ||
| 68 | -// if(!empty($v['thumb']) && !empty($v['thumb']['url'])){ | ||
| 69 | -// $v['images'] = getImageUrl($v['thumb']['url']); | ||
| 70 | -// }else{ | ||
| 71 | -// $v['images'] = ''; | ||
| 72 | -// } | ||
| 73 | - $lists[$k] = $v; | ||
| 74 | - } | 62 | + $lists = $this->model->list(); |
| 63 | + if(!empty($lists) && !empty($lists['list'])){ | ||
| 64 | + foreach ($lists as $v){ | ||
| 65 | + $customer_visit_id[] = $v['id']; | ||
| 75 | } | 66 | } |
| 76 | - return $lists; | 67 | + $itemModel = new VisitItem(); |
| 68 | + $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']); | ||
| 69 | + foreach ($lists as $key => $value){ | ||
| 70 | + $sub = []; | ||
| 71 | + foreach ($itemList as $sonValue){ | ||
| 72 | + if($value['id'] == $sonValue['customer_visit_id']){ | ||
| 73 | + $sub[] = $sonValue; | ||
| 77 | } | 74 | } |
| 78 | - public function categoryName($product_id,$data){ | ||
| 79 | - $cateRelatedModel = new CategoryRelated(); | ||
| 80 | - $category_id = $cateRelatedModel->where('product_id',$product_id)->pluck('cate_id')->toArray(); | ||
| 81 | - $category_name = ''; | ||
| 82 | - if(!empty($category_id) && !empty($data)){ | ||
| 83 | - foreach ($category_id as $v){ | ||
| 84 | - if(isset($data[$v])){ | ||
| 85 | - $category_name .= $data[$v].','; | ||
| 86 | } | 75 | } |
| 76 | + $value['sub'] = $sub; | ||
| 77 | + $lists[$key] = $value; | ||
| 87 | } | 78 | } |
| 88 | - $category_name = trim($category_name,','); | ||
| 89 | } | 79 | } |
| 90 | - return $category_name; | 80 | + return $this->success($lists); |
| 91 | } | 81 | } |
| 82 | + | ||
| 92 | /** | 83 | /** |
| 93 | - * @remark :获取所有分类 | ||
| 94 | - * @name :getCategoryList | 84 | + * @remark :导出访问明细 |
| 85 | + * @name :exportData | ||
| 95 | * @author :lyh | 86 | * @author :lyh |
| 96 | * @method :post | 87 | * @method :post |
| 97 | - * @time :2023/9/14 13:56 | 88 | + * @time :2025/4/8 11:32 |
| 98 | */ | 89 | */ |
| 99 | - public function getCategoryList(){ | ||
| 100 | - $data = Common::get_user_cache('product_category',1225); | ||
| 101 | - if(empty($data)){ | ||
| 102 | - $categoryModel = new Category(); | ||
| 103 | - $data = []; | ||
| 104 | - $cateList = $categoryModel->list(['project_id'=>1225],['id','title']); | ||
| 105 | - if(!empty($cateList)){ | ||
| 106 | - foreach ($cateList as $value){ | ||
| 107 | - $data[$value['id']] = $value['title']; | ||
| 108 | - } | ||
| 109 | - } | ||
| 110 | - Common::set_user_cache($data,'product_category',1225); | 90 | + public function exportData($data){ |
| 91 | + // 创建一个新的 Excel 电子表格实例 | ||
| 92 | + $spreadsheet = new Spreadsheet(); | ||
| 93 | + $sheet = $spreadsheet->getActiveSheet(); | ||
| 94 | + // 添加表头 | ||
| 95 | + $sheet->setCellValue('A1', '浏览时间'); | ||
| 96 | + $sheet->setCellValue('B1', '访客来源'); | ||
| 97 | + $sheet->setCellValue('C1', '访客入路页面'); | ||
| 98 | + $sheet->setCellValue('D1', '终端'); | ||
| 99 | + $sheet->setCellValue('E1', '国家ip'); | ||
| 100 | + $sheet->setCellValue('F1', '深度访问页数'); | ||
| 101 | + $rowCount = 2; | ||
| 102 | + foreach ($data as $v) { | ||
| 103 | + $sheet->setCellValue('A' . $rowCount, $v['created_at']); | ||
| 104 | + $sheet->setCellValue('B' . $rowCount, $v['referrer_url']); | ||
| 105 | + $sheet->setCellValue('C' . $rowCount, $v['url']); | ||
| 106 | + $sheet->setCellValue('D' . $rowCount, $v['device_text']); | ||
| 107 | + $sheet->setCellValue('E' . $rowCount, $v['ip']); | ||
| 108 | + $sheet->setCellValue('F' . $rowCount, $v['depth']); | ||
| 109 | + $rowCount++; | ||
| 111 | } | 110 | } |
| 112 | - return $data; | 111 | + // 创建一个新的 Excel Writer 对象 |
| 112 | + $writer = new Xlsx($spreadsheet); | ||
| 113 | + $filename = time().'.xlsx'; | ||
| 114 | + // 设置导出文件的保存路径和文件名 | ||
| 115 | + $filePath = public_path('upload/excel/'.$filename); | ||
| 116 | + // 导出 Excel 文件 | ||
| 117 | + $writer->save($filePath); | ||
| 118 | + echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL; | ||
| 119 | + // 返回导出文件的响应 | ||
| 120 | + return ['file_link'=>url('upload/excel/'.$filename)]; | ||
| 113 | } | 121 | } |
| 122 | + | ||
| 114 | // public function exportData($data){ | 123 | // public function exportData($data){ |
| 115 | // // 创建一个新的 Excel 电子表格实例 | 124 | // // 创建一个新的 Excel 电子表格实例 |
| 116 | // $spreadsheet = new Spreadsheet(); | 125 | // $spreadsheet = new Spreadsheet(); |
| 117 | // $sheet = $spreadsheet->getActiveSheet(); | 126 | // $sheet = $spreadsheet->getActiveSheet(); |
| 118 | // // 添加表头 | 127 | // // 添加表头 |
| 119 | -// $sheet->setCellValue('A1', '浏览时间'); | ||
| 120 | -// $sheet->setCellValue('B1', '访客来源'); | ||
| 121 | -// $sheet->setCellValue('C1', '访客入路页面'); | ||
| 122 | -// $sheet->setCellValue('D1', '终端'); | ||
| 123 | -// $sheet->setCellValue('E1', '国家ip'); | ||
| 124 | -// $sheet->setCellValue('F1', '深度访问页数'); | 128 | +// $sheet->setCellValue('A1', '产品名称'); |
| 129 | +//// $sheet->setCellValue('B1', '产品短描述'); | ||
| 130 | +//// $sheet->setCellValue('C1', '产品内容'); | ||
| 131 | +//// $sheet->setCellValue('D1', '产品路由'); | ||
| 132 | +//// $sheet->setCellValue('E1', '产品分类'); | ||
| 133 | +//// $sheet->setCellValue('F1', '产品状态'); | ||
| 134 | +//// $sheet->setCellValue('G1', '产品主图'); | ||
| 135 | +//// $sheet->setCellValue('H1', '产品seo_title'); | ||
| 136 | +//// $sheet->setCellValue('I1', '产品seo_keyword'); | ||
| 137 | +//// $sheet->setCellValue('J1', '产品seo_title'); | ||
| 125 | // $rowCount = 2; | 138 | // $rowCount = 2; |
| 126 | // foreach ($data as $v) { | 139 | // foreach ($data as $v) { |
| 127 | -// $sheet->setCellValue('A' . $rowCount, $v['created_at']); | ||
| 128 | -// $sheet->setCellValue('B' . $rowCount, $v['referrer_url']); | ||
| 129 | -// $sheet->setCellValue('C' . $rowCount, $v['url']); | ||
| 130 | -// $sheet->setCellValue('D' . $rowCount, $v['device_text']); | ||
| 131 | -// $sheet->setCellValue('E' . $rowCount, $v['ip']); | ||
| 132 | -// $sheet->setCellValue('F' . $rowCount, $v['depth']); | 140 | +// $sheet->setCellValue('A' . $rowCount, $v['title']); |
| 141 | +//// $sheet->setCellValue('B' . $rowCount, $v['intro']); | ||
| 142 | +//// $sheet->setCellValue('C' . $rowCount, $v['content']); | ||
| 143 | +//// $sheet->setCellValue('D' . $rowCount, $v['url']); | ||
| 144 | +//// $sheet->setCellValue('E' . $rowCount, $v['category_id_text']); | ||
| 145 | +//// $sheet->setCellValue('F' . $rowCount, '发布中'); | ||
| 146 | +//// $sheet->setCellValue('G' . $rowCount, $v['images']); | ||
| 147 | +//// $sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']); | ||
| 148 | +//// $sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']); | ||
| 149 | +//// $sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']); | ||
| 133 | // $rowCount++; | 150 | // $rowCount++; |
| 134 | // } | 151 | // } |
| 135 | // // 创建一个新的 Excel Writer 对象 | 152 | // // 创建一个新的 Excel Writer 对象 |
| @@ -143,69 +160,28 @@ class DownloadProject extends Command | @@ -143,69 +160,28 @@ class DownloadProject extends Command | ||
| 143 | // // 返回导出文件的响应 | 160 | // // 返回导出文件的响应 |
| 144 | // return ['file_link'=>url('upload/excel/'.$filename)]; | 161 | // return ['file_link'=>url('upload/excel/'.$filename)]; |
| 145 | // } | 162 | // } |
| 146 | - | ||
| 147 | - public function exportData($data){ | ||
| 148 | - // 创建一个新的 Excel 电子表格实例 | ||
| 149 | - $spreadsheet = new Spreadsheet(); | ||
| 150 | - $sheet = $spreadsheet->getActiveSheet(); | ||
| 151 | - // 添加表头 | ||
| 152 | - $sheet->setCellValue('A1', '产品名称'); | ||
| 153 | -// $sheet->setCellValue('B1', '产品短描述'); | ||
| 154 | -// $sheet->setCellValue('C1', '产品内容'); | ||
| 155 | -// $sheet->setCellValue('D1', '产品路由'); | ||
| 156 | -// $sheet->setCellValue('E1', '产品分类'); | ||
| 157 | -// $sheet->setCellValue('F1', '产品状态'); | ||
| 158 | -// $sheet->setCellValue('G1', '产品主图'); | ||
| 159 | -// $sheet->setCellValue('H1', '产品seo_title'); | ||
| 160 | -// $sheet->setCellValue('I1', '产品seo_keyword'); | ||
| 161 | -// $sheet->setCellValue('J1', '产品seo_title'); | ||
| 162 | - $rowCount = 2; | ||
| 163 | - foreach ($data as $v) { | ||
| 164 | - $sheet->setCellValue('A' . $rowCount, $v['title']); | ||
| 165 | -// $sheet->setCellValue('B' . $rowCount, $v['intro']); | ||
| 166 | -// $sheet->setCellValue('C' . $rowCount, $v['content']); | ||
| 167 | -// $sheet->setCellValue('D' . $rowCount, $v['url']); | ||
| 168 | -// $sheet->setCellValue('E' . $rowCount, $v['category_id_text']); | ||
| 169 | -// $sheet->setCellValue('F' . $rowCount, '发布中'); | ||
| 170 | -// $sheet->setCellValue('G' . $rowCount, $v['images']); | ||
| 171 | -// $sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']); | ||
| 172 | -// $sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']); | ||
| 173 | -// $sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']); | ||
| 174 | - $rowCount++; | ||
| 175 | - } | ||
| 176 | - // 创建一个新的 Excel Writer 对象 | ||
| 177 | - $writer = new Xlsx($spreadsheet); | ||
| 178 | - $filename = time().'.xlsx'; | ||
| 179 | - // 设置导出文件的保存路径和文件名 | ||
| 180 | - $filePath = public_path('upload/excel/'.$filename); | ||
| 181 | - // 导出 Excel 文件 | ||
| 182 | - $writer->save($filePath); | ||
| 183 | - echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL; | ||
| 184 | - // 返回导出文件的响应 | ||
| 185 | - return ['file_link'=>url('upload/excel/'.$filename)]; | ||
| 186 | - } | ||
| 187 | - | ||
| 188 | - public function downloadItem($filed = ['id','depth','created_at','referrer_url','url','device_port','country','ip']){ | ||
| 189 | - $visitModel = new Visit(); | ||
| 190 | - $page = 1; | ||
| 191 | - $pageSize = 3000; | ||
| 192 | - $lists = $visitModel->lists(['updated_date'=>['between',['2025-02-01','2025-02-31']]],$page,$pageSize,'id',$filed); | ||
| 193 | - foreach ($lists as $v){ | ||
| 194 | - $customer_visit_id[] = $v['id']; | ||
| 195 | - } | ||
| 196 | - $itemModel = new VisitItem(); | ||
| 197 | - $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']); | ||
| 198 | - foreach ($lists as $key => $value){ | ||
| 199 | - $sub = []; | ||
| 200 | - foreach ($itemList as $sonValue){ | ||
| 201 | - if($value['id'] == $sonValue['customer_visit_id']){ | ||
| 202 | - $sub[] = $sonValue; | ||
| 203 | - } | ||
| 204 | - } | ||
| 205 | - $value['sub'] = $sub; | ||
| 206 | - $lists[$key] = $value; | ||
| 207 | - } | ||
| 208 | - return $lists; | ||
| 209 | - } | 163 | +// |
| 164 | +// public function downloadItem($filed = ['id','depth','created_at','referrer_url','url','device_port','country','ip']){ | ||
| 165 | +// $visitModel = new Visit(); | ||
| 166 | +// $page = 1; | ||
| 167 | +// $pageSize = 3000; | ||
| 168 | +// $lists = $visitModel->lists(['updated_date'=>['between',['2025-02-01','2025-02-31']]],$page,$pageSize,'id',$filed); | ||
| 169 | +// foreach ($lists as $v){ | ||
| 170 | +// $customer_visit_id[] = $v['id']; | ||
| 171 | +// } | ||
| 172 | +// $itemModel = new VisitItem(); | ||
| 173 | +// $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']); | ||
| 174 | +// foreach ($lists as $key => $value){ | ||
| 175 | +// $sub = []; | ||
| 176 | +// foreach ($itemList as $sonValue){ | ||
| 177 | +// if($value['id'] == $sonValue['customer_visit_id']){ | ||
| 178 | +// $sub[] = $sonValue; | ||
| 179 | +// } | ||
| 180 | +// } | ||
| 181 | +// $value['sub'] = $sub; | ||
| 182 | +// $lists[$key] = $value; | ||
| 183 | +// } | ||
| 184 | +// return $lists; | ||
| 185 | +// } | ||
| 210 | 186 | ||
| 211 | } | 187 | } |
-
请 注册 或 登录 后发表评论