作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6

正在显示 35 个修改的文件 包含 1140 行增加134 行删除
<?php
namespace App\Console\Commands;
use App\Http\Logic\Aside\Project\DomainInfoLogic;
use App\Models\Com\UpdateNotify;
use App\Models\Devops\DevopsTask as DevopsTaskModel;
use App\Models\Devops\DevopsTaskLog;
use App\Models\Domain\DomainInfo;
use App\Models\File\File;
use App\Models\File\Image;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
/**
* 测试
* Class Traffic
* @package App\Console\Commands
* @author zbj
* @date 2023/5/18
*/
class Test extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test';
/**
* The console command description.
*
* @var string
*/
protected $description = '测试';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$projects = Project::all();
foreach ($projects as $project){
echo "project " . $project->id;
if(!ProjectServer::useProject($project->id)){
echo '-->' . '未配置数据库' . PHP_EOL;
continue;
}
try {
$page = BCustomTemplate::where('url', '404')->first();
if(!$page){
$page = new BCustomTemplate();
}
$page->project_id = $project->id;
$page->name = '404';
$page->status = 1;
$page->url = '404';
$page->html = '<main>
<section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
id="sectionIdyxqu938">
<div class="layout" data-unable="demo01-error404">
<img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" />
</div>
<p style="text-align: center">SORRY. THE PAGE HAS EITHER MOVED OR CANNOT BE FOUND.</p>
<style>
.section-block-error404 .layout {
height: 700px;
display: flex;
align-items: center;
justify-content: center;
}
.section-block-error404 img {
width: 400px;
}
@media only screen and (max-width:500) {
.section-block-error404 img {
max-width: 100%;
}
}
</style>
<script>
</script>
</section>
</main>';
$page->html_style = '<style id="globalsojs-styles"></style>';
$page->description = 'Sorry. The page has either moved or cannot be found.';
$page->title = '404-Page not found';
$page->save();
$domain = (new DomainInfo())->getDomain($project['deploy_optimize']['domain']);
$url = $domain.'api/delHtml/?project_id='.$project->id.'&route=404';
curlGet($url);
}catch (QueryException | \Exception $e){
echo '-->' . $e->getMessage() . PHP_EOL;
continue;
}
echo '-->成功:' . PHP_EOL;
}
}
}
... ...
... ... @@ -3,6 +3,10 @@
namespace App\Console\Commands;
use App\Helper\Common;
use App\Helper\Translate;
use App\Models\Ai\AiCommand as AiCommandModel;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -57,17 +61,19 @@ class UpdateSeoTdk extends Command
try {
ProjectServer::useProject($project_id);
$this->updateProduct($project_id);
$this->updateProductCate($project_id);
$this->updateBlogs($project_id);
$this->updateBlogCate($project_id);
$this->updateNews($project_id);
$this->updateNewsCate($project_id);
$this->updatePage($project_id);
DB::disconnect('custom_mysql');
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
}
echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
}
}
/**
* @remark :更新产品tdk
* @name :updateProduct
... ... @@ -83,20 +89,64 @@ class UpdateSeoTdk extends Command
$seo_arr = json_decode($v['seo_mate'], true) ?: [];
//更新seo_title
if(!isset($seo_arr['title'])){
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first();
//生成seo_title
$seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']);
if(!empty($setting['product_prefix']) && !empty($setting['product_suffix'])){
$seo_arr['title'] = $setting['product_prefix'] . '-' . $seo_arr['title'] . '-' . $setting['product_suffix'];
}else{
$seo_arr['title'] = $this->ai_send('seo_title',$seo_arr['title']);
}
}
//更新seo_keyword
if(!isset($seo_arr['keyword'])){
$seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']);
$seo_arr['keyword'] = $this->ai_send('seo_keywords',$v['title']);
}
//更新seo_keyword
if(!isset($seo_arr['description'])){
$seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']);
$seo_arr['description'] = $this->ai_send('seo_meta_description',$v['title']);
}
$ser_str = json_encode($seo_arr,true);
DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]);
}
}
return true;
}
/**
* @remark :更新产品tdk
* @name :updateProduct
* @author :lyh
* @method :post
* @time :2023/8/19 9:25
*/
public function updateProductCate($project_id){
$list = DB::connection('custom_mysql')->table('gl_product_category')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $v){
$v = (array)$v;
$data = [];
if(empty($v['seo_title'])){
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first();
//生成seo_title
if(!empty($setting['product_cate_prefix']) && !empty($setting['product_cate_suffix'])){
$data['seo_title'] = $setting['product_cate_prefix'] . '-' . $v['title'] . '-' . $setting['product_cate_suffix'];
}else{
$data['seo_title'] = $this->ai_send('seo_title',$v['title']);
}
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['title']);
}
if(empty($v['seo_des'])){
$name = $this->companyName($project_id);
$data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name);
}
if(!$data){
continue;
}
DB::connection('custom_mysql')->table('gl_product_category')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
... ... @@ -115,13 +165,19 @@ class UpdateSeoTdk extends Command
$v = (array)$v;
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $this->ai_send('news_seo_title',$v['name']);
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first();
//生成seo_title
if(!empty($setting['single_page_suffix'])){
$data['seo_title'] = $v['name'] . '-' . $setting['single_page_suffix'];
}else{
$data['seo_title'] = $this->ai_send('seo_title',$v['name']);
}
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('news_seo_keyword',$v['name']);
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('news_seo_description',$v['name']);
$data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']);
}
if(!$data){
continue;
... ... @@ -133,6 +189,44 @@ class UpdateSeoTdk extends Command
}
/**
* @remark :更新新闻Tdk
* @name :updateNews
* @author :lyh
* @method :post
* @time :2023/8/19 10:06
*/
public function updateNewsCate($project_id){
$list = DB::connection('custom_mysql')->table('gl_news_category')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$v = (array)$v;
$data = [];
if(empty($v['seo_title'])){
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first();
//生成seo_title
if(!empty($setting['single_page_suffix'])){
$data['seo_title'] = $v['name'] . '-' . $setting['single_page_suffix'];
}else{
$data['seo_title'] = $this->ai_send('seo_title',$v['name']);
}
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
}
if(empty($v['seo_des'])){
$name = $this->companyName($project_id);
$data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name);
}
if(!$data){
continue;
}
DB::connection('custom_mysql')->table('gl_news_category')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @remark :更新blogTdk
* @name :updateBlogs
* @author :lyh
... ... @@ -146,13 +240,19 @@ class UpdateSeoTdk extends Command
$v = (array)$v;
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']);
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first();
//生成seo_title
if(!empty($setting['single_page_suffix'])){
$data['seo_title'] = $v['name'] . '-' . $setting['single_page_suffix'];
}else{
$data['seo_title'] = $this->ai_send('seo_title',$v['name']);
}
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('blog_seo_keyword',$v['name']);
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']);
$data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']);
}
if(!$data){
continue;
... ... @@ -164,19 +264,134 @@ class UpdateSeoTdk extends Command
}
/**
* @remark :更新新闻Tdk
* @name :updateNews
* @author :lyh
* @method :post
* @time :2023/8/19 10:06
*/
public function updateBlogCate($project_id){
$list = DB::connection('custom_mysql')->table('gl_blog_category')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$v = (array)$v;
$data = [];
if(empty($v['seo_title'])){
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first();
//生成seo_title
if(!empty($setting['single_page_suffix'])){
$data['seo_title'] = $v['name'] . '-' . $setting['single_page_suffix'];
}else{
$data['seo_title'] = $this->ai_send('seo_title',$v['name']);
}
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
}
if(empty($v['seo_des'])){
$name = $this->companyName($project_id);
$data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name);
}
if(!$data){
continue;
}
DB::connection('custom_mysql')->table('gl_blog_category')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @remark :单页面更新tdk
* @name :updatePage
* @author :lyh
* @method :post
* @time :2023/10/30 11:04
*/
public function updatePage($project_id){
$list = DB::connection('custom_mysql')->table('gl_web_custom_template')->select(['id','title','keywords','description','project_id'])->where(['project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $v){
$v = (array)$v;
$data = [];
if(empty($v['seo_title'])){
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first();
//生成seo_title
if(!empty($setting['single_page_suffix'])){
$data['title'] = $v['title'] . '-' . $setting['single_page_suffix'];
}else{
$data['title'] = $this->ai_send('seo_title',$v['title']);
}
}
if(empty($v['keywords'])){
//获取核心关键词
$main_keyword = $this->mainKeywords($project_id);
if(!empty($main_keyword)){
$data['keywords'] = $this->ai_send('seo_keywords',$main_keyword);
}else{
$data['keywords'] = $this->ai_send('seo_keywords',$v['title']);
}
}
if(empty($v['description'])){
$name = $this->companyName($project_id);
$data['description'] = $this->ai_send('page_meta_description',$v['title'],$name);
}
if(!$data){
continue;
}
DB::connection('custom_mysql')->table('gl_web_custom_template')->where(['id'=>$v['id']])->update($data);
}
}
}
/**
* @remark :获取公司名称
* @name :companyName
* @author :lyh
* @method :post
* @time :2023/10/30 11:22
*/
public function companyName($project_id){
$projectModel = new Project();
$info = $projectModel->read(['id'=>$project_id],['id','company']);
return $info['company'];
}
/**
* @remark :获取公司核心关键词
* @name :mainKeywords
* @author :lyh
* @method :post
* @time :2023/10/30 11:22
*/
public function mainKeywords($project_id){
$str = '';
$projectOptimizeModel = new DeployOptimize();
$info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','main_keywords']);
if($info === false){
$arr = explode(',',$info['main_keywords']);
if(isset($arr[0])){
$str = $arr[0];
}
}
return $str;
}
/**
* @remark :AI发送
* @name :ai_send
* @author :lyh
* @method :post
* @time :2023/8/19 10:40
*/
public function ai_send($key,$keywords){
$chat_url = 'v2/openai_chat';
public function ai_send($key,$keywords,$name = ''){
$chat_url = 'v2/openai_chat_qqs';
$param = [
'key'=>$key,
'keywords'=>$keywords,
];
$data = Common::send_openai_msg($chat_url,$param);
$data = Common::send_openai_msg($chat_url,$param,$name);
return $data['text'];
}
}
... ...
... ... @@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel
$schedule->command('rank_data_indexed_pages')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次
$schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
$schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
$schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
// $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Helper;
use App\Models\Ai\AiCommand as AiCommandModel;
use App\Models\Project\Project;
use App\Models\User\UserLog as UserLogModel;
use App\Models\User\UserLogin as UserLoginModel;
use Illuminate\Encryption\Encrypter;
... ... @@ -54,7 +55,7 @@ class Common
* @author :liyuhang
* @method
*/
public static function send_openai_msg($url,$param){
public static function send_openai_msg($url,$param,$name = ''){
$url = HTTP_OPENAI_URL.$url;
$aiCommandModel = New AiCommandModel();
//指定库获取指令
... ... @@ -79,6 +80,8 @@ class Common
$str = 'Please answer in '.$lang;
//替换关键字
$content = str_replace('$keyword$', $param['keywords'], $info['ai']);
//$company$变量时替换为公司名
$content = str_replace('$company$', $name , $content);
$data = [
'messages'=>[
// ['role'=>'system','content'=>$info['scene']],
... ... @@ -183,4 +186,38 @@ class Common
return $crypt->decrypt($string);
}
//处理关键词
public function deal_keywords($data){
$str = ['1. ','2. ','3. ','4. ','5. ','6. ','7. ','8. ','1) ','2) ','3) ','4) ','5) ','6) ','7) ','7) ','8) '];
$ar_keywords_t = explode("\n",$data);
$ar_keywords = [];
foreach ($ar_keywords_t as $v){
if(trim($v)){
$keyword = trim($v);
if(strpos($keyword,'search keyword') !== false){
$tmp_first = explode('1. ',$keyword);
if(count($tmp_first) > 1){
$keyword = $tmp_first[1];
}else{
$tmp_first = explode('1) ',$keyword);
if(count($tmp_first) > 1){
$keyword = $tmp_first[1];
}
}
}
$keyword = str_replace($str,'',$keyword);
$keyword = trim($keyword,'.');
if(strpos(strtolower($keyword),'hope') === false && strpos(strtolower($keyword),'remember') === false && strpos(strtolower($keyword),'help') === false && strpos(strtolower($keyword),'website') === false && strpos(strtolower($keyword),'search keywords') === false && strpos(strtolower($keyword),'here are 8') === false && strpos(strtolower($keyword),'search keywords') === false && strpos(strtolower($keyword),'thank you') === false && strpos(strtolower($keyword),'thanks') === false && strpos(strtolower($keyword),'copywriter') === false ){
$ar_keywords[] = $keyword;
}
}
}
return implode(',',$ar_keywords);
}
//过滤特殊字符
public function deal_str($str){
return str_replace(['{','}','”','“','"'],'',$str);
}
}
... ...
... ... @@ -5,7 +5,9 @@ namespace App\Http\Controllers\Aside;
use App\Enums\Common\Code;
use App\Http\Logic\Aside\LoginLogic;
use App\Models\Domain\DomainInfo;
use App\Models\Manage\Manage;
use App\Models\Project\Project;
use App\Models\Sms\SmsLog;
use App\Rules\Mobile;
use Illuminate\Http\Request;
... ... @@ -98,5 +100,4 @@ class LoginController extends BaseController
SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN);
$this->response('success');
}
}
... ...
... ... @@ -672,4 +672,6 @@ class ProjectController extends BaseController
$lists = $renewLog->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -53,4 +53,5 @@ class AiCommandController extends BaseController
$aiLog = new AiLog();
return $aiLog->add($param);
}
}
... ...
<?php
/**
* @remark :
* @name :PageSettingController.php
* @author :lyh
* @method :post
* @time :2023/10/21 15:25
*/
namespace App\Http\Controllers\Bside\BCom;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Project\PageSetting;
class PageSettingController extends BaseController
{
/**
* @remark :根据项目设置获取页面是否使用公共头部底部
* @name :read
* @author :lyh
* @method :post
* @time :2023/10/21 15:26
*/
public function info(){
$pageSettingModel = new PageSetting();
$info = $pageSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$info = [
'project_id'=>$this->user['project_id'],
'product_list'=>0,
'product_details'=>0,
'page_keyword'=>0,
'blog_lists'=>0,
'blog_details'=>0,
'news_list'=>0,
'news_details'=>0,
'polymerization'=>0,
];
$pageSettingModel->add($info);
}
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :设置是否使用公共头和底
* @name :edit
* @author :lyh
* @method :post
* @time :2023/10/21 15:36
*/
public function edit(){
$pageSettingModel = new PageSetting();
$rs = $pageSettingModel->edit($this->param,['project_id'=>$this->user['project_id']]);
if($rs === false){
$this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR);
}
$this->response('success');
}
}
... ...
... ... @@ -21,13 +21,13 @@ class BlogCategoryController extends BaseController
//搜索条件
$this->map['project_id'] = $this->user['project_id'];
$filed = ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at'];
$lists = $blogCategoryModel->list($this->map,$this->order,$filed);
$lists = $blogCategoryModel->list($this->map,$this->order = ['sort','id'],$filed);
$data = [];
if(!empty($lists)){
$blogModel = new BlogModel();
foreach ($lists as $k => $v){
$v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['url'] = $this->user['domain'] . RouteMap::PATH_BLOG_CATE . '/' . $v['alias'];
$v['url'] = $this->user['domain'] . $v['alias'].'/';
$lists[$k] = $v;
}
if(!isset($this->map['name'])){
... ...
... ... @@ -35,7 +35,7 @@ class BlogController extends BaseController
$user = new User();
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] .$v['url'];
$v['url'] = $this->user['domain'] .$v['url'].'/';
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = $user->getName($v['operator_id']);
$lists['list'][$k] = $v;
... ... @@ -65,6 +65,9 @@ class BlogController extends BaseController
if(isset($this->map['status'])){
$query = $query->where('status',$this->map['status']);
}
if(isset($this->map['name']) && !empty($this->map['name'])){
$query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
}
if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){
$query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]);
}
... ...
... ... @@ -16,6 +16,7 @@ use App\Helper\Common;
use App\Helper\Translate;
use App\Helper\Wechat;
use App\Http\Logic\Bside\User\UserLoginLogic;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\Service\Service;
use App\Models\Sms\SmsLog;
... ... @@ -293,5 +294,4 @@ class LoginController extends BaseController
}
return $data;
}
}
... ...
... ... @@ -21,13 +21,13 @@ class NewsCategoryController extends BaseController
//搜索条件
$this->map['project_id'] = $this->user['project_id'];
$filed = ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at'];
$lists = $newsCategory->list($this->map,$this->order,$filed);
$lists = $newsCategory->list($this->map,$this->order = ['sort','id'],$filed);
$data = [];
if(!empty($lists)){
$newsModel = new NewsModel();
foreach ($lists as $k => $v){
$v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['url'] = $this->user['domain'] . RouteMap::PATH_BLOG_CATE . '/' . $v['alias'];
$v['url'] = $this->user['domain'] . $v['alias'].'/';
$lists[$k] = $v;
}
if(!isset($this->map['name'])){
... ...
... ... @@ -35,7 +35,7 @@ class NewsController extends BaseController
$user = new User();
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] .$v['url'];
$v['url'] = $this->user['domain'] .$v['url'].'/';
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = $user->getName($v['operator_id']);
$lists['list'][$k] = $v;
... ... @@ -65,6 +65,9 @@ class NewsController extends BaseController
if(isset($this->map['status'])){
$query = $query->where('status',$this->map['status']);
}
if(isset($this->map['name']) && !empty($this->map['name'])){
$query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
}
if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){
$query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]);
}
... ...
... ... @@ -37,7 +37,7 @@ class CategoryController extends BaseController
$data = [];
if(!empty($list)){
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'];
$v['url'] = $this->user['domain'] . $v['route'].'/';
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image']);
$list[$k] = $v;
... ...
... ... @@ -46,7 +46,7 @@ class KeywordController extends BaseController
}else{
$v['tdk'] = 0;
}
$v['url'] = $this->user['domain'] . $v['route'];
$v['url'] = $this->user['domain'] . $v['route'].'/';
}
}
return $this->response('success',Code::SUCCESS,$data);
... ... @@ -65,8 +65,8 @@ class KeywordController extends BaseController
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at', 'route', 'url']));
$data = $logic->getKeywordInfo();
return $this->success($data);
}
/**
... ...
... ... @@ -59,7 +59,7 @@ class ProductController extends BaseController
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
$v['url'] = $this->user['domain'].$v['route'];
$v['url'] = $this->user['domain'].$v['route'].'/';
$lists['list'][$k] = $v;
}
}
... ... @@ -287,6 +287,18 @@ class ProductController extends BaseController
}
/**
* @remark :直接编辑列表数据
* @name :editList
* @author :lyh
* @method :post
* @time :2023/10/26 9:48
*/
public function editList(ProductLogic $logic){
$logic->editList();
$this->response('success');
}
/**
* @remark :删除
* @name :delete
* @author :lyh
... ...
<?php
/**
* @remark :
* @name :AggregationSettingController.php
* @author :lyh
* @method :post
* @time :2023/10/23 11:06
*/
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Bside\BaseController;
use App\Models\WebSetting\AggregationSetting;
/**
* @remark :聚合页
* @name :AggregationSettingController
* @author :lyh
* @method :post
* @time :2023/10/23 11:06
*/
class AggregationSettingController extends BaseController
{
/**
* @remark :获取聚合页设置详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/10/23 11:08
*/
public function info(){
$aggSettingModel = new AggregationSetting();
$info = $aggSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$data = [
'title'=>'',
'content'=>'',
'top_banner'=>json_encode([]),
'foot_banner'=>json_encode([]),
'project_id'=>$this->user['project_id']
];
$aggSettingModel->add($data);
$info = $data;
}
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :修改聚合页设置
* @name :edit
* @author :lyh
* @method :post
* @time :2023/10/23 11:11
*/
public function edit(){
$aggSettingModel = new AggregationSetting();
if(isset($this->param['top_banner']) && !empty($this->param['top_banner'])){
$this->param['top_banner'] = Arr::a2s($this->param['top_banner']);
}
if(isset($this->param['foot_banner']) && !empty($this->param['foot_banner'])){
$this->param['foot_banner'] = Arr::a2s($this->param['foot_banner']);
}
$rs = $aggSettingModel->edit($this->param,['project_id'=>$this->user['project_id']]);
if($rs === false){
$this->response('系统错误请联系管理员',Code::SYSTEM_ERROR);
}
$this->response('success');
}
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
use App\Http\Requests\Bside\Template\TemplateRequest;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Template;
class BTemplateController extends BaseController
... ... @@ -141,4 +142,28 @@ class BTemplateController extends BaseController
$BTemplateLogic->savePublicTemplateHtml();
$this->response('模板保存成功');
}
/**
* @remark :获取可视化详情页模板数据
* @name :getDetailInfo
* @author :lyh
* @method :post
* @time :2023/10/24 11:27
*/
public function getDetailInfo(BTemplateLogic $BTemplateLogic){
$html = $BTemplateLogic->getDetail();
$this->response('success',Code::SUCCESS,['html'=>$html]);
}
/**
* @remark :保存详情页模板数据
* @name :saveDetail
* @author :lyh
* @method :post
* @time :2023/10/24 14:47
*/
public function saveDetail(BTemplateLogic $BTemplateLogic){
$BTemplateLogic->saveDetail();
$this->response('success');
}
}
... ...
... ... @@ -26,6 +26,7 @@ class CustomTemplateController extends BaseController
$lists = $customTemplateLogic->customTemplateLists($this->map,$this->page,$this->row,$this->order);
if (!empty($lists)){
foreach ($lists['list'] as $k => $v){
$v['url'] = $v['url'].'/';
$lists['list'][$k] = $v;
}
}
... ...
... ... @@ -266,18 +266,6 @@ class ProjectLogic extends BaseLogic
if($param['type'] == Project::TYPE_ONE){
//改为异步
NoticeLog::createLog(NoticeLog::TYPE_INIT_PROJECT, ['project_id' => $param['id']]);
// //初始化数据库
// if(isset($param['mysql_id']) && !empty($param['mysql_id'])){
// $this->initializationMysql($param['id']);
// }
// //初始账号
// if(isset($param['mobile']) && !empty($param['mobile'])){
// $this->createUser($param['mobile'],$param['id'],$param['lead_name']);
// }
// //更改服务器状态
// if(isset($param['serve_id']) && !empty($param['serve_id'])){
// $this->updateServe($param['serve_id']);
// }
}
return $this->success();
}
... ...
... ... @@ -7,13 +7,16 @@ use App\Models\Blog\BlogCategory;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateLog;
use App\Models\Template\Template;
use App\Models\Template\TemplateTypeMain;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use mysql_xdevapi\Exception;
... ... @@ -61,12 +64,10 @@ class BTemplateLogic extends BaseLogic
if($info === false){
$this->fail('请先选择模版');
}
$TemplateInfo = [];
if($this->param['source'] == $this->model::SOURCE_HOME){//首页
$TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']);
}
if($this->param['source'] == $this->model::SOURCE_PRODUCT){//产品页
$TemplateInfo = $this->productHtml($info,$this->param['source'],$this->param['source_id']);
}else{
$TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']);
}
return $this->success($TemplateInfo);
}
... ... @@ -120,13 +121,13 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :处理产品页数据
* @remark :处理其他页数据
* @name :ProductHtml
* @author :lyh
* @method :post
* @time :2023/7/25 16:40
*/
public function productHtml($info,$source,$source_id){
public function otherHtml($info,$source,$source_id){
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
if($homeTemplateInfo === false){
$this->fail('请先装修首页');
... ... @@ -134,15 +135,15 @@ class BTemplateLogic extends BaseLogic
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
if($TemplateInfo === false){
$main_html = "<main>{$this->getProductModule()}</main>";
$main_style = "<style id='globalsojs-styles'></style>";
$mainInfo = $this->getCommonMain($source,$source_id);
$main_html = $mainInfo['main_html'];
$main_style = $mainInfo['main_css'];
$TemplateInfo['template_id'] = $info['template_id'];
}else{
$main_html = $TemplateInfo['main_html'];
$main_style = $TemplateInfo['main_css'];
}
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
$commonInfo = $this->getCommonPage($source,$source_id,$info['template_id']);
if($commonInfo !== false){
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
... ... @@ -155,6 +156,72 @@ class BTemplateLogic extends BaseLogic
}
/**
* @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;}
//查询有没有公共模板详情样式
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'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 :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;
}
/**
* @remark :设置模板
* @name :setTemplate
* @author :lyh
... ... @@ -197,6 +264,7 @@ class BTemplateLogic extends BaseLogic
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
//字符串截取
$this->param = $this->stringProcessing($this->param);
//保存头部信息
$this->saveCommonTemplate($this->param);
$this->param = $this->templateSaveParam($this->param);//组装数据
if($info === false){
... ... @@ -224,8 +292,9 @@ class BTemplateLogic extends BaseLogic
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($param){
$type = $this->getType($param['source'],$param['source_id']);
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
$data = [
'head_html'=>$param['head_html'],
'head_css'=>$param['head_css'],
... ... @@ -236,7 +305,7 @@ class BTemplateLogic extends BaseLogic
if($info === false){
$data['template_id'] = $param['template_id'];
$data['project_id'] = $this->user['project_id'];
$data['type'] = 1;
$data['type'] = $type;
$templateCommonModel->add($data);
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
... ... @@ -245,6 +314,29 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($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 $type;
}
/**
* @remark :生成记录
* @name :setTemplateLog
* @author :lyh
... ... @@ -281,15 +373,9 @@ class BTemplateLogic extends BaseLogic
if($source == BTemplate::SOURCE_HOME){
$type = 'index';
$route = '';
//路由映射
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
}elseif($source == BTemplate::SOURCE_PRODUCT){
$type = RouteMap::SOURCE_PRODUCT;
$productModel = new Product();
$info = $productModel->read(['id'=>$source_id]);
$route = $info['route'];
return $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route]);
}
return $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route]);
return $this->success();
}
/**
... ... @@ -357,11 +443,11 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/7/27 15:08
*/
public function getProductModule(){
public function getModule($type){
//获取公共主题头部底部
$serviceSettingModel = new ServiceSettingModel();
$info = $serviceSettingModel->read(['type'=>$serviceSettingModel::TYPE_PRODUCT]);
return $info['values'];
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type]);
return $info['main_html'];
}
/**
... ... @@ -419,19 +505,13 @@ class BTemplateLogic extends BaseLogic
$newCategory = NewsCategory::where($map)->get();
$blogCategory = BlogCategory::where($map)->get();
if (!empty($productCategory)){
foreach ($productCategory as $item){
$data["products"]["category"][] =$item;
}
foreach ($productCategory as $item){$data["products"]["category"][] =$item;}
}
if (!empty($newCategory)){
foreach ($newCategory as $item){
$data["news"]["category"][] =$item;
}
foreach ($newCategory as $item){$data["news"]["category"][] =$item;}
}
if (!empty($blogCategory)){
foreach ($blogCategory as $item){
$data["blogs"]["category"][] =$item;
}
foreach ($blogCategory as $item){$data["blogs"]["category"][] =$item;}
}
//返回
return $this->success($data);
... ... @@ -455,4 +535,100 @@ class BTemplateLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :获取详情模板详情
* @name :getDetail
* @author :lyh
* @method :post
* @time :2023/10/24 11:29
*/
public function getDetail(){
$bSettingModel = new Setting();
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($bSettingInfo === false){
$this->fail('请先设置模板');
}
//获取首页公共部分
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
if($commonInfo === false){
$this->fail('已装修的项目使用当前功能时,可视化保存首页数据一次,未装修首页请先装修首页');
}
//判断当前项目是否有设置独立头部的权限
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
//有权限时,获取独立头部
$commonTypeInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
if($commonTypeInfo !== false){
$commonInfo = $commonTypeInfo;
}
}
//获取设置的默认中间部分
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
if($mainInfo === false){
$main_html = "<main>{$this->getModule($this->param['type'])}</main>";
$main_style = "<style id='globalsojs-styles'></style>";
}else{
$main_html = $mainInfo['main_html'];
$main_style = $mainInfo['main_css'];
}
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);//组装数据
return $this->success($html);
}
/**
* @remark :保存详情模板数据
* @name :saveDetail
* @author :lyh
* @method :post
* @time :2023/10/24 11:53
*/
public function saveDetail(){
$bSettingModel = new Setting();
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($bSettingInfo === false){
$this->fail('请先设置模板');
}
$data = [
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
];
$data['section_list_id'] = $this->param['section_list_id'];
//保存中间部分
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
if($mainInfo === false){
$data['project_id'] = $this->user['project_id'];
$data['type'] = $this->param['type'];
$bTemplateMainModel->add($data);
}else{
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
}
$publicData = [
'head_html' => characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html' => characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
];
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
$templateCommonModel = new BTemplateCommon();
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
$templateCommonInfo = $templateCommonModel->read(['type'=>$this->param['type'],'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
if($templateCommonInfo === false){
$publicData['type'] = $this->param['type'];
$publicData['project_id'] = $this->user['project_id'];
$publicData['template_id'] = $bSettingInfo['template_id'];
$templateCommonModel->add($publicData);
}else{
$templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
}
}else{
//更新首页头部底部
$templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
}
return $this->success();
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BCustomTemplate;
... ... @@ -109,30 +110,49 @@ class CustomTemplateLogic extends BaseLogic
* @method :post
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($html){
//获取设置的默认模版
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先设置模版');
}
//查看当前
public function saveCommonTemplate($param){
$type = $this->getType();
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$settingInfo['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo === false){
$this->fail('请先装修首页');
}
$info = $templateCommonModel->read(['template_id'=>$param['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")),
'head_html'=>$param['head_html'],
'head_css'=>$param['head_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
if($info === false){
$data['template_id'] = $param['template_id'];
$data['project_id'] = $this->user['project_id'];
$data['type'] = $type;
$templateCommonModel->add($data);
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
}
return $this->success();
}
/**
* @remark :获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType(){
$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 ($pageInfo['page_list'] != 0) {
$type = 9;
}
}
}
return $type;
}
/**
* @remark :查看路由是否更新
... ... @@ -224,9 +244,8 @@ class CustomTemplateLogic extends BaseLogic
if($info === false){
$this->fail('请先设置模版');
}
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
//获取type类型
$commonInfo = $this->getCommonPage($info['template_id']);
$html = '';
if($commonInfo !== false){
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
... ... @@ -249,6 +268,34 @@ class CustomTemplateLogic extends BaseLogic
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonPage($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();
if ($pageInfo['page_list'] != 0) {
//使用独立头和底
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 9]);
}
}
}
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;
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
... ...
... ... @@ -10,6 +10,7 @@ use App\Models\Com\UpdateNotify;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteDelete;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
* @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常
... ... @@ -69,6 +70,15 @@ class BaseLogic extends Logic
*/
public function getParam(){
$requestAll = $this->request->all();
foreach ($requestAll as $k => $v){
if(is_array($v)){
continue;
}else{
if(Str::endsWith($k, '_link')){
unset($requestAll[$k]);
}
}
}
return $this->success($requestAll);
}
... ...
... ... @@ -59,8 +59,8 @@ class NewsLogic extends BaseLogic
public function newsSave()
{
//拼接参数
DB::beginTransaction();
try {
// DB::beginTransaction();
// try {
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
//是否更新路由
... ... @@ -72,11 +72,11 @@ class NewsLogic extends BaseLogic
//更新路由
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
$this->edit(['url' => $route], ['id' => $id]);
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
// DB::commit();
// } catch (\Exception $e) {
// DB::rollBack();
// $this->fail('系统错误,请联系管理员');
// }
//通知更新
$this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]);
return $this->success();
... ...
... ... @@ -241,25 +241,22 @@ class CategoryLogic extends BaseLogic
*/
public function categoryDelete(){
$ids = $this->param['ids'];
DB::beginTransaction();
try {
foreach ($ids as $id){
$info = $this->model->read(['pid'=>$id],['id']);
if($info !== false){
$this->fail('分类id:'.$id.'拥有子集不允许删除');
}
$productModel = new Product();
foreach ($ids as $id){
$product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);
if($product_info !== false){
$this->fail('当前分类拥有产品不允许删除');
}
//删除路由
$this->delRoute($id);
$this->model->del(['id'=>$id]);
$product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);
if($product_info !== false){
$this->fail('当前分类拥有产品不允许删除');
}
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('删除失败');
//删除路由
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
return $this->success();
}
... ...
... ... @@ -34,9 +34,9 @@ class KeywordLogic extends BaseLogic
* @method :post
* @time :2023/8/23 16:50
*/
public function getInfo($id)
public function getKeywordInfo()
{
$info = parent::getInfo($id);
$info = $this->model->read($this->param);
$info['url'] = $this->user['domain'] . $info['route'];
return $this->success($info);
}
... ... @@ -51,6 +51,7 @@ class KeywordLogic extends BaseLogic
public function keywordSave(){
DB::beginTransaction();
try {
$this->param = $this->handleSaveParam($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
$info = $this->model->read(['id'=>$this->param['id']],['id','route']);
$route = $info['route'];
... ... @@ -77,6 +78,23 @@ class KeywordLogic extends BaseLogic
}
/**
* @remark :保存数据时参数处理
* @name :handleSaveParam
* @author :lyh
* @method :post
* @time :2023/10/23 14:47
*/
public function handleSaveParam($param){
if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){
$param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner']);
}
if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){
$param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner']);
}
return $param;
}
/**
* @remark :批量添加数据
* @name :batchAdd
* @author :lyh
... ...
... ... @@ -3,9 +3,11 @@
namespace App\Http\Logic\Bside\Product;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
... ... @@ -66,6 +68,55 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :编辑列表数据
* @name :editList
* @author :lyh
* @method :post
* @time :2023/10/26 9:49
*/
public function editList(){
$this->param['category_id'] = $this->getLastCategory($this->param['category_id']);
$this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
return $this->success();
}
/**
* @remark :保存关键字标签处理
* @name :saveKeyword
* @author :lyh
* @method :post
* @time :2023/10/26 9:51
*/
public function saveKeyword($keyword){
$str = '';
if(isset($keyword) && !empty($keyword)){
$arr = [];
$keywordModel = new Keyword();
foreach ($keyword as $v){
//查询当前关键字是否存在
$info = $keywordModel->read(['title'=>$v],['id']);
if($info === false){
$param['project_id'] = $this->user['project_id'];
$param['created_at'] = date('Y-m-d H:i:s');
$param['updated_at'] = $param['created_at'];
$param['title'] = $v;
$id = $keywordModel->insertGetId($param);
$route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
//清除缓存
Common::del_user_cache('product_keyword',$this->user['project_id']);
$arr[] = $id;
}else{
$arr[] = $info['id'];
}
}
$str = ','.implode(',',$arr).',';
}
return $str;
}
/**
* @remark :不使用save处理参数
* @name :handleSaveParam
* @author :lyh
... ... @@ -84,9 +135,7 @@ class ProductLogic extends BaseLogic
}
$param['attrs'] = Arr::a2s($param['attrs'] ?? '');
$param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? '');
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getLastCategory($param['category_id']);
}
$param['category_id'] = $this->getLastCategory($param['category_id']);
if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
$param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).',';
}
... ... @@ -113,11 +162,13 @@ class ProductLogic extends BaseLogic
*/
public function getLastCategory($category){
$str = '';
$cateModel = new Category();
foreach ($category as $v){
$info = $cateModel->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
if(isset($category) && !empty($category)){
$cateModel = new Category();
foreach ($category as $v){
$info = $cateModel->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
}
return ','.$str;
... ...
... ... @@ -44,7 +44,7 @@ class WebSettingSeoLogic extends BaseLogic
* @time :2023/9/11 16:34
*/
public function seoSave(){
// try {
try {
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
... ... @@ -52,9 +52,9 @@ class WebSettingSeoLogic extends BaseLogic
}else{
$this->model->edit($this->param,['project_id'=>$this->user['project_id']]);
}
// }catch (\Exception $e){
// $this->fail('error');
// }
}catch (\Exception $e){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -4,7 +4,9 @@ namespace App\Http\Logic\Bside\Setting;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Domain\DomainInfo;
use App\Models\File\Image;
use App\Models\Project\Project;
use App\Models\WebSetting\WebSettingService;
use Illuminate\Support\Facades\DB;
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Models\Product;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
... ... @@ -19,4 +20,26 @@ class Keyword extends Base
// public function getRouteAttribute(){
// return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id);
// }
/**
* @remark :图
* @name :getKeywordTopBannerAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getKeywordTopBannerAttribute($value){
return getImageUrl($value);
}
/**
* @remark :图
* @name :getKeywordTopBannerAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getKeywordFootBannerAttribute($value){
return getImageUrl($value);
}
}
... ...
<?php
/**
* @remark :
* @name :PageSetting.php
* @author :lyh
* @method :post
* @time :2023/10/21 15:24
*/
namespace App\Models\Project;
use App\Models\Base;
/**
* @remark :项目页面头部底部设置
* @name :PageSetting
* @author :lyh
* @method :post
* @time :2023/10/21 15:24
*/
class PageSetting extends Base
{
protected $table = 'gl_project_page_setting';
}
... ...
<?php
/**
* @remark :
* @name :BTemplateMain.php
* @author :lyh
* @method :post
* @time :2023/10/24 11:19
*/
namespace App\Models\Template;
use App\Models\Base;
class BTemplateMain extends Base
{
protected $table = 'gl_web_template_main';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :TemplateTypeMain.php
* @author :lyh
* @method :post
* @time :2023/10/27 17:49
*/
namespace App\Models\Template;
use App\Models\Base;
/**
* @remark :默认数据main详情表
* @name :TemplateTypeMain
* @author :lyh
* @method :post
* @time :2023/10/27 17:49
*/
class TemplateTypeMain extends Base
{
protected $table = 'gl_template_type_main';
}
... ...
<?php
/**
* @remark :
* @name :AggregationSetting.php
* @author :lyh
* @method :post
* @time :2023/10/23 10:45
*/
namespace App\Models\WebSetting;
use App\Helper\Arr;
use App\Models\Base;
/**
* @remark :产品关键字聚合页设置
* @name :AggregationSetting
* @author :lyh
* @method :post
* @time :2023/10/23 10:48
*/
class AggregationSetting extends Base
{
//设置关联表名
protected $table = 'gl_aggregation_setting';
/**
* @remark :顶部banner获取器
* @name :getGalleryAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getTopBannerAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
foreach ($value as $k => $v){
$v = getImageUrl($v);
$value[$k] = $v;
}
}
return $value;
}
/**
* @remark :底部banner获取器
* @name :getGalleryAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getFootBannerAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
foreach ($value as $k => $v){
$v = getImageUrl($v);
$value[$k] = $v;
}
}
return $value;
}
}
... ...
... ... @@ -26,7 +26,11 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/role_list', [\App\Http\Controllers\Bside\User\UserController::class, 'role_list'])->name('user_role_list');
Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del');
});
//项目独立头部和底部设置
Route::prefix('pageSetting')->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\BCom\PageSettingController::class, 'info'])->name('pageSetting_info');
Route::any('/edit',[\App\Http\Controllers\Bside\BCom\PageSettingController::class, 'edit'])->name('pageSetting_edit');
});
//站内信
Route::prefix('mail')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Mail\MailController::class, 'lists'])->name('mail_lists');
... ... @@ -178,6 +182,12 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingImageController::class, 'save'])->name('web_image_save');
});
//聚合页相关配置
Route::prefix('aggregation')->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\Setting\AggregationSettingController::class, 'info'])->name('aggregation_info');
Route::any('/edit',[\App\Http\Controllers\Bside\Setting\AggregationSettingController::class, 'edit'])->name('aggregation_edit');
});
});
//产品
Route::prefix('product')->group(function () {
... ... @@ -185,6 +195,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\Product\ProductController::class, 'index'])->name('product');
Route::get('/info', [\App\Http\Controllers\Bside\Product\ProductController::class, 'info'])->name('product_info');
Route::post('/save', [\App\Http\Controllers\Bside\Product\ProductController::class, 'save'])->name('product_save');
Route::post('/editList', [\App\Http\Controllers\Bside\Product\ProductController::class, 'editList'])->name('product_editList');
Route::post('/sort', [\App\Http\Controllers\Bside\Product\ProductController::class, 'sort'])->name('product_sort');
Route::any('/delete', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delete'])->name('product_delete');
Route::any('/statusNum', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getStatusNumber'])->name('product_statusNum');
... ... @@ -291,6 +302,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/getHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getHeadFooter'])->name('template_getHeadFooter');
Route::any('/setHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setHeadFooter'])->name('template_setHeadFooter');
Route::any('/savePublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'savePublicTemplate'])->name('template_savePublicTemplate');
Route::any('/getDetailInfo', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getDetailInfo'])->name('template_getDetailInfo');
Route::any('/saveDetail', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'saveDetail'])->name('template_saveDetail');
// 模板
Route::prefix('module')->group(function () {
//获取所有左侧模版
... ...