作者 刘锟

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

@@ -25,7 +25,14 @@ class RemainDay extends Command @@ -25,7 +25,14 @@ class RemainDay extends Command
25 protected $signature = 'remain_day'; 25 protected $signature = 'remain_day';
26 26
27 protected $projectId = [ 27 protected $projectId = [
28 - 1434 28 + 1434,1812
  29 + ];//需要单独处理的项目
  30 +
  31 + /**
  32 + * @var 暂停的项目
  33 + */
  34 + protected $ceaseProjectId = [
  35 + 354
29 ];//需要单独处理的项目 36 ];//需要单独处理的项目
30 /** 37 /**
31 * The console command description. 38 * The console command description.
@@ -62,6 +69,11 @@ class RemainDay extends Command @@ -62,6 +69,11 @@ class RemainDay extends Command
62 }else{ 69 }else{
63 if($item['type'] == Project::TYPE_TWO){ 70 if($item['type'] == Project::TYPE_TWO){
64 //获取当前项目的达标天数 71 //获取当前项目的达标天数
  72 + if(in_array($item->id,$this->ceaseProjectId) && ($item->is_compliance == 1)){
  73 + //查看今日是否达标(已达标减1)
  74 + $item->finish_remain_day = (($item->finish_remain_day - 1) < 0) ? 0 : $item->finish_remain_day - 1;
  75 + $item->pause_days = $item->pause_days + 1;
  76 + }
65 $compliance_day = $item->finish_remain_day ?? 0; 77 $compliance_day = $item->finish_remain_day ?? 0;
66 $remain_day = $item['deploy_build']['service_duration'] - $compliance_day; 78 $remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
67 }else{ 79 }else{
@@ -44,24 +44,13 @@ class RankData extends BaseCommands @@ -44,24 +44,13 @@ class RankData extends BaseCommands
44 public function do() 44 public function do()
45 { 45 {
46 try { 46 try {
47 -  
48 -  
49 Log::channel('rank_data')->info('开始-排名数据'); 47 Log::channel('rank_data')->info('开始-排名数据');
50 - //同步api_no  
51 -// try {  
52 -// $this->SyncApiNo();  
53 -// } catch (\Exception $e) {  
54 -// Log::channel('rank_data')->error('同步api_no失败:' . $e->getMessage());  
55 -// }  
56 -  
57 -  
58 //所有项目 今日是否达标 重置 48 //所有项目 今日是否达标 重置
59 //有失败会重跑任务,导致达标又被重置 加缓存一天只重置一次 49 //有失败会重跑任务,导致达标又被重置 加缓存一天只重置一次
60 if (!Cache::get('clear_remain_today_' . date('Y-m-d'))) { 50 if (!Cache::get('clear_remain_today_' . date('Y-m-d'))) {
61 Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]); 51 Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]);
62 Cache::set('clear_remain_today_' . date('Y-m-d'), 1, 24 * 3600); 52 Cache::set('clear_remain_today_' . date('Y-m-d'), 1, 24 * 3600);
63 } 53 }
64 -  
65 $error = 0; 54 $error = 0;
66 $api = new QuanqiusouApi(); 55 $api = new QuanqiusouApi();
67 //有排名api编号的项目 56 //有排名api编号的项目
@@ -102,7 +91,6 @@ class RankData extends BaseCommands @@ -102,7 +91,6 @@ class RankData extends BaseCommands
102 if(!$deploy_optimizes){ 91 if(!$deploy_optimizes){
103 return true; 92 return true;
104 } 93 }
105 -  
106 $api = new QuanqiusouApi(); 94 $api = new QuanqiusouApi();
107 $ai_nos = $api->getWebApiNo(); 95 $ai_nos = $api->getWebApiNo();
108 if($ai_nos){ 96 if($ai_nos){
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtensionModuleController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/7 11:47
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\ExtentModule;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Models\ExtentModule\ExtensionModule;
  15 +
  16 +class ExtensionModuleController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :获取当前项目的拓展数据模块
  20 + * @name :getModuleLists
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2024/8/7 11:48
  24 + */
  25 + public function getModuleLists(){
  26 + $extensionModuleModel = new ExtensionModule();
  27 + $list = $extensionModuleModel->list();
  28 + $this->response('success',Code::SUCCESS,$list);
  29 + }
  30 +}
@@ -29,8 +29,10 @@ class CustomTemplateController extends BaseController @@ -29,8 +29,10 @@ class CustomTemplateController extends BaseController
29 public function lists(CustomTemplateLogic $customTemplateLogic){ 29 public function lists(CustomTemplateLogic $customTemplateLogic){
30 $lists = $customTemplateLogic->customTemplateLists($this->map,$this->page,$this->row,$this->order); 30 $lists = $customTemplateLogic->customTemplateLists($this->map,$this->page,$this->row,$this->order);
31 if (!empty($lists)){ 31 if (!empty($lists)){
  32 + $userModel = new User();
32 foreach ($lists['list'] as $k => $v){ 33 foreach ($lists['list'] as $k => $v){
33 $v['url'] = $v['url'].'/'; 34 $v['url'] = $v['url'].'/';
  35 + $v['operator_name'] = $userModel->getName($v['operator_id']);
34 $lists['list'][$k] = $v; 36 $lists['list'][$k] = $v;
35 } 37 }
36 } 38 }
@@ -494,7 +494,7 @@ class BTemplateLogic extends BaseLogic @@ -494,7 +494,7 @@ class BTemplateLogic extends BaseLogic
494 } 494 }
495 } 495 }
496 } 496 }
497 - $data['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); 497 + $data['main_html'] = characterTruncationStr($html,"<main","</main>");
498 $data['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); 498 $data['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
499 return $this->success($data); 499 return $this->success($data);
500 } 500 }
@@ -375,9 +375,7 @@ class RankDataLogic extends BaseLogic @@ -375,9 +375,7 @@ class RankDataLogic extends BaseLogic
375 if (!$project) { 375 if (!$project) {
376 throw new \Exception($api_no . '关联的项目不存在'); 376 throw new \Exception($api_no . '关联的项目不存在');
377 } 377 }
378 -  
379 $api = new QuanqiusouApi(); 378 $api = new QuanqiusouApi();
380 -  
381 $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); 379 $model = RankData::where('project_id', $project_id)->where('lang', '')->first();
382 if (!$model || $model->updated_date != date('Y-m-d') || $force) { 380 if (!$model || $model->updated_date != date('Y-m-d') || $force) {
383 $res = $api->getGoogleRank($api_no, '', 7, $force); 381 $res = $api->getGoogleRank($api_no, '', 7, $force);
@@ -424,9 +422,11 @@ class RankDataLogic extends BaseLogic @@ -424,9 +422,11 @@ class RankDataLogic extends BaseLogic
424 public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){ 422 public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){
425 $without_project_ids = []; //不用处理排名的项目 423 $without_project_ids = []; //不用处理排名的项目
426 $without_extension_project_ids = [658]; //是否达标只统计主词的 424 $without_extension_project_ids = [658]; //是否达标只统计主词的
  425 + $extension_project_ids = [354]; //扩展词也到达标的
427 426
428 $first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0; 427 $first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0;
429 $first_page_without_extension_num = 0; //不算扩展词在首页的数量 428 $first_page_without_extension_num = 0; //不算扩展词在首页的数量
  429 + $first_page_extension_num = 0; //扩展词在首页的数量
430 430
431 foreach ($data as &$ranks){ 431 foreach ($data as &$ranks){
432 ksort($ranks); 432 ksort($ranks);
@@ -448,6 +448,7 @@ class RankDataLogic extends BaseLogic @@ -448,6 +448,7 @@ class RankDataLogic extends BaseLogic
448 if($last['position'] > 0 && $last['position'] <= 10){ 448 if($last['position'] > 0 && $last['position'] <= 10){
449 $first_page_num ++; 449 $first_page_num ++;
450 $last['g'] == 1 && $first_page_without_extension_num++; 450 $last['g'] == 1 && $first_page_without_extension_num++;
  451 + $last['g'] == 2 && $first_page_extension_num++;
451 } 452 }
452 //排名前三页 453 //排名前三页
453 if($last['position'] > 0 && $last['position'] <= 30){ 454 if($last['position'] > 0 && $last['position'] <= 30){
@@ -482,6 +483,9 @@ class RankDataLogic extends BaseLogic @@ -482,6 +483,9 @@ class RankDataLogic extends BaseLogic
482 if(in_array($project_id, $without_extension_project_ids)){ 483 if(in_array($project_id, $without_extension_project_ids)){
483 $is_compliance = $first_page_without_extension_num >= $keyword_num; 484 $is_compliance = $first_page_without_extension_num >= $keyword_num;
484 } 485 }
  486 + if(in_array($project_id, $extension_project_ids)){
  487 + $is_compliance = $first_page_extension_num >= $keyword_num;
  488 + }
485 if ($keyword_num && $type == Project::TYPE_TWO && $is_compliance) { 489 if ($keyword_num && $type == Project::TYPE_TWO && $is_compliance) {
486 Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num . ' - ' . $first_page_without_extension_num); 490 Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num . ' - ' . $first_page_without_extension_num);
487 //项目表更新 491 //项目表更新
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtensionModule.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/7 14:13
  8 + */
  9 +
  10 +namespace App\Models\ExtentModule;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ExtensionModule extends Base
  15 +{
  16 +
  17 + protected $table = 'gl_extension_module';
  18 + //连接数据库
  19 + protected $connection = 'custom_mysql';
  20 +}