作者 赵彬吉
... ... @@ -9,16 +9,9 @@
namespace App\Console\Commands\UpgradeKeyword;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -56,7 +49,6 @@ class UpdateKeyword extends Command
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
... ... @@ -64,6 +56,7 @@ class UpdateKeyword extends Command
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
return true;
}
... ...
... ... @@ -47,7 +47,7 @@ class Kernel extends ConsoleKernel
// $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::手机号码同步 每天执行一次
$schedule->command('update_keyword_route')->dailyAt('01:00')->withoutOverlapping(1); //升级项目--清除路由相同的关键字
$schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
// 每日推送视频任务
$schedule->command('video_task')->dailyAt('02:30')->withoutOverlapping(1);
... ...
<?php
/**
* @remark :
* @name :CNoticeController.php
* @author :lyh
* @method :post
* @time :2023/9/12 10:04
*/
namespace App\Http\Controllers\Aside\Com;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Domain\DomainInfo;
use App\Models\Project\DeployBuild;
use Illuminate\Http\Request;
/**
* @remark :通知C端
* @name :CNoticeController
* @author :lyh
* @method :post
* @time :2023/9/12 10:38
*/
class CNoticeController extends BaseController
{
/**
* 更新通知C端
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function sendNotify(Request $request)
{
//获取当前项目的域名
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]);
if($domainInfo === false){
//获取测试域名
$deployBuildModel = new DeployBuild();
$buildInfo = $deployBuildModel->read(['project_id'=>$this->param['project_id']]);
$this->param['domain'] = $buildInfo['test_domain'];
}else{
$this->param['domain'] = 'https://'.$domainInfo['domain'].'/';
}
$url = $this->param['domain'].'api/update_page/';
$param = [
'project_id' => $this->param['project_id'],
'type' => intval($request->input('type', 1)),
'route' => intval($request->input('page', 1)),
'url' => $request->input('url', []),
'language'=> $request->input('language', []),
];
http_post($url, json_encode($param));
$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,16 +47,12 @@ 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'];
$this->model->edit($this->param,['id'=>$this->param['id']]);
$id = $this->param['id'];
... ...
<?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());
}
}
... ...
... ... @@ -14,6 +14,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white');
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::prefix('user')->group(function () {
... ...