作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

<?php
/**
* @remark :
* @name :UpdateRoute.php
* @author :lyh
* @method :post
* @time :2023/11/20 15:07
*/
namespace App\Console\Commands;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* @remark :更新所有项目的路由
* @name :UpdateRoute
* @author :lyh
* @method :post
* @time :2023/11/20 15:08
*/
class UpdateRoute extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_route';
/**
* The console command description.
*
* @var string
*/
protected $description = '更新路由';
/**
* @remark :统一更新路由
* @name :handle
* @author :lyh
* @method :post
* @time :2023/11/20 15:13
*/
public function handle(){
$projectModel = new Project();
$lists = $projectModel->list(['is_upgrade'=>0,'type'=>['!=',0]]);
foreach ($lists as $k => $v){
echo date('Y-m-d H:i:s') . ' start: 项目id为' . $v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->setProductRoute($v['id']);
$this->setProductKeywordRoute($v['id']);
$this->setBlogRoute($v['id']);
$this->setNewsRoute($v['id']);
$this->setBlogCateRoute($v['id']);
$this->setNewsCateRoute($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . ' end: 项目id为' . $v['id'] . PHP_EOL;
}
/**
* @remark :设置路由
* @name :setRoute
* @author :lyh
* @method :post
* @time :2023/11/20 15:30
*/
public function setProductRoute($project_id){
$productModel = new Product();
$productList = $productModel->list(['status'=>['!=',2]],'id',['id','route']);
foreach ($productList as $v){
$route = preg_replace('/-product.*/', '', $v['route']);
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $project_id);
$route = $route.'-product';
$productModel->edit(['route'=>$route],['id'=>$v['id']]);
RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $project_id);
}
return true;
}
/**
* @remark :设置路由
* @name :setRoute
* @author :lyh
* @method :post
* @time :2023/11/20 15:30
*/
public function setNewsRoute($project_id){
$newsModel = new News();
$newsList = $newsModel->list(['status'=>['!=',2]],'id',['id','url']);
foreach ($newsList as $v){
RouteMap::setRoute($v['url'], RouteMap::SOURCE_NEWS, $v['id'], $project_id);
}
return true;
}
/**
* @remark :设置路由
* @name :setRoute
* @author :lyh
* @method :post
* @time :2023/11/20 15:30
*/
public function setNewsCateRoute($project_id){
$newsCateModel = new NewsCategory();
$newsList = $newsCateModel->list([],'id',['id','alias']);
foreach ($newsList as $v){
RouteMap::setRoute($v['alias'], RouteMap::SOURCE_NEWS_CATE, $v['id'], $project_id);
}
return true;
}
/**
* @remark :设置路由
* @name :setRoute
* @author :lyh
* @method :post
* @time :2023/11/20 15:30
*/
public function setBlogRoute($project_id){
$blogModel = new Blog();
$blogList = $blogModel->list(['status'=>['!=',2]],'id',['id','url']);
foreach ($blogList as $v){
RouteMap::setRoute($v['url'], RouteMap::SOURCE_BLOG, $v['id'], $project_id);
}
return true;
}
/**
* @remark :设置路由
* @name :setRoute
* @author :lyh
* @method :post
* @time :2023/11/20 15:30
*/
public function setBlogCateRoute($project_id){
$blogCateModel = new BlogCategory();
$blogList = $blogCateModel->list([],'id',['id','alias']);
foreach ($blogList as $v){
RouteMap::setRoute($v['alias'], RouteMap::SOURCE_BLOG_CATE, $v['id'], $project_id);
}
return true;
}
/**
* @remark :设置路由
* @name :setRoute
* @author :lyh
* @method :post
* @time :2023/11/20 15:30
*/
public function setProductKeywordRoute($project_id){
$keywordModel = new Keyword();
$keywordList = $keywordModel->list([],'id',['id','route']);
foreach ($keywordList as $v){
if(!ends_with($v['route'],'-tag')){
$route = $v['route'].'-tag';
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
RouteMap::setRoute($route, RouteMap::SOURCE_BLOG_CATE, $v['id'], $project_id);
}
}
return true;
}
}
... ...
<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Helper\Common;
use App\Helper\Gpt;
use App\Helper\Translate;
use App\Models\Ai\AiCommand;
use App\Models\Mail\Mail;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\User\User;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
/**
* 初始化项目
* Class InitProject
* @package App\Console\Commands
* @author zbj
* @date 2023/10/8
*/
class UpdateSeoTdkCrontab extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_seo_tdk_crontab';
/**
* The console command description.
*
* @var string
*/
protected $description = '一键生成tdk';
/**
* @return bool
*/
public function handle()
{
$project_ids = Project::where('type', Project::TYPE_TWO)->pluck('id')->toArray();
foreach ($project_ids as $project_id){
ProjectUpdateTdk::add_task($project_id);
}
}
}
... ...
... ... @@ -37,6 +37,7 @@ class Kernel extends ConsoleKernel
$schedule->command('domain_info')->dailyAt('01:00')->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
}
/**
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\MenuLogic;
use App\Models\Inquiry\InquiryData;
use App\Models\Manage\Manage;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
... ... @@ -71,4 +72,34 @@ class IndexController extends BaseController
$this->response('success');
}
/**
* @remark :同步询盘记录
* @name :sync_inquiry
* @author :lyh
* @method :post
* @time :2023/11/16 9:51
*/
public function sync_inquiry(){
$this->request->validate([
'data' => 'required|array',
'identifying'=>'required',
'code'=>'required'
], [
'data.required' => '自定义询盘数据不为空',
'data.array' => '必须为数组',
'identifying.required' => '唯一标识不为空',
'code'=>'加密串不能为空'
]);
$code = base64_encode(md5($this->param['identifying']));
if($code != $this->param['code']){
$this->response('签名错误',Code::SYSTEM_ERROR);
}
$inquiryModel = new InquiryData();
$rs = $inquiryModel->add($this->param);
if($rs === false){
$this->response('error',Code::SYSTEM_ERROR);
}
$this->response('success');
}
}
... ...
... ... @@ -103,6 +103,7 @@ class OptimizeController extends BaseController
'gl_project.finish_remain_day AS finish_remain_day',
'gl_project.is_remain_today AS is_remain_today',
'gl_project.remain_day AS remain_day',
'gl_project.robots AS robots',
'gl_project_online_check.id AS online_check_id',
'gl_project_online_check.question AS question',
'gl_project_online_check.go_question AS go_question',
... ... @@ -224,4 +225,27 @@ class OptimizeController extends BaseController
}
$this->response('success');
}
/**
* @remark :设置开关
* @name :setRobots
* @author :lyh
* @method :post
* @time :2023/11/20 9:42
*/
public function setRobots(){
$this->request->validate([
'robots'=>'required',
'project_id'=>'required',
],[
'robots.required' => 'robots不能为空',
'project_id.required' => 'project_id不能为空',
]);
$projectModel = new Project();
$rs = $projectModel->edit(['robots'=>$this->param['robots']],['id'=>$this->param['project_id']]);
if($rs === false){
$this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR);
}
$this->response('success');
}
}
... ...
... ... @@ -14,6 +14,8 @@ use App\Http\Requests\Aside\Project\ProcessRecordsRequest;
use App\Http\Requests\Aside\Project\ProjectRequest;
use App\Models\ASide\APublicModel;
use App\Models\Channel\Channel;
use App\Models\Channel\User;
use App\Models\Channel\Zone;
use App\Models\Com\City;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
... ... @@ -800,10 +802,42 @@ class ProjectController extends BaseController
],[
'project_id.required' => 'project_id不能为空',
]);
$token = $logic->getSiteToken($this->map);
$this->response('success',Code::SUCCESS,['site_token' => $token]);
}
/**
* @remark :单独保存其他项目配置
* @name :saveOtherProject
* @author :lyh
* @method :post
* @time :2023/11/17 15:23
*/
public function saveOtherProject(ProjectLogic $logic){
$logic->saveOtherProject();
$this->response('success');
}
/**
* @remark :获取渠道信息
* @name :getChannel
* @author :lyh
* @method :post
* @time :2023/11/17 16:08
*/
public function getChannel(){
$zoneModel = new Zone();
$zone_list = $zoneModel->list();
$channelModel = new Channel();
$channelUserModel = new User();
foreach ($zone_list as $k => $v){
$channel_list = $channelModel->list(['zone_id'=>$v['id']]);
foreach ($channel_list as $k1 => $v1){
$user_list = $channelUserModel->list(['channel_id'=>$v1['id']]);
$channel_list[$k1]['sub'] = $user_list;
}
$zone_list[$k]['sub'] = $channel_list;
}
$this->response('success',Code::SUCCESS,$zone_list);
}
}
... ...
... ... @@ -16,7 +16,6 @@ use App\Helper\Common;
use App\Helper\Translate;
use App\Helper\Wechat;
use App\Http\Logic\Bside\User\UserLoginLogic;
use App\Models\Channel\Channel;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\Service\Service;
... ... @@ -25,9 +24,7 @@ use App\Models\User\DeptUser;
use App\Models\User\ProjectRole;
use App\Models\User\User;
use App\Utils\EncryptUtils;
use App\Utils\LogUtils;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Mrgoon\AliSms\AliSms;
class LoginController extends BaseController
... ... @@ -302,4 +299,5 @@ class LoginController extends BaseController
}
return $data;
}
}
... ...
... ... @@ -50,23 +50,6 @@ class BTemplateController extends BaseController
}
/**
* @remark :设置默认模板
* @name :setModuleTemplate
* @author :lyh
* @method :post
* @time :2023/6/29 9:39
*/
public function setPublicTemplate(BTemplateLogic $BTemplateLogic){
$this->request->validate([
'template_id'=>['required'],
],[
'template_id.required' => '模版ID不能为空',
]);
$BTemplateLogic->setTemplate();
$this->response('success');
}
/**
* @remark :保存编辑后的模板
* @name :save
* @author :lyh
... ...
... ... @@ -30,9 +30,8 @@ class VisualizationController extends BaseController
* @method :post
* @time :2023/11/15 10:26
*/
public function info(Visualization $visualization){
//查看当前模板是否在可视化中保存
$info = $visualization->read(['source'=>$this->map['source']],['html','source','id','project_id']);
public function info(VisualizationLogic $logic){
$info = $logic->getVisualizationInfo();
if($info === false){
$info = [];
}
... ... @@ -47,13 +46,6 @@ class VisualizationController extends BaseController
* @time :2023/11/15 10:08
*/
public function save(VisualizationLogic $logic){
$this->request->validate([
'source'=>'required',
'html'=>'required',
],[
'source.required' => '类型不能为空',
'html.required' => 'html不能为空',
]);
$logic->saveVisualization();
$this->response('success');
}
... ... @@ -74,7 +66,7 @@ class VisualizationController extends BaseController
'source_id.required' => 'source_id不能为空',
]);
$data = $logic->getHtml();
$this->response('success',Code::SUCCESS,['html'=>$data]);
$this->response('success',Code::SUCCESS,$data);
}
/**
... ...
... ... @@ -84,6 +84,9 @@ class ProjectLogic extends BaseLogic
if(isset($info['is_customized']) && $info['is_customized'] == 1){
$info['is_visualization'] = json_decode($info['is_visualization']);
}
if(isset($info['deploy_build']['other_project']) && !empty($info['deploy_build']['other_project'])){
$info['deploy_build']['other_project']= json_decode($info['deploy_build']['other_project']);
}
return $this->success($info);
}
... ... @@ -692,4 +695,19 @@ class ProjectLogic extends BaseLogic
return $project->site_token;
}
/**
* @remark :保存其他配置
* @name :saveOtherProject
* @author :lyh
* @method :post
* @time :2023/11/17 15:26
*/
public function saveOtherProject(){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success($this->param);
}
}
... ...
... ... @@ -4,8 +4,11 @@ namespace App\Http\Logic\Aside\Template;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Template;
use App\Models\Template\Setting;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class ATemplateLogic extends BaseLogic
... ... @@ -180,6 +183,8 @@ class ATemplateLogic extends BaseLogic
}else{
$rs = $bSettingModel->edit(['template_id'=>$this->param['template_id']],['id'=>$info['id']]);
}
$this->saveTemplate($this->param['project_id'],$this->param['template_id']);
//保存一条装修数据
if($rs === false){
$this->fail('error');
}
... ... @@ -187,6 +192,41 @@ class ATemplateLogic extends BaseLogic
}
/**
* @remark :设置模版保存装修首页记录
* @name :saveTemplate
* @author :lyh
* @method :post
* @time :2023/11/17 11:04
*/
public function saveTemplate($project_id,$template_id){
$templateInfo = $this->model->read(['id'=>$template_id]);
ProjectServer::useProject($project_id);
$bTemplateModel = new BTemplate();
$info = $bTemplateModel->read(['source'=>1,'template_id'=>$template_id]);
if($info === false){
$data = [
'source'=>1, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'],
'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id,
];
$bTemplateModel->add($data);
}
//保存一次公共头部信息
$bCommonTemplateModel = new BTemplateCommon();
$commonInfo = $bCommonTemplateModel->read(['template_id'=>$template_id,'type'=>1]);
if($commonInfo === false){
$commonData = [
'type'=>1, 'template_id'=>$template_id, 'head_html'=>$templateInfo['head_html'],
'head_css'=>$templateInfo['head_css'], 'footer_html'=>$templateInfo['footer_html'],
'footer_css'=>$templateInfo['footer_css'],'project_id'=>$project_id,
'other'=>str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"))
];
$bCommonTemplateModel->add($commonData);
}
DB::disconnect('custom_mysql');
return $this->success();
}
/**
* @remark :获取选择的模版
* @name :getSettingInfo
* @author :lyh
... ...
... ... @@ -47,8 +47,8 @@ class BTemplateLogic extends BaseLogic
*/
public function publicTemplateLists($map,$page,$row,$order = 'created_at',$filed = ['id','name','image','url','created_at','status','deleted_status']){
$templateModel = new Template();
$map['deleted_status'] = 0;
$map['status'] = 0;
$map['deleted_status'] = BTemplate::STATUS;
$map['status'] = BTemplate::STATUS;
$lists = $templateModel->lists($map,$page,$row,$order,$filed);
return $this->success($lists);
}
... ... @@ -222,32 +222,6 @@ class BTemplateLogic extends BaseLogic
return $commonInfo;
}
/**
* @remark :设置模板
* @name :setTemplate
* @author :lyh
* @method :post
* @time :2023/6/29 9:47
*/
public function setTemplate(){
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$param = [
'project_id'=>$this->user['project_id'],
'template_id'=>$this->param['template_id'],
];
$rs = $bSettingModel->add($param);
}else{
$rs = $bSettingModel->edit(['template_id'=>$this->param['template_id']],['project_id'=>$this->user['project_id']]);
}
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @remark :保存修改后的模版
* @name :templateSave
... ...
... ... @@ -47,8 +47,10 @@ class CustomTemplateLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在');
}
$html = $this->getBodyHeaderFooter($info['html'],$info['html_style']);
$info['html'] = $this->getHeadFooter($html);
if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){
$html = $this->getBodyHeaderFooter($info['html'],$info['html_style']);
$info['html'] = $this->getHeadFooter($html);
}
return $this->success($info);
}
... ... @@ -90,15 +92,16 @@ class CustomTemplateLogic extends BaseLogic
*/
public function saveHtml(){
$html = $this->param['html'];
$this->saveCommonTemplate($html);
$this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$info = $this->model->read(['id'=>$this->param['id']],['id','is_visualization','url']);
if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){//非定制项目+可视化页面
$this->saveCommonTemplate($html);
$this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理');
}
//TODO::通知网站更新
$info = $this->model->read(['id'=>$this->param['id']],['id','url']);
$data = ['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PAGE, 'route'=>$info['url']];
$this->updateNotify($data);
return $this->success();
... ...
... ... @@ -10,8 +10,14 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Project\PageSetting;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\Template;
use App\Models\Template\TemplateTypeMain;
use App\Models\Visualization\Visualization;
class VisualizationLogic extends BaseLogic
... ... @@ -19,11 +25,56 @@ class VisualizationLogic extends BaseLogic
public function __construct()
{
parent::__construct();
$this->model = new Visualization();
$this->model = new BTemplateMain();
$this->param = $this->requestAll;
}
/**
* @remark :获取代码块
* @name :getVisualizationInfo
* @author :lyh
* @method :post
* @time :2023/11/17 14:44
*/
public function getVisualizationInfo(){
$data = $this->getSource($this->param['type']);
$source = $data['source'];
$source_id = $data['source_id'];
$type = $this->getType($source,$source_id);
$typeArray = [1,3,5,7];//单页数据
if(in_array($type,$typeArray)){
$bTemplateModel = new BTemplate();
$info = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]);
if($info === false){
$html = '';
}else{
$html = $info['html'];
}
}else{//模块数据
$bTemplateMainModel = new BTemplateMain();
$info = $bTemplateMainModel->read(['type'=>$type]);
if($info === false){
$html = '';
}else{
$html = $info['main_html'];
}
}
return $this->success(['html'=>$html]);
}
public function getSource($type){
$source_id = 0;
if ($type == 2){$source = 2;$source_id = 1;
}elseif ($type == 3){$source = 2;
}elseif ($type == 4){$source = 3;$source_id = 1;
}elseif ($type == 5){$source = 3;
}elseif ($type == 6){$source = 4;$source_id = 1;
}elseif ($type == 7){$source = 4;
}else{$source = 1;}
return ['source'=>$source,'source_id'=>$source_id];
}
/**
* @remark :保存定制html
* @name :saveHtml
* @author :lyh
... ... @@ -32,11 +83,38 @@ class VisualizationLogic extends BaseLogic
*/
public function saveVisualization(){
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
$sourceData = $this->getSource($this->param['type']);
$source = $sourceData['source'];
$source_id = $sourceData['source_id'];
$type = $this->param['type'];
$typeArray = [1,3,5,7];//单页数据
if(in_array($type,$typeArray)){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read(['source'=>$source,'source'=>$source_id,'template_id'=>0]);
if($templateInfo === false){
$data = [
'html'=>$this->param['html'],
'project_id'=>$this->user['project_id'],
'source'=>$source,
'source_id'=>$source_id,
];
$bTemplateModel->add($data);
}else{
$bTemplateModel->edit(['html'=>$this->param['html']],['id'=>$templateInfo['id']]);
}
}else{//模块数据
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['type'=>$type]);
if($mainInfo === false){
$mainData = [
'project_id'=>$this->user['project_id'],
'type'=>$type,
'main_html'=>$this->param['html']
];
$bTemplateMainModel->add($mainData);
}else{
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
}
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
... ... @@ -45,37 +123,145 @@ class VisualizationLogic extends BaseLogic
}
/**
* @remark :可视化装修获取html
* @remark :定制页面支持可视化装修获取html
* @name :getHtml
* @author :lyh
* @method :post
* @time :2023/11/15 11:30
*/
public function getHtml(){
$type = $this->getType($this->param['source'],$this->param['source_id']);//获取类型
$page_array = (array)$this->user['is_visualization']->page_array;//获取定制界面
//查看当前类型是否是定制界面
if(in_array($type,$page_array)){//是定制界面
if(in_array($type,[1,3,5,7])){//单页
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前定制单页是否有代码块
if($templateInfo === false){
$this->fail('请先上传定制代码块');
}
return ['html'=>$templateInfo['html']];
}else{//模块页
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前页面是否可视化
if($templateInfo === false){//获取代码块
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['type'=>$type]);
if($mainInfo === false){
$this->fail('请先上传定制代码块');
}
return ['html'=>$mainInfo['main_html']];
}
return ['html'=>$templateInfo['html']];
}
}else{//非定制界面
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先选择模版');
}
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);//查看当前页面是否可视化
if($templateInfo === false){
//根据类型在获取中间部分
$mainData = $this->getCommonMain($this->param['source'],$this->param['source_id']);
}else{
$mainData = [
'main_html'=>$templateInfo['main_html'],
'main_css'=>$templateInfo['main_css']
];
}
//获取公共头部底部
$commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);
//拼接数据
$html = $commonInfo['head_css'].$mainData['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$mainData['main_html'].$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);
return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
}
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
* @method :post
* @time :2023/7/21 17:22
*/
public function getHeadFooter($html){
//获取公共主题头部底部
$serviceSettingModel = new ServiceSettingModel();
$list = $serviceSettingModel->list(['type'=>2],'created_at');
//拼接html
foreach ($list as $v){
if($v['key'] == 'head'){
$html = $v['values'].$html;
}
if($v['key'] == 'footer'){
$html = $html.$v['values'];
}
}
return $html;
}
/**
* @remark :获取可视化装修记录
* @name :getWebTemplate
* @author :lyh
* @method :post
* @time :2023/11/16 11:21
*/
public function getWebTemplate($source,$source_id,$template_id = 0){
//查询可视化是否第一次保存
$bTemplateModel = new BTemplate();
$TemplateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
$param = [
'source'=>$source,
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
]);
if($this->param['source'] == 2){
if($this->param['source_id'] == 0){$source = 3;}else{$source = 2;}
'source_id'=>$source_id,
'template_id'=>$template_id
];
return $bTemplateModel->read($param);
}
/**
* @remark :获取类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
*/
public function getType($source,$source_id){
$type = 1;
if($source == 2){
if($source_id == 0){$type = 3;}else{$type = 2;}
}
if($this->param['source'] == 3){
if($this->param['source_id'] == 0){$source = 5;}else{$source = 4;}
if($source == 3){
if($source_id == 0){$type = 5;}else{$type = 4;}
}
if($this->param['source'] == 4){
if($this->param['source_id'] == 0){$source = 7;}else{$source = 6;}
if($source == 4){
if($source_id == 0){$type = 7;}else{$type = 6;}
}
if($TemplateInfo === false){
$info = $this->model->read(['source'=>$source],['html','source','id','project_id']);
if($info === false){
$this->fail('请先上传定制代码块');
return $type;
}
/**
* @remark :获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getSaveType($source,$source_id){
$type = 1;//首页公共头部底部
//查看页面是否设置自定义头部底部
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo !== false) {
if ($source == 2) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = 2;}} else {if ($pageInfo['product_list'] != 0) {$type = 3;}}}
if ($source == 3) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = 4;}} else {if ($pageInfo['blog_list'] != 0) {$type = 5;}}}
if ($source == 4) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = 6;}} else {if ($pageInfo['news_list'] != 0) {$type = 7;}}}
if ($source == 5) {if ($pageInfo['polymerization'] != 0) {$type = 8;}}
}
return $info['html'];
}
return $TemplateInfo['html'];
return $type;
}
/**
... ... @@ -86,26 +272,154 @@ class VisualizationLogic extends BaseLogic
* @time :2023/11/15 11:47
*/
public function saveHtml(){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
]);
$page_array = (array)$this->user['is_visualization']->page_array;
$type = $this->getType($this->param['source'],$this->param['source_id']);
try {
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$bTemplateModel->add($this->param);
if(in_array($type,$page_array)){//定制页面
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
]);
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$bTemplateModel->add($this->param);
}else{
$bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
}
}else{
$bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
'template_id'=>$this->param['template_id'],
]);
$this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
//保存头部
$this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$bTemplateModel->add($this->param);
}else{
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
}
}
}catch (\Exception $e){
$this->fail('系统错误请联系管理员');
$this->fail('系统错误请联系管理员');
}
return $this->success();
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($html,$source,$source_id,$template_id){
$type = $this->getSaveType($source,$source_id);
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
$data = [
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
];
$other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
if($info === false){
$data['template_id'] = $template_id;
$data['project_id'] = $this->user['project_id'];
$data['type'] = $type;
$templateCommonModel->add($data);
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
}
//更新所有界面的other
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]);
return $this->success();
}
/**
* @remark :获取中间公共部分
* @name :getCommonMain
* @author :lyh
* @method :post
* @time :2023/10/24 15:58
*/
public function getCommonMain($source,$source_id){
$data = [];
if ($source == 2) {if ($source_id != 0) {$type = 2;} else {$type = 3;}}
if ($source == 3) {if ($source_id != 0) {$type = 4;} else {$type = 5;}}
if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}}
if ($source == 5) {$type = 8;}
//查询有没有公共详情模板
$mainInfo = $this->model->read(['type'=>$type]);
if($mainInfo === false){
$data['main_html'] = $this->getModule($type);
$data['main_css'] = "<style id='globalsojs-styles'></style>";
}else{
$data['main_html'] = $mainInfo['main_html'];
$data['main_css'] = $mainInfo['main_css'];
}
return $data;
}
/**
* @remark :默认产品模块
* @name :getProductModule
* @author :lyh
* @method :post
* @time :2023/7/27 15:08
*/
public function getModule($type){
//获取公共主题头部底部
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type]);
return $info['main_html'];
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonPage($source,$source_id,$template_id){
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
//查看页面是否设置自定义头部底部
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo != false) {
$commonTemplateModel = new BTemplateCommon();
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id']
];
if ($source == 2) {//产品页
if($source_id != 0){$data['type'] = 2;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 3;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 3) {//博客页
if ($source_id != 0) {$data['type'] = 4;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 5;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 4) {//新闻页
if ($source_id != 0) {$data['type'] = 6;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 7;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 5) {//聚合页
$data['type'] = 8;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
}
}
//获取首页公共的头部和底部
if(!isset($commonInfo) || $commonInfo === false){
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
}
return $commonInfo;
}
}
... ...
... ... @@ -60,8 +60,9 @@ class ExtendLogic extends BaseLogic
$info = $this->model->read(['key'=>$key.$i]);
if($info !== false){
return $this->getKey($key,$i+1);
}else{
return $key.$i;
}
return $key;
}
/**
... ...
... ... @@ -113,7 +113,7 @@ class ProductLogic extends BaseLogic
unset($v['title']);
if($v['type'] == 3 || $v['type'] == 4){
foreach ($v['values'] as $k1=>$v1){
$v1 = str_replace_url($v1);
$v1['url'] = str_replace_url($v1['url']);
$v['values'][$k1] = $v1;
}
$v['values'] = json_encode($v['values']);
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Models\Channel;
use App\Models\Base;
use Illuminate\Database\Eloquent\Model;
use phpDocumentor\Reflection\Types\Self_;
... ... @@ -11,7 +12,7 @@ use phpDocumentor\Reflection\Types\Self_;
* @author zbj
* @date 2023/6/27
*/
class Channel extends Model
class Channel extends Base
{
//设置关联表名
protected $table = 'gl_channel';
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Models\Channel;
use App\Models\Base;
use Illuminate\Database\Eloquent\Model;
/**
... ... @@ -10,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
* @author zbj
* @date 2023/6/27
*/
class Zone extends Model
class Zone extends Base
{
//设置关联表名
protected $table = 'gl_channel_zone';
... ...
<?php
/**
* @remark :
* @name :InquiryData.php
* @author :lyh
* @method :post
* @time :2023/11/16 9:54
*/
namespace App\Models\Inquiry;
use App\Models\Base;
class InquiryData extends Base
{
protected $table = 'gl_inquiry_data';
}
... ...
... ... @@ -109,15 +109,7 @@ class RouteMap extends Base
if(!$route_map){
$route_map = new self();
$route_map->source = $source;
if($source == self::SOURCE_NEWS){
$route_map->path = self::SOURCE_NEWS;
}elseif($source == self::SOURCE_NEWS_CATE){
$route_map->path = self::PATH_NEWS_CATE;
}elseif ($source == self::SOURCE_BLOG){
$route_map->path = self::SOURCE_BLOG;
}elseif ($source == self::SOURCE_BLOG_CATE){
$route_map->path = self::PATH_BLOG_CATE;
}elseif ($source == self::SOURCE_PRODUCT_KEYWORD){
if ($source == self::SOURCE_PRODUCT_KEYWORD){
$route = $route.'-tag';
}elseif ($source == self::SOURCE_PRODUCT){
$route = $route.'-product';
... ... @@ -125,6 +117,15 @@ class RouteMap extends Base
$route_map->source_id = $source_id;
$route_map->project_id = $project_id;
}
if($source == self::SOURCE_NEWS){
$route_map->path = self::SOURCE_NEWS;
}elseif($source == self::SOURCE_NEWS_CATE){
$route_map->path = self::PATH_NEWS_CATE;
}elseif ($source == self::SOURCE_BLOG){
$route_map->path = self::SOURCE_BLOG;
}elseif ($source == self::SOURCE_BLOG_CATE){
$route_map->path = self::PATH_BLOG_CATE;
}
$route_map->route = $route;
$route_map->save();
}catch (\Exception $e){
... ...
... ... @@ -13,7 +13,12 @@ use App\Models\Base;
class BTemplate extends Base
{
const SOURCE_HOME = 1;//首页
const SOURCE_PRODUCT = 2;//产品页
const SOURCE_PRODUCT = 2;//产品
const SOURCE_BLOG = 3;//博客
const SOURCE_NEWS = 4;//新闻详情页
const STATUS = 0;
protected $table = 'gl_web_template';
//连接数据库
... ...
... ... @@ -171,6 +171,8 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/tdkList', [Aside\Project\ProjectController::class, 'tdkList'])->name('admin.project_tdkList');
Route::any('/copyProject', [Aside\Project\ProjectController::class, 'copyProject'])->name('admin.project_copyProject');
Route::any('/site_token', [Aside\Project\ProjectController::class, 'site_token'])->name('admin.project_site_token');
Route::any('/saveOtherProject', [Aside\Project\ProjectController::class, 'saveOtherProject'])->name('admin.project_saveOtherProject');//其他项目设置
Route::any('/getChannel', [Aside\Project\ProjectController::class, 'getChannel'])->name('admin.project_getChannel');//其他项目设置
//获取关键词前缀和后缀
Route::prefix('keyword')->group(function () {
Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix');
... ... @@ -248,6 +250,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/', [Aside\Optimize\OptimizeController::class, 'lists'])->name('admin.optimize_lists');//优化中台
Route::any('/getAiPrefix', [Aside\Optimize\OptimizeController::class, 'getAiPrefix'])->name('admin.optimize_getAiPrefix');//获取Ai前后缀
Route::any('/saveAiPrefix', [Aside\Optimize\OptimizeController::class, 'saveAiPrefix'])->name('admin.optimize_saveAiPrefix');//保存Ai前后缀
Route::any('/setRobots', [Aside\Optimize\OptimizeController::class, 'setRobots'])->name('admin.optimize_setRobots');//设置robots开关
});
//优化中台
... ... @@ -342,6 +345,8 @@ Route::group([], function () {
Route::any('get_template_detail', [Aside\Template\ATemplateController::class, 'getTemplateDetail'])->name('admin.get_template_detail');
Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect');
//同步询盘
Route::any('/sync_inquiry', [Aside\Com\IndexController::class, 'sync_inquiry'])->name('admin.sync_inquiry');
});
... ...
... ... @@ -301,8 +301,6 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/publicTemplateLists', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'publicTemplateLists'])->name('template_publicTemplateLists');
//获取选中的主题模版
Route::any('/getPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getPublicTemplate'])->name('template_getPublicTemplate');
//设置默认主题模版
Route::any('/setPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setPublicTemplate'])->name('template_setPublicTemplate');
//保存修改后的模版
Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'save'])->name('template_save');
//可视化保存获取数据类型
... ...