作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -594,12 +594,12 @@ if (!function_exists('getFileUrl')) { @@ -594,12 +594,12 @@ if (!function_exists('getFileUrl')) {
594 if(substr($path,0,2) == '//'){ 594 if(substr($path,0,2) == '//'){
595 return 'https:'.$path; 595 return 'https:'.$path;
596 } 596 }
597 -// $file_type = pathinfo($path, PATHINFO_EXTENSION);  
598 -// $fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];  
599 -// if(in_array(strtolower($file_type),$fileTypeArr)){  
600 -// $cdn2 = config('filesystems.disks.cos')['cdn2'];  
601 -// return $cdn2.$path;  
602 -// } 597 + $file_type = pathinfo($path, PATHINFO_EXTENSION);
  598 + $fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
  599 + if(in_array(strtolower($file_type),$fileTypeArr)){
  600 + $cdn2 = config('filesystems.disks.cos')['cdn2'];
  601 + return $cdn2.$path;
  602 + }
603 if($location == 0){ 603 if($location == 0){
604 //v6-file.globalso.com 604 //v6-file.globalso.com
605 $cos = config('filesystems.disks.cos'); 605 $cos = config('filesystems.disks.cos');
@@ -58,9 +58,11 @@ class UpdateController extends BaseController @@ -58,9 +58,11 @@ class UpdateController extends BaseController
58 $this->request->validate([ 58 $this->request->validate([
59 'project_id' => 'required', 59 'project_id' => 'required',
60 'type' => 'required', 60 'type' => 'required',
  61 + 'old_collect' => 'required',
61 ], [ 62 ], [
62 'project_id.required' => 'project_id不能为空', 63 'project_id.required' => 'project_id不能为空',
63 'type.required' => '是否重新采集分类不能为空', 64 'type.required' => '是否重新采集分类不能为空',
  65 + 'old_collect.required' => '现有数据是否重新采集页面不能为空',
64 ]); 66 ]);
65 67
66 $collect_un = UpdateLog::where('project_id', $this->param['project_id'])->where('collect_status', 0)->get(); 68 $collect_un = UpdateLog::where('project_id', $this->param['project_id'])->where('collect_status', 0)->get();
@@ -92,6 +94,8 @@ class UpdateController extends BaseController @@ -92,6 +94,8 @@ class UpdateController extends BaseController
92 } 94 }
93 95
94 try { 96 try {
  97 + if($this->param['old_collect'] == 1){
  98 + //现有数据需要重新采集页面
95 DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'"); 99 DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
96 if ($domain_info) { 100 if ($domain_info) {
97 //已上线项目 101 //已上线项目
@@ -99,6 +103,8 @@ class UpdateController extends BaseController @@ -99,6 +103,8 @@ class UpdateController extends BaseController
99 } else { 103 } else {
100 DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''"); 104 DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
101 } 105 }
  106 + }
  107 +
102 if ($this->param['type'] == 1) { 108 if ($this->param['type'] == 1) {
103 //需要重新采集分类 109 //需要重新采集分类
104 DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category`"); 110 DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category`");
@@ -54,15 +54,22 @@ class DescribeController extends BaseController @@ -54,15 +54,22 @@ class DescribeController extends BaseController
54 $this->response('success'); 54 $this->response('success');
55 } 55 }
56 56
57 - public function delete(Request $request, DescribeLogic $logic) 57 + /**
  58 + * @remark :删除数据
  59 + * @name :delete
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2024/4/12 16:59
  63 + */
  64 + public function delete(DescribeLogic $logic)
58 { 65 {
59 - $request->validate([  
60 - 'ids'=>['required', new Ids()] 66 + $this->request->validate([
  67 + 'ids'=>'required'
61 ],[ 68 ],[
62 'ids.required' => 'ID不能为空' 69 'ids.required' => 'ID不能为空'
63 ]); 70 ]);
64 - $data = $logic->delete($this->param['ids']);  
65 - $this->response('success',Code::SUCCESS,$data); 71 + $logic->describeDel();
  72 + $this->response('success');
66 } 73 }
67 74
68 } 75 }
@@ -85,8 +85,8 @@ class TranslateController extends BaseController @@ -85,8 +85,8 @@ class TranslateController extends BaseController
85 'url.required' => 'url不能为空', 85 'url.required' => 'url不能为空',
86 'alias.required' => 'url不能为空', 86 'alias.required' => 'url不能为空',
87 ]); 87 ]);
88 - $logic->translateSave();  
89 - $this->response('success'); 88 + $rs = $logic->translateSave();
  89 + $this->response('success',Code::SUCCESS,$rs);
90 } 90 }
91 91
92 /** 92 /**
@@ -39,4 +39,23 @@ class DescribeLogic extends BaseLogic @@ -39,4 +39,23 @@ class DescribeLogic extends BaseLogic
39 } 39 }
40 return $this->success(); 40 return $this->success();
41 } 41 }
  42 +
  43 + /**
  44 + * @remark :删除数据
  45 + * @name :del
  46 + * @author :lyh
  47 + * @method :post
  48 + * @time :2024/4/12 16:57
  49 + */
  50 + public function describeDel(){
  51 + if(in_array($this->param['ids'])){
  52 + $rs = $this->model->del(['id'=>['in',$this->param['ids']]]);
  53 + }else{
  54 + $rs = $this->model->del(['id'=>$this->param['ids']]);
  55 + }
  56 + if($rs === false){
  57 + $this->fail('系统错误,请联系管理员');
  58 + }
  59 + return $this->success();
  60 + }
42 } 61 }
@@ -424,8 +424,10 @@ class RankDataLogic extends BaseLogic @@ -424,8 +424,10 @@ class RankDataLogic extends BaseLogic
424 */ 424 */
425 public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){ 425 public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){
426 $without_project_ids = []; //不用处理排名的项目 426 $without_project_ids = []; //不用处理排名的项目
  427 + $without_extension_project_ids = [658]; //是否达标只统计主词的
427 428
428 $first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0; 429 $first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0;
  430 + $first_page_without_extension_num = 0; //不算扩展词在首页的数量
429 431
430 foreach ($data as &$ranks){ 432 foreach ($data as &$ranks){
431 ksort($ranks); 433 ksort($ranks);
@@ -446,6 +448,7 @@ class RankDataLogic extends BaseLogic @@ -446,6 +448,7 @@ class RankDataLogic extends BaseLogic
446 //排名第一页 448 //排名第一页
447 if($last['position'] > 0 && $last['position'] <= 10){ 449 if($last['position'] > 0 && $last['position'] <= 10){
448 $first_page_num ++; 450 $first_page_num ++;
  451 + $last['g'] == 1 && $first_page_without_extension_num++;
449 } 452 }
450 //排名前三页 453 //排名前三页
451 if($last['position'] > 0 && $last['position'] <= 30){ 454 if($last['position'] > 0 && $last['position'] <= 30){
@@ -476,8 +479,14 @@ class RankDataLogic extends BaseLogic @@ -476,8 +479,14 @@ class RankDataLogic extends BaseLogic
476 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num'); 479 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
477 $type = Project::where('id', $project_id)->value('type'); 480 $type = Project::where('id', $project_id)->value('type');
478 $model->is_compliance = 0; 481 $model->is_compliance = 0;
479 - if ($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num) {  
480 - Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num); 482 +
  483 + //是否达标
  484 + $is_compliance = $first_page_num >= $keyword_num;
  485 + if(in_array($project_id, $without_extension_project_ids)){
  486 + $is_compliance = $first_page_without_extension_num >= $keyword_num;
  487 + }
  488 + if ($keyword_num && $type == Project::TYPE_TWO && $is_compliance) {
  489 + Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num . ' - ' . $first_page_without_extension_num);
481 490
482 //项目表更新 491 //项目表更新
483 if (($model->updated_date != date('Y-m-d') || empty($model->is_compliance)) && !$lang) { 492 if (($model->updated_date != date('Y-m-d') || empty($model->is_compliance)) && !$lang) {
@@ -54,13 +54,12 @@ class TranslateLogic extends BaseLogic @@ -54,13 +54,12 @@ class TranslateLogic extends BaseLogic
54 $text_array = $this->getUrlRead($url); 54 $text_array = $this->getUrlRead($url);
55 // 原始校对程序 55 // 原始校对程序
56 $old_key = [];//key值组成数据 56 $old_key = [];//key值组成数据
57 - if($info !== false){  
58 - $data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 57 + $data_read = json_decode($info ? $info['data'] : '',JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
59 foreach ($data_read as $k => $v){ 58 foreach ($data_read as $k => $v){
  59 + $k = urldecode($k);
60 $old_key[] = $k; 60 $old_key[] = $k;
61 $data[] = [$k => $v]; 61 $data[] = [$k => $v];
62 } 62 }
63 - }  
64 $arr2 = []; 63 $arr2 = [];
65 foreach ($text_array as $val) { 64 foreach ($text_array as $val) {
66 if (FALSE == in_array($val, $old_key)){ 65 if (FALSE == in_array($val, $old_key)){
@@ -251,7 +250,7 @@ class TranslateLogic extends BaseLogic @@ -251,7 +250,7 @@ class TranslateLogic extends BaseLogic
251 } 250 }
252 $this->param['data'] = $data; 251 $this->param['data'] = $data;
253 } 252 }
254 - try { 253 +// try {
255 $info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); 254 $info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
256 if($info === false){ 255 if($info === false){
257 $param = [ 256 $param = [
@@ -262,21 +261,21 @@ class TranslateLogic extends BaseLogic @@ -262,21 +261,21 @@ class TranslateLogic extends BaseLogic
262 'alias'=>$this->param['alias'], 261 'alias'=>$this->param['alias'],
263 ]; 262 ];
264 $param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 263 $param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
265 - $this->model->add($param); 264 + $rs = $this->model->add($param);
266 }else{ 265 }else{
267 if(!empty($data)){ 266 if(!empty($data)){
268 $data = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 267 $data = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
269 - $this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'project_id'=>$this->user['project_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]); 268 + $rs = $this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'project_id'=>$this->user['project_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
270 } 269 }
271 } 270 }
272 //写日志 271 //写日志
273 $userLogModel = new UserLog(); 272 $userLogModel = new UserLog();
274 $userLogModel->add(['model'=>'translate/save','remark'=>json_encode($this->param,true),'type'=>0,'operator_id'=>$this->user['id'],'project_id'=>$this->user['project_id']]); 273 $userLogModel->add(['model'=>'translate/save','remark'=>json_encode($this->param,true),'type'=>0,'operator_id'=>$this->user['id'],'project_id'=>$this->user['project_id']]);
275 - }catch (\Exception $e){  
276 - $this->fail('系统错误请联系管理员');  
277 - } 274 +// }catch (\Exception $e){
  275 +// $this->fail('系统错误请联系管理员');
  276 +// }
278 $this->handleRoute($this->param['url']); 277 $this->handleRoute($this->param['url']);
279 - return $this->success(); 278 + return $this->success($rs);
280 } 279 }
281 280
282 /** 281 /**