作者 Your Name
@@ -24,8 +24,18 @@ class RemainDay extends Command @@ -24,8 +24,18 @@ class RemainDay extends Command
24 */ 24 */
25 protected $signature = 'remain_day'; 25 protected $signature = 'remain_day';
26 26
  27 + /**
  28 + * @var 按上线时间统计
  29 + */
27 protected $projectId = [ 30 protected $projectId = [
28 - 1434 31 + 1434,1812
  32 + ];//需要单独处理的项目
  33 +
  34 + /**
  35 + * @var 暂停的项目
  36 + */
  37 + protected $ceaseProjectId = [
  38 + 354
29 ];//需要单独处理的项目 39 ];//需要单独处理的项目
30 /** 40 /**
31 * The console command description. 41 * The console command description.
@@ -51,6 +61,14 @@ class RemainDay extends Command @@ -51,6 +61,14 @@ class RemainDay extends Command
51 { 61 {
52 $list = Project::whereIn('type', [Project::TYPE_TWO,Project::TYPE_THREE,Project::TYPE_FOUR])->get(); 62 $list = Project::whereIn('type', [Project::TYPE_TWO,Project::TYPE_THREE,Project::TYPE_FOUR])->get();
53 foreach ($list as $item){ 63 foreach ($list as $item){
  64 + if(in_array($item->id,$this->ceaseProjectId)){//暂停的项目
  65 + if($item['type'] == Project::TYPE_TWO && $item->is_compliance == 1){
  66 + $item->pause_days = $item->pause_days + 1;
  67 + }
  68 + if($item['type'] != Project::TYPE_THREE){
  69 + $item->pause_days = $item->pause_days + 1;
  70 + }
  71 + }
54 if(in_array($item->id,$this->projectId)){//已开始优化的时间结算 72 if(in_array($item->id,$this->projectId)){//已开始优化的时间结算
55 $optimizeModel = new DeployOptimize(); 73 $optimizeModel = new DeployOptimize();
56 $opInfo = $optimizeModel->read(['project_id'=>$item->id],['start_date']); 74 $opInfo = $optimizeModel->read(['project_id'=>$item->id],['start_date']);
@@ -58,17 +76,16 @@ class RemainDay extends Command @@ -58,17 +76,16 @@ class RemainDay extends Command
58 continue; 76 continue;
59 } 77 }
60 $diff = time() - strtotime($opInfo['start_date'] ?? $item->uptime); 78 $diff = time() - strtotime($opInfo['start_date'] ?? $item->uptime);
61 - $remain_day = $item['deploy_build']['service_duration'] - floor($diff / (60 * 60 * 24)); 79 + $remain_day = $item['deploy_build']['service_duration'] + $item->pause_days - floor($diff / (60 * 60 * 24));
62 }else{ 80 }else{
63 if($item['type'] == Project::TYPE_TWO){ 81 if($item['type'] == Project::TYPE_TWO){
64 - //获取当前项目的达标天数  
65 $compliance_day = $item->finish_remain_day ?? 0; 82 $compliance_day = $item->finish_remain_day ?? 0;
66 - $remain_day = $item['deploy_build']['service_duration'] - $compliance_day; 83 + $remain_day = $item['deploy_build']['service_duration'] + $item->pause_days - $compliance_day;
67 }else{ 84 }else{
68 if($item->uptime){ 85 if($item->uptime){
69 $diff = time() - strtotime($item->uptime); 86 $diff = time() - strtotime($item->uptime);
70 $item->finish_remain_day = floor($diff / (60 * 60 * 24)); 87 $item->finish_remain_day = floor($diff / (60 * 60 * 24));
71 - $remain_day = $item['deploy_build']['service_duration'] - floor($diff / (60 * 60 * 24)); 88 + $remain_day = $item['deploy_build']['service_duration'] + $item->pause_days - floor($diff / (60 * 60 * 24));
72 }else{ 89 }else{
73 $remain_day = $item['deploy_build']['service_duration']; 90 $remain_day = $item['deploy_build']['service_duration'];
74 } 91 }
@@ -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){
@@ -809,7 +809,13 @@ class ProjectUpdate extends Command @@ -809,7 +809,13 @@ class ProjectUpdate extends Command
809 809
810 $path_arr = explode('/', $path); 810 $path_arr = explode('/', $path);
811 811
812 - return end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2]; 812 + $route = end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2];
  813 +
  814 + if (strpos($route, ',') !== false || strpos($route, ',') !== false) {
  815 + return '';
  816 + }
  817 +
  818 + return $route;
813 } 819 }
814 820
815 //产品多级分类入库 821 //产品多级分类入库
  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\Http\Logic\Aside\ExtensionModule\ExtensionModuleLogic;
  15 +use App\Models\ExtentModule\ExtensionModule;
  16 +
  17 +class ExtensionModuleController extends BaseController
  18 +{
  19 + /**
  20 + * @remark :获取当前项目的拓展数据模块
  21 + * @name :getModuleLists
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2024/8/7 11:48
  25 + */
  26 + public function getModuleLists(){
  27 + $extensionModuleModel = new ExtensionModule();
  28 + $list = $extensionModuleModel->list();
  29 + $this->response('success',Code::SUCCESS,$list);
  30 + }
  31 +
  32 + /**
  33 + * @remark :保存拓展数据模块
  34 + * @name :saveModule
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2024/8/7 15:44
  38 + */
  39 + public function saveModule(ExtensionModuleLogic $logic){
  40 + $this->request->validate([
  41 + 'title'=>'required',
  42 + 'status'=>'required',
  43 + ],[
  44 + 'title.required' => '名称不能为空',
  45 + 'status.required' => '状态不能为空',
  46 + ]);
  47 + $data = $logic->saveExtensionModule();
  48 + $this->response('success',Code::SUCCESS,$data);
  49 + }
  50 +
  51 + /**
  52 + * @remark :删除模块
  53 + * @name :delModule
  54 + * @author :lyh
  55 + * @method :post
  56 + * @time :2024/8/7 16:02
  57 + */
  58 + public function delModule(ExtensionModuleLogic $logic){
  59 + $this->request->validate([
  60 + 'id'=>'required',
  61 + ],[
  62 + 'id.required' => '名称不能为空',
  63 + ]);
  64 + $logic->delExtensionModule();
  65 + $this->response('success');
  66 + }
  67 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtensionModuleController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/7 16:15
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\ExtensionModule;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\ExtensionModule\ExtensionModuleFieldLogic;
  15 +use App\Models\ExtentModule\ExtensionModule;
  16 +use App\Models\ExtentModule\ExtensionModuleField;
  17 +use App\Models\ExtentModule\ExtensionModuleValue;
  18 +
  19 +class ExtensionModuleController extends BaseController
  20 +{
  21 + /**
  22 + * @remark :获取扩展数据模块
  23 + * @name :getModuleList
  24 + * @author :lyh
  25 + * @method :post
  26 + * @time :2024/8/7 16:16
  27 + */
  28 + public function getModuleList(){
  29 + $moduleModel = new ExtensionModule();
  30 + $this->map['status'] = 0;
  31 + $list = $moduleModel->list($this->map);
  32 + $this->response('success',Code::SUCCESS,$list);
  33 + }
  34 +
  35 + /**
  36 + * @remark :获取当前模块字段
  37 + * @name :getModuleFiledInfo
  38 + * @author :lyh
  39 + * @method :post
  40 + * @time :2024/8/7 16:20
  41 + */
  42 + public function getModuleFiledInfo(){
  43 + $this->request->validate([
  44 + 'module_id'=>'required',
  45 + ],[
  46 + 'module_id.required' => '模块id不能为空',
  47 + ]);
  48 + $moduleFieldModel = new ExtensionModuleField();
  49 + $list = $moduleFieldModel->list(['module_id'=>$this->param['module_id']]);
  50 + $this->response('success',Code::SUCCESS,$list);
  51 + }
  52 +
  53 + /**
  54 + * @remark :添加字段
  55 + * @name :saveModuleField
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2024/8/7 16:27
  59 + */
  60 + public function saveModuleField(ExtensionModuleFieldLogic $logic){
  61 + $this->request->validate([
  62 + 'module_id'=>'required',
  63 + 'field_name'=>'required',
  64 + 'data_type'=>'required',
  65 + 'is_required'=>'required',
  66 + ],[
  67 + 'module_id.required' => '模块id不能为空',
  68 + 'field_name.required' => '字段名称不能为空',
  69 + 'data_type.required' => '数据类型不能为空',
  70 + 'is_required.required' => '是否必填不能为空',
  71 + ]);
  72 + $data = $logic->saveModuleField();
  73 + $this->response('success',Code::SUCCESS,$data);
  74 + }
  75 +
  76 + /**
  77 + * @remark :删除字段
  78 + * @name :delModuleField
  79 + * @author :lyh
  80 + * @method :post
  81 + * @time :2024/8/7 17:10
  82 + */
  83 + public function delModuleField(ExtensionModuleFieldLogic $logic){
  84 + $this->request->validate([
  85 + 'filed_id'=>'required',
  86 + ],[
  87 + 'filed_id.required' => '字段id不能为空',
  88 + ]);
  89 + $logic->delModuleField();
  90 + $this->response('success');
  91 + }
  92 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtensionModuleLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/7 15:48
  8 + */
  9 +
  10 +namespace App\Http\Logic\Aside\ExtensionModule;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\ExtentModule\ExtensionModule;
  14 +use App\Models\ExtentModule\ExtensionModuleField;
  15 +
  16 +class ExtensionModuleLogic extends BaseLogic
  17 +{
  18 + public function __construct()
  19 + {
  20 + parent::__construct();
  21 + $this->model = new ExtensionModule();
  22 + $this->param = $this->requestAll;
  23 + }
  24 +
  25 + /**
  26 + * @remark :保存数据
  27 + * @name :saveExtensionModule
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2024/8/7 15:50
  31 + */
  32 + public function saveExtensionModule(){
  33 + //查看数据是否存在
  34 + if(isset($this->param['id']) && !empty($this->param['id'])){
  35 + $info = $this->model->read(['title'=>$this->param['title'],'id'=>['!=',$this->param['id']]]);
  36 + }else{
  37 + $info = $this->model->read(['title'=>$this->param['title']]);
  38 + }
  39 + if($info !== false){
  40 + $this->fail('当前拓展数据名称已存在');
  41 + }
  42 + $this->param['data'] = empty($this->param['data']) ? null : json_encode($this->param['data']);
  43 + if(isset($this->param['id']) && !empty($this->param['id'])){
  44 + $id = $this->param['id'];
  45 + $this->model->edit($this->param,['id'=>$id]);
  46 + }else{
  47 + $id = $this->model->addReturnId($this->param);
  48 + }
  49 + return $this->success(['id'=>$id]);
  50 + }
  51 +
  52 + /**
  53 + * @remark :删除扩展数据模块
  54 + * @name :delExtensionModule
  55 + * @author :lyh
  56 + * @method :post
  57 + * @time :2024/8/7 16:07
  58 + */
  59 + public function delExtensionModule(){
  60 + $moduleFiledModel = new ExtensionModuleField();
  61 + $info = $moduleFiledModel->read(['module_id'=>$this->param['id']]);
  62 + if($info !== false){
  63 + $this->fail('请先删除当前模块的字段,在进行删除');
  64 + }
  65 + $this->model->del(['id'=>$this->param['id']]);
  66 + return $this->success();
  67 + }
  68 +}
@@ -149,7 +149,10 @@ class CustomTemplateLogic extends BaseLogic @@ -149,7 +149,10 @@ class CustomTemplateLogic extends BaseLogic
149 } 149 }
150 } 150 }
151 $this->editCustomRoute($this->param['url']); 151 $this->editCustomRoute($this->param['url']);
152 - unset($this->param['html'],$this->param['html_style']); 152 + $this->param['is_visualization'] = isset($this->param['is_visualization']) ? $this->param['is_visualization'] : 0;
  153 + if($this->param['is_visualization'] == 0 || $this->param['is_visualization'] == 1){
  154 + unset($this->param['html'],$this->param['html_style']);
  155 + }
153 $this->model->edit($this->param,['id'=>$id]); 156 $this->model->edit($this->param,['id'=>$id]);
154 }else{ 157 }else{
155 if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){ 158 if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtensionModuleFieldLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/7 16:30
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\ExtensionModule;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\ExtentModule\ExtensionModuleField;
  14 +
  15 +class ExtensionModuleFieldLogic extends BaseLogic
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->param = $this->requestAll;
  21 + $this->model = new ExtensionModuleField();
  22 + }
  23 +
  24 + /**
  25 + * @remark :保存字段
  26 + * @name :saveModuleField
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2024/8/7 16:47
  30 + */
  31 + public function saveModuleField(){
  32 + //先查看当前字段是否存在
  33 + if(isset($this->param['id']) && !empty($this->param['id'])){
  34 + $info = $this->model->read(['field_name'=>$this->param['field_name'],'id'=>['!=',$this->param['id']]]);
  35 + }else{
  36 + $info = $this->model->read(['field_name'=>$this->param['field_name']]);
  37 + }
  38 + if($info !== false){
  39 + $this->fail('当前字段名已存在');
  40 + }
  41 + $id = $this->model->addReturnId($this->param);
  42 + return $this->success(['id'=>$id]);
  43 + }
  44 +
  45 + /**
  46 + * @remark :删除字段
  47 + * @name :delModuleField
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2024/8/7 17:14
  51 + */
  52 + public function delModuleField(){
  53 +
  54 + }
  55 +}
@@ -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 + protected $table = 'gl_extension_module';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtensionModuleField.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/7 16:10
  8 + */
  9 +
  10 +namespace App\Models\ExtentModule;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ExtensionModuleField extends Base
  15 +{
  16 + protected $table = 'gl_extension_module_field';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtensionModuleValue.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/7 16:10
  8 + */
  9 +
  10 +namespace App\Models\ExtentModule;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ExtensionModuleValue extends Base
  15 +{
  16 + protected $table = 'gl_extension_module_value';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}