作者 赵彬吉
@@ -9,16 +9,9 @@ @@ -9,16 +9,9 @@
9 9
10 namespace App\Console\Commands\UpgradeKeyword; 10 namespace App\Console\Commands\UpgradeKeyword;
11 11
12 -use App\Helper\Arr;  
13 -use App\Helper\Translate;  
14 -use App\Models\CustomModule\CustomModuleCategory;  
15 -use App\Models\CustomModule\CustomModuleContent;  
16 -use App\Models\Product\CategoryRelated;  
17 use App\Models\Product\Keyword; 12 use App\Models\Product\Keyword;
18 -use App\Models\Product\Product;  
19 use App\Models\Project\Project; 13 use App\Models\Project\Project;
20 use App\Models\RouteMap\RouteMap; 14 use App\Models\RouteMap\RouteMap;
21 -use App\Models\Template\BTemplate;  
22 use App\Services\ProjectServer; 15 use App\Services\ProjectServer;
23 use Illuminate\Console\Command; 16 use Illuminate\Console\Command;
24 use Illuminate\Support\Facades\DB; 17 use Illuminate\Support\Facades\DB;
@@ -56,7 +49,6 @@ class UpdateKeyword extends Command @@ -56,7 +49,6 @@ class UpdateKeyword extends Command
56 public function handle(){ 49 public function handle(){
57 $projectModel = new Project(); 50 $projectModel = new Project();
58 $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]); 51 $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]);
59 -  
60 foreach ($list as $v){ 52 foreach ($list as $v){
61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 53 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
62 ProjectServer::useProject($v['id']); 54 ProjectServer::useProject($v['id']);
@@ -64,6 +56,7 @@ class UpdateKeyword extends Command @@ -64,6 +56,7 @@ class UpdateKeyword extends Command
64 DB::disconnect('custom_mysql'); 56 DB::disconnect('custom_mysql');
65 } 57 }
66 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 58 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  59 + return true;
67 } 60 }
68 61
69 62
@@ -47,7 +47,7 @@ class Kernel extends ConsoleKernel @@ -47,7 +47,7 @@ class Kernel extends ConsoleKernel
47 // $schedule->command('website_data')->dailyAt('01:00')->withoutOverlapping(1); // 向AICC推送数据 47 // $schedule->command('website_data')->dailyAt('01:00')->withoutOverlapping(1); // 向AICC推送数据
48 // $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件 48 // $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件
49 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次 49 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
50 - 50 + $schedule->command('update_keyword_route')->dailyAt('01:00')->withoutOverlapping(1); //升级项目--清除路由相同的关键字
51 $schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商 51 $schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
52 // 每日推送视频任务 52 // 每日推送视频任务
53 $schedule->command('video_task')->dailyAt('02:30')->withoutOverlapping(1); 53 $schedule->command('video_task')->dailyAt('02:30')->withoutOverlapping(1);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CNoticeController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/12 10:04
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Com;
  11 +
  12 +
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Models\Domain\DomainInfo;
  15 +use App\Models\Project\DeployBuild;
  16 +use Illuminate\Http\Request;
  17 +
  18 +
  19 +/**
  20 + * @remark :通知C端
  21 + * @name :CNoticeController
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2023/9/12 10:38
  25 + */
  26 +class CNoticeController extends BaseController
  27 +{
  28 + /**
  29 + * 更新通知C端
  30 + * @param Request $request
  31 + * @return \Illuminate\Http\JsonResponse
  32 + */
  33 + public function sendNotify(Request $request)
  34 + {
  35 + //获取当前项目的域名
  36 + $domainModel = new DomainInfo();
  37 + $domainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]);
  38 + if($domainInfo === false){
  39 + //获取测试域名
  40 + $deployBuildModel = new DeployBuild();
  41 + $buildInfo = $deployBuildModel->read(['project_id'=>$this->param['project_id']]);
  42 + $this->param['domain'] = $buildInfo['test_domain'];
  43 + }else{
  44 + $this->param['domain'] = 'https://'.$domainInfo['domain'].'/';
  45 + }
  46 + $url = $this->param['domain'].'api/update_page/';
  47 + $param = [
  48 + 'project_id' => $this->param['project_id'],
  49 + 'type' => intval($request->input('type', 1)),
  50 + 'route' => intval($request->input('page', 1)),
  51 + 'url' => $request->input('url', []),
  52 + 'language'=> $request->input('language', []),
  53 + ];
  54 + http_post($url, json_encode($param));
  55 + $this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
  56 + }
  57 +
  58 +}
@@ -4,6 +4,7 @@ namespace App\Http\Logic\Aside\Domain; @@ -4,6 +4,7 @@ namespace App\Http\Logic\Aside\Domain;
4 4
5 5
6 use App\Http\Logic\Aside\BaseLogic; 6 use App\Http\Logic\Aside\BaseLogic;
  7 +use App\Jobs\EditDomainBt;
7 use App\Models\Devops\ServerConfig; 8 use App\Models\Devops\ServerConfig;
8 use App\Models\Domain\DomainInfo; 9 use App\Models\Domain\DomainInfo;
9 use App\Models\Project\CountryCustom; 10 use App\Models\Project\CountryCustom;
@@ -302,12 +303,13 @@ class DomainInfoLogic extends BaseLogic @@ -302,12 +303,13 @@ class DomainInfoLogic extends BaseLogic
302 ]; 303 ];
303 $this->model->edit($data,['id'=>$this->param['id']]); 304 $this->model->edit($data,['id'=>$this->param['id']]);
304 //生成证书 305 //生成证书
305 - $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? [],$this->param['is_https'] ?? 0); 306 + EditDomainBt::dispatch($this->param['id']);
  307 +// $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? [],$this->param['is_https'] ?? 0);
306 308
307 //amp站点生成证书 309 //amp站点生成证书
308 - if($data['amp_status']){  
309 - $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);  
310 - } 310 +// if($data['amp_status']){
  311 +// $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);
  312 +// }
311 313
312 return $this->success(); 314 return $this->success();
313 } 315 }
@@ -47,16 +47,12 @@ class ProductLogic extends BaseLogic @@ -47,16 +47,12 @@ class ProductLogic extends BaseLogic
47 $this->param = $this->handleSaveParam($this->param); 47 $this->param = $this->handleSaveParam($this->param);
48 try { 48 try {
49 if(isset($this->param['id']) && !empty($this->param['id'])){ 49 if(isset($this->param['id']) && !empty($this->param['id'])){
50 - $seo_mate = (array)$this->model->read(['id'=>$this->param['id']],['seo_mate'])['seo_mate']; 50 +
51 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0 51 $is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
52 $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示 52 $six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
53 if($is_upgrade == 0 || $six_read == 1){ 53 if($is_upgrade == 0 || $six_read == 1){
54 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']); 54 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
55 } 55 }
56 - if(!empty($seo_mate)){  
57 - $seo_mate['title'] = $this->param['title'] ?? '';  
58 - $this->param['seo_mate'] = json_encode($seo_mate,true);  
59 - }  
60 $route = $this->param['route']; 56 $route = $this->param['route'];
61 $this->model->edit($this->param,['id'=>$this->param['id']]); 57 $this->model->edit($this->param,['id'=>$this->param['id']]);
62 $id = $this->param['id']; 58 $id = $this->param['id'];
  1 +<?php
  2 +
  3 +namespace App\Jobs;
  4 +
  5 +use App\Models\Devops\ServerConfig;
  6 +use App\Models\Domain\DomainInfo;
  7 +use App\Models\Project\Project;
  8 +use App\Utils\HttpUtils;
  9 +use GuzzleHttp\Exception\GuzzleException;
  10 +use Illuminate\Bus\Queueable;
  11 +use Illuminate\Contracts\Queue\ShouldQueue;
  12 +use Illuminate\Foundation\Bus\Dispatchable;
  13 +use Illuminate\Queue\InteractsWithQueue;
  14 +use Illuminate\Queue\SerializesModels;
  15 +
  16 +class EditDomainBt implements ShouldQueue
  17 +{
  18 + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  19 +
  20 + public $tries = 1; // 可配置任务重试次数
  21 +
  22 + protected $domain_id;
  23 +
  24 + /**
  25 + * Create a new job instance.
  26 + *
  27 + * @param $domain_id
  28 + */
  29 + public function __construct($domain_id)
  30 + {
  31 + $this->domain_id = $domain_id;
  32 + }
  33 +
  34 + /**
  35 + * Execute the job.
  36 + *
  37 + * @return bool
  38 + */
  39 + public function handle()
  40 + {
  41 + //获取域名数据
  42 + $domain_model = new DomainInfo();
  43 + $domain_info = $domain_model->read(['id' => $this->domain_id]);
  44 + if ($domain_info === false) {
  45 + return $this->output($domain_info['domain'] . ':获取域名数据失败');
  46 + }
  47 +
  48 + //获取项目数据
  49 + $project_model = new Project();
  50 + $project_info = $project_model->read(['id' => $domain_info['project_id']], 'serve_id');
  51 + if ($project_info === false) {
  52 + return $this->output($domain_info['domain'] . ':获取项目数据失败');
  53 + }
  54 +
  55 + //获取服务器数据
  56 + $server_model = new ServerConfig();
  57 + $server_info = $server_model->read(['id' => $project_info['serve_id']], ['init_domain', 'host']);
  58 + if ($server_info === false) {
  59 + return $this->output($domain_info['domain'] . ':获取服务器数据失败');
  60 + }
  61 +
  62 + //编辑主站
  63 + if ($domain_info['type'] == 2) {
  64 + $api_url = 'http://' . $server_info['init_domain'] . '/api/setSsl';
  65 + $api_param = [
  66 + 'domain' => $domain_info['domain'],
  67 + 'private_key' => $domain_info['private_key'],
  68 + 'cert' => $domain_info['private_cert'],
  69 + 'rewrite' => $domain_info['extend_config'],
  70 + 'other_domain' => $domain_info['other_domain'],
  71 + 'is_https' => $domain_info['is_https']
  72 + ];
  73 + } else {
  74 + $api_url = 'http://' . $server_info['init_domain'] . '/api/applySsl';
  75 + $api_param = [
  76 + 'domain' => $domain_info['domain'],
  77 + 'rewrite' => $domain_info['extend_config'],
  78 + 'other_domain' => $domain_info['other_domain'],
  79 + 'is_https' => $domain_info['is_https']
  80 + ];
  81 + }
  82 + try {
  83 + $rs = HttpUtils::get($api_url, $api_param);
  84 + $rs = json_decode($rs, true);
  85 + if (isset($rs['status']) && $rs['status'] == 200) {
  86 + $this->output($domain_info['domain'] . ':主站编辑成功');
  87 + } else {
  88 + $this->output($domain_info['domain'] . ':主站编辑失败,原因:' . ($rs['message'] ?? ''));
  89 + }
  90 + } catch (\Exception | GuzzleException $e) {
  91 + $this->output($domain_info['domain'] . ':主站编辑失败,原因:' . $e->getMessage());
  92 + }
  93 +
  94 + //编辑amp站
  95 + if ($domain_info['amp_status']) {
  96 + $api_url_amp = 'http://' . $server_info['init_domain'] . '/api/createSiteAmp';
  97 + $api_param_amp = [
  98 + 'domain' => $domain_info['domain'],
  99 + ];
  100 + if ($domain_info['amp_type'] == 2) {
  101 + $api_param_amp['private_key'] = $domain_info['amp_private_key'];
  102 + $api_param_amp['cert'] = $domain_info['amp_private_cert'];
  103 + }
  104 +
  105 + try {
  106 + $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp);
  107 + $rs_amp = json_decode($rs_amp, true);
  108 + if (isset($rs_amp['status']) && $rs_amp['status'] == 200) {
  109 + $this->output($domain_info['domain'] . ':amp站编辑成功');
  110 + } else {
  111 + $this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . ($rs_amp['message'] ?? ''));
  112 + }
  113 + } catch (\Exception | GuzzleException $e_amp) {
  114 + $this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . $e_amp->getMessage());
  115 + }
  116 + }
  117 +
  118 + return true;
  119 + }
  120 +
  121 + /**
  122 + * 输出处理日志
  123 + * @param $message
  124 + * @return bool
  125 + */
  126 + public function output($message)
  127 + {
  128 + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
  129 + return true;
  130 + }
  131 +
  132 + public function failed(\Exception $exception)
  133 + {
  134 + return $this->output($exception->getMessage());
  135 + }
  136 +}
@@ -14,6 +14,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -14,6 +14,7 @@ Route::middleware(['aloginauth'])->group(function () {
14 Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white'); 14 Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white');
15 Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white'); 15 Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white');
16 Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址 16 Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
  17 + Route::get('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
17 18
18 //会员相关 19 //会员相关
19 Route::prefix('user')->group(function () { 20 Route::prefix('user')->group(function () {