作者 刘锟

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

<?php
/**
* @remark :
* @name :AuthorityScore.php
* @author :lyh
* @method :post
* @time :2025/7/1 16:43
*/
namespace App\Console\Commands\AuthorityScore;
use App\Models\AuthorityScore\AuthorityScore as AuthorityScoreModel;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use Illuminate\Console\Command;
class AuthorityScore extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'authority_score';
/**
* The console command description.
*
* @var string
*/
protected $description = '白帽外链数据详情,每月统计一次';
/**
* @remark :执行方法
* @name :handle
* @author :lyh
* @method :post
* @time :2025/7/1 16:46
*/
public function handle(){
$projectModel = new Project();
$projectIdArr = $projectModel->selectField(['project_type'=>1,'delete_status' => 0,'extend_type'=>0,'type'=>2],'id');
$domainModel = new DomainInfo();
$url = 'https://www.cmer.site/api/domain/organic?domain=';
foreach ($projectIdArr as $item){
$domainInfo = $domainModel->read(['project_id'=>$item],['domain']);
if($domainInfo === false){
continue;
}
echo '执行的项目id'.$item.PHP_EOL;
$url = $url.$domainInfo['domain'];
$data = http_get($url);
if(!empty($data) && !empty($data['data'])){
echo json_encode($data).PHP_EOL;
$data = $data['data'];
$this->saveHandleData($data,$item);
}
}
return true;
}
/**
* @remark :保存数据
* @name :handleData
* @author :lyh
* @method :post
* @time :2025/7/1 17:23
*/
public function saveHandleData($data,$project_id){
$authorityScoreModel = new AuthorityScoreModel();
return $authorityScoreModel->addReturnId([
'project_id'=>$project_id,
'ascore'=>(int)($data['ascore'] ?? 0),
'total'=>(int)($data['total'] ?? 0),
'domains_num'=>(int)($data['domains_num'] ?? 0),
'rank'=>(int)($data['Rank'] ?? 0),
'organic_keywords'=>(int)($data['Organic_Keywords'] ?? 0),
'organic_traffic'=>(int)($data['Organic_Traffic'] ?? 0),
'date'=>date('Y-m-d')
]);
}
}
... ...
... ... @@ -162,68 +162,51 @@ class DownloadProject extends Command
return ['file_link'=>url('upload/excel/'.$filename)];
}
// public function exportData($data){
// // 创建一个新的 Excel 电子表格实例
// $spreadsheet = new Spreadsheet();
// $sheet = $spreadsheet->getActiveSheet();
// // 添加表头
// $sheet->setCellValue('A1', '产品名称');
//// $sheet->setCellValue('B1', '产品短描述');
//// $sheet->setCellValue('C1', '产品内容');
//// $sheet->setCellValue('D1', '产品路由');
//// $sheet->setCellValue('E1', '产品分类');
//// $sheet->setCellValue('F1', '产品状态');
//// $sheet->setCellValue('G1', '产品主图');
//// $sheet->setCellValue('H1', '产品seo_title');
//// $sheet->setCellValue('I1', '产品seo_keyword');
//// $sheet->setCellValue('J1', '产品seo_title');
// $rowCount = 2;
// foreach ($data as $v) {
// $sheet->setCellValue('A' . $rowCount, $v['title']);
//// $sheet->setCellValue('B' . $rowCount, $v['intro']);
//// $sheet->setCellValue('C' . $rowCount, $v['content']);
//// $sheet->setCellValue('D' . $rowCount, $v['url']);
//// $sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
//// $sheet->setCellValue('F' . $rowCount, '发布中');
//// $sheet->setCellValue('G' . $rowCount, $v['images']);
//// $sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']);
//// $sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']);
//// $sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']);
// $rowCount++;
// }
// // 创建一个新的 Excel Writer 对象
// $writer = new Xlsx($spreadsheet);
// $filename = time().'.xlsx';
// // 设置导出文件的保存路径和文件名
// $filePath = public_path('upload/excel/'.$filename);
// // 导出 Excel 文件
// $writer->save($filePath);
// echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL;
// // 返回导出文件的响应
// return ['file_link'=>url('upload/excel/'.$filename)];
// }
//
// public function downloadItem($filed = ['id','depth','created_at','referrer_url','url','device_port','country','ip']){
// $visitModel = new Visit();
// $page = 1;
// $pageSize = 3000;
// $lists = $visitModel->lists(['updated_date'=>['between',['2025-02-01','2025-02-31']]],$page,$pageSize,'id',$filed);
// foreach ($lists as $v){
// $customer_visit_id[] = $v['id'];
// }
// $itemModel = new VisitItem();
// $itemList = $itemModel->list(['customer_visit_id'=>['in',$customer_visit_id]],['customer_visit_id','url']);
// foreach ($lists as $key => $value){
// $sub = [];
// foreach ($itemList as $sonValue){
// if($value['id'] == $sonValue['customer_visit_id']){
// $sub[] = $sonValue;
// }
// }
// $value['sub'] = $sub;
// $lists[$key] = $value;
// }
// return $lists;
// }
/**
* @remark :导入产品
* @name :exportProductData
* @author :lyh
* @method :post
* @time :2025/6/30 16:46
*/
public function exportProductData($data){
// 创建一个新的 Excel 电子表格实例
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
// 添加表头
$sheet->setCellValue('A1', '产品名称');
$sheet->setCellValue('B1', '产品短描述');
$sheet->setCellValue('C1', '产品内容');
$sheet->setCellValue('D1', '产品路由');
$sheet->setCellValue('E1', '产品分类');
$sheet->setCellValue('F1', '产品状态');
$sheet->setCellValue('G1', '产品主图');
$sheet->setCellValue('H1', '产品seo_title');
$sheet->setCellValue('I1', '产品seo_keyword');
$sheet->setCellValue('J1', '产品seo_title');
$rowCount = 2;
foreach ($data as $v) {
$sheet->setCellValue('A' . $rowCount, $v['title']);
$sheet->setCellValue('B' . $rowCount, $v['intro']);
$sheet->setCellValue('C' . $rowCount, $v['content']);
$sheet->setCellValue('D' . $rowCount, $v['url']);
$sheet->setCellValue('E' . $rowCount, $v['category_id_text']);
$sheet->setCellValue('F' . $rowCount, '发布中');
$sheet->setCellValue('G' . $rowCount, $v['images']);
$sheet->setCellValue('H' . $rowCount, $v['seo_mate']['title']);
$sheet->setCellValue('I' . $rowCount, $v['seo_mate']['keyword']);
$sheet->setCellValue('J' . $rowCount, $v['seo_mate']['description']);
$rowCount++;
}
// 创建一个新的 Excel Writer 对象
$writer = new Xlsx($spreadsheet);
$filename = time().'.xlsx';
// 设置导出文件的保存路径和文件名
$filePath = public_path('upload/excel/'.$filename);
// 导出 Excel 文件
$writer->save($filePath);
echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL;
// 返回导出文件的响应
return ['file_link'=>url('upload/excel/'.$filename)];
}
}
... ...
... ... @@ -41,40 +41,10 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
return $this->aggregate_keyword_affix();
}
/**
* @remark :获取数据
* @name :aggregate_keyword_affix
* @author :lyh
* @method :post
* @time :2025/6/26 17:58
*/
public function aggregate_keyword_affix(){
$projectModel = new Project();
$lists = $projectModel->list(['delete_status' => 0,'project_type'=>0,'extend_type'=>0,'type'=>['in',[1,2,4,6]]], 'id', ['id']);
$keywordAffixModel = new AggregateKeywordAffix();
foreach ($lists as $val){
$info = $keywordAffixModel->read(['project_id'=>$val['id']]);
$prefix = "How To find"."\n"."Why Choose"."\n"."China Top"."\n"."Best Way To Choose"."\n"."Methods To Choose";
$suffix = "Manufacturer"."\n"."Supplier"."\n"."Products"."\n"."Factory";
if($info === false){
echo '执行的项目id:'.$val['id'].PHP_EOL;
$data = [
'project_id'=>$val['id'],
'prefix'=>$prefix,
'suffix'=>$suffix,
];
$keywordAffixModel->addReturnId($data);
}
}
return true;
}
public function _actionTemplateMain(){
$data = [];
$projectModel = new Project();
... ...
... ... @@ -35,7 +35,7 @@ class UpdateSeoTdkCrontab extends Command
*/
public function handle()
{
$project_ids = Project::where('type', Project::TYPE_TWO)->where('uptime', '<=', date('Y-m-d H:i:s'))->pluck('id')->toArray();
$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();
foreach ($project_ids as $project_id){
try {
ProjectUpdateTdk::add_task($project_id);
... ... @@ -44,7 +44,7 @@ class UpdateSeoTdkCrontab extends Command
}
}
$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();
$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();
foreach ($project_ids as $project_id){
try {
ProjectKeywordAiTask::add_task($project_id);
... ...
... ... @@ -112,7 +112,7 @@ if (!function_exists('http_get')) {
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_ENCODING, '');
curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch1, CURLOPT_TIMEOUT, 120);
curl_setopt($ch1, CURLOPT_TIMEOUT, 60);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
... ...
<?php
/**
* @remark :
* @name :AuthorityScoreController.php
* @author :lyh
* @method :post
* @time :2025/7/1 11:11
*/
namespace App\Http\Controllers\Bside\BCom;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BCom\AuthorityScoreLogic;
use Illuminate\Http\Request;
/**
* @remark :白帽版本报表
* @name :AuthorityScoreController
* @author :lyh
* @method :post
* @time :2025/7/1 11:12
*/
class AuthorityScoreController extends BaseController
{
public function __construct(Request $request)
{
parent::__construct($request);
$this->logic = new AuthorityScoreLogic();
}
/**
* @remark :豹猫数据统计表详情
* @name :whiteHatReportInfo
* @author :lyh
* @method :post
* @time :2025/7/1 11:13
*/
public function authorityScoreInfo(){
$this->request->validate([
'date'=>'required',
], [
'date.required' => '请选择报表时间',
]);
$data = $this->logic->LogicAuthorityScoreInfo();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -75,6 +75,9 @@ class CustomModuleLogic extends BaseLogic
if(!isset($param['id']) || empty($param['id'])){
$param['project_id'] = $this->param['project_id'];
}
if(in_array($param['route'],['blogs','news','top_blog','blog','product','products'])){
$this->fail('不允许使用项目默认模块路由');
}
return $this->success($param);
}
... ...
<?php
/**
* @remark :
* @name :AuthorityScoreLogic.php
* @author :lyh
* @method :post
* @time :2025/7/1 11:15
*/
namespace App\Http\Logic\Bside\BCom;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiVideo;
use App\Models\AuthorityScore\AuthorityScore;
use App\Models\RankData\RankDataBmseo;
use App\Models\SeoSetting\LinkData;
/**
* @remark :报表详情数据
* @name :AuthorityScoreLogic
* @author :lyh
* @method :post
* @time :2025/7/1 11:15
*/
class AuthorityScoreLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
}
/**
* @remark :获取当前项目日期的报表
* @name :LogicWhiteHatReportInfo
* @author :lyh
* @method :post
* @time :2025/7/1 11:43
*/
public function LogicAuthorityScoreInfo(){
$data = [];
$bSeoModel = new RankDataBmseo();
$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']);
$data['rank'] = $bSeoInfo;
$authorityScoreModel = new AuthorityScore();
$data['authority_score'] = $authorityScoreModel->list(['project_id'=>$this->user['project_id']],'id',['*'],'desc',10);
$startTime = date('Y-m-01 00:00:00', strtotime($this->param['date']));
// 结束时间(当月最后一天)
$endTime = date('Y-m-t 23:59:59', strtotime($this->param['date']));
//当月ai_blog发布数量及链接
$aiBlogModel = new AiBlog();
$data['ai_blog']['count'] = $aiBlogModel->counts(['created_at'=>['between',[$startTime,$endTime]]]);
$aiRouteArr = $aiBlogModel->selectField(['created_at'=>['between',[$startTime,$endTime]]],'route');
if(!empty($aiRouteArr)){
foreach ($aiRouteArr as $k => $item){
$aiRouteArr[$k] = $this->user['domain'] . 'blog/' . $item;
}
}
$data['ai_blog']['link'] = $aiRouteArr;
//当月ai_video发布数量及链接
$aiVideoModel = new AiVideo();
$data['ai_video']['count'] =$aiVideoModel->counts(['created_at'=>['between',[$startTime,$endTime]]]);
$aiVideoRouteArr = $aiVideoModel->selectField(['created_at'=>['between',[$startTime,$endTime]]],'route');
if(!empty($aiVideoRouteArr)){
foreach ($aiVideoRouteArr as $kVideo => $itemVideo){
$aiVideoRouteArr[$kVideo] = $this->user['domain'] . 'video/' . $itemVideo;
}
}
$data['ai_video']['link'] = $aiVideoRouteArr;
//白帽关键字
$data['keyword']['count'] = 0;
$data['keyword']['link'] = [];
//外链发布条数
$linkDataModel = new LinkData();
$data['link_data']['count'] = $linkDataModel->counts(['send_time'=>['between',[$startTime,$endTime]]]);
$data['link_data']['total_count'] = $linkDataModel->count();
$data['link_data']['ten_count'] = $linkDataModel->counts(['da_values'=>['between',[10,30]]]);
$data['link_data']['thirty_count'] = $linkDataModel->counts(['da_values'=>['between',[30,50]]]);
$data['link_data']['fifty_count'] = $linkDataModel->counts(['da_values'=>['>=',50]]);
return $this->success($data);
}
}
... ...
<?php
/**
* @remark :
* @name :AuthorityScore.php
* @author :lyh
* @method :post
* @time :2025/7/1 17:37
*/
namespace App\Models\AuthorityScore;
use App\Models\Base;
/**
* @remark :白帽第三方拉取排名数据
* @name :AuthorityScore
* @author :lyh
* @method :post
* @time :2025/7/1 17:38
*/
class AuthorityScore extends Base
{
protected $table = 'gl_authority_score';
}
... ...
... ... @@ -744,6 +744,10 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('google_link')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleLinkController::class,'getLink'])->name('google_link_getLink');
});
//白帽版本统计(SEMRUSH得分)
Route::prefix('authority_score')->group(function () {
Route::any('/authorityScoreInfo', [\App\Http\Controllers\Bside\BCom\AuthorityScoreController::class,'AuthorityScoreInfo'])->name('authority_score_AuthorityScoreInfo');
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...