作者 刘锟

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

... ... @@ -143,7 +143,6 @@ class Count extends Command
}
}
}
//加上其他询盘
ProjectServer::useProject($project_id);
$arr['inquiry_num'] += InquiryFormData::getCount();
... ... @@ -155,8 +154,6 @@ class Count extends Command
$countryArr[$v1['country']] = $v1['count'];
}
}
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 20, true);
$arr['country'] = json_encode($top20);
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Console\Commands\Project;
use App\Helper\Translate;
use App\Models\Com\NoticeLog;
use App\Models\Product\Keyword;
use App\Models\RouteMap\RouteMap;
... ... @@ -80,7 +81,12 @@ class InitKeyword extends Command
foreach ($keyword as $val) {
$this->output(' keywordID: ' . $val->id . ', title: ' . $val->title);
try {
$route = RouteMap::setRoute($val['title'],RouteMap::SOURCE_PRODUCT_KEYWORD, $val->id, $notice['data']['project_id']);
if(contains_russian($val['title'])){
$title = Translate::tran($val['title'], 'en');
}else{
$title = $val['title'];
}
$route = RouteMap::setRoute($title,RouteMap::SOURCE_PRODUCT_KEYWORD, $val->id, $notice['data']['project_id']);
$val->route = $route;
$val->save();
} catch (\Exception $e) {
... ...
... ... @@ -199,7 +199,7 @@ class UpdateSeoTdk extends Command
if($table == 'gl_product'){
foreach ($map as $field){
$field_arr = explode('.', $field);
$query->orWhereRaw('JSON_EXTRACT('.$field_arr[0].', "$.'.$field_arr[1].'") IS NULL OR JSON_EXTRACT('.$field_arr[0].', "$.'.$field_arr[1].'") = ""');
$query->orWhereRaw('JSON_CONTAINS('.$field_arr[0].', "null", "$.'.$field_arr[1].'") OR JSON_EXTRACT('.$field_arr[0].', "$.'.$field_arr[1].'") = ""');
}
}else{
foreach ($map as $field){
... ...
... ... @@ -16,8 +16,8 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// 每日更新最新模块
// $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
// $schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
$schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
$schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
// $schedule->command('inspire')->hourly();
$schedule->command('remain_day')->dailyAt('09:00')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
... ...
... ... @@ -119,6 +119,45 @@ if (!function_exists('http_get')) {
}
}
if (!function_exists('curl_get')) {
function curl_get($url,$is_array=true)
{
$header = array(
'Expect:',
'Content-Type: application/json; charset=utf-8'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 'all');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$content = curl_exec($ch);
curl_close($ch);
return $is_array ? json_decode($content, true) : $content;
}
}
/**
* @remark :判断是否为俄语
* @name :contains_russian
* @author :lyh
* @method :post
* @time :2024/6/5 10:38
*/
function contains_russian($text) {
// 使用正则表达式检查是否包含俄语字符
return preg_match('/[\x{0400}-\x{04FF}]/u', $text) > 0;
}
if (!function_exists('curl_c')) {
/**
* @param $url
... ... @@ -148,7 +187,6 @@ if (!function_exists('curl_c')) {
$content = curl_exec($ch);
$http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
if($http_code == 200){
return $is_array ? json_decode($content, true) : $content;
}else{
... ...
... ... @@ -40,7 +40,8 @@ class PrivateController extends BaseController
$result = Project::select($field)->leftJoin('gl_project_deploy_optimize as b', 'gl_project.id', '=', 'b.project_id')
->leftJoin('gl_project_online_check as c', 'gl_project.id', '=', 'c.project_id')
->leftJoin('gl_domain_info as d', 'gl_project.id', '=', 'd.project_id')
->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR])
->where('gl_project.type', Project::TYPE_TWO)
->where('gl_project.extend_type', 0) // 是否续费是由extend_type字段控制
->where(function ($subQuery) {
$subQuery->orwhere('c.qa_status', OnlineCheck::STATUS_ONLINE_TRUE)->orwhere('gl_project.is_upgrade', Project::IS_UPGRADE_TRUE);
})
... ...
... ... @@ -60,7 +60,7 @@ class KeywordVideoController extends BaseController
* @time :2023/8/18 10:58
*/
public function searchParam(&$query){
if(isset($this->map['title']) && is_array($this->map['title'])){
if(isset($this->map['title'])){
$query->where('gl_project.title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['status'])){
... ... @@ -108,7 +108,6 @@ class KeywordVideoController extends BaseController
if($info === false){
$this->response('请先设置域名',Code::SYSTEM_ERROR);
}
$this->param['num'] = $this->param['number'];
$rs = $keywordModel->add($this->param);
if($rs === false){
$this->response('添加失败',Code::SYSTEM_ERROR);
... ...
... ... @@ -262,7 +262,7 @@ class OptimizeController extends BaseController
if(isset($this->map['test_domain']) && !empty($this->map['test_domain'])){
$query = $query->where('gl_project_deploy_build.test_domain','like','%'.$this->map['test_domain'].'%');
}
$query = $query->whereIn('gl_project.type',[2,4]);//TODO::2,4代表优化项目
$query = $query->where('gl_project.type',2);//TODO::2,4代表优化项目; 2024-06-05修改项目中台只显示为类型为2
$query->where(function ($subQuery) {
$subQuery->orwhere('gl_project_online_check.qa_status',1)->orwhere('gl_project.is_upgrade',1);
});
... ...
... ... @@ -63,8 +63,7 @@ class ProjectController extends BaseController
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id')
->leftJoin('gl_web_setting_template', 'gl_project.id', '=', 'gl_web_setting_template.project_id')
->where('gl_project.delete_status',Project::TYPE_ZERO)
->where('gl_project.extend_type',Project::TYPE_ZERO);
->where('gl_project.delete_status',Project::TYPE_ZERO);
$query = $this->searchParam($query);
$query = $this->orderByList($query);
$lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
... ... @@ -368,7 +367,7 @@ class ProjectController extends BaseController
$item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN);
$item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]);
$item['collect_time'] = $item['is_upgrade'] ? UpdateLog::getProjectUpdate($item['id']) : '';
return $item;
}
... ...
... ... @@ -87,6 +87,7 @@ class MonthReportController extends BaseController
])->count();
$info['service_duration'] = $this->user['service_duration'];//服务天数
$info['ip_total'] = (new Visit())->count();//ip总数
$info['remain_day'] = $this->user['remain_day'];//剩余服务天数
$info['speed'] = round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2);
$this->response('success',Code::SUCCESS,$info);
... ...
... ... @@ -257,4 +257,25 @@ class BaseController extends Controller
}
return 0;
}
/**
* @remark :批量通知C端
* @name :sendHttpC
* @author :lyh
* @method :post
* @time :2024/6/6 10:26
*/
public function sendHttpC($url = []){
//其他服务器:请求对应C端接口
$c_url = $this->user['domain'].'api/update_page/';
$param = [
'project_id' => $this->user['project_id'],
'type' => 1,
'route' => 3,
'url' => $url,
'language'=> [],
'is_sitemap' => 0
];
return http_post($c_url, json_encode($param));
}
}
... ...
... ... @@ -313,7 +313,7 @@ class NewsController extends BaseController
],[
'keyword.required' => 'keyword不能为空',
]);
$data = curl_c('http://gnews.globalso.com/gnews_news.php?keyword='.$this->param['keyword'],false);
$data = curl_get('http://gnews.globalso.com/gnews_news.php?keyword='.$this->param['keyword'],true);
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -218,8 +218,17 @@ class KeywordController extends BaseController
'title.max' => '批量操作不能超过500条数据'
]);
$keywordModel = new Keyword();
foreach ($this->param['title'] as $v){
$keywordModel->edit(['is_video_keyword'=>$this->param['is_video_keyword']],['title'=>$v]);
$rs = $keywordModel->edit(['is_video_keyword'=>$this->param['is_video_keyword']],['title'=>['in',$this->param['title']]]);
if($rs === false){
$this->fail('编辑失败,请联系管理员');
}
if($this->param['is_video_keyword'] == 1){
$url = [];
$keywordList = $keywordModel->list(['title'=>['in',$this->param['title']]],'id',['id','route','is_video_keyword']);
foreach ($keywordList as $v){
$url[] = $v['route'];
}
$this->sendHttpC($url);
}
$this->response('success');
}
... ...
... ... @@ -32,10 +32,8 @@ class BTemplateLabelController extends BaseController
*/
public function getUserLists(TemplateLabel $templateLabel){
$this->request->validate([
'template_id'=>'required',
'type'=>'required',
],[
'template_id.required' => '模版id不能为空',
'type.required' => '模版类型不能为空不能为空',
]);
$data = $templateLabel->list($this->map);
... ...
... ... @@ -8,6 +8,7 @@ use App\Http\Logic\Bside\BTemplate\BTemplateModuleLogic;
use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic;
use App\Models\Template\BModuleProject;
use App\Models\Template\TemplateLabel;
use App\Models\Template\TemplateModule;
/**
* @remark :左侧模块管理
... ... @@ -29,6 +30,8 @@ class BTemplateModuleController extends BaseController
$this->map['test_model'] = ['in',[0,1]];
$this->map['project_id'] = 0;
}
$templateLabel = new TemplateLabel();
$this->searchLabelName($templateLabel);
$data = [];
$list = $bTemplateModuleLogic->ModuleList($this->map,$this->order);
$data['list'] = $list;
... ... @@ -38,6 +41,22 @@ class BTemplateModuleController extends BaseController
}
/**
* @remark :搜索label
* @name :searchLabelName
* @author :lyh
* @method :post
* @time :2024/6/3 11:11
*/
public function searchLabelName($templateLabel){
if(isset($this->map['label_name']) && !empty($this->map['label_name'])){
$id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%'],'type'=>2])->pluck('template_id')->toArray();
$this->map['id'] = ['in',$id_arr];
unset($this->map['label_name']);
}
return true;
}
/**
* @remark :获取详情
* @name :read
* @author :lyh
... ... @@ -77,7 +96,8 @@ class BTemplateModuleController extends BaseController
],[
'id.required' => 'id不能为空',
]);
$this->model->where('id', $this->param['id'])->increment('number');
$moduleModel = new TemplateModule();
$moduleModel->where('id', $this->param['id'])->increment('number');
$this->response('success');
}
}
... ...
... ... @@ -284,17 +284,19 @@ class ProjectLogic extends BaseLogic
$deploy_optimize['special'] = !empty($deploy_optimize['special']) ? ','.trim($deploy_optimize['special'],',').',' : '';
//是否更新了api_no
$api_no = DeployOptimize::where('id', $deploy_optimize['id'])->value('api_no');
if($api_no != $deploy_optimize['api_no']){
if($deploy_optimize['api_no']){
NoticeLog::createLog(NoticeLog::TYPE_RANK_DATA, ['api_no' => $deploy_optimize['api_no'] ?: 0]);
}else{
//清空已有排名数据
RankData::where('project_id', $deploy_optimize['project_id'])->delete();
ExternalLinks::where('project_id', $deploy_optimize['project_id'])->delete();
IndexedPages::where('project_id', $deploy_optimize['project_id'])->delete();
RecommDomain::where('project_id', $deploy_optimize['project_id'])->delete();
Speed::where('project_id', $deploy_optimize['project_id'])->delete();
RankWeek::where('project_id', $deploy_optimize['project_id'])->delete();
if(!empty($api_no)){
if($api_no != $deploy_optimize['api_no']){
if($deploy_optimize['api_no']){
NoticeLog::createLog(NoticeLog::TYPE_RANK_DATA, ['api_no' => $deploy_optimize['api_no'] ?: 0]);
}else{
//清空已有排名数据
RankData::where('project_id', $deploy_optimize['project_id'])->delete();
ExternalLinks::where('project_id', $deploy_optimize['project_id'])->delete();
IndexedPages::where('project_id', $deploy_optimize['project_id'])->delete();
RecommDomain::where('project_id', $deploy_optimize['project_id'])->delete();
Speed::where('project_id', $deploy_optimize['project_id'])->delete();
RankWeek::where('project_id', $deploy_optimize['project_id'])->delete();
}
}
}
$deployOptimizeModel->edit($deploy_optimize,['id'=>$deploy_optimize['id']]);
... ...
... ... @@ -9,7 +9,7 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Aside\BaseLogic;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Template\TemplateLabel;
/**
... ... @@ -49,7 +49,7 @@ class BTemplateLabelLogic extends BaseLogic
}else{
$info = $this->model->read(['name'=>$this->param['name'],'template_id'=>$this->param['template_id']],['id']);
if($info === false){
$this->param['manager_id'] = $this->manager['id'];
$this->param['manager_id'] = $this->user['manager_id'] ?? 0;
$id = $this->model->addReturnId($this->param);
}else{
$id = $info['id'];
... ...
... ... @@ -29,7 +29,7 @@ class BTemplateModuleLogic extends BaseLogic
$list = $this->model->list($map,$order,$filed);
$templateLabel = new TemplateLabel();
foreach ($list as $k => $v){
$v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>2],'id',['id','name'],'desc',5);
$v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>2],'id',['id','name'],'desc');
$list[$k] = $v;
}
return $this->success($list);
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Template\BModuleProject;
use App\Models\Template\TemplateLabel;
use App\Models\Template\TemplateModule;
class BTemplateModuleProjectLogic extends BaseLogic
... ... @@ -33,6 +34,11 @@ class BTemplateModuleProjectLogic extends BaseLogic
$map['deleted_status'] = 0;
$map['project_id'] = $this->user['project_id'];
$lists = $this->model->list($map,$order,$filed);
$templateLabel = new TemplateLabel();
foreach ($lists as $k => $v){
$v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>2],'id',['id','name'],'desc');
$lists[$k] = $v;
}
return $this->success($lists);
}
... ...
... ... @@ -186,4 +186,25 @@ class BaseLogic extends Logic
}
return $this->success();
}
/**
* @remark :批量通知C端
* @name :sendHttpC
* @author :lyh
* @method :post
* @time :2024/6/6 10:26
*/
public function sendHttpC($url = []){
//其他服务器:请求对应C端接口
$c_url = $this->user['domain'].'api/update_page/';
$param = [
'project_id' => $this->user['project_id'],
'type' => 1,
'route' => 3,
'url' => $url,
'language'=> [],
'is_sitemap' => 0
];
return http_post($c_url, json_encode($param));
}
}
... ...
... ... @@ -61,9 +61,15 @@ class KeywordLogic extends BaseLogic
if($info !== false){
$this->fail('当前title已存在');
}
//TODO::不能修改路由
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_KEYWORD, $this->param['id'], $this->user['project_id']);
$this->param['route'] = $route;
//todo::通知C端生成
if(isset($this->param['is_video_keyword']) && ($this->param['is_video_keyword'] == 1)){
$info = $this->model->read(['id'=>$this->param['id']],['id','is_video_keyword','video']);
if(($info['is_video_keyword'] != $this->param['is_video_keyword']) && ($info['video'] != null || $info['video'] != '')){
$this->sendHttpC([$route]);
}
}
$this->model->edit($this->param,['id'=>$this->param['id']]);
$data = ['id'=>$this->param['id']];
}else{
... ... @@ -125,10 +131,11 @@ class KeywordLogic extends BaseLogic
}
/**
* 批量添加关键词任务, 异步处理
* @return array
* @throws BsideGlobalException
* @throws \App\Exceptions\AsideGlobalException
* @remark :批量添加关键词任务, 异步处理
* @name :batchAdd
* @author :lyh
* @method :post
* @time :2024/6/6 10:27
*/
public function batchAdd(){
try {
... ...
... ... @@ -482,7 +482,7 @@ class RankDataLogic extends BaseLogic
$model = new RankData();
}
//g-top方案达标天数
$this->g_top_plan($project_id,$first_page_num);
$this->g_top_plan($project_id,$first_page_without_extension_num);
//保证关键词数
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
$type = Project::where('id', $project_id)->value('type');
... ...
... ... @@ -263,7 +263,7 @@ class TranslateLogic extends BaseLogic
if($info === false){
$sourceInfo = $this->getRouteSource($sendData['new_route']);
$param = [
'type'=>$this->param['type'],
'type'=>$this->param['type'] ?? 1,
'project_id'=>$this->user['project_id'],
'url'=>str_replace_url($this->param['url']),
'language_id'=>$this->param['language_id'],
... ...
... ... @@ -55,10 +55,11 @@ class RouteMap extends Base
public static function generateRoute($title, $source, $source_id, $project_id){
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
$title = Translate::tran($title, 'en');
}elseif(preg_match('/^[\x{0400}-\x{04FF}]+$/u', $title)){
$title = Translate::tran($title, 'en');
}else{
if(contains_russian($title)){
$title = Translate::tran($title, 'en');
}
}
$i=1;
$sign = generateRoute($title);
$length = strlen($sign);
... ...