WhiteHatReportLogic.php 3.4 KB
<?php
/**
 * @remark :
 * @name   :WhiteHatReportLogic.php
 * @author :lyh
 * @method :post
 * @time   :2025/7/1 11:15
 */

namespace App\Http\Logic\Bside\Com;

use App\Http\Logic\Bside\BaseLogic;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiVideo;
use App\Models\RankData\RankDataBmseo;
use App\Models\SeoSetting\LinkData;

/**
 * @remark :报表详情数据
 * @name   :WhiteHatReportLogic
 * @author :lyh
 * @method :post
 * @time   :2025/7/1 11:15
 */
class WhiteHatReportLogic 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 LogicWhiteHatReportInfo(){
        $data = [];
        $bSeoModel = new RankDataBmseo();
        $bSeoInfo = $bSeoModel->read(['project_id'=>$this->user['project_id'],'lang'=>''],['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num','indexed_pages_num']);
        $data['rank'] = $bSeoInfo;
        $parsedUrl = parse_url($this->user['domain']);
        $domain = $parsedUrl['host'];
        $url = 'https://www.cmer.site/api/domain/organic?domain='.$domain;
        try {
            $data['sem'] = http_get($url)['data'];
        }catch (\Exception $e){
            $data['sem'] = [];
        }
        $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->count(['da'=>['between'=>[10,30]]]);
        $data['link_data']['thirty_count'] = $linkDataModel->count(['da'=>['between'=>[30,50]]]);
        $data['link_data']['fifty_count'] = $linkDataModel->count(['da'=>['>=',50]]);
        return $this->success($data);
    }
}