作者 刘锟

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

正在显示 72 个修改的文件 包含 2546 行增加746 行删除
... ... @@ -55,7 +55,7 @@ class RemainDay extends Command
{
$list = Project::whereIn('type', [2,3,4])->get();
foreach ($list as $item){
if($item['type'] == 3){
if($item['type'] == Project::TYPE_TWO){
//排名达标天数
$compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0;
$remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
... ...
<?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;
}
}
}
... ...
... ... @@ -7,6 +7,7 @@
*/
namespace App\Console\Commands\Test;
use App\Helper\Common;
use App\Models\Blog\Blog;
use App\Models\Devops\ServerConfig;
use App\Models\File\Image;
... ... @@ -15,6 +16,7 @@ use App\Models\Manage\Dept;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\ManageHr;
use App\Services\ProjectServer;
use App\Services\SyncService;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -75,6 +77,14 @@ class Demo extends Command
*/
public function handle()
{
$result = app(SyncService::class)->projectAcceptAddress(1);
dd($result);
$data = [
'key' => 'productkey_keyword',
'keywords' => 'apple watch'
];
$result = Common::send_openai_msg('v2/openai_chat', $data);
dd();
$string = 'demo.globalso.site/';
$domain_array = parse_url($string);
$domain = $domain_array['host'] ?? $domain_array['path'];
... ...
<?php
/**
* @remark :
* @name :UpdateProgress.php
* @author :lyh
* @method :post
* @time :2023/11/1 9:22
*/
namespace App\Console\Commands;
use App\Models\Mail\Mail;
use App\Models\User\User;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Models\Com\UpdateProgress as UpdateProgressModel;
class UpdateProgress extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_progress';
/**
* The console command description.
*
* @var string
*/
protected $description = '守护进程--更新界面';
/**
* @name :(定时执行)handle
* @author :lyh
* @method :post
* @time :2023/5/12 14:48
*/
public function handle()
{
while (true){
$project_id = Redis::rpop('updateProgress');
if(!$project_id){
sleep(2);
continue;
}
echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL;
try {
ProjectServer::useProject($project_id);
$this->getUpdateProgress($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 :查看是否有为更新的记录
* @name :updateProgress
* @author :lyh
* @method :post
* @time :2023/11/1 10:47
*/
public function getUpdateProgress($project_id){
$info = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->first();
if(!empty($info)){
$time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60);
if($time > date("Y-m-d H:i:s")){
DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]);
//获取当前项目的用户
$user = new User();
$info = $user->read(['project_id'=>$project_id,'role'=>0]);
//发送站内信,请重新更新
$data["title"] = "页面更新通知";
$data["user_list"] = $info['id'];
$data["content"] = "部分页面更新超时,请重新更新,或联系管理员";
$mail = new Mail();
$mail->add($data);
}else{
Redis::lpush('updateProgress', $project_id);
}
}
return true;
}
}
... ...
<?php
namespace App\Console\Commands;
use App\Helper\Common;
use App\Models\Ai\AiCommand;
use App\Models\Project\DeployOptimize;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
/**
* 初始化项目
* Class InitProject
* @package App\Console\Commands
* @author zbj
* @date 2023/10/8
*/
class UpdateSeoTdk extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_seo_tdk';
/**
* The console command description.
*
* @var string
*/
protected $description = '一键生成sdk';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
while (true){
$project_id = Redis::rpop('updateSeoTdk');
if(!$project_id){
sleep(2);
continue;
}
echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL;
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
* @author :lyh
* @method :post
* @time :2023/8/19 9:25
*/
public function updateProduct($project_id){
echo date('Y-m-d H:i:s') . '更新产品--updateProduct: 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table('gl_product')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $v){
$v = (array)$v;
echo date('Y-m-d H:i:s') . ' updateProduct: ' . $v['id'] . PHP_EOL;
$seo_arr = json_decode($v['seo_mate'], true) ?: [];
//更新seo_title
if(!isset($seo_arr['title']) || empty($seo_arr['title'])){
//查看是否有指令
$aiCommandModel = new AiCommand();
$AiInfo = $aiCommandModel->read(['key'=>'product_seo_title'],['ai']);
if(!empty($AiInfo['ai'])){
$seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']);
}else {
$seo_arr['title'] = $v['title'];
}
}
//更新seo_keyword
if(!isset($seo_arr['keyword']) || empty($seo_arr['keyword'])){
$seo_arr['keyword'] = $this->ai_send('seo_keywords',$v['title']);
}
//更新seo_keyword
if(!isset($seo_arr['description']) || empty($seo_arr['description'])){
$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){
echo date('Y-m-d H:i:s') . '更新产品分类--updateProductCate: 项目id' . $project_id . PHP_EOL;
$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;
echo date('Y-m-d H:i:s') . ' updateProductCate: ' . $v['id'] . PHP_EOL;
$data = [];
if(empty($v['seo_title'])){
$aiCommandModel = new AiCommand();
$AiInfo = $aiCommandModel->read(['key'=>'product_cate_seo_title'],['ai']);
if(!empty($AiInfo['ai'])){
$data['seo_title'] = $this->ai_send('product_cate_seo_title',$v['title']);
}else{
$data['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);
if(!empty($name)){
$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;
}
/**
* @remark :更新新闻Tdk
* @name :updateNews
* @author :lyh
* @method :post
* @time :2023/8/19 10:06
*/
public function updateNews($project_id){
echo date('Y-m-d H:i:s') . '更新新闻--updateNews: 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table('gl_news')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$v = (array)$v;
echo date('Y-m-d H:i:s') . ' updateNews: ' . $v['id'] . PHP_EOL;
$data = [];
if(empty($v['seo_title'])){
$aiCommandModel = new AiCommand();
$AiInfo = $aiCommandModel->read(['key'=>'news_seo_title'],['ai']);
if(!empty($AiInfo['ai'])){
$data['seo_title'] = $this->ai_send('news_seo_title',$v['name']);
}else{
$data['seo_title'] = $v['name'];
}
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']);
}
if(!$data){
continue;
}
DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @remark :更新新闻Tdk
* @name :updateNews
* @author :lyh
* @method :post
* @time :2023/8/19 10:06
*/
public function updateNewsCate($project_id){
echo date('Y-m-d H:i:s') . '更新新闻分类--updateNewsCate: 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table('gl_news_category')->where(['status'=>0,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$v = (array)$v;
echo date('Y-m-d H:i:s') . ' updateNewsCate: ' . $v['id'] . PHP_EOL;
$data = [];
if(empty($v['seo_title'])){
$aiCommandModel = new AiCommand();
$AiInfo = $aiCommandModel->read(['key'=>'news_cate_seo_title'],['ai']);
if(!empty($AiInfo['ai'])){
$data['seo_title'] = $this->ai_send('news_cate_seo_title',$v['name']);
}else{
$data['seo_title'] = $v['name'];
}
}
if(empty($v['seo_keywords'])){
//获取核心关键词
$main_keyword = $this->mainKeywords($project_id);
if(!empty($main_keyword)){
$data['seo_keywords'] = $this->ai_send('seo_keywords',$main_keyword);
}
}
if(empty($v['seo_des'])){
$name = $this->companyName($project_id);
if(!empty($name)){
$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
* @method :post
* @time :2023/8/19 10:07
*/
public function updateBlogs($project_id){
echo date('Y-m-d H:i:s') . '更新博客--updateBlogs: 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table('gl_blog')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$v = (array)$v;
echo date('Y-m-d H:i:s') . ' updateBlogs: ' . $v['id'] . PHP_EOL;
$data = [];
if(empty($v['seo_title'])){
$aiCommandModel = new AiCommand();
$AiInfo = $aiCommandModel->read(['key'=>'blog_seo_title'],['ai']);
if(!empty($AiInfo['ai'])){
$data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']);
}else{
$data['seo_title'] = $v['name'];
}
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']);
}
if(!$data){
continue;
}
DB::connection('custom_mysql')->table('gl_blog')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @remark :更新新闻Tdk
* @name :updateNews
* @author :lyh
* @method :post
* @time :2023/8/19 10:06
*/
public function updateBlogCate($project_id){
echo date('Y-m-d H:i:s') . '更新博客分类--updateBlogCate: 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table('gl_blog_category')->where(['status'=>0,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$v = (array)$v;
echo date('Y-m-d H:i:s') . ' updateBlogCate: ' . $v['id'] . PHP_EOL;
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $v['name'];
}
if(empty($v['seo_keywords'])){
//获取核心关键词
$main_keyword = $this->mainKeywords($project_id);
if(!empty($main_keyword)){
$data['seo_keywords'] = $this->ai_send('seo_keywords',$main_keyword);
}
}
if(empty($v['seo_des'])){
$name = $this->companyName($project_id);
$data['seo_des'] = $this->ai_send('page_meta_description',$v['name'],$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){
echo date('Y-m-d H:i:s') . '更新自定义界面--updatePage: 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table('gl_web_custom_template')->select(['id','name','title','keywords','description','project_id'])->where(['project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $v){
$v = (array)$v;
echo date('Y-m-d H:i:s') . ' updatePage: ' . $v['id'] . PHP_EOL;
$data = [];
if(empty($v['title'])){
//生成seo_title
$data['title'] = $v['name'];
}
if(empty($v['keywords'])){
//获取核心关键词
$main_keyword = $this->mainKeywords($project_id);
if(!empty($main_keyword)){
$data['keywords'] = $this->ai_send('seo_keywords',$main_keyword);
}
}
if(empty($v['description'])){
$name = $this->companyName($project_id);
if(!empty($name)){
$data['description'] = $this->ai_send('page_meta_description',$v['name'],$name);
}
}
if(!$data){
continue;
}
DB::connection('custom_mysql')->table('gl_web_custom_template')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @remark :获取公司英文名称
* @name :companyName
* @author :lyh
* @method :post
* @time :2023/10/30 11:22
*/
public function companyName($project_id,$key = ''){
$data = [
'product_long_description',
];
$projectOptimizeModel = new DeployOptimize();
$info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','company_en_name','company_en_description']);
if(in_array($key,$data)){
return $info['company_en_description'];
}else{
return $info['company_en_name'];
}
}
/**
* @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){
if(!empty($info['main_keywords'])){
$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,$name = ''){
$chat_url = 'v2/openai_chat_qqs';
$param = [
'key'=>$key,
'keywords'=>$keywords,
];
$data = Common::send_openai_msg($chat_url,$param,$name);
$data['text'] = Common::deal_keywords($data['text']);
$data['text'] = Common::deal_str($data['text']);
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分钟一次
... ...
... ... @@ -212,4 +212,21 @@ class Arr extends \Illuminate\Support\Arr
}
return $data;
}
/**
* 根据列表查找指定id下的所有子id
* @param $dataArray
* @param $parentId
* @param $resultArray
* @author zbj
* @date 2023/10/17
*/
public static function findChildIds($dataArray, $parentId, &$resultArray) {
foreach ($dataArray as $value) {
if ($value['pid'] == $parentId) {
$resultArray[] = $value['id'];
self::findChildIds($dataArray, $value['id'], $resultArray);
}
}
}
}
... ...
... ... @@ -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();
//指定库获取指令
... ... @@ -73,16 +74,19 @@ class Common
if (isset($result['texts']['sl']) && isset(Translate::$tls_list[$result['texts']['sl']])) {
$lang = Translate::$tls_list[$result['texts']['sl']]['text'];
} else {
$lang = '中文';
$lang = 'Chinese';
}
}
$str = ',请使用'.$lang.'回答';
$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']],
['role'=>'assistant','content'=>$content.$str],
// ['role'=>'system','content'=>$info['scene']],
['role'=>'user','content'=>$content.$str],
]
];
return http_post($url,json_encode($data));
... ... @@ -183,4 +187,38 @@ class Common
return $crypt->decrypt($string);
}
//处理关键词
public static 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 static function deal_str($str){
return str_replace(['{','}','”','“','"'],'',$str);
}
}
... ...
... ... @@ -13,6 +13,7 @@ use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
/**
* @remark :b端网站更新相关
... ... @@ -36,116 +37,7 @@ class UpdateController extends BaseController
],[
'project_id.required' => 'project_id不能为空',
]);
ProjectServer::useProject($this->param['project_id']);
$this->updateProduct($this->param['project_id']);
$this->updateBlogs($this->param['project_id']);
$this->updateNews($this->param['project_id']);
DB::disconnect('custom_mysql');
$this->response('success');
}
/**
* @remark :更新产品tdk
* @name :updateProduct
* @author :lyh
* @method :post
* @time :2023/8/19 9:25
*/
public function updateProduct($project_id){
$list = DB::connection('custom_mysql')->table('gl_product')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $v){
if(!empty($v['seo_mate'])){
$seo_arr = $v['seo_mate'];
//更新seo_title
if(!isset($seo_arr['title'])){
//生成seo_title
$seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']);
}
//更新seo_keyword
if(!isset($seo_arr['keyword'])){
$seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']);
}
//更新seo_keyword
if(!isset($seo_arr['description'])){
$seo_arr['description'] = $this->ai_send('product_seo_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 :updateNews
* @author :lyh
* @method :post
* @time :2023/8/19 10:06
*/
public function updateNews($project_id){
$list = DB::connection('custom_mysql')->table('gl_news')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $this->ai_send('news_seo_title',$v['name']);
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('news_seo_keyword',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('news_seo_description',$v['name']);
}
DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @remark :更新blogTdk
* @name :updateBlogs
* @author :lyh
* @method :post
* @time :2023/8/19 10:07
*/
public function updateBlogs($project_id){
$list = DB::connection('custom_mysql')->table('gl_blog')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
if(!empty($list)){
foreach ($list as $k => $v){
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']);
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('blog_seo_keyword',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']);
}
DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update($data);
}
}
return true;
}
/**
* @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';
$param = [
'key'=>$key,
'keywords'=>$keywords,
];
$data = Common::send_openai_msg($chat_url,$param);
return $data['text'];
Redis::lpush('updateSeoTdk', $this->param['project_id']);
$this->response('任务添加成功');
}
}
... ...
... ... @@ -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;
... ... @@ -62,7 +64,7 @@ class LoginController extends BaseController
* @time :2023/8/7 9:07
*/
public function getAccessAddress(LoginLogic $logic){
$data = $logic->accessAddress();
$data = $logic->accessAddress($this->manage['id']);
return $this->response('success',Code::SUCCESS,$data);
}
... ... @@ -98,5 +100,4 @@ class LoginController extends BaseController
SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN);
$this->response('success');
}
}
... ...
... ... @@ -144,12 +144,18 @@ class OnlineController extends BaseController
*/
public function setQuestion(){
$this->request->validate([
'id'=>'required',
'project_id'=>'required',
],[
'id.required' => 'ID不能为空',
'project_id.required' => 'project_id不能为空',
]);
$onlineCheckModel = new OnlineCheck();
$rs = $onlineCheckModel->edit($this->param,['id'=>$this->param['id']]);
$info = $onlineCheckModel->read(['project_id'=>$this->param['project_id']]);
if($info === false){
$this->param['created_manage_id'] = $this->manage['id'];
$rs = $onlineCheckModel->add($this->param);
}else{
$rs = $onlineCheckModel->edit($this->param,['project_id'=>$this->param['project_id']]);
}
if($rs === false){
$this->response('error',Code::USER_ERROR);
}
... ...
... ... @@ -36,7 +36,7 @@ class OptimizeController extends BaseController
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id');
$query = $this->searchParam($query);
$query = $this->searchParam($query)->orderBy('gl_project_deploy_optimize.start_date','asc')->orderBy('gl_project_deploy_optimize.id','desc');
$lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
if(!empty($lists) && !empty($lists['list'])){
$rankDataModel = new RankData();
... ... @@ -127,6 +127,7 @@ class OptimizeController extends BaseController
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_optimize.quality_mid AS quality_mid',
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.start_date AS start_date',
];
return $select;
}
... ... @@ -161,10 +162,10 @@ class OptimizeController extends BaseController
if(isset($this->map['optimize_assist_mid']) && !empty($this->map['optimize_assist_mid'])){
$query = $query->where('gl_project_deploy_optimize.assist_mid','like','%'.$this->map['optimize_assist_mid'].'%');
}
if(isset($this->map['user_id']) && !empty($this->map['user_id'])){
if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){
$query->where(function ($subQuery) {
$subQuery->orWhere('gl_project.channel','like','%"user_id": "'.$this->map['user_id'].'"%')
->orWhere('gl_project.channel','like','%"user_id": '.$this->map['user_id'].'%');
$subQuery->orWhere('gl_project.channel','like','%"zone_id": "'.$this->map['channel_id'].'"%')
->orWhere('gl_project.channel','like','%"zone_id": '.$this->map['channel_id'].'%');
});
}
if(isset($this->map['domain']) && !empty($this->map['domain'])){
... ...
... ... @@ -199,7 +199,8 @@ class ProjectController extends BaseController
$info = $managerHr->read(['manage_id'=>$this->manage['id']]);
//获取当前用户自己的项目
$query->where(function ($subQuery) use ($info) {
$subQuery->where('gl_project_deploy_build.leader_mid', $this->manage['id'])
$subQuery->whereIn('gl_project.id',[1,3])//项目1+项目3默认显示
->orWhere('gl_project_deploy_build.leader_mid', $this->manage['id'])
->orWhere('gl_project_deploy_build.manager_mid', $this->manage['id'])
->orWhere('gl_project_deploy_build.designer_mid', $this->manage['id'])
->orWhere('gl_project_deploy_build.tech_mid', $this->manage['id'])
... ... @@ -571,18 +572,36 @@ class ProjectController extends BaseController
*/
public function getProjectByChannel(){
$id = $this->param['id'] ?? [];
$source_id = $this->param['channel_id']; //原系统渠道id
$source_id = $this->param['channel_id'] ?? 0; //原系统渠道id
$size = $this->param['page_size'] ?? 20;
$type = $this->param['type'] ?? '';
$company = $this->param['company'] ?? '';
if(!$source_id && !$id){
$this->response('参数异常',Code::SYSTEM_ERROR);
}
$channel_id = 0;
if($source_id){
$channel = Channel::where('source_id', $source_id)->first();
if(!$channel){
$this->response('渠道不存在',Code::SYSTEM_ERROR);
}
if ($id && FALSE == is_array($id))
$channel_id = $channel->id;
}
if ($id){
if(!is_array($id)){
$id = explode(',', $id);
}
}
$data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])->where(['channel->channel_id' => $channel->id, 'delete_status' => 0])->where(function ($query) use ($type, $company, $id){
$data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])
->where('delete_status', 0)
->where(function ($query) use ($channel_id, $type, $company, $id){
if ($channel_id) {
$query->where('channel->channel_id', $channel_id);
}
if ($type) {
$query->where('type', $type);
}
... ... @@ -601,6 +620,7 @@ class ProjectController extends BaseController
$domain_array = parse_url($domain_pro ? $domain_pro->domain : '');
$domain = $domain_array['host'] ?? $domain_array['path'];
}
$manage = new Manage();
$param = [
"id" => $item['id'],
"title" => $item['title'],
... ... @@ -621,8 +641,11 @@ class ProjectController extends BaseController
"test_domain" => $item['deploy_build']['test_domain'] ?? '',
"online_time" => $item['online_check']['qa_check_time'] ?? '',
"cooperate_date" => $item['cooperate_date'],
"project_manager_name" => $manage->getName($item['deploy_build']['manager_mid']), //项目经理
"after_sales_manager_name" => $manage->getName($item['deploy_optimize']['manager_mid']), //售后服务经理
"leader_name" => $manage->getName($item['deploy_build']['leader_mid']), //组长
];
if ($item['type'] == 3) {
if ($item['type'] == Project::TYPE_TWO) {
$param['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0;
} else {
$param['is_compliance'] = 1;
... ... @@ -650,4 +673,6 @@ class ProjectController extends BaseController
$lists = $renewLog->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -8,11 +8,13 @@ use App\Helper\Translate;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Controllers\Bside\:写入日志;
use App\Models\Ai\AiLog;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
class AiCommandController extends BaseController
{
//获取文本内容
public $chat_url = 'v2/openai_chat';
public $chat_url = 'v2/openai_chat_qqs';
/**
* @name :ai生成
* @author :liyuhang
... ... @@ -27,7 +29,9 @@ class AiCommandController extends BaseController
'key.required' => '场景不能为空',
]);
#TODO 通过key获取到ai指令对象
$data = Common::send_openai_msg($this->chat_url,$this->param);
$data = Common::send_openai_msg($this->chat_url,$this->param,$this->companyName($this->param['key'],$this->user['project_id']));
$data['text'] = Common::deal_keywords($data['text']);
$data['text'] = Common::deal_str($data['text']);
$param = [
'key'=>$this->param['key'],
'keywords'=>$this->param['keywords'],
... ... @@ -38,6 +42,28 @@ class AiCommandController extends BaseController
}
/**
* @remark :获取公司英文名称
* @name :companyName
* @author :lyh
* @method :post
* @time :2023/10/30 11:22
*/
public function companyName($key,$project_id){
$data = [
'news_remark',
'blog_remark',
'product_long_description'
];
$projectOptimizeModel = new DeployOptimize();
$info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','company_en_name','company_en_description']);
if(in_array($key,$data)){
return $info['company_en_description'];
}else{
return $info['company_en_name'];
}
}
/**
* @name :写入日志
* @author :liyuhang
* @method
... ... @@ -53,4 +79,5 @@ class AiCommandController extends BaseController
$aiLog = new AiLog();
return $aiLog->add($param);
}
}
... ...
... ... @@ -19,6 +19,7 @@ use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\WebSettingCountry;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
/**
* @remark :通知C端
... ... @@ -139,7 +140,9 @@ class CNoticeController extends BaseController
'created_at'=>date('Y-m-d H;i:s')
];
$updateProgressModel = new UpdateProgress();
return $updateProgressModel->insert($data);
$updateProgressModel->insert($data);
Redis::lpush('updateProgress', $this->user['project_id']);
return true;
}
/**
... ...
<?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_list'=>0,
'blog_list'=>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');
}
}
... ...
<?php
/**
* @remark :
* @name :UpdateController.php
* @author :lyh
* @method :post
* @time :2023/8/19 9:08
*/
namespace App\Http\Controllers\Bside\BCom;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Blog\Blog;
use App\Models\News\News;
use App\Models\Product\Product;
/**
* @remark :b端网站更新相关
* @name :UpdateController
* @author :lyh
* @method :post
* @time :2023/8/19 9:08
*/
class UpdateController extends BaseController
{
/**
* @remark :一键更新所有tdk
* @name :updateSeoTdk
* @author :lyh
* @method :post
* @time :2023/8/19 9:25
*/
public function updateSeoTdk(){
$this->updateProduct();
$this->updateBlogs();
$this->updateNews();
$this->response('success');
}
/**
* @remark :更新产品tdk
* @name :updateProduct
* @author :lyh
* @method :post
* @time :2023/8/19 9:25
*/
public function updateProduct(){
$productModel = new Product();
$list = $productModel->list(['status'=>Product::STATUS_ON,'project_id'=>$this->user['project_id']],'id',['id','seo_mate','title']);
if(!empty($list)){
foreach ($list as $v){
if(!empty($v['seo_mate'])){
$seo_arr = $v['seo_mate'];
//更新seo_title
if(!isset($seo_arr['title'])){
//生成seo_title
$seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']);
}
//更新seo_keyword
if(!isset($seo_arr['keyword'])){
$seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']);
}
//更新seo_keyword
if(!isset($seo_arr['description'])){
$seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']);
}
$ser_str = json_encode($seo_arr,true);
$productModel->edit(['seo_mate'=>$ser_str],['id'=>$v['id']]);
}
}
}
return true;
}
/**
* @remark :更新新闻Tdk
* @name :updateNews
* @author :lyh
* @method :post
* @time :2023/8/19 10:06
*/
public function updateNews(){
$newsModel = new News();
$list = $newsModel->list(['status'=>$newsModel::STATUS_ONE],'id',['id','name','seo_title','seo_keywords','seo_description']);
if(!empty($list)){
foreach ($list as $k => $v){
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $this->ai_send('news_seo_title',$v['name']);
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('news_seo_keyword',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('news_seo_description',$v['name']);
}
$newsModel->edit($data,['id'=>$v['id']]);
}
}
return true;
}
/**
* @remark :更新blogTdk
* @name :updateBlogs
* @author :lyh
* @method :post
* @time :2023/8/19 10:07
*/
public function updateBlogs(){
$blogModel = new Blog();
$list = $blogModel->list(['status'=>$blogModel::STATUS_ONE]);
if(!empty($list)){
foreach ($list as $k => $v){
$data = [];
if(empty($v['seo_title'])){
$data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']);
}
if(empty($v['seo_keywords'])){
$data['seo_keywords'] = $this->ai_send('blog_seo_keyword',$v['name']);
}
if(empty($v['seo_description'])){
$data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']);
}
$blogModel->edit($data,['id'=>$v['id']]);
}
}
return true;
}
/**
* @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';
$param = [
'key'=>$key,
'keywords'=>$keywords,
];
$data = Common::send_openai_msg($chat_url,$param);
return $data['text'];
}
}
... ... @@ -20,19 +20,42 @@ class BlogCategoryController extends BaseController
public function lists(BlogCategoryModel $blogCategoryModel){
//搜索条件
$this->map['project_id'] = $this->user['project_id'];
$lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order,
['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']);
if(!empty($lists['list'])){
$filed = ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at'];
$lists = $blogCategoryModel->list($this->map,$this->order = ['sort','id'],$filed);
$data = [];
if(!empty($lists)){
$blogModel = new BlogModel();
foreach ($lists['list'] as $k => $v){
foreach ($lists as $k => $v){
$v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $v['id'], $this->user['project_id']);
$v['url'] = $this->user['domain'] . RouteMap::PATH_BLOG_CATE . '/' . $v['alias'];
$v['hasChildren'] = (($blogCategoryModel->read(['pid'=>$v['id']])) != false) ? true : false;
$lists['list'][$k] = $v;
$v['url'] = $this->user['domain'] . $v['alias'].'/';
$lists[$k] = $v;
}
if(!isset($this->map['name'])){
$data = $this->getListSon($lists);
}else{
$data = $lists;
}
$this->response('success',Code::SUCCESS,$lists);
}
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :无分页子集处理
* @name :getListSon
* @author :lyh
* @method :post
* @time :2023/8/17 11:12
*/
public function getListSon($list){
$data = array();
foreach ($list as $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $list);
$data[] = $v;
}
}
return $data;
}
/**
... ...
... ... @@ -4,13 +4,12 @@ namespace App\Http\Controllers\Bside\Blog;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Blog\BlogCategoryLogic;
use App\Http\Logic\Bside\Blog\BlogLabelLogic;
use App\Http\Logic\Bside\Blog\BlogLogic;
use App\Http\Requests\Bside\Blog\BlogRequest;
use App\Models\Blog\Blog as BlogModel;
use App\Models\Blog\BlogCategory;
use App\Models\RouteMap\RouteMap;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
use App\Models\Product\Category;
use App\Models\User\User;
class BlogController extends BaseController
... ... @@ -23,16 +22,20 @@ class BlogController extends BaseController
* @method :post
* @time :2023/9/14 10:45
*/
public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){
$this->map = $this->searchParam();
$lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order = 'sort', ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']);
if(!empty($lists) && !empty($lists['list'])){
//获取当前项目的所有分类
public function lists(BlogModel $blogModel){
$filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url'];
$this->order = 'sort';
$query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc');
$query = $this->searchParam($query);
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
// //获取当前项目的所有分类
$data = $this->getCategoryList();
$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;
... ... @@ -48,16 +51,52 @@ class BlogController extends BaseController
* @method :post
* @time :2023/9/14 10:01
*/
public function searchParam(){
$this->map['project_id'] = $this->user['project_id'];
if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
$this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%'];
public function searchParam(&$query){
$query = $query->where('project_id',$this->user['project_id']);
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
$str = [];
$this->getLastLevelIds($this->map['category_id'],$str);
$query->where(function ($subQuery) use ($str) {
foreach ($str as $v) {
$subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);
}
});
}
if(isset($this->map['status'])){
$query = $query->where('status',$this->map['status']);
}
return $this->map;
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']]);
}
return $query;
}
/**
* @remark :获取所有分类
* @remark :获取当前分类的最后一级id
* @name :getLastLevelIds
* @author :lyh
* @method :post
* @time :2023/10/20 15:02
*/
public function getLastLevelIds($id, &$str = []) {
$cateModel = new BlogCategoryModel();
$subList = $cateModel->where('pid', $id)->get();
if ($subList->isEmpty()) {
// 如果没有子集,将当前 ID 添加到最后一级 ID 数组
$str[] = $id;
} else {
// 如果有子集,继续向下遍历
foreach ($subList as $v) {
$this->getLastLevelIds($v->id, $str);
}
}
}
/**
* @remark :获取所有分类名称
* @name :getCategoryList
* @author :lyh
* @method :post
... ... @@ -109,13 +148,28 @@ class BlogController extends BaseController
}
/**
* @name :获取分页列表
* @throws \App\Exceptions\BsideGlobalException
* @author :liyuhang
* @method
* @remark :(搜索)获取分类
* @name :get_category_list
* @author :lyh
* @method :post
* @time :2023/10/19 15:08
*/
public function get_category_list(BlogLogic $blogLogic){
$list = $blogLogic->blog_get_category_list();
public function get_category_list(){
$this->map['status'] = 0;
$this->map['project_id'] = $this->user['project_id'];
$blogCategoryModel = new BlogCategoryModel();
$cate_list = $blogCategoryModel->list($this->map,'sort');
if($cate_list === false){
$this->fail('error',Code::USER_ERROR);
}
$list = [];
foreach ($cate_list as $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $cate_list);
$list[] = $v;
}
}
$this->response('success',Code::SUCCESS,$list);
}
... ...
... ... @@ -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;
}
}
... ...
... ... @@ -29,7 +29,7 @@ class NavController extends BaseController
*/
public function index(BNav $nav){
$this->map['project_id'] = $this->user['project_id'];
$lists = $nav->list($this->map,$this->order = 'sort');
$lists = $nav->list($this->map,$this->order = ['sort','id']);
$data = array();
foreach ($lists as $v){
$v = (array)$v;
... ...
... ... @@ -20,19 +20,42 @@ class NewsCategoryController extends BaseController
public function lists(NewsCategoryModel $newsCategory){
//搜索条件
$this->map['project_id'] = $this->user['project_id'];
$lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order = 'sort',
['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']);
if(!empty($lists['list'])){
$filed = ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at'];
$lists = $newsCategory->list($this->map,$this->order = ['sort','id'],$filed);
$data = [];
if(!empty($lists)){
$newsModel = new NewsModel();
foreach ($lists['list'] as $k => $v){
foreach ($lists as $k => $v){
$v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $v['id'], $this->user['project_id']);
$v['url'] = $this->user['domain'] . RouteMap::PATH_NEWS_CATE . '/' . $v['alias'];
$v['hasChildren'] = (($newsCategory->read(['pid'=>$v['id']])) != false) ? true : false;
$lists['list'][$k] = $v;
$v['url'] = $this->user['domain'] . $v['alias'].'/';
$lists[$k] = $v;
}
if(!isset($this->map['name'])){
$data = $this->getListSon($lists);
}else{
$data = $lists;
}
$this->response('success',Code::SUCCESS,$lists);
}
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :无分页子集处理
* @name :getListSon
* @author :lyh
* @method :post
* @time :2023/8/17 11:12
*/
public function getListSon($list){
$data = array();
foreach ($list as $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $list);
$data[] = $v;
}
}
return $data;
}
/**
... ... @@ -58,7 +81,6 @@ class NewsCategoryController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $newsCategoryLogic->info_news_category();
$info['url'] = $this->user['domain'] . $info['alias'];
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -4,12 +4,10 @@ namespace App\Http\Controllers\Bside\News;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\News\NewsCategoryLogic;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Http\Requests\Bside\News\NewsRequest;
use App\Models\News\News as NewsModel;
use App\Models\News\NewsCategory;
use App\Models\RouteMap\RouteMap;
use App\Models\User\User;
... ... @@ -24,17 +22,20 @@ class NewsController extends BaseController
* @author :liyuhang
* @method
*/
public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){
$this->map = $this->searchParam();
$lists = $news->lists($this->map,$this->page,$this->row,$this->order = 'sort',
['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']);
if(!empty($lists) && !empty($lists['list'])){
//获取当前项目的所有分类
public function lists(NewsModel $news){
$filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url'];
$this->order = 'sort';
$query = $news->orderBy($this->order ,'desc')->orderBy('id','desc');
$query = $this->searchParam($query);
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
// //获取当前项目的所有分类
$data = $this->getCategoryList();
$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;
... ... @@ -50,12 +51,48 @@ class NewsController extends BaseController
* @method :post
* @time :2023/9/14 10:01
*/
public function searchParam(){
$this->map['project_id'] = $this->user['project_id'];
if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
$this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%'];
public function searchParam(&$query){
$query = $query->where('project_id',$this->user['project_id']);
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
$str = [];
$this->getLastLevelIds($this->map['category_id'],$str);
$query->where(function ($subQuery) use ($str) {
foreach ($str as $v) {
$subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);
}
});
}
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']]);
}
return $query;
}
/**
* @remark :获取当前分类的最后一级id
* @name :getLastLevelIds
* @author :lyh
* @method :post
* @time :2023/10/20 15:02
*/
public function getLastLevelIds($id, &$str = []) {
$cateModel = new NewsCategory();
$subList = $cateModel->where('pid', $id)->get();
if ($subList->isEmpty()) {
// 如果没有子集,将当前 ID 添加到最后一级 ID 数组
$str[] = $id;
} else {
// 如果有子集,继续向下遍历
foreach ($subList as $v) {
$this->getLastLevelIds($v->id, $str);
}
}
return $this->map;
}
/**
... ... @@ -132,7 +169,6 @@ class NewsController extends BaseController
'id.required' => 'ID不能为空',
]);
$info = $newsLogic->newsInfo();
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -37,12 +37,16 @@ class CategoryController extends BaseController
$data = [];
if(!empty($list)){
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'];
$v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->where(['status'=>1])->count();
$v['url'] = $this->user['domain'] . $v['route'].'/';
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image']);
$list[$k] = $v;
}
if(!isset($this->map['title'])){
$data = $this->getListSon($list);
}else{
$data = $list;
}
}
return $this->response('success',Code::SUCCESS,$data);
}
... ... @@ -58,10 +62,6 @@ class CategoryController extends BaseController
if(!empty($this->map['title'])){
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
}
if(!empty($this->map['search'])){
$this->map['title'] = ['like','%'.$this->map['search'].'%'];
}
unset($this->map['search']);
$this->map['project_id'] = $this->user['project_id'];
return $this->map;
}
... ... @@ -79,10 +79,6 @@ class CategoryController extends BaseController
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $list);
foreach ($v['sub'] as $sub){
$v['product_num'] += $sub['product_num'];
}
$data[] = $v;
}
}
... ... @@ -90,6 +86,17 @@ class CategoryController extends BaseController
}
/**
* @name :(添加/编辑时获取顶级分类)topList
* @author :lyh
* @method :post
* @time :2023/6/13 9:03
*/
public function categoryTopList(CategoryLogic $logic){
$list = $logic->categoryTopList();
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :获取详情
* @name :info
* @author :lyh
... ...
... ... @@ -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);
}
/**
... ...
... ... @@ -40,11 +40,14 @@ class ProductController extends BaseController
*/
public function index(Product $product)
{
$this->map = $this->searchParam();
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
$lists = $product->lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed);
if(!empty($lists) && !empty($lists['list'])){
$this->order = 'sort';
$query = $product->orderBy($this->order ,'desc')->orderBy('id','desc');
$query = $this->searchParam($query);
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
$cate_data = $this->getCategoryList();//分类
$key_data = $this->getKeywordsList();//关键字
//获取当前用户选择的模版
... ... @@ -56,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;
}
}
... ... @@ -64,21 +67,54 @@ class ProductController extends BaseController
}
/**
* @remark :搜索参数处理
* @name :searchParam
* @remark :处理列表返回参数
* @name :handleReturnParam
* @author :lyh
* @method :post
* @time :2023/9/14 14:32
* @time :2023/9/14 10:01
*/
public function searchParam(){
public function searchParam(&$query){
$query = $query->where('project_id',$this->user['project_id']);
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
$str = [];
$this->getLastLevelIds($this->map['category_id'],$str);
$query->where(function ($subQuery) use ($str) {
foreach ($str as $v) {
$subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);
}
});
}
if(isset($this->map['title']) && !empty($this->map['title'])){
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
$query = $query->where('title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['status'])){
$query = $query->where('status',$this->map['status']);
}
if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){
$query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]);
}
return $query;
}
/**
* @remark :获取当前分类的最后一级id
* @name :getLastLevelIds
* @author :lyh
* @method :post
* @time :2023/10/20 15:02
*/
public function getLastLevelIds($id, &$str = []) {
$cateModel = new Category();
$subList = $cateModel->where('pid', $id)->get();
if ($subList->isEmpty()) {
// 如果没有子集,将当前 ID 添加到最后一级 ID 数组
$str[] = $id;
} else {
// 如果有子集,继续向下遍历
foreach ($subList as $v) {
$this->getLastLevelIds($v->id, $str);
}
if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
$this->map['category_id'] = ['like','%'.$this->map['category_id'].'%'];
}
$this->map['project_id'] = $this->user['project_id'];
return $this->map;
}
/**
... ... @@ -217,16 +253,7 @@ class ProductController extends BaseController
* @time :2023/8/17 9:15
*/
public function handleParam($v){
$v['category_id_text'] = '';
$v['keyword_id_text'] = '';
if(!empty($v['category_id'])){
$categoryModel = new Category();
$category_data = $categoryModel->list(['id'=>['in',$v['category_id']]],'id',['title']);
foreach ($category_data as $v1){
$v['category_id_text'] .= $v1['title'].',';
}
$v['category_id_text'] = trim($v['category_id_text'],',');
}
if(!empty($v['keyword_id'])){
$keywordModel = new Keyword();
$keyword_data = $keywordModel->list(['id'=>['in',$v['keyword_id']]]);
... ... @@ -260,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([]),
'video_url'=>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']);
}
if(isset($this->param['video_url']) && !empty($this->param['video_url'])){
$this->param['video_url'] = Arr::a2s($this->param['video_url']);
}
$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');
}
}
... ...
... ... @@ -33,6 +33,7 @@ class BTemplateLogController extends BaseController
* @time :2023/8/23 11:05
*/
public function lists(BTemplateLog $bTemplateLog){
unset($this->map['template_id']);
$this->map['project_id'] = $this->user['project_id'];
$this->map['source'] = 1;
$lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']);
... ...
... ... @@ -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;
}
}
... ...
... ... @@ -94,9 +94,6 @@ class FileController
if ($type == 'multi') {
return $this->multi($files);
} else {
$size = $files->getSize();
$file_type = $files->getClientOriginalExtension();
$mime = $files->getMimeType();
return $this->single($files);
}
}
... ... @@ -113,7 +110,12 @@ class FileController
$name = $files->getClientOriginalName();
//查看文件是否存在
$fileModel = new File();
$file_hash = $fileModel->read(['hash'=>$hash]);
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
$file_hash = $fileModel->read($param);
if($file_hash !== false){
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name));
}
... ... @@ -150,6 +152,7 @@ class FileController
'refer'=>$this->param['refer'] ?? 1,
'is_cos'=>$is_cos,
'mime'=>$mime,
'project_id'=>$this->cache['project_id'] ?? 0,
'name'=>$name,
];
$rs = $fileModel->add($data);
... ... @@ -172,7 +175,11 @@ class FileController
$fileModel = new File();
$name = $file->getClientOriginalName();
$hash = hash_file('md5', $file->getPathname());
$file_hash = $fileModel->read(['hash'=>$hash]);
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
$file_hash = $fileModel->read($param);
if($file_hash !== false){
$data[] = $this->responseData($file_hash['path'], $name);
continue;
... ...
... ... @@ -162,7 +162,7 @@ class ImageController extends Controller
$this->response('没有上传的文件!', Code::USER_ERROR);
}
$type = $this->request->post('type','single');
$this->setUrl();
$this->setUrl($files);
if ($type == 'multi') {
return $this->multi($files);
}else{
... ... @@ -298,7 +298,6 @@ class ImageController extends Controller
*/
public function download(){
$imageModel = new ImageModel();
;
$info = $imageModel->read(['path' => str_replace_url($this->param['path'])]);
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
... ... @@ -371,11 +370,24 @@ class ImageController extends Controller
* @method :post
* @time :2023/7/18 15:36
*/
public function setUrl(){
public function setUrl($files){
//A端上传
if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
$this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
}else{
//TODO::设置上传文件大小(B端上传)
$max = config('upload.default_b_image')['size']['max'];
if(is_array($files)){
foreach ($files as $file){
if ($file->getSize() > $max) {
return $this->response('图片最大为500K',Code::SYSTEM_ERROR);
}
}
}else{
if ($files->getSize() > $max) {
return $this->response('图片最大为500K',Code::SYSTEM_ERROR);
}
}
if(!isset($this->param['upload_method'])){
//根据项目上传标识区分上传到cos/本地
$projectModel = new Project();
... ...
... ... @@ -35,7 +35,7 @@ class DomainInfoLogic extends BaseLogic
{
$domain = parse_url($this->param['domain'], PHP_URL_HOST);
if(!empty($domain)){
$this->param['domain'] = $domain['host'];
$this->param['domain'] = trim($domain['host']);
}
//验证域名
$this->verifyDomain($this->param['domain'],isset($this->param['id']) ?? '');
... ... @@ -193,6 +193,7 @@ class DomainInfoLogic extends BaseLogic
try {
$rs = HttpUtils::get($api_url, $api_param);
$rs = json_decode($rs, true);
if(isset($rs['status']) && $rs['status'] == 200){
return $this->success();
}else{
... ...
... ... @@ -8,8 +8,10 @@ use App\Models\Manage\LoginLog;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Manage\MenuSpecial;
use App\Models\Project\Project;
use App\Models\Service\Service;
use App\Models\Sms\SmsLog;
use App\Models\User\User;
use App\Utils\EncryptUtils;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
... ... @@ -109,7 +111,7 @@ class LoginLogic extends BaseLogic
* @method :post
* @time :2023/8/7 9:09
*/
public function accessAddress(){
public function accessAddress($manage_id){
$serviceSettingModel = new Service();
$info = $serviceSettingModel->read(['type'=>4]);
if($info === false){
... ... @@ -120,6 +122,16 @@ class LoginLogic extends BaseLogic
'domain'=>$info['values'],
'remark'=>'自动登录地址和code',
];
//演示账号 用自己的号登录
if(!empty($this->param['project_id']) && $this->param['project_id'] == Project::DEMO_PROJECT_ID){
unset($this->param['project_id']);
$mobile = Manage::where('id', $manage_id)->value('mobile');
$user = User::where('mobile', $mobile)->first();
if(!$user){
$this->fail('未在演示项目注册账号');
}
$this->param['user_id'] = $user->id;
}
//获取超级管理员登录
if(isset($this->param['project_id']) && !empty($this->param['project_id'])){
$data['autologin_code'] = $encrypt->lock_url(json_encode(['project_id'=>$this->param['project_id'],'manager_id'=>$this->manager['id']]),$info['values']);
... ...
... ... @@ -11,6 +11,8 @@ use App\Models\Manage\JobLevel;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Manage\Menu;
use App\Models\Project\Project;
use App\Models\User\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
... ... @@ -73,6 +75,10 @@ class HrLogic extends BaseLogic
$managerModel = new Manage();
$this->param['manage_id'] = $managerModel->addReturnId($data);
$this->model->add($this->param);
//同步到B端演示项目
$this->syncBProjectUser($this->param['mobile'], $this->param['mobile'], $this->param['name'], $this->param['status']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -109,6 +115,10 @@ class HrLogic extends BaseLogic
//同步更新管理员手机号码
$managerModel->edit(['mobile'=>$this->param['mobile']],['id'=>$hrInfo['manage_id']]);
$this->model->edit($this->param,['id'=>$this->param['id']]);
//同步到B端演示项目
$this->syncBProjectUser($hrInfo['mobile'], $this->param['mobile'], $this->param['name'], $this->param['status']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -118,6 +128,37 @@ class HrLogic extends BaseLogic
}
/**
* 同步到B端用户
* @author zbj
* @date 2023/10/23
*/
public function syncBProjectUser($old_mobile, $mobile, $name, $status){
$user = User::where('project_id', Project::DEMO_PROJECT_ID)->where('mobile', $old_mobile)->first();
//在职
if($status == ManageHr::STATUS_ONE){
if(!$user){
$user = new User();
$user->project_id = Project::DEMO_PROJECT_ID;
$user->mobile = $mobile;
$user->name = $name;
$user->password = base64_encode(md5('v6.' . substr($mobile, -6)));
$user->type = User::TYPE_ONE;
$user->role_id = 38; //技术总部
$user->save();
}else{
$user->mobile = $mobile;
$user->name = $name;
$user->save();
}
}else{
//离职
if($user){
$user->delete();
}
}
}
/**
* @remark :获取详情
* @name :getHrInfo
* @author :lyh
... ...
... ... @@ -7,6 +7,7 @@ use App\Models\Devops\ServerConfig;
use App\Models\Project\ProjectRenew;
use App\Models\User\ProjectMenu;
use App\Models\User\ProjectRole;
use App\Services\SyncService;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Arr as SupArr;
... ... @@ -119,6 +120,7 @@ class ProjectLogic extends BaseLogic
DB::rollBack();
$this->fail('请填写完整后再提交');
}
(new SyncService())->projectAcceptAddress($this->param['id']);
return $this->success();
}
... ... @@ -142,14 +144,18 @@ class ProjectLogic extends BaseLogic
}
if(isset($param['notice_file']) && !empty($param['notice_file'])){
foreach ($param['notice_file'] as &$v1) {
if(isset($v1['url']) && !empty($v1['url'])){
$v1['url'] = str_replace_url($v1['url']);
}
}
$param['notice_file'] = Arr::a2s($param['notice_file']);
}
if(isset($param['confirm_file']) && !empty($param['confirm_file'])){
foreach ($param['confirm_file'] as &$v2) {
if(isset($v2['url']) && !empty($v2['url'])){
$v2['url'] = str_replace_url($v2['url']);
}
}
$param['confirm_file'] = Arr::a2s($param['confirm_file']);
}
unset($param['payment'],$param['deploy_build'],$param['deploy_optimize'],$param['online_check'],$param['project_after']);
... ... @@ -260,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();
}
... ...
... ... @@ -14,6 +14,7 @@ use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateLog;
use App\Models\Template\Setting;
class BTemplateLogLogic extends BaseLogic
{
... ... @@ -42,17 +43,26 @@ class BTemplateLogLogic extends BaseLogic
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
}
//获取当前项目的模版
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先选择模版');
}
//切换模版
if($info['template_id'] != $settingInfo['template_id']){
$bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]);
}
try {
$data = $this->setParam($info);
$BTemplateModel = new BTemplate();
$BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
//同步更新公共头和底
return $this->success();
}
... ... @@ -65,13 +75,8 @@ class BTemplateLogLogic extends BaseLogic
*/
public function setParam($info){
$data = [
'html'=>$info['text'],
'head_html'=>$info['head_html'],
'head_css'=>$info['head_css'],
'main_html'=>$info['main_html'],
'main_css'=>$info['main_css'],
'footer_html'=>$info['footer_html'],
'footer_css'=>$info['footer_css'],
];
return $this->success($data);
}
... ...
... ... @@ -3,17 +3,22 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
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\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 +66,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);
}
... ... @@ -105,7 +108,7 @@ class BTemplateLogic extends BaseLogic
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
}else{
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
if($commonInfo !== false){
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
... ... @@ -120,13 +123,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,33 +137,93 @@ class BTemplateLogic extends BaseLogic
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
if($TemplateInfo === false){
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo !== false){
$html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html'];
$mainInfo = $this->getCommonMain($source,$source_id);
$main_html = $mainInfo['main_html'];
$main_style = $mainInfo['main_css'];
$TemplateInfo['template_id'] = $info['template_id'];
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
$main_html = $TemplateInfo['main_html'];
$main_style = $TemplateInfo['main_css'];
}
}else{
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
$commonInfo = $this->getCommonPage($source,$source_id,$info['template_id']);
if($commonInfo !== false){
$html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
}
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $main_style, $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $main_html, $html);
}
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
return $this->success($TemplateInfo);
}
/**
* @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
... ... @@ -203,12 +266,13 @@ 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);//组装数据
$param = $this->templateSaveParam($this->param);//组装数据
if($info === false){
$this->model->add($this->param);
$this->model->add($param);
}else{
$this->model->edit($this->param,['id'=>$info['id']]);
$this->model->edit($param,['id'=>$info['id']]);
}
//写入操作模版记录
$this->setTemplateLog($this->param);
... ... @@ -230,27 +294,53 @@ 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']]);
// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND);
$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'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
];
$other = str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
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']]);
}
//更新所有界面的other
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]);
return $this->success();
}
/**
* @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
... ... @@ -289,13 +379,30 @@ class BTemplateLogic extends BaseLogic
$route = '';
//路由映射
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
}elseif($source == BTemplate::SOURCE_PRODUCT){
}else{
//其他界面通知更新
if($source == 2 && $source_id != 0){
$type = RouteMap::SOURCE_PRODUCT;
$productModel = new Product();
$info = $productModel->read(['id'=>$source_id]);
$route = $info['route'];
$productInfo = $productModel->read(['id'=>$source_id],['route']);
$route = $productInfo['route'];
}elseif($source == 3 && $source_id != 0){
$type = RouteMap::SOURCE_BLOG;
$blogModel = new Blog();
$blogInfo = $blogModel->read(['id'=>$source_id],['url']);
$route = $blogInfo['url'];
}elseif($source == 4 && $source_id != 0){
$type = RouteMap::SOURCE_NEWS;
$newsModel = new News();
$newsInfo = $newsModel->read(['id'=>$source_id],['url']);
$route = $newsInfo['url'];
}else{
$type = 0;
$route = 'all';
}
}
return $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route]);
return $this->success();
}
/**
... ... @@ -307,11 +414,8 @@ class BTemplateLogic extends BaseLogic
*/
public function templateSaveParam($param){
$param['project_id'] = $this->user['project_id'];
if($param['source'] == 1){//首页
$param['html'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s');
}else{
$param['html'] = $param['main_html'];
}
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
return $this->success($param);
}
... ... @@ -363,11 +467,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'];
}
/**
... ... @@ -425,19 +529,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);
... ... @@ -461,4 +559,101 @@ 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 = $this->getModule($this->param['type']);
$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'),
'other'=>str_replace('<header','',characterTruncation($this->param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/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();
}
}
... ...
... ... @@ -22,7 +22,7 @@ class BTemplateModuleLogic extends BaseLogic
* @method :post
* @time :2023/6/29 13:35
*/
public function ModuleList($map,$order = 'created_at',$filed = ['*']){
public function ModuleList($map,$order = 'created_at',$filed = ['id','name','type','sort','status','image','test_model']){
$map['deleted_status'] = 0;
$map['status'] = 0;
$lists = $this->model->list($map,$order,$filed);
... ...
... ... @@ -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;
... ... @@ -89,7 +90,7 @@ class CustomTemplateLogic extends BaseLogic
public function saveHtml(){
$html = $this->param['html'];
$this->saveCommonTemplate($html);
$this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
$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){
... ... @@ -110,29 +111,53 @@ class CustomTemplateLogic extends BaseLogic
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($html){
$type = $this->getType();
//获取设置的默认模版
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先设置模版');
}
//查看当前
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
$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'=>$bSettingInfo['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")),
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
$other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
if($info === false){
$data['template_id'] = $bSettingInfo['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 :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 +249,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 +273,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: 逻辑层基类 控制器调用 统一返回 统一抛出异常
... ... @@ -73,7 +74,7 @@ class BaseLogic extends Logic
if(is_array($v)){
continue;
}else{
if(empty($v) && ($v == null)){
if(Str::endsWith($k, '_link')){
unset($requestAll[$k]);
}
}
... ...
... ... @@ -19,24 +19,6 @@ class BlogCategoryLogic extends BaseLogic
}
/**
* @param $v
* @name :获取分类名称
* @return void
* @author :liyuhang
* @method
*/
public function get_category_name($v){
//获取用户已读还是未读
$category_info = $this->model->list(['id'=>['in',explode(',',trim($v['category_id'],','))]],'id',['name']);
$str = '';
foreach ($category_info as $v1){
$str .= $v1['name'].',';
}
$v['category_name'] = trim($str,',');
return $this->success($v);
}
/**
* @remark :保存数据
* @name :categorySave
* @author :lyh
... ... @@ -49,12 +31,9 @@ class BlogCategoryLogic extends BaseLogic
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//验证参数是否可编辑
$this->verifyParamEdit($this->param['id'],$this->param['pid']);
//查看路由是否更新
$id = $this->editCategoryRoute($this->param['id'],
isset($this->param['alias']) ?? RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']));
$id = $this->editCategoryRoute($this->param['id'], $this->param['alias']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
... ... @@ -78,6 +57,48 @@ class BlogCategoryLogic extends BaseLogic
}
/**
* @remark :编辑分类,处理博客数据
* @name :editCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:32
*/
public function editHandleCategory($id,$pid){
$info = $this->model->read(['id'=>$id],['id','pid']);
if($info['pid'] != $pid){
//修改勒上级,先查看上级是否拥有博客
$blogModel = new BlogModel();
$blogCount = $blogModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
if($blogCount > 0){
//随机获取最后一级id
$replacement = $this->getLastId($id);
//存在博客时,移动所有博客到当前分类最后一级
$blogModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
$blogModel->where('category_id', 'like', '%,' . $pid . ',%')
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
}
}
return $this->success();
}
/**
* @remark :随机获取当前id下最后一级的id
* @name :getLastId
* @author :lyh
* @method :post
* @time :2023/10/20 9:45
*/
public function getLastId($id){
$info = $this->model->read(['pid'=>$id],['id']);
if($info !== false){
return $this->getLastId($info['id']);
}else{
return $id;
}
}
/**
* @remark :编辑路由时生成路由记录
* @name :editCategoryRoute
* @author :lyh
... ... @@ -94,35 +115,7 @@ class BlogCategoryLogic extends BaseLogic
];
$this->setRouteDeleteSave($data);
}
return $this->success();
}
/**
* @remark :查看参数是否可编辑
* @name :verifyParamEdit
* @author :lyh
* @method :post
* @time :2023/7/31 16:31
*/
public function verifyParamEdit($id,$pid){
$info = $this->model->read(['id'=>$id]);
if($info['id'] == $pid){
$this->fail('不能成为自己的上级');
}
if($info['pid'] != $pid){
$info = $this->model->read(['pid'=>$id]);
if($info !== false){
$this->fail('当前分类拥有子分类不允许修改父级');
}
//查询当前分类下是否有商品
$blogModel = new BlogModel();
$info = $blogModel->read(['id'=>['like','%,'.$id.',%']]);
if($info !== false){
$this->fail('当前分类下已存在博客,不允许修改上级');
}
}
return $this->success();
return $this->success($id);
}
/**
... ... @@ -181,7 +174,7 @@ class BlogCategoryLogic extends BaseLogic
}
//查看当前分内下是否有博客
$blogModel = new BlogModel();
$rs = $blogModel->read(['category_id'=>$id],['id']);
$rs = $blogModel->read(['category_id'=>['like','%,'.$id.',%']],['id']);
if($rs !== false){
$this->response('当前分类拥有博客,不允许删除');
}
... ... @@ -195,13 +188,44 @@ class BlogCategoryLogic extends BaseLogic
* @time :2023/6/13 9:09
*/
public function categoryTopList(){
$map = [
'project_id'=>$this->user['project_id'],
'pid'=>0,
'status'=>0,
];
$list = $this->model->list($map);
return $this->success($list);
$this->param['project_id'] = $this->user['project_id'];
$this->param['status'] = 0;
if(isset($this->param['id']) && !empty($this->param['id'])){
$str = [];
//排序掉当前id下所有子集
$str = $this->getAllSub($this->param['id'],$str);
$str[] = (int)$this->param['id'];
$this->param['id'] = ['not in',$str];
}
$menu = array();
$list = $this->model->list($this->param);
if(!empty($list)){
foreach ($list as $k => $v){
if($v['pid'] == 0){
$v['sub'] = _get_child($v['id'],$list);
$menu[] = $v;
}
}
}
return $this->success($menu);
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
}
/**
... ... @@ -259,7 +283,7 @@ class BlogCategoryLogic extends BaseLogic
$blogModel = new BlogModel();
$blog_count = $blogModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
if ($blog_count > 0) {
$replacement = ','. $this->param['pid'] . ',' . $cate_id . ',';
$replacement = ',' . $cate_id . ',';
$old = ',' . $this->param['pid'] . ',';
//更新所有商品到当前分类
$blogModel->where('category_id', 'like', '%' . $old . '%')
... ...
... ... @@ -23,14 +23,13 @@ class BlogLabelLogic extends BaseLogic
* @author :liyuhang
* @method
*/
public function get_label_name($v){
$label_info = $this->model->list(['id'=>['in',explode(',',trim($v['label_id'],','))]],'id',['name']);
$str = '';
foreach ($label_info as $v1){
$str .= $v1['name'].',';
}
$v['label_name'] = trim($str,',');
return $this->success($v);
public function getLabelName($label_id){
$label_name = '';
if(!empty($label_id)){
$label_arr = $this->model->formatQuery(['id'=>['in',explode(',',trim($label_id,','))]])->pluck('name')->toArray();
$label_name = implode(',',$label_arr);
}
return $this->success($label_name);
}
/**
* @name :新增标签
... ...
... ... @@ -2,8 +2,6 @@
namespace App\Http\Logic\Bside\Blog;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
... ... @@ -24,32 +22,6 @@ class BlogLogic extends BaseLogic
}
/**
* @name :获取分类列表
* @return array
* @throws \App\Exceptions\BsideGlobalException
* @author :liyuhang
* @method
*/
public function blog_get_category_list(){
$this->map['status'] = 0;
$this->map['project_id'] = $this->user['project_id'];
$blogCategoryModel = new BlogCategoryModel();
$cate_list = $blogCategoryModel->list($this->map,'sort');
if($cate_list === false){
$this->fail('error',Code::USER_ERROR);
}
$list = [];
foreach ($cate_list as $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $cate_list);
$list[] = $v;
}
}
return $this->success($list);
}
/**
* @remark :保存数据
* @name :blogSave
* @author :lyh
... ... @@ -123,26 +95,19 @@ class BlogLogic extends BaseLogic
* @method
*/
public function blogInfo(){
//读取缓存
$info = Common::get_user_cache($this->model->getTable(),$this->param['id']);
if(empty($info)){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('error');
}
//获取分类名称
$blogCategoryLogic = new BlogCategoryLogic();
$info = $blogCategoryLogic->get_category_name($info);
$info['category_id'] = explode(',',trim($info['category_id'],','));
//获取标签名称
$blogLabelLogic = new BlogLabelLogic();
$info = $blogLabelLogic->get_label_name($info);
$info['label_name'] = $blogLabelLogic->getLabelName($info['label_id']);
$info['image_link'] = getImageUrl($info['image']);
//写入缓存
Common::set_user_cache($info,$this->model->getTable(),$this->param['id']);
}
return $this->success($info);
}
/**
* @name :修改状态
* @return array
... ... @@ -210,20 +175,39 @@ class BlogLogic extends BaseLogic
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = ','.trim($param['category_id'],',').',';
$param['category_id'] = $this->getLastCategory($param['category_id']);
}
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = ','.$param['category_id'].',';
$param['category_id'] = $this->getLastCategory($param['category_id']);
}
}
return $this->success($param);
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
$cateModel = new BlogCategoryModel();
foreach ($category as $v){
$info = $cateModel->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
return ','.$str;
}
/**
* @remark :根据状态获取数量
* @name :getStatusNumber
* @author :lyh
... ...
... ... @@ -26,6 +26,7 @@ class NavLogic extends BaseLogic
$this->model = new BNav();
}
/**
* @remark :保存数据
* @name :navSave
... ... @@ -35,8 +36,6 @@ class NavLogic extends BaseLogic
*/
public function navSave()
{
DB::beginTransaction();
try {
if(!empty($this->param['location'])){
if($this->param['location'] == 'header'){
$this->param['group_id'] = BNavGroup::DEFAULT_HEADER_ID;
... ... @@ -54,11 +53,6 @@ class NavLogic extends BaseLogic
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
//编辑菜单后,通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']);
return $this->success();
... ...
... ... @@ -18,35 +18,15 @@ class NewsCategoryLogic extends BaseLogic
}
/**
* @param $v
* @name :获取分类名称
* @return void
* @author :liyuhang
* @method
*/
public function get_category_name($v){
if(!empty($v['category_id'])){
//获取用户已读还是未读
$category_info = $this->model->list([
'id'=>['in',explode(',',trim($v['category_id'],','))]],'id',['name']);
$str = '';
foreach ($category_info as $v1){
$str .= $v1['name'].',';
}
$v['category_name'] = trim($str,',');
}
return $this->success($v);
}
/**
* @name :详情
* @return array
* @throws \App\Exceptions\BsideGlobalException
* @author :liyuhang
* @method
* @remark :获取详情
* @name :info_news_category
* @author :lyh
* @method :post
* @time :2023/10/19 16:04
*/
public function info_news_category(){
$info = $this->model->read($this->param);
$info['url'] = $this->user['domain'] . $info['alias'];
return $this->success($info);
}
... ... @@ -63,12 +43,10 @@ class NewsCategoryLogic extends BaseLogic
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//验证是否可编辑
$this->verifyEditParam($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
//查看路由是否更新
$id = $this->editCategoryRoute($this->param['id'],$this->param['alias'] ?? RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']));
$id = $this->editCategoryRoute($this->param['id'],$this->param['alias']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param = $this->addParamProcessing($this->param);
... ... @@ -81,13 +59,54 @@ class NewsCategoryLogic extends BaseLogic
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
$this->fail('系统错误,请联系管理员');
}
//更新通知记录表
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]);
return $this->success();
}
/**
* @remark :编辑分类,处理博客数据
* @name :editCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:32
*/
public function editHandleCategory($id,$pid){
$info = $this->model->read(['id'=>$id],['id','pid']);
if($info['pid'] != $pid){
//修改勒上级,先查看上级是否拥有博客
$newsModel = new NewsModel();
$newsCount = $newsModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
//随机获取最后一级id
$replacement = $this->getLastId($id);
if($newsCount > 0){
//存在博客时,移动所有博客到当前分类最后一级
$newsCount->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
$newsCount->where('category_id', 'like', '%,' . $pid . ',%')
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
}
}
return $this->success();
}
/**
* @remark :随机获取当前id下最后一级的id
* @name :getLastId
* @author :lyh
* @method :post
* @time :2023/10/20 9:45
*/
public function getLastId($id){
$info = $this->model->read(['pid'=>$id],['id']);
if($info !== false){
return $this->getLastId($info['id']);
}else{
return $id;
}
}
/**
* @remark :编辑路由时生成路由记录
... ... @@ -109,32 +128,6 @@ class NewsCategoryLogic extends BaseLogic
return $id;
}
/**
* @remark :验证是否可编辑
* @name :verifyEditParam
* @author :lyh
* @method :post
* @time :2023/7/31 15:41
*/
public function verifyEditParam($id,$pid){
$info = $this->model->read(['id'=>$id]);
if($info['id'] == $pid){
$this->fail('不能成为自己的上级');
}
if($info['pid'] != $pid){
$info = $this->model->read(['pid'=>$id]);
if($info !== false){
$this->fail('当前分类拥有子分类不允许修改父级');
}
//查询当前分类下是否有商品
$newsModel = new NewsModel();
$info = $newsModel->read(['id'=>['like','%,'.$id.',%']]);
if($info !== false){
$this->fail('当前分类下已存在新闻,不允许修改上级');
}
}
return $this->success();
}
/**
* @name :修改状态
... ... @@ -166,7 +159,7 @@ class NewsCategoryLogic extends BaseLogic
$newsModel = new NewsModel();
$rs = $newsModel->read(['category_id'=>$id],['id']);
if($rs !== false){
$this->fail('当前分类拥有商品');
$this->fail('当前分类拥有商品,不允许删除');
}
$this->delRoute($id);
$this->model->del(['id'=>$id]);
... ... @@ -181,13 +174,44 @@ class NewsCategoryLogic extends BaseLogic
* @time :2023/6/13 9:09
*/
public function categoryTopList(){
$map = [
'project_id'=>$this->user['project_id'],
'pid'=>0,
'status'=>0,
];
$list = $this->model->list($map);
return $this->success($list);
$this->param['project_id'] = $this->user['project_id'];
$this->param['status'] = 0;
if(isset($this->param['id']) && !empty($this->param['id'])){
$str = [];
//排序掉当前id下所有子集
$str = $this->getAllSub($this->param['id'],$str);
$str[] = (int)$this->param['id'];
$this->param['id'] = ['not in',$str];
}
$menu = array();
$list = $this->model->list($this->param);
if(!empty($list)){
foreach ($list as $k => $v){
if($v['pid'] == 0){
$v['sub'] = _get_child($v['id'],$list);
$menu[] = $v;
}
}
}
return $this->success($menu);
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
}
/**
... ... @@ -241,7 +265,7 @@ class NewsCategoryLogic extends BaseLogic
$newsModel = new NewsModel();
$news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
if ($news_count > 0) {
$replacement = ','. $this->param['pid'] .','. $cate_id . ',';
$replacement = ',' . $cate_id . ',';
$old = ',' . $this->param['pid'] . ',';
//更新所有商品到当前分类
$newsModel->where('category_id', 'like', '%' . $old . '%')
... ...
... ... @@ -3,9 +3,9 @@
namespace App\Http\Logic\Bside\News;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap\RouteMap;
use App\Services\CosService;
... ... @@ -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();
... ... @@ -147,9 +147,11 @@ class NewsLogic extends BaseLogic
public function newsInfo()
{
$info = $this->model->read($this->param);
if($info === false){
$this->fail('error');
}
$info['category_id'] = explode(',',trim($info['category_id'],','));
$info['image_link'] = getImageUrl($info['image']);
$newsCategoryLogic = new NewsCategoryLogic();
$info = $newsCategoryLogic->get_category_name($info);
return $this->success($info);
}
... ... @@ -183,23 +185,42 @@ class NewsLogic extends BaseLogic
*/
public function paramProcessing($param)
{
if (isset($this->param['id'])) {
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if (isset($param['category_id']) && !empty($param['category_id'])) {
$param['category_id'] = ',' . trim($param['category_id'], ',') . ',';
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getLastCategory($param['category_id']);
}
} else {
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
if (isset($param['category_id']) && !empty($param['category_id'])) {
$param['category_id'] = ',' . $param['category_id'] . ',';
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = $this->getLastCategory($param['category_id']);
}
}
return $this->success($param);
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
$cateModel = new NewsCategoryModel();
foreach ($category as $v){
$info = $cateModel->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
return ','.$str;
}
/**
* @remark :根据状态获取数量
* @name :getStatusNumber
* @author :lyh
... ...
... ... @@ -6,6 +6,7 @@ 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\Product;
use App\Models\RouteMap\RouteMap;
use Illuminate\Support\Facades\DB;
... ... @@ -30,7 +31,7 @@ class CategoryLogic extends BaseLogic
$data = parent::getList($map, $sort, $columns, $limit);
foreach ($data as &$v){
$v['url'] = $this->user['domain'] . $v['route'] ;
$v['product_num'] = Product::where('category_id','like' ,'%,'.$v['category_id'].',%')->count();;
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image']);
}
if(!$map){
... ... @@ -40,6 +41,53 @@ class CategoryLogic extends BaseLogic
}
/**
* @name :(添加/编辑分类时获取级分类)categoryTopList
* @author :lyh
* @method :post
* @time :2023/6/13 9:09
*/
public function categoryTopList(){
$this->param['project_id'] = $this->user['project_id'];
$this->param['status'] = 1;
if(isset($this->param['id']) && !empty($this->param['id'])){
$str = [];
//排序掉当前id下所有子集
$str = $this->getAllSub($this->param['id'],$str);
$str[] = (int)$this->param['id'];
$this->param['id'] = ['not in',$str];
}
$menu = array();
$list = $this->model->list($this->param);
if(!empty($list)){
foreach ($list as $k => $v){
if($v['pid'] == 0){
$v['sub'] = _get_child($v['id'],$list);
$menu[] = $v;
}
}
}
return $this->success($menu);
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
}
/**
* @remark :获取详情
* @name :getInfo
* @author :lyh
... ... @@ -51,8 +99,6 @@ class CategoryLogic extends BaseLogic
$info = $this->model->read(['id'=>$id]);
$info['url'] = $info['route'];
$info['image_link'] = getImageUrl($info['image']);
//获取当前分类子集
$info['sub'] = $this->model->read(['pid'=>$info['id']]);
return $this->success($info);
}
... ... @@ -67,13 +113,15 @@ class CategoryLogic extends BaseLogic
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->handleEditParam($this->param);
//是否编辑路由
$id = $this->editCategoryRoute($this->param['id'],$this->param['route']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
//处理子集
$this->addProcessingSon($id);
}
//路由映射
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
... ... @@ -92,6 +140,79 @@ class CategoryLogic extends BaseLogic
}
/**
* @param $cate_id
* @name :(处理子集)addProcessingSon
* @author :lyh
* @method :post
* @time :2023/6/13 11:59
*/
public function addProcessingSon($cate_id){
if(!isset($this->param['pid'])){
$this->param['pid'] = 0;
}
//判断为子分类时
if($this->param['pid'] != 0){
//查看当前上级分类下是否有其他子分类
$cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);
if ($cate_info === false) {
//查看当前上一级分类下是否有新闻
$productModel = new Product();
$blog_count = $productModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
if ($blog_count > 0) {
$replacement = ',' . $cate_id . ',';
$old = ',' . $this->param['pid'] . ',';
//更新所有商品到当前分类
$productModel->where('category_id', 'like', '%' . $old . '%')
->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
}
}
}
return $this->success();
}
/**
* @remark :编辑分类,处理博客数据
* @name :editCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:32
*/
public function editHandleCategory($id,$pid){
$info = $this->model->read(['id'=>$id],['id','pid']);
if($info['pid'] != $pid){
//修改勒上级,先查看上级是否拥有博客
$productModel = new Product();
$blogCount = $productModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
if($blogCount > 0){
//随机获取最后一级id
$replacement = $this->getLastId($id);
//存在博客时,移动所有博客到当前分类最后一级
$productModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
$productModel->where('category_id', 'like', '%,' . $pid . ',%')
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
}
}
return $this->success();
}
/**
* @remark :随机获取当前id下最后一级的id
* @name :getLastId
* @author :lyh
* @method :post
* @time :2023/10/20 9:45
*/
public function getLastId($id){
$info = $this->model->read(['pid'=>$id],['id']);
if($info !== false){
return $this->getLastId($info['id']);
}else{
return $id;
}
}
/**
* @remark :编辑路由时生成路由记录
* @name :editCategoryRoute
* @author :lyh
... ... @@ -112,31 +233,6 @@ class CategoryLogic extends BaseLogic
}
/**
* @remark :验证编辑时是否可修改pid
* @name :handleEditParam
* @author :lyh
* @method :post
* @time :2023/8/21 17:43
*/
public function handleEditParam(&$param){
if($param['pid'] == $param['id']){
$this->fail('上级分类不能是本分类');
}
// $info = $this->model->read(['id'=>$param['id']]);
// $sub_info = $this->model->read(['pid'=>$param['id']]);
// if(($info['pid'] != $param['pid']) && ($sub_info != false)){
// $this->fail('当前分类拥有子分类,不允许修改上级分类');
// }
// $productModel = new Product();
// $product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]);
// if(($product_info !== false) && ($info['pid'] != $param['pid'])){
// $this->fail('当前产品分类拥有产品不允许编辑上级分类');
// }
return $this->success();
}
/**
* @remark :删除
* @name :delete
* @author :lyh
... ... @@ -145,10 +241,12 @@ class CategoryLogic extends BaseLogic
*/
public function categoryDelete(){
$ids = $this->param['ids'];
DB::beginTransaction();
try {
$productModel = new Product();
foreach ($ids as $id){
$info = $this->model->read(['pid'=>$id],['id']);
if($info !== false){
$this->fail('分类id:'.$id.'拥有子集不允许删除');
}
$productModel = new Product();
$product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);
if($product_info !== false){
$this->fail('当前分类拥有产品不允许删除');
... ... @@ -159,11 +257,6 @@ class CategoryLogic extends BaseLogic
}
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('删除失败');
}
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,26 @@ 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']);
}
if(isset($param['keyword_video']) && !empty($param['keyword_video'])){
$param['keyword_video'] = Arr::a2s($param['keyword_video']);
}
return $param;
}
/**
* @remark :批量添加数据
* @name :batchAdd
* @author :lyh
... ... @@ -91,7 +112,8 @@ class KeywordLogic extends BaseLogic
$param['updated_at'] = $param['created_at'];
$param['title'] = $v;
$id = $this->model->insertGetId($param);
RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
}
}
return $this->success();
... ...
... ... @@ -3,8 +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;
... ... @@ -34,10 +37,11 @@ class ProductLogic extends BaseLogic
* @time :2023/8/21 18:35
*/
public function productSave(){
// $category_ids = $this->param['category_id'] ?? [];
//参数处理
$this->param = $this->handleSaveParam($this->param);
DB::beginTransaction();
try {
// DB::connection('custom_mysql')->beginTransaction();
// try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//查看路由是否更新
$id = $this->editProductRoute($this->param['id'],$this->param['route']);
... ... @@ -51,17 +55,68 @@ class ProductLogic extends BaseLogic
//路由映射
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误请联系管理员');
}
//产品分类关联
// CategoryRelated::saveRelated($id, $category_ids);
// DB::connection('custom_mysql')->commit();
// }catch (\Exception $e){
// DB::connection('custom_mysql')->rollBack();
// $this->fail('系统错误请联系管理员');
// }
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]);
return $this->success();
}
/**
* @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
... ... @@ -80,8 +135,8 @@ 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'] = ','.Arr::arrToSet($param['category_id']).',';
if(isset($param['category_id']) && !empty($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']).',';
... ... @@ -101,6 +156,27 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
if(isset($category) && !empty($category)){
$cateModel = new Category();
foreach ($category as $v){
$info = $cateModel->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
}
return ','.$str;
}
/**
* @remark :编辑产品
* @name :editProduct
* @author :lyh
... ... @@ -128,7 +204,7 @@ class ProductLogic extends BaseLogic
* @time :2023/8/21 17:11
*/
public function productDelete(){
DB::beginTransaction();
DB::connection('custom_mysql')->beginTransaction();
try {
foreach ($this->param['ids'] as $id) {
$info = $this->model->read(['id'=>$id],['id','status']);
... ... @@ -142,9 +218,9 @@ class ProductLogic extends BaseLogic
$this->model->edit(['status'=>Product::STATUS_RECYCLE],['id'=>$id]);
}
}
DB::commit();
DB::connection('custom_mysql')->commit();
}catch (\Exception $e){
DB::rollBack();
DB::connection('custom_mysql')->rollBack();
$this->fail('删除失败');
}
return $this->success();
... ... @@ -334,7 +410,7 @@ class ProductLogic extends BaseLogic
* @time :2023/8/15 17:53
*/
public function batchSetCategory(){
DB::beginTransaction();
DB::connection('custom_mysql')->beginTransaction();
try {
//批量
$param = [
... ... @@ -342,10 +418,14 @@ class ProductLogic extends BaseLogic
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
DB::commit();
//分类关联
foreach ($this->param['id'] as $id){
CategoryRelated::saveRelated($id, $this->param['category_id']);
}
DB::connection('custom_mysql')->commit();
//对应添加关联表
}catch (\Exception $e){
DB::rollBack();
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
return $this->success();
... ...
... ... @@ -461,7 +461,7 @@ class RankDataLogic extends BaseLogic
//保证关键词数
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
$type = Project::where('id', $project_id)->value('type');
if($keyword_num && $type == 2 && $first_page_num >= $keyword_num){
if($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num){
$model->compliance_day = $model->compliance_day + 1;
$model->is_compliance = 1;
... ...
... ... @@ -35,6 +35,10 @@ class ProjectCountryLogic extends BaseLogic
* @time :2023/4/28 17:42
*/
public function country_save(){
//处理数据
if(!isset($this->param['country_lists']) || empty($this->param['country_lists'])){
$this->param['country_lists'] = '';
}
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
... ... @@ -45,7 +49,6 @@ class ProjectCountryLogic extends BaseLogic
if($rs === false){
$this->fail('当前数据不存在');
}
//TODO::配置多语言翻译api接口
return $this->success();
}
}
... ...
... ... @@ -14,7 +14,6 @@ class WebSettingLogic extends BaseLogic
public function __construct()
{
parent::__construct();
$this->model = new WebSetting();
$this->param = $this->requestAll;
}
... ... @@ -26,14 +25,10 @@ class WebSettingLogic extends BaseLogic
* @time :2023/4/28 15:14
*/
public function setting_read(){
$info = CommonHelper::get_user_cache($this->model->getTable(),$this->user['project_id']);
if(empty($info)){
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$info = [];
}
CommonHelper::set_user_cache($info,$this->model->getTable(),$this->user['project_id']);
}
return $this->success($info);
}
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSettingReceiving;
use App\Models\WebSetting\WebSettingText;
use App\Services\SyncService;
class WebSettingReceivingLogic extends BaseLogic
{
... ... @@ -45,6 +46,7 @@ class WebSettingReceivingLogic extends BaseLogic
}catch (\Exception $e){
$this->fail('error');
}
app(SyncService::class)->projectAcceptAddress($this->user['project_id']);
return $this->success();
}
}
... ...
... ... @@ -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;
... ...
... ... @@ -115,14 +115,12 @@ class UserLoginLogic
$this->fail('该项目未找到注册账号');
}
$info = $this->autoAssembleParam($has_user);
if(!Cache::get($info['token'])){
//生成新token
$token = md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
$info['manager_id'] = $data['manager_id'];//代表自动登录写入日志
Cache::add($token,$info,3600 * 12);
}
Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip(),
'project_id'=>$info['project_id'], 'type'=>1 ,'remark' => '自动登录,操作管理员为:'.$data['manager_id']]);
return $info;
... ... @@ -168,6 +166,7 @@ class UserLoginLogic
$info['is_customized'] = $project['is_customized'];
$info['is_upload_manage'] = $project['is_upload_manage'];
$info['upload_config'] = $project['upload_config'];
$info['configuration'] = $project['deploy_build']['configuration'];
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
return $this->success($info);
... ... @@ -196,6 +195,7 @@ class UserLoginLogic
$info['is_customized'] = $project['is_customized'];
$info['is_upload_manage'] = $project['is_upload_manage'];
$info['upload_config'] = $project['upload_config'];
$info['configuration'] = $project['deploy_build']['configuration'];
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
return $this->success($info);
... ... @@ -213,10 +213,18 @@ class UserLoginLogic
public function getProjectInfo($id){
$projectModel = new Project();
$info = $projectModel->with('payment')->with('deploy_build')
->with('deploy_optimize')->with('online_check')->where(['id'=>$id])->first();
->with('deploy_optimize')->with('online_check')->where(['id'=>$id])->first()->toArray();
if($info['extend_type'] != 0){
$info['type'] = $info['extend_type'];
}
if($info['deploy_build']['configuration'] == null){
$info['deploy_build']['configuration'] = ["is_SEO" => "0", "is_head"=> "0", "is_home"=> "0", "build_status"=> "0"];
}else{
if(!isset($info['deploy_build']['configuration']['is_SEO'])){$info['deploy_build']['configuration']['is_SEO'] = "0";}
if(!isset($info['deploy_build']['configuration']['is_head'])){$info['deploy_build']['configuration']['is_head'] = "0";}
if(!isset($info['deploy_build']['configuration']['is_home'])){$info['deploy_build']['configuration']['is_home'] = "0";}
if(!isset($info['deploy_build']['configuration']['build_status'])){$info['deploy_build']['configuration']['build_status'] = "0";}
}
return $this->success($info);
}
... ...
... ... @@ -35,6 +35,7 @@ class NavRequest extends FormRequest
// 'group_id' => ['required','integer'],
'pid' => ['required','integer'],
'name' => ['required','max:100'],
'url' => ['required'],
];
return $rule;
}
... ... @@ -49,6 +50,7 @@ class NavRequest extends FormRequest
'pid.integer' => '上级选择错误',
'name.required' => '名称必须',
'name.max' => '名称不能超过100个字符',
'url.required' => '链接不能为空',
];
}
}
... ...
... ... @@ -24,7 +24,7 @@ class NewsRequest extends FormRequest
public function rules()
{
return [
'name'=>'required|max:100',
'name'=>'required|max:200',
'url'=>'required',
];
}
... ... @@ -33,7 +33,7 @@ class NewsRequest extends FormRequest
{
return [
'name.required'=>'请填写名称',
'name.max'=>'名称最大100字',
'name.max'=>'名称最大200字',
'url.required'=>'新闻链接不能为空'
];
}
... ...
... ... @@ -30,7 +30,7 @@ class CategoryRequest extends FormRequest
public function rules()
{
return [
'title'=>'required|max:50',
'title'=>'required|max:200',
'route'=>'required',
// 'image'=>'required',
// 'keywords'=>'max:50',
... ... @@ -42,7 +42,7 @@ class CategoryRequest extends FormRequest
{
return [
'title.required' => '请输入分类名称',
'title.max' => '分类名称不能超过50个字符',
'title.max' => '分类名称不能超过200个字符',
'route.required' => '路由不能为空',
// 'image.required' => '请上传分类图片',
// 'keywords.max' => '分类关键词不能超过50个字符',
... ...
... ... @@ -23,6 +23,8 @@ class FileManage extends Base
public $appends = ['url'];
public function getUrlAttribute($value){
return getImageUrl($this->path);
$cosCdn = 'https://file.globalso.com';
$value = $cosCdn.$this->path;
return $value;
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Models\Product;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
... ... @@ -21,4 +22,35 @@ class Category extends Base
const STATUS_ACTIVE = 1;
/**
* 获取指定分类的所有子分类IDS(包括自己)
* @param $id
* @return array
* @author zbj
* @date 2023/10/17
*/
public static function getChildIdsArr($id)
{
if(!$id){
return [];
}
$list = self::where('status', self::STATUS_ACTIVE)->select(['id','pid'])->get()->toArray();
$ids = [];
Arr::findChildIds($list, $id, $ids);
$ids[] = $id; //包含自己
return $ids;
}
/**
* 关联产品数量
* @param $cate_id
* @return mixed
* @author zbj
* @date 2023/4/28
*/
public static function getProductNum($cate_id){
$cate_ids = self::getChildIdsArr($cate_id);
$product_ids = CategoryRelated::whereIn('cate_id', $cate_ids)->groupBy('product_id')->select(['product_id'])->get();
return count($product_ids);
}
}
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Models\Product;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
... ... @@ -19,4 +20,40 @@ 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);
}
/**
* @remark :视频
* @name :getKeywordVideoAttribute
* @author :lyh
* @method :post
* @time :2023/10/31 11:26
*/
public function getKeywordVideoAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
}
return $value;
}
}
... ...
... ... @@ -40,6 +40,44 @@ class Product extends Base
];
/**
* 产品列表
* @param $map
* @param $page
* @param $row
* @param string $order
* @param string[] $fields
* @param string $sort
* @return array
* @author zbj
* @date 2023/10/17
*/
public function product_lists($map, $page, $row, $order = 'id', $fields = ['*'], $sort = 'desc'): array
{
$category_id = $map['category_id'] ?? 0;
$query = $this->where(function ($query) use ($category_id) {
if ($category_id) {
$category_ids = Category::getChildIdsArr($category_id);
$query->whereIn('id', function ($subQuery) use ($category_ids) {
$subQuery->select('product_id')
->from('gl_product_category_related')
->whereIn('cate_id', $category_ids)
->groupBy('product_id');
});
}
});
unset($map['category_id']);
$query = $this->formatQuery($map, $query);
$query = $this->sortOrder($query,$order,$sort);
$lists = $query->select($fields)->paginate($row, ['*'], 'page', $page);
if (empty($lists)) {
return [];
}
$lists = $lists->toArray();
return $lists;
}
public function getThumbAttribute($value){
if(!empty($value)){
$value = json_decode($value,true);
... ...
<?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;
}
/**
* @remark :视频
* @name :getVideoUrlAttribute
* @author :lyh
* @method :post
* @time :2023/10/31 11:23
*/
public function getVideoUrlAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
}
return $value;
}
}
... ...
... ... @@ -136,6 +136,7 @@ class ProjectServer extends BaseService
<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;
... ... @@ -155,7 +156,7 @@ class ProjectServer extends BaseService
<script>
</script>
</section>
</main>', 'html_style' => '<style id="globalsojs-styles"></style>','created_at' => $created_at, 'updated_at' => $created_at];
</main>', 'html_style' => '<style id="globalsojs-styles"></style>','title' => '404-Page not found', 'description' => 'Sorry. The page has either moved or cannot be found.', 'created_at' => $created_at, 'updated_at' => $created_at];
$id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data);
//路由
$info = DB::connection('custom_mysql')->table('gl_route_map')->first();
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/10/26
* Time: 17:19
*/
namespace App\Services;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\WebSetting\WebSettingReceiving;
use Illuminate\Support\Facades\Log;
/**
* TODO 同步数据到其他平台
* Class SyncService
* @package App\Services
*/
class SyncService extends BaseService
{
/**
* 同步信息到表单系统
* TODO 已经有正式域名
* 项目已经上线 && 已经有正式域名 && 用户设置收件邮箱或者手机号码
* @param int $project_id
* @return mixed
*/
public function projectAcceptAddress($project_id = 0)
{
try {
$url = 'https://form.globalso.com/api/globalsov6';
// 项目信息
$project = Project::with('deploy_build')->with('deploy_optimize')->where(['id'=>$project_id])->first();
// 不满足条件 不同步到表单系统
if (empty($project->deploy_optimize->domain)) {
return false;
}
// 生产域名
$domain = (new DomainInfo())->getDomain($project->deploy_optimize->domain);
// 收件设置信息
ProjectServer::useProject($project_id);
$receive = WebSettingReceiving::where(['project_id' => $project_id])->get();
// 处理收件信息
$email = $phone = [];
foreach ($receive as $value) {
if ($value->type == 1)
array_push($email, $value->values);
if ($value->type == 2)
array_push($phone, $value->values);
}
// 请求参数
$data = [
'id' => $project_id,
'company_name' => $project->company,
'plan' => Project::planMap()[$project->deploy_build->plan],
'emails' => implode(',', $email),
'phones' => implode(',', $phone),
'main_url' => $domain,
'test_url' => $project->deploy_build->test_domain,
'token' => md5($project_id . 'qqs' . date('Y-m-d'))
];
list($code, $result) = $this->curlRequest($url, $data);
Log::info('同步收件信息至表单系统: 项目ID:' . $project_id . ', data: ' . var_export($data, true) . ', result: ' . $result);
return true;
} catch (\Exception $e) {
Log::info('同步收件信息至表单系统: 项目ID:' . $project_id . ', error: ' . $e->getMessage());
return false;
}
}
/**
* @param $url
* @param $data
* @param string $method
* @param array $header
* @param int $time_out
* @return array
*/
public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if ($data)
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
'Expect:',
'Content-type: application/json',
'Accept: application/json',
], $header)
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [$code, $response];
}
}
\ No newline at end of file
... ...
... ... @@ -22,10 +22,18 @@ return [
'path_b' => '/upload/p',
'path_a' => '/upload/m',
],
//默认
'default_b_image' =>[
'size' => [
'max' => 500 * 1024, // 2M
],
'path_b' => '/upload/p',
'path_a' => '/upload/m',
],
//默认视频
'default_file' =>[
'size' => [
'max' => 1024*1024*20, // 20M
'max' => 1024*1024*50, // 50M
],
'path_b' => '/upload/p',
'path_a' => '/upload/m',
... ...
... ... @@ -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');
... ... @@ -193,6 +204,7 @@ Route::middleware(['bloginauth'])->group(function () {
//产品分类
Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category');
Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info');
Route::any('category/categoryTopList', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'categoryTopList'])->name('product_category_categoryTopList');
Route::post('category/save', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'save'])->name('product_category_save');
Route::post('category/sort', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'sort'])->name('product_category_sort');
Route::any('category/delete', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'delete'])->name('product_category_delete');
... ... @@ -290,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 () {
//获取所有左侧模版
... ...