作者 张关杰

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

... ... @@ -594,12 +594,12 @@ if (!function_exists('getFileUrl')) {
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
// $file_type = pathinfo($path, PATHINFO_EXTENSION);
// $fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
// if(in_array(strtolower($file_type),$fileTypeArr)){
// $cdn2 = config('filesystems.disks.cos')['cdn2'];
// return $cdn2.$path;
// }
$file_type = pathinfo($path, PATHINFO_EXTENSION);
$fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
if(in_array(strtolower($file_type),$fileTypeArr)){
$cdn2 = config('filesystems.disks.cos')['cdn2'];
return $cdn2.$path;
}
if($location == 0){
//v6-file.globalso.com
$cos = config('filesystems.disks.cos');
... ...
... ... @@ -58,9 +58,11 @@ class UpdateController extends BaseController
$this->request->validate([
'project_id' => 'required',
'type' => 'required',
'old_collect' => 'required',
], [
'project_id.required' => 'project_id不能为空',
'type.required' => '是否重新采集分类不能为空',
'old_collect.required' => '现有数据是否重新采集页面不能为空',
]);
$collect_un = UpdateLog::where('project_id', $this->param['project_id'])->where('collect_status', 0)->get();
... ... @@ -92,13 +94,17 @@ class UpdateController extends BaseController
}
try {
DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
if ($domain_info) {
//已上线项目
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = ''");
} else {
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
if($this->param['old_collect'] == 1){
//现有数据需要重新采集页面
DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
if ($domain_info) {
//已上线项目
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = ''");
} else {
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
}
}
if ($this->param['type'] == 1) {
//需要重新采集分类
DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category`");
... ...
... ... @@ -54,15 +54,22 @@ class DescribeController extends BaseController
$this->response('success');
}
public function delete(Request $request, DescribeLogic $logic)
/**
* @remark :删除数据
* @name :delete
* @author :lyh
* @method :post
* @time :2024/4/12 16:59
*/
public function delete(DescribeLogic $logic)
{
$request->validate([
'ids'=>['required', new Ids()]
$this->request->validate([
'ids'=>'required'
],[
'ids.required' => 'ID不能为空'
]);
$data = $logic->delete($this->param['ids']);
$this->response('success',Code::SUCCESS,$data);
$logic->describeDel();
$this->response('success');
}
}
... ...
... ... @@ -85,8 +85,8 @@ class TranslateController extends BaseController
'url.required' => 'url不能为空',
'alias.required' => 'url不能为空',
]);
$logic->translateSave();
$this->response('success');
$rs = $logic->translateSave();
$this->response('success',Code::SUCCESS,$rs);
}
/**
... ...
... ... @@ -39,4 +39,23 @@ class DescribeLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :删除数据
* @name :del
* @author :lyh
* @method :post
* @time :2024/4/12 16:57
*/
public function describeDel(){
if(in_array($this->param['ids'])){
$rs = $this->model->del(['id'=>['in',$this->param['ids']]]);
}else{
$rs = $this->model->del(['id'=>$this->param['ids']]);
}
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -424,8 +424,10 @@ class RankDataLogic extends BaseLogic
*/
public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){
$without_project_ids = []; //不用处理排名的项目
$without_extension_project_ids = [658]; //是否达标只统计主词的
$first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0;
$first_page_without_extension_num = 0; //不算扩展词在首页的数量
foreach ($data as &$ranks){
ksort($ranks);
... ... @@ -446,6 +448,7 @@ class RankDataLogic extends BaseLogic
//排名第一页
if($last['position'] > 0 && $last['position'] <= 10){
$first_page_num ++;
$last['g'] == 1 && $first_page_without_extension_num++;
}
//排名前三页
if($last['position'] > 0 && $last['position'] <= 30){
... ... @@ -476,8 +479,14 @@ class RankDataLogic extends BaseLogic
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
$type = Project::where('id', $project_id)->value('type');
$model->is_compliance = 0;
if ($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num) {
Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num);
//是否达标
$is_compliance = $first_page_num >= $keyword_num;
if(in_array($project_id, $without_extension_project_ids)){
$is_compliance = $first_page_without_extension_num >= $keyword_num;
}
if ($keyword_num && $type == Project::TYPE_TWO && $is_compliance) {
Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num . ' - ' . $first_page_without_extension_num);
//项目表更新
if (($model->updated_date != date('Y-m-d') || empty($model->is_compliance)) && !$lang) {
... ...
... ... @@ -54,12 +54,11 @@ class TranslateLogic extends BaseLogic
$text_array = $this->getUrlRead($url);
// 原始校对程序
$old_key = [];//key值组成数据
if($info !== false){
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
foreach ($data_read as $k => $v){
$old_key[] = $k;
$data[] = [$k => $v];
}
$data_read = json_decode($info ? $info['data'] : '',JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
foreach ($data_read as $k => $v){
$k = urldecode($k);
$old_key[] = $k;
$data[] = [$k => $v];
}
$arr2 = [];
foreach ($text_array as $val) {
... ... @@ -251,7 +250,7 @@ class TranslateLogic extends BaseLogic
}
$this->param['data'] = $data;
}
try {
// try {
$info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
if($info === false){
$param = [
... ... @@ -262,21 +261,21 @@ class TranslateLogic extends BaseLogic
'alias'=>$this->param['alias'],
];
$param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$this->model->add($param);
$rs = $this->model->add($param);
}else{
if(!empty($data)){
$data = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$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']]);
$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']]);
}
}
//写日志
$userLogModel = new UserLog();
$userLogModel->add(['model'=>'translate/save','remark'=>json_encode($this->param,true),'type'=>0,'operator_id'=>$this->user['id'],'project_id'=>$this->user['project_id']]);
}catch (\Exception $e){
$this->fail('系统错误请联系管理员');
}
// }catch (\Exception $e){
// $this->fail('系统错误请联系管理员');
// }
$this->handleRoute($this->param['url']);
return $this->success();
return $this->success($rs);
}
/**
... ...