|
...
|
...
|
@@ -20,6 +20,7 @@ use App\Models\RankData\ExternalLinks as ExternalLinksModel; |
|
|
|
use App\Models\RankData\IndexedPages;
|
|
|
|
use App\Models\RankData\IndexedPages as IndexedPagesModel;
|
|
|
|
use App\Models\RankData\RankData;
|
|
|
|
use App\Models\RankData\RankDataBmseo;
|
|
|
|
use App\Models\RankData\RankWeek;
|
|
|
|
use App\Models\RankData\RankWeek as RankWeekModel;
|
|
|
|
use App\Models\RankData\RecommDomain;
|
|
...
|
...
|
@@ -32,6 +33,7 @@ use Illuminate\Database\Eloquent\Model; |
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
class RankDataLogic extends BaseLogic
|
|
|
|
{
|
|
...
|
...
|
@@ -193,6 +195,11 @@ class RankDataLogic extends BaseLogic |
|
|
|
$data['current_api_no'] = $api_no;
|
|
|
|
$data['current_api_source'] = $api_no == 10690 ? 'Yandex' : 'Google';
|
|
|
|
}
|
|
|
|
$data['api_no'] = $api_no;
|
|
|
|
$bmseo_id = RankDataBmseo::where('project_id', $project_id)->value('id');
|
|
|
|
if($bmseo_id){
|
|
|
|
$data['bmseo_api_no'] = $bmseo_id . '_bmseo';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
...
|
...
|
@@ -226,7 +233,12 @@ class RankDataLogic extends BaseLogic |
|
|
|
$ai_projects = $this->getAiProjects()['data'] ?? [];
|
|
|
|
$flg_ai = $this->getAiFlag($ai_projects, $domain);
|
|
|
|
$ai_domain = str_replace('www.', '', $this->getAiProjects($domain)['domain'] ?? '');
|
|
|
|
if (Str::endsWith($api_no, '_bmseo')) {
|
|
|
|
$list = RankDataBmseo::where('project_id', $project_id)->where('api_no', $api_no)->where('lang', $lang)->value('data') ?: [];
|
|
|
|
} else {
|
|
|
|
$list = RankData::where('project_id', $project_id)->where('api_no', $api_no)->where('lang', $lang)->value('data') ?: [];
|
|
|
|
}
|
|
|
|
|
|
|
|
$list30 = []; //排名前三十的
|
|
|
|
$list30_0 = []; //排名前三十且近三天没有排名的
|
|
|
|
$list100 = []; //排名前100的
|
|
...
|
...
|
@@ -360,6 +372,34 @@ class RankDataLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取白帽seo站点项目
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/5/12
|
|
|
|
*/
|
|
|
|
public function getBmSeoProjects($domain = '')
|
|
|
|
{
|
|
|
|
$key = 'weblist_bm';
|
|
|
|
$data = Cache::get($key);
|
|
|
|
if (!$data) {
|
|
|
|
$api_url = 'http://api.quanqiusou.cn/api/index/weblist_bm';
|
|
|
|
try {
|
|
|
|
$data = HttpUtils::get($api_url, ['key'=> '289c1fc81c89d79c04ed4fd72822948e']);
|
|
|
|
if ($data) {
|
|
|
|
$data = Arr::s2a($data);
|
|
|
|
Cache::put($key, $data, 4 * 3600);
|
|
|
|
}
|
|
|
|
} catch (\Exception | GuzzleException $e) {
|
|
|
|
errorLog('白帽seo站点项目获取失败', [], $e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($domain) {
|
|
|
|
return array_search($domain, $data);
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取AI站点项目
|
|
|
|
*
|
|
|
|
* @author zbj
|
|
...
|
...
|
@@ -622,6 +662,58 @@ class RankDataLogic extends BaseLogic |
|
|
|
return $model->is_compliance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function save_rank_bmseo($project_id, $api_no, $data){
|
|
|
|
$first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0;
|
|
|
|
$first_page_without_extension_num = 0; //不算扩展词在首页的数量
|
|
|
|
$first_page_extension_num = 0; //扩展词在首页的数量
|
|
|
|
foreach ($data as &$ranks){
|
|
|
|
ksort($ranks);
|
|
|
|
$last = Arr::last($ranks);
|
|
|
|
//第一名
|
|
|
|
if($last['position'] == 1){
|
|
|
|
$first_num ++;
|
|
|
|
}
|
|
|
|
//排名第一页
|
|
|
|
if($last['position'] > 0 && $last['position'] <= 10){
|
|
|
|
$first_page_num ++;
|
|
|
|
$last['g'] == 1 && $first_page_without_extension_num++;
|
|
|
|
$last['g'] == 2 && $first_page_extension_num++;
|
|
|
|
}
|
|
|
|
//排名前三页
|
|
|
|
if($last['position'] > 0 && $last['position'] <= 30){
|
|
|
|
$first_three_pages_num ++;
|
|
|
|
}
|
|
|
|
//排名前五页
|
|
|
|
if($last['position'] > 0 && $last['position'] <= 50){
|
|
|
|
$first_five_pages_num ++;
|
|
|
|
}
|
|
|
|
//排名前十页
|
|
|
|
if($last['position'] > 0 && $last['position'] <= 100){
|
|
|
|
$first_ten_pages_num ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$where = [
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'api_no' => $api_no,
|
|
|
|
];
|
|
|
|
$model = RankDataBmseo::where($where)->first();
|
|
|
|
if(!$model){
|
|
|
|
$model = new RankDataBmseo();
|
|
|
|
}
|
|
|
|
$model->project_id = $project_id;
|
|
|
|
$model->api_no = $api_no;
|
|
|
|
$model->first_num = $first_num;
|
|
|
|
$model->first_page_num = $first_page_num;
|
|
|
|
$model->first_three_pages_num = $first_three_pages_num;
|
|
|
|
$model->first_five_pages_num = $first_five_pages_num;
|
|
|
|
$model->first_ten_pages_num = $first_ten_pages_num;
|
|
|
|
$model->data = $data;
|
|
|
|
$model->updated_date = date('Y-m-d');
|
|
|
|
$model->save();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :g_top
|
|
|
|
* @name :g_top_plan
|
...
|
...
|
|