作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AuthorityScore.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/1 16:43
  8 + */
  9 +
  10 +namespace App\Console\Commands\AuthorityScore;
  11 +
  12 +use App\Models\AuthorityScore\AuthorityScore as AuthorityScoreModel;
  13 +use App\Models\Domain\DomainInfo;
  14 +use App\Models\Project\Project;
  15 +use Illuminate\Console\Command;
  16 +
  17 +class AuthorityScore extends Command
  18 +{
  19 + /**
  20 + * The name and signature of the console command.
  21 + *
  22 + * @var string
  23 + */
  24 + protected $signature = 'authority_score';
  25 +
  26 + /**
  27 + * The console command description.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $description = '白帽外链数据详情,每月统计一次';
  32 +
  33 + /**
  34 + * @remark :执行方法
  35 + * @name :handle
  36 + * @author :lyh
  37 + * @method :post
  38 + * @time :2025/7/1 16:46
  39 + */
  40 + public function handle(){
  41 + $projectModel = new Project();
  42 + $projectIdArr = $projectModel->selectField(['project_type'=>1,'delete_status' => 0,'extend_type'=>0,'type'=>2],'id');
  43 + $domainModel = new DomainInfo();
  44 + $url = 'https://www.cmer.site/api/domain/organic?domain=';
  45 + foreach ($projectIdArr as $item){
  46 + $domainInfo = $domainModel->read(['project_id'=>$item],['domain']);
  47 + if($domainInfo === false){
  48 + continue;
  49 + }
  50 + echo '执行的项目id'.$item.PHP_EOL;
  51 + $url = $url.$domainInfo['domain'];
  52 + $data = http_get($url);
  53 + if(!empty($data) && !empty($data['data'])){
  54 + echo json_encode($data).PHP_EOL;
  55 + $data = $data['data'];
  56 + $this->saveHandleData($data,$item);
  57 + }
  58 + }
  59 + return true;
  60 + }
  61 +
  62 + /**
  63 + * @remark :保存数据
  64 + * @name :handleData
  65 + * @author :lyh
  66 + * @method :post
  67 + * @time :2025/7/1 17:23
  68 + */
  69 + public function saveHandleData($data,$project_id){
  70 + $authorityScoreModel = new AuthorityScoreModel();
  71 + return $authorityScoreModel->addReturnId([
  72 + 'project_id'=>$project_id,
  73 + 'ascore'=>(int)($data['ascore'] ?? 0),
  74 + 'total'=>(int)($data['total'] ?? 0),
  75 + 'domains_num'=>(int)($data['domains_num'] ?? 0),
  76 + 'rank'=>(int)($data['Rank'] ?? 0),
  77 + 'organic_keywords'=>(int)($data['Organic_Keywords'] ?? 0),
  78 + 'organic_traffic'=>(int)($data['Organic_Traffic'] ?? 0),
  79 + 'date'=>date('Y-m-d')
  80 + ]);
  81 + }
  82 +}
@@ -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 }
@@ -41,40 +41,10 @@ class lyhDemo extends Command @@ -41,40 +41,10 @@ class lyhDemo extends Command
41 protected $description = '更新路由'; 41 protected $description = '更新路由';
42 42
43 public function handle(){ 43 public function handle(){
44 - return $this->aggregate_keyword_affix();  
45 - }  
46 -  
47 - /**  
48 - * @remark :获取数据  
49 - * @name :aggregate_keyword_affix  
50 - * @author :lyh  
51 - * @method :post  
52 - * @time :2025/6/26 17:58  
53 - */  
54 - public function aggregate_keyword_affix(){  
55 - $projectModel = new Project();  
56 - $lists = $projectModel->list(['delete_status' => 0,'project_type'=>0,'extend_type'=>0,'type'=>['in',[1,2,4,6]]], 'id', ['id']);  
57 - $keywordAffixModel = new AggregateKeywordAffix();  
58 - foreach ($lists as $val){  
59 - $info = $keywordAffixModel->read(['project_id'=>$val['id']]);  
60 -  
61 -  
62 - $prefix = "How To find"."\n"."Why Choose"."\n"."China Top"."\n"."Best Way To Choose"."\n"."Methods To Choose";  
63 - $suffix = "Manufacturer"."\n"."Supplier"."\n"."Products"."\n"."Factory";  
64 - if($info === false){  
65 - echo '执行的项目id:'.$val['id'].PHP_EOL;  
66 - $data = [  
67 - 'project_id'=>$val['id'],  
68 - 'prefix'=>$prefix,  
69 - 'suffix'=>$suffix,  
70 - ];  
71 - $keywordAffixModel->addReturnId($data);  
72 - }  
73 -  
74 - }  
75 return true; 44 return true;
76 } 45 }
77 46
  47 +
78 public function _actionTemplateMain(){ 48 public function _actionTemplateMain(){
79 $data = []; 49 $data = [];
80 $projectModel = new Project(); 50 $projectModel = new Project();
@@ -35,7 +35,7 @@ class UpdateSeoTdkCrontab extends Command @@ -35,7 +35,7 @@ class UpdateSeoTdkCrontab extends Command
35 */ 35 */
36 public function handle() 36 public function handle()
37 { 37 {
38 - $project_ids = Project::where('type', Project::TYPE_TWO)->where('uptime', '<=', date('Y-m-d H:i:s'))->pluck('id')->toArray(); 38 + $project_ids = Project::where('type', Project::TYPE_TWO)->where('site_status',0)->where('extend_type',0)->where('delete_status',0)->where('uptime', '<=', date('Y-m-d H:i:s'))->pluck('id')->toArray();
39 foreach ($project_ids as $project_id){ 39 foreach ($project_ids as $project_id){
40 try { 40 try {
41 ProjectUpdateTdk::add_task($project_id); 41 ProjectUpdateTdk::add_task($project_id);
@@ -44,7 +44,7 @@ class UpdateSeoTdkCrontab extends Command @@ -44,7 +44,7 @@ class UpdateSeoTdkCrontab extends Command
44 } 44 }
45 } 45 }
46 46
47 - $project_ids = Project::where('type', Project::TYPE_TWO)->where('tag_page_version', '>' ,1)->where('uptime', '<=', date('Y-m-d H:i:s'))->pluck('id')->toArray(); 47 + $project_ids = Project::where('type', Project::TYPE_TWO)->where('site_status',0)->where('extend_type',0)->where('delete_status',0)->where('tag_page_version', '>' ,1)->where('uptime', '<=', date('Y-m-d H:i:s'))->pluck('id')->toArray();
48 foreach ($project_ids as $project_id){ 48 foreach ($project_ids as $project_id){
49 try { 49 try {
50 ProjectKeywordAiTask::add_task($project_id); 50 ProjectKeywordAiTask::add_task($project_id);
@@ -112,7 +112,7 @@ if (!function_exists('http_get')) { @@ -112,7 +112,7 @@ if (!function_exists('http_get')) {
112 curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); 112 curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
113 curl_setopt($ch1, CURLOPT_ENCODING, ''); 113 curl_setopt($ch1, CURLOPT_ENCODING, '');
114 curl_setopt($ch1, CURLOPT_MAXREDIRS, 10); 114 curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
115 - curl_setopt($ch1, CURLOPT_TIMEOUT, 120); 115 + curl_setopt($ch1, CURLOPT_TIMEOUT, 60);
116 curl_setopt($ch1, CURLOPT_HTTPHEADER, $header); 116 curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
117 curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout); 117 curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
118 curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true); 118 curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AuthorityScoreController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/1 11:11
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\BCom;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\BCom\AuthorityScoreLogic;
  15 +use Illuminate\Http\Request;
  16 +
  17 +/**
  18 + * @remark :白帽版本报表
  19 + * @name :AuthorityScoreController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2025/7/1 11:12
  23 + */
  24 +class AuthorityScoreController extends BaseController
  25 +{
  26 + public function __construct(Request $request)
  27 + {
  28 + parent::__construct($request);
  29 + $this->logic = new AuthorityScoreLogic();
  30 + }
  31 +
  32 + /**
  33 + * @remark :豹猫数据统计表详情
  34 + * @name :whiteHatReportInfo
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2025/7/1 11:13
  38 + */
  39 + public function authorityScoreInfo(){
  40 + $this->request->validate([
  41 + 'date'=>'required',
  42 + ], [
  43 + 'date.required' => '请选择报表时间',
  44 + ]);
  45 + $data = $this->logic->LogicAuthorityScoreInfo();
  46 + $this->response('success',Code::SUCCESS,$data);
  47 + }
  48 +}
@@ -75,6 +75,9 @@ class CustomModuleLogic extends BaseLogic @@ -75,6 +75,9 @@ class CustomModuleLogic extends BaseLogic
75 if(!isset($param['id']) || empty($param['id'])){ 75 if(!isset($param['id']) || empty($param['id'])){
76 $param['project_id'] = $this->param['project_id']; 76 $param['project_id'] = $this->param['project_id'];
77 } 77 }
  78 + if(in_array($param['route'],['blogs','news','top_blog','blog','product','products'])){
  79 + $this->fail('不允许使用项目默认模块路由');
  80 + }
78 return $this->success($param); 81 return $this->success($param);
79 } 82 }
80 83
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AuthorityScoreLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/1 11:15
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\BCom;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Ai\AiBlog;
  14 +use App\Models\Ai\AiVideo;
  15 +use App\Models\AuthorityScore\AuthorityScore;
  16 +use App\Models\RankData\RankDataBmseo;
  17 +use App\Models\SeoSetting\LinkData;
  18 +
  19 +/**
  20 + * @remark :报表详情数据
  21 + * @name :AuthorityScoreLogic
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2025/7/1 11:15
  25 + */
  26 +class AuthorityScoreLogic extends BaseLogic
  27 +{
  28 + public function __construct()
  29 + {
  30 + parent::__construct();
  31 + $this->param = $this->requestAll;
  32 + }
  33 +
  34 + /**
  35 + * @remark :获取当前项目日期的报表
  36 + * @name :LogicWhiteHatReportInfo
  37 + * @author :lyh
  38 + * @method :post
  39 + * @time :2025/7/1 11:43
  40 + */
  41 + public function LogicAuthorityScoreInfo(){
  42 + $data = [];
  43 + $bSeoModel = new RankDataBmseo();
  44 + $bSeoInfo = $bSeoModel->read(['project_id'=>$this->user['project_id']],['updated_date','first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']);
  45 + $data['rank'] = $bSeoInfo;
  46 + $authorityScoreModel = new AuthorityScore();
  47 + $data['authority_score'] = $authorityScoreModel->list(['project_id'=>$this->user['project_id']],'id',['*'],'desc',10);
  48 + $startTime = date('Y-m-01 00:00:00', strtotime($this->param['date']));
  49 + // 结束时间(当月最后一天)
  50 + $endTime = date('Y-m-t 23:59:59', strtotime($this->param['date']));
  51 + //当月ai_blog发布数量及链接
  52 + $aiBlogModel = new AiBlog();
  53 + $data['ai_blog']['count'] = $aiBlogModel->counts(['created_at'=>['between',[$startTime,$endTime]]]);
  54 + $aiRouteArr = $aiBlogModel->selectField(['created_at'=>['between',[$startTime,$endTime]]],'route');
  55 + if(!empty($aiRouteArr)){
  56 + foreach ($aiRouteArr as $k => $item){
  57 + $aiRouteArr[$k] = $this->user['domain'] . 'blog/' . $item;
  58 + }
  59 + }
  60 + $data['ai_blog']['link'] = $aiRouteArr;
  61 + //当月ai_video发布数量及链接
  62 + $aiVideoModel = new AiVideo();
  63 + $data['ai_video']['count'] =$aiVideoModel->counts(['created_at'=>['between',[$startTime,$endTime]]]);
  64 + $aiVideoRouteArr = $aiVideoModel->selectField(['created_at'=>['between',[$startTime,$endTime]]],'route');
  65 + if(!empty($aiVideoRouteArr)){
  66 + foreach ($aiVideoRouteArr as $kVideo => $itemVideo){
  67 + $aiVideoRouteArr[$kVideo] = $this->user['domain'] . 'video/' . $itemVideo;
  68 + }
  69 + }
  70 + $data['ai_video']['link'] = $aiVideoRouteArr;
  71 + //白帽关键字
  72 + $data['keyword']['count'] = 0;
  73 + $data['keyword']['link'] = [];
  74 + //外链发布条数
  75 + $linkDataModel = new LinkData();
  76 + $data['link_data']['count'] = $linkDataModel->counts(['send_time'=>['between',[$startTime,$endTime]]]);
  77 + $data['link_data']['total_count'] = $linkDataModel->count();
  78 + $data['link_data']['ten_count'] = $linkDataModel->counts(['da_values'=>['between',[10,30]]]);
  79 + $data['link_data']['thirty_count'] = $linkDataModel->counts(['da_values'=>['between',[30,50]]]);
  80 + $data['link_data']['fifty_count'] = $linkDataModel->counts(['da_values'=>['>=',50]]);
  81 + return $this->success($data);
  82 + }
  83 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AuthorityScore.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/1 17:37
  8 + */
  9 +
  10 +namespace App\Models\AuthorityScore;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :白帽第三方拉取排名数据
  16 + * @name :AuthorityScore
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2025/7/1 17:38
  20 + */
  21 +class AuthorityScore extends Base
  22 +{
  23 + protected $table = 'gl_authority_score';
  24 +}
@@ -744,6 +744,10 @@ Route::middleware(['bloginauth'])->group(function () { @@ -744,6 +744,10 @@ Route::middleware(['bloginauth'])->group(function () {
744 Route::prefix('google_link')->group(function () { 744 Route::prefix('google_link')->group(function () {
745 Route::any('/', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleLinkController::class,'getLink'])->name('google_link_getLink'); 745 Route::any('/', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleLinkController::class,'getLink'])->name('google_link_getLink');
746 }); 746 });
  747 + //白帽版本统计(SEMRUSH得分)
  748 + Route::prefix('authority_score')->group(function () {
  749 + Route::any('/authorityScoreInfo', [\App\Http\Controllers\Bside\BCom\AuthorityScoreController::class,'AuthorityScoreInfo'])->name('authority_score_AuthorityScoreInfo');
  750 + });
747 }); 751 });
748 //无需登录验证的路由组 752 //无需登录验证的路由组
749 Route::group([], function () { 753 Route::group([], function () {