RankDataLogic.php
4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
namespace App\Http\Logic\Bside;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\RankData\ExternalLinks;
use App\Models\RankData\IndexedPages;
use App\Models\RankData\RankData;
use App\Models\RankData\RankWeek;
use App\Models\RankData\RecommDomain;
use App\Models\RankData\Speed;
use Illuminate\Support\Str;
class RankDataLogic extends BaseLogic
{
/**
* 统计数据
* @author zbj
* @date 2023/5/11
*/
public function index()
{
$project_id = $this->user['project_id'];
//查数据
$project = app(ProjectLogic::class)->getInfo($project_id);
$rank = RankData::where('project_id', $project_id)->first();
$rank_week = RankWeek::where('project_id', $project_id)->first();
$recomm_domain = RecommDomain::where('project_id', $project_id)->first();
$external_links = ExternalLinks::where('project_id', $project_id)->first();
$indexed_pages = IndexedPages::where('project_id', $project_id)->first();
$speed = Speed::where('project_id', $project_id)->first();
//排名数据
$data = [
'first_num' => $rank['first_num'] ?? 0,
'first_page_num' => $rank['first_page_num'] ?? 0,
'first_three_pages_num' => $rank['first_three_pages_num'] ?? 0,
'first_five_pages_num' => $rank['first_five_pages_num'] ?? 0,
'first_ten_pages_num' => $rank['first_ten_pages_num'] ?? 0,
'indexed_pages_num' => $rank['indexed_pages_num'] ?? 0,
'external_links_num' => $external_links['total'] ?? 0,
];
//小语种列表
$langs = Arr::pluck($project['deploy_optimize']['minor_languages'], 'tl');
foreach ($langs as $lang){
$data['langs'][$lang] = Translate::getTls($lang);
}
//项目信息
$data['project'] = [
'company' => $project['company'],
'domain' => $project['deploy_optimize']['domain'],
'domain_info' => '',
'cert_info' => '',
'plan' => str_replace('营销大师-', '全球搜-', $project['deploy_build']['plan'][0]),
'keyword_num' => $project['deploy_build']['keyword_num'],
'compliance_day' => $rank['compliance_day'] ?? 0,
'remain_day' => $project['deploy_build']['service_duration'] - ($rank['compliance_day'] ?? 0),
];
//测速
$data['speed'] = $speed['data'] ?? [];
//seo基础设置
$data['seo'] = [
'H1,H2,H3标签',
'TDK设置(Title, Description, Keywords)',
'Google 收录提交',
'Sitemap.xml Google站长地图',
'Robots.txt文件优化',
'Google站长工具优化设置'
];
//外链引荐域名
$data['external_links_domain_chat'] = [
'labels' => array_map(function ($item) {
return Str::substrReplace($item, '***', 2, 3);
}, Arr::pluck($recomm_domain['data'] ?? [], 'domain')),
'data' => Arr::pluck($recomm_domain['data'] ?? [], 'backlinks_num'),
'list_date' => $recomm_domain['updated_at'] ?? '',
];
//SEO数据周期分析图 外链数
$data['external_links_chat'] = [
'labels' => array_keys($external_links['data'] ?? []),
'data' => array_values($external_links['data'] ?? []),
];
//SEO数据周期分析图 收录数
$data['indexed_pages_chat'] = [
'labels' => array_keys($indexed_pages['data'] ?? []),
'data' => array_values($indexed_pages['data'] ?? []),
];
//收录数加上当日数据
if((Arr::last($data['indexed_pages_chat']['labels'])) != date('Y-m-d')){
$data['indexed_pages_chat']['labels'][] = date('Y-m-d');
$data['indexed_pages_chat']['data'][] = $data['indexed_pages_num'];
}
//关键词排名分析图
$data['rank_chat'] = [
'data' => $rank_week['data'],
'labels' => $rank_week['date'],
];
return $data;
}
/**
* 关键词排名
* @author zbj
* @date 2023/5/12
*/
public function keywords_rank_list(){
$lang = $this->request['lang'];
}
}