作者 张关杰

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

... ... @@ -39,7 +39,7 @@ class RankWeek extends BaseCommands
LogUtils::info('start rank_data_week:' . count($list));
foreach ($list as $project_id => $api_no) {
$rankDataLogic = new RankDataLogic();
$rankDataLogic->syncRankWeek($api_no);
$rankDataLogic->syncRankWeek($api_no, true);
}
return true;
... ...
... ... @@ -167,13 +167,25 @@ class UpdateSeoTdk extends Command
$ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray();
$ai_commands = Arr::setValueToKey($ai_commands, 'key');
foreach ($this->maps as $table => $map) {
$update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0];
$total_page = DB::connection('custom_mysql')->table($table)->count();
$update[$table] = ['total_page'=>$total_page, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0];
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table($table)->select('id')->get();
$list = DB::connection('custom_mysql')->table($table)
->where(function ($query) use ($table, $map){
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].'") = ""');
}
}else{
foreach ($map as $field){
$query->orWhereRaw($field . " IS NULL OR ".$field." = ''");
}
}
})->select('id')->get();
if (!empty($list)) {
$list = $list->toArray();
foreach ($list as $v) {
$update[$table]['total_page']++;
$v = (array)$v;
//缓存 在处理的项目数据 id
... ...
... ... @@ -36,7 +36,11 @@ class UpdateSeoTdkCrontab extends Command
{
$project_ids = Project::where('type', Project::TYPE_TWO)->pluck('id')->toArray();
foreach ($project_ids as $project_id){
ProjectUpdateTdk::add_task($project_id);
try {
ProjectUpdateTdk::add_task($project_id);
}catch (\Exception $e){
}
}
}
... ...
... ... @@ -61,7 +61,8 @@ class WebTrafficSpecial extends Command
* @var array
*/
protected $projects = [
509 => 30
509 => 30,
79 => 20,
];
... ...
... ... @@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel
$schedule->command('rank_data_external_links')->dailyAt('18:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
$schedule->command('rank_data_indexed_pages')->dailyAt('07:30')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次
$schedule->command('rank_data_recomm_domain')->dailyAt('07:40')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
$schedule->command('rank_data_week')->dailyAt('08:30')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
$schedule->command('rank_data_week')->weeklyOn([1,2], '08:300')->withoutOverlapping(1); // 排名数据,每周一、二早上执行一次
// $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
// $schedule->command('count')->dailyAt('00:30')->withoutOverlapping(1); //每天凌晨1点执行一次
$schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
... ... @@ -43,7 +43,7 @@ class Kernel extends ConsoleKernel
$schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
// $schedule->command('update_progress')->everyThirtyMinutes()->withoutOverlapping(1);//监控更新
$schedule->command('update_seo_tdk_crontab')->dailyAt('00:00')->withoutOverlapping(1); //更新上线项目TDK
$schedule->command('update_seo_tdk_crontab')->dailyAt('20:00')->withoutOverlapping(1); //更新上线项目TDK
// $schedule->command('website_data')->dailyAt('01:00')->withoutOverlapping(1); // 向AICC推送数据
// $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件
$schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
... ...
... ... @@ -27,21 +27,21 @@ class QuanqiusouApi
*/
public function getSiteRes()
{
$key = 'quanqiusou_api_site_res_' . date('Y-m-d');
$res = Cache::get($key);
if (!$res) {
// $key = 'quanqiusou_api_site_res_' . date('Y-m-d');
// $res = Cache::get($key);
// if (!$res) {
$api_url = $this->url . '/google-rank/echo_site_res.php';
try {
$res = HttpUtils::get($api_url, []);
if($res){
$res = Arr::s2a($res);
Cache::put($key, $res, 2 * 3600);
// Cache::put($key, $res, 2 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('获取站点收录页面数', [], $e);
return false;
}
}
// }
return $res;
}
... ...
... ... @@ -10,10 +10,14 @@
namespace App\Http\Controllers\Aside\Com;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Country as CountryModel;
use App\Models\Project\DeployBuild;
use App\Models\WebSetting\WebLanguage;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
/**
... ... @@ -55,4 +59,23 @@ class CNoticeController extends BaseController
$this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
}
/**
* @remark :获取当前项目选中的语种
* @name :getCountry
* @author :lyh
* @method :post
* @time :2023/9/12 15:20
*/
public function getCountry(){
$countryModel = new CountryModel();
$info = $countryModel->read(['project_id'=>$this->param['project_id']],['id','country_lists']);
$ids = [];
if($info !== false){
$ids = explode(',',$info['country_lists']);
}
$languageModel = new WebLanguage();
//根据排序查询选中的小语种
$lists = $languageModel->whereIn('id', $ids)->orderByRaw(DB::raw("FIND_IN_SET(id,'" . implode(',', $ids) . "'" . ')'))->get()->toArray();
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -40,7 +40,11 @@ class UpdateController extends BaseController
], [
'project_id.required' => 'project_id不能为空',
]);
ProjectUpdateTdk::add_task($this->param['project_id']);
try {
ProjectUpdateTdk::add_task($this->param['project_id']);
}catch (\Exception $e){
$this->fail($e->getMessage());
}
$this->response('任务添加成功');
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Logic\Aside\Domain;
use App\Http\Logic\Aside\BaseLogic;
use App\Jobs\EditDomainBt;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\Project\CountryCustom;
... ... @@ -302,12 +303,13 @@ class DomainInfoLogic extends BaseLogic
];
$this->model->edit($data,['id'=>$this->param['id']]);
//生成证书
$this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? [],$this->param['is_https'] ?? 0);
EditDomainBt::dispatch($this->param['id']);
// $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? [],$this->param['is_https'] ?? 0);
//amp站点生成证书
if($data['amp_status']){
$this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);
}
// if($data['amp_status']){
// $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);
// }
return $this->success();
}
... ...
... ... @@ -47,18 +47,13 @@ class ProductLogic extends BaseLogic
$this->param = $this->handleSaveParam($this->param);
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$seo_mate = (array)$this->model->read(['id'=>$this->param['id']],['seo_mate'])['seo_mate'];
$is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
$six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
if($is_upgrade == 0 || $six_read == 1){
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
}
if(!empty($seo_mate)){
$seo_mate['title'] = $this->param['title'] ?? '';
}
$this->param['seo_mate'] = json_encode($seo_mate,true);
$route = $this->param['route'];
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($this->param, true) . PHP_EOL, FILE_APPEND);
$this->model->edit($this->param,['id'=>$this->param['id']]);
$id = $this->param['id'];
}else{
... ...
<?php
namespace App\Jobs;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class EditDomainBt implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 1; // 可配置任务重试次数
protected $domain_id;
/**
* Create a new job instance.
*
* @param $domain_id
*/
public function __construct($domain_id)
{
$this->domain_id = $domain_id;
}
/**
* Execute the job.
*
* @return bool
*/
public function handle()
{
//获取域名数据
$domain_model = new DomainInfo();
$domain_info = $domain_model->read(['id' => $this->domain_id]);
if ($domain_info === false) {
return $this->output($domain_info['domain'] . ':获取域名数据失败');
}
//获取项目数据
$project_model = new Project();
$project_info = $project_model->read(['id' => $domain_info['project_id']], 'serve_id');
if ($project_info === false) {
return $this->output($domain_info['domain'] . ':获取项目数据失败');
}
//获取服务器数据
$server_model = new ServerConfig();
$server_info = $server_model->read(['id' => $project_info['serve_id']], ['init_domain', 'host']);
if ($server_info === false) {
return $this->output($domain_info['domain'] . ':获取服务器数据失败');
}
//编辑主站
if ($domain_info['type'] == 2) {
$api_url = 'http://' . $server_info['init_domain'] . '/api/setSsl';
$api_param = [
'domain' => $domain_info['domain'],
'private_key' => $domain_info['private_key'],
'cert' => $domain_info['private_cert'],
'rewrite' => $domain_info['extend_config'],
'other_domain' => $domain_info['other_domain'],
'is_https' => $domain_info['is_https']
];
} else {
$api_url = 'http://' . $server_info['init_domain'] . '/api/applySsl';
$api_param = [
'domain' => $domain_info['domain'],
'rewrite' => $domain_info['extend_config'],
'other_domain' => $domain_info['other_domain'],
'is_https' => $domain_info['is_https']
];
}
try {
$rs = HttpUtils::get($api_url, $api_param);
$rs = json_decode($rs, true);
if (isset($rs['status']) && $rs['status'] == 200) {
$this->output($domain_info['domain'] . ':主站编辑成功');
} else {
$this->output($domain_info['domain'] . ':主站编辑失败,原因:' . ($rs['message'] ?? ''));
}
} catch (\Exception | GuzzleException $e) {
$this->output($domain_info['domain'] . ':主站编辑失败,原因:' . $e->getMessage());
}
//编辑amp站
if ($domain_info['amp_status']) {
$api_url_amp = 'http://' . $server_info['init_domain'] . '/api/createSiteAmp';
$api_param_amp = [
'domain' => $domain_info['domain'],
];
if ($domain_info['amp_type'] == 2) {
$api_param_amp['private_key'] = $domain_info['amp_private_key'];
$api_param_amp['cert'] = $domain_info['amp_private_cert'];
}
try {
$rs_amp = HttpUtils::get($api_url_amp, $api_param_amp);
$rs_amp = json_decode($rs_amp, true);
if (isset($rs_amp['status']) && $rs_amp['status'] == 200) {
$this->output($domain_info['domain'] . ':amp站编辑成功');
} else {
$this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . ($rs_amp['message'] ?? ''));
}
} catch (\Exception | GuzzleException $e_amp) {
$this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . $e_amp->getMessage());
}
}
return true;
}
/**
* 输出处理日志
* @param $message
* @return bool
*/
public function output($message)
{
echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
return true;
}
public function failed(\Exception $exception)
{
return $this->output($exception->getMessage());
}
}
... ...
... ... @@ -48,8 +48,8 @@ class QueryListener
$log = $log.' [ RunTime:'.$event->time.'ms ] ';
Log::debug($log);
}
//监听9644这个api_no是TM咋个被改的
if (in_array(9644, $event->bindings) && Str::contains($event->sql, 'update') && Str::contains($event->sql, '`api_no` =')) {
//监听api_no是TM咋个被改的
if (Str::contains($event->sql, 'update') && Str::contains($event->sql, '`api_no` =')) {
//记录debug 根据这个溯源
$trace = debug_backtrace();
$traces = [];
... ...
... ... @@ -27,14 +27,20 @@ class ProjectUpdateTdk extends Base
/**
* 新建任务
* @param $project_id
* @throws \Exception
* @author zbj
* @date 2023/11/9
*/
public static function add_task($project_id){
Redis::lpush('updateSeoTdk', $project_id);
$task = self::where('project_id', $project_id)->where('status', self::STATUS_PENDING)->first();
if($task){
throw new \Exception('该项目有未执行的任务,请勿重复添加');
}
$model = new self();
$model->project_id = $project_id;
$model->save();
Redis::lpush('updateSeoTdk', $project_id);
}
/**
... ...
... ... @@ -15,6 +15,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white');
Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
Route::get('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
Route::get('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
//会员相关
Route::prefix('user')->group(function () {
... ...