作者 赵彬吉
正在显示 31 个修改的文件 包含 441 行增加387 行删除
... ... @@ -80,6 +80,7 @@ class VideoTask extends Command
if (empty($task_project)){
break;
}
echo '开始,项目id:'.$task_project->project_id.PHP_EOL;
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['project_id'=>$task_project->project_id]);
if($domainInfo === false){
... ... @@ -89,9 +90,9 @@ class VideoTask extends Command
}
ProjectServer::useProject($task_project->project_id);
if(!empty($task_project->keywords)){
$task_project->keywords = explode(',',trim(',',$task_project->keywords));
$keywords = explode(',',trim(',',$task_project->keywords));
}
$keyword = $this->getProjectKeyword($task_project->number,$task_project->keywords);
$keyword = $this->getProjectKeyword($task_project->number,$keywords ?? []);
// 已经没有需要生成视频的关键词
if (!$keyword) {
$task_project->status = KeywordVideoTask::STATUS_CLOSE;
... ... @@ -176,24 +177,15 @@ class VideoTask extends Command
*/
public function getProjectKeyword($number,$keywords = [])
{
if(!empty($keywords)){
$keyword_id = Keyword::where('video', null)->whereIn("title", $keywords)
->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->pluck('id')->toArray();
if(count($keyword_id) == 0){
$keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')
->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number)->pluck('id')->toArray();
}else{
$keyword_arr_id = Keyword::where('video', null)->whereNotIn("title", $keywords)->where('route', 'not like', '%-tag')
->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number - count($keyword_id))->pluck('id')->toArray();
$keyword_arr_id = array_merge($keyword_id,$keyword_arr_id);
}
}else{
$keyword_id = Keyword::where('video', null)->whereIn("title", $keywords)
->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->limit($number)->pluck('id')->toArray();
$need = $number - count($keyword_id);
if ($need > 0) {
$keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')
->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number)->pluck('id')->toArray();
}
if(count($keyword_arr_id) == 0){
return [];
->whereNotNull('keyword_content')->whereNotIn('id', $keyword_id)->orderBy('id','asc')->limit($need)->pluck('id')->toArray();
}
$keyword_arr_id = array_merge($keyword_id, $keyword_arr_id);
$keyword = Keyword::whereIn("id", $keyword_arr_id)->get();
return $keyword;
}
... ... @@ -235,7 +227,7 @@ class VideoTask extends Command
}
}
//TODO::所有产品
$thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);
$thumb = $this->getRecommendAndHotProducts($keyword_id);
$keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();
$data = [
'url'=> 'https://' . $domain.'/'.$keywordInfo['route'],
... ... @@ -251,38 +243,24 @@ class VideoTask extends Command
/**
* 关键词聚合页-推荐&热门产品
*/
public function getRecommendAndHotProducts($route,$project_id): ?array
public function getRecommendAndHotProducts($keyword_id): ?array
{
$productIds = [];
$productKeyword = Keyword::where("project_id",$project_id)->where("route",$route)->first();
if (!empty($productKeyword)){
$productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();
if (!empty($productsQuery)){
foreach ($productsQuery as $item){
$productIds[] = $item->id;
}
if (count($productIds)<7){
$product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$array_count = count($product_all_id);
if ($array_count > 0) {
$product_id = array_rand($product_all_id, min($array_count, $number - count($productIds)));
$randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
$products = $productsQuery->merge($randomData);
}
}else{
$products = $productsQuery;
}
$productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(13)->get();
if (count($productsQuery) > 0){
foreach ($productsQuery as $item){
$productIds[] = $item->id;
}
if (count($productIds) < 13){
$product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray();
$randomData = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get();
$products = $productsQuery->merge($randomData);
}else{
$product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$array_count = count($product_all_id);
if ($array_count > 0)
{
$product_id = array_rand($product_all_id, min($array_count, $number-count($productIds)));
$products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
}
$products = $productsQuery;
}
}else{
$product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray();
$products = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get();
}
$data = [];
if (!empty($products)){
... ... @@ -293,12 +271,13 @@ class VideoTask extends Command
if(count($data) > 13){
break;
}
$keyword_id = implode(',',$item->keyword_id);
if (strpos(','.$keyword_id.',', ','.$productKeyword->id.',') === false) {
$keyword_ids = implode(',',$item->keyword_id);
if (strpos(','.$keyword_ids.',', ','.$keyword_id.',') === false) {
//不包含
$productModel = new Product();
$keyword_id = ','.$keyword_id.',' . $productKeyword->id.',';
$productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]);
$keyword_ids = !empty($keyword_ids) ? ','.$keyword_ids.',' : ',' ;
$keyword_id_str = $keyword_ids . $keyword_id.',';
$productModel->edit(['keyword_id'=>$keyword_id_str],['id'=>$item->id]);
}
$data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
}
... ...
... ... @@ -119,18 +119,21 @@ class RecommendedSuppliers extends Command
* @time :2024/5/29 16:38
*/
public function savePurchaserInfo($project_id,$keyword,$data){
$param = [];
$purchaserInfoModel = new PurchaserInfo();
foreach ($data as $k =>$v){
$v['project_id'] = $project_id;
$v['keyword'] = $keyword;
$v['email'] = json_encode($v['email'],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['mobile'] = json_encode($v['mobile'],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['social_media'] = json_encode($v['social_media'],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = $v['created_at'];
$param[] = $v;
// $v['created_at'] = date('Y-m-d H:i:s');
// $v['updated_at'] = $v['created_at'];
$param = $v;
$info = $purchaserInfoModel->read(['keyword'=>$keyword,'buyer'=>$v['buyer'],'project_id'=>$project_id],['id']);
if($info === false){
$purchaserInfoModel->add($param);
}
}
$purchaserInfoModel = new PurchaserInfo();
return $purchaserInfoModel->insert($param);
return true;
}
}
... ...
... ... @@ -9,16 +9,23 @@ namespace App\Console\Commands\Test;
use App\Models\Com\KeywordVideoTask;
use App\Models\Com\KeywordVideoTaskLog;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\File\File;
use App\Models\File\File as FileModel;
use App\Models\File\Image;
use App\Models\File\Image as ImageModel;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
use App\Models\Project\Project;
use App\Models\Purchaser\PurchaserInfo;
use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
use App\Utils\EncryptUtils;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -40,54 +47,64 @@ class Demo extends Command
*/
protected $description = 'demo';
// /**
// * Execute the job.
// *
// * @return void
// */
// public function handle()
// {
// $this->param['project_id'] = 181;
// $imageModel = new ImageModel();
// //获取当前项目的所有图片
// $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);
// if(!empty($imageList)){
// $amazonS3Service = new AmazonS3Service();
// foreach ($imageList as $k => $v){
// $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
// $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
// }
// }
//
// $fileModel = new FileModel();
// $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);
// if(!empty($fileList)){
// $amazonS3Service = new AmazonS3Service();
// foreach ($fileList as $k => $v){
// echo date('Y-m-d H:i:s') . '执行的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;
// $amazonS3Service->syncImageFiles(getFileUrl($v['path']));
// $fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);
// gc_collect_cycles();
// }
// }
// return true;
// }
public function handle(){
$p = new PurchaserInfo();
$lists = $p->list();
foreach ($lists as $k => $v){
$info = $p->read(['project_id'=>$v['project_id'],'keyword'=>$v['keyword'],'buyer'=>$v['buyer']]);
if($info === false){
continue;
}
$p->del(['project_id'=>$v['project_id'],'keyword'=>$v['keyword'],'buyer'=>$v['buyer'],'id'=>['!=',$v['id']]]);
}
return true;
}
// public function handle(){
// $keywordVideoModel = new KeywordVideoTask();
// $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();
// //查看是否有子记录
// foreach ($project_id_arr as $values){
// $logModel = new KeywordVideoTaskLog();
// $logInfo = $logModel->read(['project_id'=>$values]);
// if($logInfo === false){
// echo date('Y-m-d H:i:s') . '开启的项目project_id:'.$values . PHP_EOL;
// $keywordVideoModel->edit(['status'=>0],['project_id'=>$values]);
// }
// }
// $projectModel = new Project();
// $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);
// $data = [];
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
// $this->saveKeyword();
// $this->getProductList();
// DB::disconnect('custom_mysql');
// }
// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
// }
// public function getProductList(){
// $productModel = new Product();
// $product_all_id = $productModel::whereRaw('LENGTH(keyword_id) > 50')->pluck('id')->toArray();
// if(empty($product_all_id)){
// return true;
// }
// $lists = $productModel->whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get()->toArray();
// foreach ($lists as $k => $v){
// echo date('Y-m-d H:i:s') . '项目id:'.$v['project_id'].'+产品product_id:'.$v['id'] . PHP_EOL;
// $str = ',';
// shuffle($v['keyword_id']);
// foreach ($v['keyword_id'] as $key => $value){
// if($key == 6){
// break;
// }
// $str .= $value.',';
// }
// $productModel->edit(['keyword_id'=>$str],['id'=>$v['id']]);
// }
// return true;
// }
//
// /**
// * @remark :关键字有视频的改为1
... ...
... ... @@ -53,109 +53,6 @@ class Temp extends Command
$this->output('end');
}
// public function handle()
// {
// $domain_model = new DomainInfo();
// $notify_model = new Notify();
// $project_model = new Project();
//
// $domain_list = $domain_model->list(['amp_status' => 1]);
// foreach ($domain_list as $info) {
// if ($info['project_id'] > 0) {
// $notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
// if (!$notify_info) {
//
// $domain_array = parse_url($info['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';
// }
// $amp_domain = implode('.', $host_array);
//
// $project_info = $project_model->read(['id' => $info['project_id']]);
//
// $notify_model->add([
// 'project_id' => $info['project_id'],
// 'type' => 3,
// 'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
// 'server_id' => $project_info['serve_id'],
// ]);
// }
// }
// }
// }
// public function handle()
// {
// $domain_model = new DomainInfo();
// $server_model = new ServerConfig();
// $project_model = new Project();
//
// $domain_list = $domain_model->list(['domain' => ['like', 'www.%']], 'id', ['id', 'domain', 'project_id'], 'asc');
// foreach ($domain_list as $info) {
// $this->output('domain:' . $info['domain'] . ',开始');
//
// $project_info = $project_model->read(['id' => $info['project_id']], 'serve_id');
// if ($project_info === false) {
// $this->output('获取项目数据失败');
// continue;
// }
//
// $server_info = $server_model->read(['id' => $project_info['serve_id']], ['init_domain', 'host']);
// if ($server_info === false) {
// $this->output('获取服务器数据失败');
// continue;
// }
//
// $domain_array = parse_url($info['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';
// }
// $amp_domain = implode('.', $host_array);
// if (!$this->check_cname($amp_domain, $server_info)) {
// $this->output('AMP站点域名' . $amp_domain . '未解析至目标服务器');
// continue;
// }
//
// $api_url = 'http://' . $server_info['init_domain'] . '/api/createSiteAmp';
// $api_param = [
// 'domain' => $info['domain'],
// 'private_key' => '',
// 'cert' => ''
// ];
//
// try {
// $rs = HttpUtils::get($api_url, $api_param);
// $rs = json_decode($rs, true);
// if (isset($rs['status']) && $rs['status'] == 200) {
// $this->output('创建AMP站点成功');
// } else {
// $this->output($rs['message'] ?? '');
// continue;
// }
// } catch (\Exception | GuzzleException $e) {
// errorLog('创建AMP站点', $api_param, $e);
// $this->output('创建AMP站点失败');
// continue;
// }
//
// $data = [
// 'amp_status' => 1,
// 'amp_type' => 1,
// ];
// $domain_model->edit($data, ['id' => $info['id']]);
// }
//
// echo '成功' . PHP_EOL;
// }
public function check_cname($domain, $server_info)
{
$checkA = false;
... ... @@ -166,7 +63,7 @@ class Temp extends Command
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkA = strpos($line, $server_info['host']) !== false;
$checkA = strpos($line, $server_info['ip']) !== false;
if ($checkA) {
return $domain;
}
... ... @@ -179,7 +76,7 @@ class Temp extends Command
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkCname = (strpos($line, $server_info['init_domain']) !== false);
$checkCname = (strpos($line, $server_info['domain']) !== false);
if ($checkCname) {
return $domain;
}
... ...
... ... @@ -874,3 +874,37 @@ function textareaToArr($content, $separator = ','){
return trim($v);
},explode($separator, $content)))));
}
/**
* @remark :字符串
* @name :base62_encode
* @author :lyh
* @method :post
* @time :2024/6/26 10:46
*/
function ip_to_unique_string($ip) {
// 将IP地址转换为数值表示
$ip_number = ip2long($ip);
// 使用哈希函数生成唯一数值
$hash = hash('sha256', $ip_number, false);
$hash_number = hexdec(substr($hash, 0, 15)); // 取前15位作为大整数
// 将哈希值转换为Base62编码
$unique_string = base62_encode($hash_number);
// 确保唯一字符串为6位,如果不足则补齐,超出则截取前6位
$unique_string = str_pad($unique_string, 6, '0', STR_PAD_LEFT);
$unique_string = substr($unique_string, 0, 6);
return strtolower($unique_string);
}
function base62_encode($num) {
$characters = '23456789abcdefghijkmnpqrstuvwxyz';
$base = strlen($characters);
$result = '';
while ($num > 0) {
$result = $characters[$num % $base] . $result;
$num = intval($num / $base);
}
return $result;
}
... ...
... ... @@ -79,17 +79,19 @@ class ServersController extends BaseController
$this->request->validate([
'server_name'=>'required',
'service_type'=>'required',
'total'=>'required',
'account'=>'required',
'password'=>'required',
'port'=>'required'
'port'=>'required',
'ip_total'=>'required',
'domain'=>'required'
],[
'server_name.required' => '服务器名称server_name不能为空',
'service_type.required' => '服务器类型不能为空',
'total.required' => '总数不能为空',
'account.required' => '账号不能为空',
'password.required' => '密码不能为空',
'port.required' => '端口不能为空'
'port.required' => '端口不能为空',
'ip_total.required' => 'ip使用數量不能为空',
'domain.required' => '初始域名不能为空',
]);
$data = $serversLogic->saveServers();
$this->response('success',Code::SUCCESS,$data);
... ...
... ... @@ -12,7 +12,9 @@ namespace App\Http\Controllers\Aside\Devops;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Devops\ServersIpLogic;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp as ServersIpModel;
use App\Models\Project\Project;
class ServersIpController extends BaseController
{
... ... @@ -30,8 +32,21 @@ class ServersIpController extends BaseController
],[
'servers_id.required' => '服务器servers_id不能为空'
]);
$serverModel = new Servers();
$info = $serverModel->read(['id'=>$this->param['servers_id']]);
if($info === false){
$this->response('當前服務器不存在',Code::SERVER_ERROR);
}
$serversIpModel = new ServersIpModel();
$this->map['status'] = 0;
$data = $serversIpModel->list($this->map);
foreach ($data as $k => $v){
$v['is_optional'] = 0;//是否可选择
if($v['total'] >= $info['ip_total']){
$v['is_optional'] = 1;//不可选择
}
$data[$k] = $v;
}
$this->response('success',Code::SUCCESS,$data);
}
... ... @@ -49,7 +64,15 @@ class ServersIpController extends BaseController
'servers_id.required' => '服务器servers_id不能为空'
]);
$serversIpModel = new ServersIpModel();
$this->map['status'] = 0;
$data = $serversIpModel->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($data) && !empty($data['list'])){
$projectModel = new Project();
foreach ($data['list'] as $k => $v){
$v['project_title'] = $projectModel->formatQuery(['serve_id'=>$v['id']])->pluck('title')->toArray();
$data['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$data);
}
... ... @@ -60,14 +83,13 @@ class ServersIpController extends BaseController
* @method :post
* @time :2024/6/25 14:52
*/
public function info(){
public function info(ServersIpLogic $serversIpLogic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'id不能为空'
]);
$serversIpModel = new ServersIpModel();
$data = $serversIpModel->read(['id'=>$this->param['id']]);
$data = $serversIpLogic->infoServersIp();
$this->response('success',Code::SUCCESS,$data);
}
... ... @@ -101,13 +123,56 @@ class ServersIpController extends BaseController
*/
public function batchSave(ServersIpLogic $serversIpLogic){
$this->request->validate([
'data'=>'required',
'ip'=>'required|array',
'servers_id'=>'required',
],[
'data.required' => 'data集合不能为空',
'ip.required' => 'ip集合不能为空',
'servers_id.required' => '服务器servers_id不能为空',
]);
$data = $serversIpLogic->batchSaveServersIp();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :批量删除数据
* @name :batchDel
* @author :lyh
* @method :post
* @time :2024/6/27 13:52
*/
public function batchDel(ServersIpLogic $serversIpLogic){
$this->request->validate([
'ids'=>'required|array',
],[
'ids.required' => 'ip集合不能为空',
]);
$serversIpLogic->batchDelServersIp();
$this->response('success');
}
/**
* @remark :导出文件获取数据
* @name :downloadFile
* @author :lyh
* @method :post
* @time :2024/6/28 10:26
*/
public function downloadFile(){
$this->request->validate([
'servers_id'=>'required',
],[
'servers_id.required' => '服务器servers_id不能为空',
]);
$serverModel = new Servers();
$info = $serverModel->read(['id'=>$this->map['servers_id']]);
$data = [];
$serversIpModel = new ServersIpModel();
$list = $serversIpModel->list($this->map);
foreach ($list as $v){
$position = strpos($v['domain'], '.');
$result = substr($v['domain'], 0, $position);
$data[] = ['记录类型'=>'A','主机记录'=>$result,'解析线路'=>'默认','记录值'=>$v['ip'],'MAX优先级'=>'','TTL值'=>600,'状态(暂停/启用)'=>'启用','备注'=>$info['server_name']];
}
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -422,7 +422,6 @@ class OptimizeController extends BaseController
if($info === false){
$this->response('请先创建视频任务,才能开启',Code::SYSTEM_ERROR);
}
$keywordVideoModel->edit(['status'=>$this->param['status']],['project_id'=>$this->param['project_id']]);
$optimizeModel = new DeployOptimize();
$optimizeModel->edit(['ai_video'=>$this->param['status']],['project_id'=>$this->param['project_id']]);
$this->response('success');
... ...
... ... @@ -46,12 +46,12 @@ class ReplaceHtmlController extends BaseController
public function replaceTemplateMainHtml(ReplaceHtmlLogic $logic){
$this->request->validate([
'name'=>'required',
'html'=>'required',
// 'html'=>'required',
'old_html'=>'required',
'project_id'=>'required',
],[
'name.required' => '需替换页面标识不能为空',
'html.required' => 'html不能为空',
// 'html.required' => 'html不能为空',
'old_html.required' => '替换前的html不能为空',
'project_id.required' => 'project_id不能为空',
]);
... ...
... ... @@ -88,10 +88,7 @@ class AyrReleaseController extends BaseController
}
//发送请求发布社交文章
$res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
//保存数据库
if($res){
$ayrReleaseLogic->release_add($res);
}
$ayrReleaseLogic->release_add($res);
//保存返回的内容
$this->response('success',Code::SUCCESS,json_decode($res));
}
... ...
... ... @@ -225,9 +225,12 @@ class CNoticeController extends BaseController
$ids = explode(',',$info['country_lists']);
}
$languageModel = new WebLanguage();
if(empty($ids)){
array_push($ids,1);
}
//根据排序查询选中的小语种
$lists = $languageModel->whereIn('id', $ids)->orderByRaw(DB::raw("FIND_IN_SET(id,'" . implode(',', $ids) . "'" . ')'))->get()->toArray();
// $lists = $languageModel->list(['id'=>['in',$ids]]);
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -31,7 +31,6 @@ class ProjectKeywordController extends BaseController
$data['search_keywords'] = $info['search_keywords'];
$data['customer_keywords'] = $info['customer_keywords'];
$data['brand_keyword'] = $info['brand_keyword'];
$data['minor_keywords'] = $info['minor_keywords'];
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -59,9 +59,9 @@ class ProductController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
$userModel = new User();
foreach ($lists['list'] as $k=>$v){
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);;
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);
$v['category_id_text'] = $this->categoryName($v['id'],$cate_data);
$v['keyword_id_text'] = mb_substr($this->keywordName($v['keyword_id'],$key_data), 0, 20, 'UTF-8').'...';
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
$v = $this->getHandleFileImage($v);
... ... @@ -213,29 +213,6 @@ class ProductController extends BaseController
}
/**
* @remark :获取所有关键词
* @name :getCategoryList
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
*/
public function getKeywordsList(){
$data = Common::get_user_cache('product_keyword',$this->user['project_id']);
if(empty($data)) {
$keywordModel = new Keyword();
$data = [];
$cateList = $keywordModel->list(['project_id' => $this->user['project_id']], ['id', 'title']);
if (!empty($cateList)) {
foreach ($cateList as $value) {
$data[$value['id']] = $value['title'];
}
}
Common::set_user_cache($data,'product_keyword',$this->user['project_id']);
}
return $data;
}
/**
* @remark :获取分类名称
* @name :categoryName
* @author :lyh
... ...
... ... @@ -43,7 +43,8 @@ class WebSettingFromController extends BaseController
{
$message = $request->input('message', 'success');
$url = $request->input('url');
$webSettingFromLogic->fromBackMsgSet($message, $url);
$other = $request->input('other') ?? false;
$webSettingFromLogic->fromBackMsgSet($message, $url, $other);
$this->response('success');
}
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\Suppliers;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Purchaser\Purchaser;
use App\Models\Purchaser\PurchaserInfo;
/**
* @remark :推荐采购商
... ... @@ -22,7 +23,7 @@ use App\Models\Purchaser\Purchaser;
*/
class SuppliersController extends BaseController
{
public $domain = 'https://admin.hagro.cn/';
public $domain = 'https://fob.ai.cc/';
/**
* @remark :推荐采购商
... ... @@ -32,21 +33,14 @@ class SuppliersController extends BaseController
* @time :2024/3/4 10:10
*/
public function recommendedPurchaser(){
$purchaserModel = new Purchaser();
$data = [];
$purchaserModel = new PurchaserInfo();
$this->map['project_id'] = $this->user['project_id'];
$lists = $purchaserModel->list($this->map);
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['data'])){
$resultData = json_decode($v['data'],true);
foreach ($resultData as $value){
$value = (array)$value;
$value['keyword'] = $v['keyword'];
$data[] = $value;
}
}
}
$data = $purchaserModel->list($this->map);
foreach ($data as $k => $v){
$v['email'] = json_decode($v['email'],true);
$v['mobile'] = json_decode($v['mobile'],true);
$v['social_media'] = json_decode($v['social_media'],true);
$data[$k] = $v;
}
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -10,7 +10,9 @@
namespace App\Http\Logic\Aside\Devops;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Project\Project;
class ServersIpLogic extends BaseLogic
{
... ... @@ -25,6 +27,20 @@ class ServersIpLogic extends BaseLogic
}
/**
* @remark :获取数据详情
* @name :infoServersIp
* @author :lyh
* @method :post
* @time :2024/6/27 15:52
*/
public function infoServersIp(){
$info = $this->model->read(['id'=>$this->param['id']]);
$projectModel = new Project();
$info['project_title'] = $projectModel->formatQuery(['serve_id'=>$info['id']])->pluck('title')->toArray();
return $this->success($info);
}
/**
* @remark :保存数据
* @name :saveServersIp
* @author :lyh
... ... @@ -32,6 +48,11 @@ class ServersIpLogic extends BaseLogic
* @time :2024/6/24 17:28
*/
public function saveServersIp(){
//验证域名是否唯一
$info = $this->model->read(['domain'=>$this->param['domain']]);
if($info !== false){
$this->fail('当前初始域名已存在');
}
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$this->param['id']]);
... ... @@ -49,17 +70,41 @@ class ServersIpLogic extends BaseLogic
* @time :2024/6/24 17:25
*/
public function batchSaveServersIp(){
$data = [];
foreach ($this->param['data'] as $v){
if(empty($v['ip']) || empty($v['domain'])){
//獲取初始域名
$serverModel = new Servers();
$info = $serverModel->read(['id'=>$this->param['servers_id']]);
if($info === false){
$this->fail('當前服務器數據不存在');
}
foreach ($this->param['ip'] as $v){
if(empty($v)){
continue;
}
$data[] = [
'ip'=>$v['ip'],
'domain'=>$v['domain'],
$param = [
'ip'=>$v,
'domain'=>ip_to_unique_string($v).'.'.$info['domain'],
'servers_id'=>$this->param['servers_id']
];
$this->model->addReturnId($param);
}
return $this->success();
}
/**
* @remark :批量删除数据
* @name :batchDelServersIp
* @author :lyh
* @method :post
* @time :2024/6/27 13:55
*/
public function batchDelServersIp(){
foreach ($this->param['ids'] as $id){
$info = $this->model->read(['id'=>$id],['total']);
if($info['total'] != 0){
continue;
}
$this->model->edit(['status'=>1],['id'=>$id]);
}
return $this->addReturnId($data);
return $this->success();
}
}
... ...
... ... @@ -8,6 +8,8 @@ use App\Jobs\EditAmpDomainBt;
use App\Jobs\EditCustomDomainBt;
use App\Jobs\EditDomainBt;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
use App\Models\Project\CountryCustom;
use App\Models\Project\DeployOptimize;
... ... @@ -258,11 +260,14 @@ class DomainInfoLogic extends BaseLogic
if($project_info === false){
$this->fail('获取项目数据失败');
}
$server_model = new ServerConfig();
$server_info = $server_model->read(['id'=>$project_info['serve_id']],['init_domain', 'host']);
if($server_info === false){
$serverIpModel = new ServersIp();
$serversIpInfo = $serverIpModel->read(['id'=>$project_info['serve_id']],['servers_id','ip']);
if($serversIpInfo === false){
$this->fail('获取服务器数据失败');
}
$serverModel = new Servers();
$serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']);
$server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']];
if($project_info['serve_id'] == 9){
$this->fail('请切换服务器,生成站点不能使用测试服务器');
}
... ... @@ -312,11 +317,9 @@ class DomainInfoLogic extends BaseLogic
$this->model->edit($data,['id'=>$this->param['id']]);
//主站生成证书
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']){
EditAmpDomainBt::dispatch($this->param['id']);
// $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);
}
return $this->success();
}
... ... @@ -339,7 +342,7 @@ class DomainInfoLogic extends BaseLogic
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line){
if($line){
$checkA = strpos($line, $server_info['host']) !== false;
$checkA = strpos($line, $server_info['ip']) !== false;
if($checkA){
return $domain;
}
... ... @@ -352,7 +355,7 @@ class DomainInfoLogic extends BaseLogic
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line){
if($line){
$checkCname = (strpos($line, $server_info['init_domain']) !== false);
$checkCname = (strpos($line, $server_info['domain']) !== false);
if($checkCname){
return $domain;
}
... ... @@ -378,12 +381,14 @@ class DomainInfoLogic extends BaseLogic
$custom_model = new CountryCustom();
if($this->param['is_create']){
//需要创建站点
$server_model = new ServerConfig();
$server_info = $server_model->read(['id'=>$project_info['serve_id']],['init_domain', 'host']);
if($server_info === false){
$serverIpModel = new ServersIp();
$serversIpInfo = $serverIpModel->read(['id'=>$project_info['serve_id']],['servers_id','ip']);
if($serversIpInfo === false){
$this->fail('获取服务器数据失败');
}
$serverModel = new Servers();
$serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']);
$server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']];
//域名是否都已经解析
if(strpos($this->param['custom_domain'],'//') === false){
$this->param['custom_domain'] = '//'.$this->param['custom_domain'];
... ... @@ -419,9 +424,6 @@ class DomainInfoLogic extends BaseLogic
if($this->param['is_create']){
//创建站点,设置证书
EditCustomDomainBt::dispatch($id);
// $this->param['key'] = $this->param['private_key'] ?? '';
// $this->param['cert'] = $this->param['private_cert'] ?? '';
// $this->setDomainSsl($server_info['init_domain'],$this->param['custom_domain'],[],[],1);
}
return $this->success();
... ...
... ... @@ -165,8 +165,10 @@ class HrLogic extends BaseLogic
if(($this->manager['gid'] != ManageHr::GID_ZERO) && isset($this->param['id'])){
$groupModel = new Group();
$groupInfo = $groupModel->read(['id'=>$this->manager['gid']]);
if (!in_array(20,$groupInfo['rights']) && ($data['manage_id'] != $this->manager['id'])) {
$this->fail('无权限查看其他用户信息');
if ((!in_array(20,$groupInfo['rights'])) && ($data['manage_id'] != $this->manager['id'])) {
if(strpos($this->manager['rules'],'20') == false){
$this->fail('无权限查看其他用户信息');
}
}
}
foreach ($this->model::specieField() as $v){
... ...
... ... @@ -10,7 +10,6 @@ use App\Helper\Arr;
use App\Helper\Common;
use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Aside\BaseLogic;
use App\Http\Logic\Aside\Domain\DomainInfoLogic;
use App\Jobs\CopyImageFileJob;
use App\Jobs\CopyProjectJob;
use App\Models\Channel\Channel;
... ... @@ -18,7 +17,8 @@ use App\Models\Channel\User;
use App\Models\Channel\Zone;
use App\Models\Com\NoticeLog;
use App\Models\Com\UpdateLog;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryIP;
use App\Models\Inquiry\InquirySet;
... ... @@ -38,18 +38,14 @@ use App\Models\RankData\RankData;
use App\Models\RankData\RankWeek;
use App\Models\RankData\RecommDomain;
use App\Models\RankData\Speed;
use App\Models\RouteMap\RouteMap;
use App\Models\User\ProjectMenu;
use App\Models\User\ProjectRole;
use App\Models\User\User as UserModel;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
use App\Services\SyncService;
use App\Utils\HttpUtils;
use App\Utils\LogUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
/**
... ... @@ -128,10 +124,10 @@ class ProjectLogic extends BaseLogic
public function getInitDomain($serve_id = ''){
$domain = '';
if(!empty($serve_id)){
$serveModel = new ServerConfig();
$info = $serveModel->read(['id'=>$serve_id]);
$serverIpModel = new ServersIp();
$info = $serverIpModel->read(['id'=>$serve_id]);
if($info !== false){
$domain = $info['init_domain'];
$domain = $info['domain'];
}
}
return $this->success(['domain'=>$domain]);
... ... @@ -145,36 +141,64 @@ class ProjectLogic extends BaseLogic
* @time :2023/8/30 11:57
*/
public function projectSave(){
DB::beginTransaction();
try {
if($this->param['type'] == Project::TYPE_SEVEN){
//错误单直接返回,单独处理
$this->setTypeSevenEdit($this->param);
}else{
//初始化项目
$this->createProjectData($this->param);
//保存项目信息
$this->saveProject($this->param);
//保存建站部署信息
$this->saveProjectDeployBuild($this->param['deploy_build']);
//保存付费信息
$this->saveProjectPayment($this->param['payment']);
//保存优化信息
$this->saveProjectDeployOptimize($this->param['deploy_optimize']);
//保存售后信息
$this->saveProjectAfter($this->param['project_after']);
//单独保存小语种配置
$this->saveMinorLanguages($this->param['minor_languages'] ?? [],$this->param['id']);
//同步图片文件
$this->syncImageFile($this->param['project_location'],$this->param['id']);
//同步信息表
(new SyncService())->projectAcceptAddress($this->param['id']);
if($this->param['type'] == Project::TYPE_SEVEN){
//错误单直接返回,单独处理
$this->setTypeSevenEdit($this->param);
}else{
//初始化项目
$this->createProjectData($this->param);
//双向绑定服务器,需放到保存项目的上方
$this->setServers($this->param['serve_id'],$this->param['id']);
//保存项目信息
$this->saveProject($this->param);
//保存建站部署信息
$this->saveProjectDeployBuild($this->param['deploy_build']);
//保存付费信息
$this->saveProjectPayment($this->param['payment']);
//保存优化信息
$this->saveProjectDeployOptimize($this->param['deploy_optimize']);
//保存售后信息
$this->saveProjectAfter($this->param['project_after']);
//单独保存小语种配置
$this->saveMinorLanguages($this->param['minor_languages'] ?? [],$this->param['id']);
//同步图片文件
$this->syncImageFile($this->param['project_location'],$this->param['id']);
//同步信息表
(new SyncService())->projectAcceptAddress($this->param['id']);
}
return $this->success();
}
/**
* @remark :选择服务器后双向绑定
* @name :setServers
* @author :lyh
* @method :post
* @time :2024/6/25 15:34
*/
public function setServers($servers_id,$project_id){
//查看當前項目服務器是否有更改
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id],['serve_id']);
$serversIpModel = new ServersIp();
$serversModel = new Servers();
if(!empty($projectInfo['serve_id'])){
if($projectInfo['serve_id'] == $servers_id){
return $this->success();
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败,请联系管理员');
$oldServerIpInfo = $serversIpModel->read(['id'=>$projectInfo['serve_id']]);
if($oldServerIpInfo !== false){
$serversIpModel->where(['id'=>$projectInfo['serve_id']])->decrement('total',1);
$serversModel->where(['id'=>$oldServerIpInfo['servers_id']])->decrement('being_number',1);
}
}
$serversIpInfo = $serversIpModel->read(['id'=>$servers_id]);
$serversInfo = $serversModel->read(['id'=>$serversIpInfo['servers_id']]);
if($serversIpInfo['total'] >= $serversInfo['ip_total']){
$this->fail('请选择其他服务器,当前ip已满');
}
$serversIpModel->where(['id'=>$servers_id])->increment('total',1);
$serversModel->where(['id'=>$serversInfo['id']])->increment('being_number',1);
return $this->success();
}
... ... @@ -613,12 +637,21 @@ class ProjectLogic extends BaseLogic
public function channelSource($param){
switch ($param['type']){
case Project::TYPE_ONE:
return Zone::pluck('title', 'id')->toArray();
$data = [0=>'所有'];
$list = (new Zone())->list([],'id',['id','title'],'asc');
foreach ($list as $v){
$data[$v['id']] = $v['title'];
}
return $data;
case Project::TYPE_TWO:
if(isset($param['alias'])){
return Channel::where('alias', 'like' ,'%'.$param['alias'].'%')->pluck('alias', 'id')->toArray();
}
return Channel::where('zone_id', $param['zone_id']??0)->pluck('alias', 'id')->toArray();
$map = [];
if($param['zone_id'] != 0){
$map['zone_id'] = $param['zone_id'];
}
return Channel::where($map)->pluck('alias', 'id')->toArray();
case Project::TYPE_THREE:
return User::where('channel_id', $param['channel_id']??0)->pluck('name', 'id')->toArray();
}
... ... @@ -634,7 +667,18 @@ class ProjectLogic extends BaseLogic
* @time :2023/9/4 14:29
*/
public function editDomainStatus($domain,$project_id){
$projectOptimize = new DeployOptimize();
$optimizeInfo = $projectOptimize->read(['project_id'=>$project_id],['domain']);
if($optimizeInfo['domain'] == $domain){
return $this->success();
}
$domainModel = new DomainInfo();
//查看当前域名是否已使用
$domainInfo = $domainModel->read(['id'=>$domain,'project_id'=>['!=',0]]);
if($domainInfo !== false){
$this->fail('当前域名已被其他服务器使用');
}
//先清空上一次所绑定的域名
$info = $domainModel->read(['project_id'=>$project_id]);
if($info !== false){
... ... @@ -664,37 +708,6 @@ class ProjectLogic extends BaseLogic
}
/**
* 创建站点
* @param $param
* @throws AsideGlobalException
* @author Akun
* @date 2023/10/17 10:04
*/
public function createSite($param){
if(isset($param['serve_id']) && $param['serve_id'] && isset($param['deploy_optimize']['domain']) && $param['deploy_optimize']['domain']){
$server_model = new ServerConfig();
$server_info = $server_model->read(['id'=>$param['serve_id']],['init_domain','host']);
$domain_model = new DomainInfo();
$domain_info = $domain_model->read(['id'=>$param['deploy_optimize']['domain']],'domain');
if($server_info && $domain_info){
//验证解析
if (!empty($domain_info['domain']) && !DomainInfoLogic::instance()->check_cname($domain_info['domain'], $server_info)) {
throw new AsideGlobalException(Code::SYSTEM_ERROR,'域名' . $domain_info['domain'] . '未解析至目标服务器');
}
$api_url = 'http://'.$server_info['init_domain'].'/api/createSite';
$api_param = ['domain'=>$domain_info['domain']];
try {
HttpUtils::get($api_url, $api_param);
} catch (\Exception | GuzzleException $e) {
errorLog('创建站点', $api_param, $e);
}
}
}
}
/**
* @remark :复制项目
* @name :copyProject
* @author :lyh
... ...
... ... @@ -156,7 +156,7 @@ class ReplaceHtmlLogic extends BaseLogic
'template_id'=>$template_id,
'status'=>$this->model::STATUS,
'old_html'=>$param['old_html'],
'html'=>$param['html'],
'html'=>$param['html'] ?? '',
'project_id'=>$param['project_id'],
'total_num'=>0,
'operator_id'=>$this->manager['id']
... ...
... ... @@ -47,10 +47,7 @@ class AyrReleaseLogic extends BaseLogic
$this->param['platforms'] = json_encode($this->param['platforms']);
$info = $this->model->read(['platforms'=>$this->param['platforms'],'operator_id'=>$this->param['operator_id'],'project_id'=>$this->param['project_id'],'title'=>$this->param['title']]);
if($info === false){
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error');
}
$this->model->add($this->param);
}
return $this->success();
}
... ...
... ... @@ -28,9 +28,18 @@ class BTemplateModuleLogic extends BaseLogic
$map['status'] = 0;
$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');
$list[$k] = $v;
$label = [];
foreach ($list as $v){
$label[] = $v['id'];
}
$label_arr = $templateLabel->list(['template_id'=>['in',$label],'type'=>2],'id',['id','template_id','name'],'desc');
foreach ($list as $k1 => $v1){
foreach ($label_arr as $v2){
if($v2['template_id'] == $v1['id']){
$v1['label'][] = $v2;
}
}
$list[$k1] = $v1;
}
return $this->success($list);
}
... ...
... ... @@ -33,13 +33,22 @@ class BTemplateModuleProjectLogic extends BaseLogic
public function ModuleList($map,$order = 'created_at',$filed = ['id','name','status','image','html','project_id']){
$map['deleted_status'] = 0;
$map['project_id'] = $this->user['project_id'];
$lists = $this->model->list($map,$order,$filed);
$list = $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;
$label = [];
foreach ($list as $v){
$label[] = $v['id'];
}
return $this->success($lists);
$label_arr = $templateLabel->list(['template_id'=>['in',$label],'type'=>2],'id',['id','template_id','name'],'desc');
foreach ($list as $k1 => $v1){
foreach ($label_arr as $v2){
if($v2['template_id'] == $v1['id']){
$v1['label'][] = $v2;
}
}
$list[$k1] = $v1;
}
return $this->success($list);
}
/**
... ...
... ... @@ -326,13 +326,10 @@ class ProductLogic extends BaseLogic
* @time :2023/10/20 9:02
*/
public function handleListCategory($category){
$str = '';
if(isset($category) && !empty($category)){
foreach ($category as $v){
$str .= $v.',';
}
return ','.implode(',',$category).',';
}
return !empty(trim($str,',')) ? ','.$str.',' : '';
return '';
}
... ...
... ... @@ -61,10 +61,10 @@ class WebSettingFromLogic extends BaseLogic
* @param $url
* @return WebSettingFormBack|mixed
*/
public function fromBackMsgSet($message, $url)
public function fromBackMsgSet($message, $url, $other = false)
{
$project_id = $this->user['project_id'];
$info = WebSettingFormBack::saveBack($project_id, $message, $url);
$info = WebSettingFormBack::saveBack($project_id, $message, $url,$other);
return $info;
}
... ...
... ... @@ -25,7 +25,7 @@ class BlogRequest extends FormRequest
{
return [
'name'=>'required|max:200',
'seo_keywords'=>'max:1000',
'seo_keywords'=>'max:500',
'url'=>'required',
];
}
... ...
... ... @@ -3,6 +3,8 @@
namespace App\Jobs;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Utils\HttpUtils;
... ... @@ -51,16 +53,17 @@ class EditAmpDomainBt implements ShouldQueue
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) {
$serverIpModel = new ServersIp();
$serversIpInfo = $serverIpModel->read(['id'=>$project_info['serve_id']],['servers_id','ip']);
if ($serversIpInfo === false) {
return $this->output($domain_info['domain'] . ':获取服务器数据失败');
}
$serverModel = new Servers();
$serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']);
$server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']];
//编辑amp站
$api_url_amp = 'http://' . $server_info['init_domain'] . '/api/createSiteAmp';
$api_url_amp = 'http://' . $server_info['domain'] . '/api/createSiteAmp';
$api_param_amp = [
'domain' => $domain_info['domain'],
];
... ...
... ... @@ -3,6 +3,8 @@
namespace App\Jobs;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Project\CountryCustom;
use App\Models\Project\Project;
use App\Utils\HttpUtils;
... ... @@ -51,14 +53,17 @@ class EditCustomDomainBt implements ShouldQueue
return $this->output($domain_info['custom_domain'] . ':获取项目数据失败');
}
//获取服务器数据
$server_model = new ServerConfig();
$server_info = $server_model->read(['id' => $project_info['serve_id']], ['init_domain', 'host']);
if ($server_info === false) {
$serverIpModel = new ServersIp();
$serversIpInfo = $serverIpModel->read(['id'=>$project_info['serve_id']],['servers_id','ip']);
if ($serversIpInfo === false) {
return $this->output($domain_info['custom_domain'] . ':获取服务器数据失败');
}
$serverModel = new Servers();
$serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']);
$server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']];
//编辑站点
if ($domain_info['type'] == 2) {
$api_url = 'http://' . $server_info['init_domain'] . '/api/setSsl';
$api_url = 'http://' . $server_info['domain'] . '/api/setSsl';
$api_param = [
'domain' => $domain_info['custom_domain'],
'private_key' => $domain_info['private_key'],
... ... @@ -68,7 +73,7 @@ class EditCustomDomainBt implements ShouldQueue
'is_https' => 1
];
} else {
$api_url = 'http://' . $server_info['init_domain'] . '/api/applySsl';
$api_url = 'http://' . $server_info['domain'] . '/api/applySsl';
$api_param = [
'domain' => $domain_info['custom_domain'],
'rewrite' => [],
... ...
... ... @@ -3,6 +3,8 @@
namespace App\Jobs;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Utils\HttpUtils;
... ... @@ -53,15 +55,17 @@ class EditDomainBt implements ShouldQueue
}
//获取服务器数据
$server_model = new ServerConfig();
$server_info = $server_model->read(['id' => $project_info['serve_id']], ['init_domain', 'host']);
if ($server_info === false) {
$serverIpModel = new ServersIp();
$serversIpInfo = $serverIpModel->read(['id'=>$project_info['serve_id']],['servers_id','ip']);
if ($serversIpInfo === false) {
return $this->output($domain_info['domain'] . ':获取服务器数据失败');
}
$serverModel = new Servers();
$serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']);
$server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']];
//编辑主站
if ($domain_info['type'] == 2) {
$api_url = 'http://' . $server_info['init_domain'] . '/api/setSsl';
$api_url = 'http://' . $server_info['domain'] . '/api/setSsl';
$api_param = [
'domain' => $domain_info['domain'],
'private_key' => $domain_info['private_key'],
... ... @@ -71,7 +75,7 @@ class EditDomainBt implements ShouldQueue
'is_https' => $domain_info['is_https']
];
} else {
$api_url = 'http://' . $server_info['init_domain'] . '/api/applySsl';
$api_url = 'http://' . $server_info['domain'] . '/api/applySsl';
$api_param = [
'domain' => $domain_info['domain'],
'rewrite' => $domain_info['extend_config'],
... ...
... ... @@ -17,7 +17,6 @@ class Project extends Base
protected $table = 'gl_project';
const DATABASE_NAME_FIX = 'gl_data_';
const CUSTOMIZED_ONE = 1;//定制项目
const DEMO_PROJECT_ID = 1;
... ...
... ... @@ -447,7 +447,9 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/list', [Aside\Devops\ServersIpController::class, 'list'])->name('admin.servers_list');
Route::any('/save', [Aside\Devops\ServersIpController::class, 'save'])->name('admin.servers_save');
Route::any('/batchSave', [Aside\Devops\ServersIpController::class, 'batchSave'])->name('admin.servers_batchSave');
Route::any('/batchDel', [Aside\Devops\ServersIpController::class, 'batchDel'])->name('admin.servers_batchDel');
Route::any('/info', [Aside\Devops\ServersIpController::class, 'info'])->name('admin.servers_info');
Route::any('/downloadFile', [Aside\Devops\ServersIpController::class, 'downloadFile'])->name('admin.servers_downloadFile');
});
});
... ...