作者 lyh

扩展模块不允许使用默认路由

@@ -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 :WhiteHatReportController.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\Com\WhiteHatReportLogic;
  15 +use Illuminate\Http\Request;
  16 +
  17 +/**
  18 + * @remark :白帽版本报表
  19 + * @name :WhiteHatReportController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2025/7/1 11:12
  23 + */
  24 +class WhiteHatReportController extends BaseController
  25 +{
  26 + public function __construct(Request $request)
  27 + {
  28 + parent::__construct($request);
  29 + $this->logic = new WhiteHatReportLogic();
  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 whiteHatReportInfo(){
  40 + $this->request->validate([
  41 + 'date'=>'required',
  42 + ], [
  43 + 'date.required' => '请选择报表时间',
  44 + ]);
  45 + $data = $this->logic->LogicWhiteHatReportInfo();
  46 + $this->response('success',Code::SUCCESS,$data);
  47 + }
  48 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :WhiteHatReportLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/7/1 11:15
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\Com;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Ai\AiBlog;
  14 +use App\Models\Ai\AiVideo;
  15 +use App\Models\Project\ProjectKeyword;
  16 +use App\Models\SeoSetting\LinkData;
  17 +
  18 +/**
  19 + * @remark :报表详情数据
  20 + * @name :WhiteHatReportLogic
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2025/7/1 11:15
  24 + */
  25 +class WhiteHatReportLogic extends BaseLogic
  26 +{
  27 + public function __construct()
  28 + {
  29 + parent::__construct();
  30 + $this->param = $this->requestAll;
  31 + }
  32 +
  33 + /**
  34 + * @remark :获取当前项目日期的报表
  35 + * @name :LogicWhiteHatReportInfo
  36 + * @author :lyh
  37 + * @method :post
  38 + * @time :2025/7/1 11:43
  39 + */
  40 + public function LogicWhiteHatReportInfo(){
  41 + $parsedUrl = parse_url($this->user['domain']);
  42 + $domain = $parsedUrl['host'];
  43 + $url = 'https://www.cmer.site/api/domain/organic?domain='.$domain;
  44 + $data = [];
  45 + try {
  46 + $data['sem'] = http_get($url)['data'];
  47 + }catch (\Exception $e){
  48 + $data['sem'] = [];
  49 + }
  50 + $startTime = date('Y-m-01 00:00:00', strtotime($this->param['date']));
  51 + // 结束时间(当月最后一天)
  52 + $endTime = date('Y-m-t 23:59:59', strtotime($this->param['date']));
  53 + //当月ai_blog发布数量及链接
  54 + $aiBlogModel = new AiBlog();
  55 + $data['ai_blog']['count'] = $aiBlogModel->counts(['created_at'=>['between'=>[$startTime,$endTime]]]);
  56 + $aiRouteArr = $aiBlogModel->selectField(['created_at'=>['between'=>[$startTime,$endTime]]],'route');
  57 + if(!empty($aiRouteArr)){
  58 + foreach ($aiRouteArr as $k => $item){
  59 + $aiRouteArr[$k] = $this->user['domain'] . 'blog/' . $item;
  60 + }
  61 + }
  62 + $data['ai_blog']['link'] = $aiRouteArr;
  63 + //当月ai_video发布数量及链接
  64 + $aiVideoModel = new AiVideo();
  65 + $data['ai_video']['count'] =$aiVideoModel->counts(['created_at'=>['between'=>[$startTime,$endTime]]]);
  66 + $aiVideoRouteArr = $aiVideoModel->selectField(['created_at'=>['between'=>[$startTime,$endTime]]],'route');
  67 + if(!empty($aiVideoRouteArr)){
  68 + foreach ($aiVideoRouteArr as $kVideo => $itemVideo){
  69 + $aiVideoRouteArr[$kVideo] = $this->user['domain'] . 'video/' . $itemVideo;
  70 + }
  71 + }
  72 + $data['ai_video']['link'] = $aiVideoRouteArr;
  73 + //白帽关键字
  74 + $data['keyword']['count'] = 0;
  75 + $data['keyword']['link'] = [];
  76 + //外链发布条数
  77 + $linkDataModel = new LinkData();
  78 + $data['link_data']['count'] = $linkDataModel->counts(['send_time'=>['between'=>[$startTime,$endTime]]]);
  79 + $data['link_data']['total_count'] = $linkDataModel->count();
  80 + $data['link_data']['ten_count'] = $linkDataModel->count(['da'=>['between'=>[10,30]]]);
  81 + $data['link_data']['thirty_count'] = $linkDataModel->count(['da'=>['between'=>[30,50]]]);
  82 + $data['link_data']['fifty_count'] = $linkDataModel->count(['da'=>['>=',50]]);
  83 + return $this->success($data);
  84 + }
  85 +}
@@ -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 + //白帽版本
  748 + Route::prefix('white_hat_report')->group(function () {
  749 + Route::any('/whiteHatReportInfo', [\App\Http\Controllers\Bside\BCom\WhiteHatReportController::class,'whiteHatReportInfo'])->name('white_hat_report_whiteHatReportInfo');
  750 + });
747 }); 751 });
748 //无需登录验证的路由组 752 //无需登录验证的路由组
749 Route::group([], function () { 753 Route::group([], function () {