|
...
|
...
|
@@ -10,9 +10,13 @@ |
|
|
|
namespace App\Http\Controllers\Bside\BCom;
|
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
use App\Models\Com\Notify;
|
|
|
|
use App\Models\Com\UpdateNotify;
|
|
|
|
use App\Models\Com\UpdateProgress;
|
|
|
|
use App\Models\Devops\ServerConfig;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\Project\Country as CountryModel;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
...
|
...
|
@@ -37,15 +41,66 @@ class CNoticeController extends BaseController |
|
|
|
*/
|
|
|
|
public function sendNotify(Request $request)
|
|
|
|
{
|
|
|
|
$url = $this->user['domain'].'api/update_page/';
|
|
|
|
$param = [
|
|
|
|
'project_id' => $this->user['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));
|
|
|
|
$project_id = $this->user['project_id'];
|
|
|
|
$type = intval($request->input('type', 1));
|
|
|
|
$route = intval($request->input('page', 1));
|
|
|
|
$url = $request->input('url', []);
|
|
|
|
$language = $request->input('language', []);
|
|
|
|
$is_sitemap = intval($request->input('is_sitemap', 0));
|
|
|
|
|
|
|
|
//获取项目所在服务器
|
|
|
|
$project_model = new Project();
|
|
|
|
$project_info = $project_model->read(['id'=>$project_id],['serve_id']);
|
|
|
|
|
|
|
|
if($project_info && $project_info['serve_id'] == ServerConfig::SELF_SITE_ID){
|
|
|
|
//自建站服务器:如果项目已经上线,不请求C端接口,数据直接入库
|
|
|
|
$domain_model = new DomainInfo();
|
|
|
|
$domain_info = $domain_model->read(['project_id'=>$this->user['project_id']],['domain']);
|
|
|
|
if($domain_info){
|
|
|
|
//判断是否已有更新进行中
|
|
|
|
$notify_model = new Notify();
|
|
|
|
$data = [
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'type' => $type,
|
|
|
|
'route' => $route,
|
|
|
|
'server_id' => ServerConfig::SELF_SITE_ID,
|
|
|
|
'status' => ['<',Notify::STATUS_FINISH_PAGE]
|
|
|
|
];
|
|
|
|
$notify = $notify_model->read($data,['id']);
|
|
|
|
|
|
|
|
if(!$notify){
|
|
|
|
$domain = $domain_info['domain'];
|
|
|
|
if($type == Notify::TYPE_AMP){
|
|
|
|
$domain_array = parse_url($domain);
|
|
|
|
$host = $domain_array['host'] ?? $domain_array['path'];
|
|
|
|
$host_array = explode('.',$host);
|
|
|
|
if(count($host_array) <= 2){
|
|
|
|
array_unshift($host_array,'m');
|
|
|
|
}else{
|
|
|
|
$host_array[0] = 'm';
|
|
|
|
}
|
|
|
|
$domain = implode('.',$host_array);
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['data'] = Arr::a2s(['domain'=>$domain,'url'=>$url,'language'=>$language]);
|
|
|
|
$data['status'] = $is_sitemap == 1 ? Notify::STATUS_FINISH_PAGE : Notify::STATUS_INIT;
|
|
|
|
$notify_model->add($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//其他服务器:请求对应C端接口
|
|
|
|
$c_url = $this->user['domain'].'api/update_page/';
|
|
|
|
$param = [
|
|
|
|
'project_id' => $this->user['project_id'],
|
|
|
|
'type' => $type,
|
|
|
|
'route' => $route,
|
|
|
|
'url' => $url,
|
|
|
|
'language'=> $language,
|
|
|
|
'is_sitemap' => $is_sitemap
|
|
|
|
];
|
|
|
|
http_post($c_url, json_encode($param));
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|