Merge remote-tracking branch 'origin/master' into akun
正在显示
72 个修改的文件
包含
2546 行增加
和
746 行删除
| @@ -55,7 +55,7 @@ class RemainDay extends Command | @@ -55,7 +55,7 @@ class RemainDay extends Command | ||
| 55 | { | 55 | { |
| 56 | $list = Project::whereIn('type', [2,3,4])->get(); | 56 | $list = Project::whereIn('type', [2,3,4])->get(); |
| 57 | foreach ($list as $item){ | 57 | foreach ($list as $item){ |
| 58 | - if($item['type'] == 3){ | 58 | + if($item['type'] == Project::TYPE_TWO){ |
| 59 | //排名达标天数 | 59 | //排名达标天数 |
| 60 | $compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0; | 60 | $compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0; |
| 61 | $remain_day = $item['deploy_build']['service_duration'] - $compliance_day; | 61 | $remain_day = $item['deploy_build']['service_duration'] - $compliance_day; |
app/Console/Commands/Test.php
0 → 100755
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Aside\Project\DomainInfoLogic; | ||
| 6 | +use App\Models\Com\UpdateNotify; | ||
| 7 | +use App\Models\Devops\DevopsTask as DevopsTaskModel; | ||
| 8 | +use App\Models\Devops\DevopsTaskLog; | ||
| 9 | +use App\Models\Domain\DomainInfo; | ||
| 10 | +use App\Models\File\File; | ||
| 11 | +use App\Models\File\Image; | ||
| 12 | +use App\Models\Product\CategoryRelated; | ||
| 13 | +use App\Models\Product\Product; | ||
| 14 | +use App\Models\Project\Project; | ||
| 15 | +use App\Models\RouteMap\RouteMap; | ||
| 16 | +use App\Models\Template\BCustomTemplate; | ||
| 17 | +use App\Services\ProjectServer; | ||
| 18 | +use Illuminate\Console\Command; | ||
| 19 | +use Illuminate\Database\QueryException; | ||
| 20 | +use Illuminate\Support\Facades\DB; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * 测试 | ||
| 24 | + * Class Traffic | ||
| 25 | + * @package App\Console\Commands | ||
| 26 | + * @author zbj | ||
| 27 | + * @date 2023/5/18 | ||
| 28 | + */ | ||
| 29 | +class Test extends Command | ||
| 30 | +{ | ||
| 31 | + /** | ||
| 32 | + * The name and signature of the console command. | ||
| 33 | + * | ||
| 34 | + * @var string | ||
| 35 | + */ | ||
| 36 | + protected $signature = 'test'; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * The console command description. | ||
| 40 | + * | ||
| 41 | + * @var string | ||
| 42 | + */ | ||
| 43 | + protected $description = '测试'; | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * Create a new command instance. | ||
| 47 | + * | ||
| 48 | + * @return void | ||
| 49 | + */ | ||
| 50 | + public function __construct() | ||
| 51 | + { | ||
| 52 | + parent::__construct(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * @return bool | ||
| 57 | + */ | ||
| 58 | + public function handle() | ||
| 59 | + { | ||
| 60 | + $projects = Project::all(); | ||
| 61 | + foreach ($projects as $project){ | ||
| 62 | + echo "project " . $project->id; | ||
| 63 | + | ||
| 64 | + if(!ProjectServer::useProject($project->id)){ | ||
| 65 | + echo '-->' . '未配置数据库' . PHP_EOL; | ||
| 66 | + continue; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + try { | ||
| 70 | + $page = BCustomTemplate::where('url', '404')->first(); | ||
| 71 | + if(!$page){ | ||
| 72 | + $page = new BCustomTemplate(); | ||
| 73 | + } | ||
| 74 | + $page->project_id = $project->id; | ||
| 75 | + $page->name = '404'; | ||
| 76 | + $page->status = 1; | ||
| 77 | + $page->url = '404'; | ||
| 78 | + $page->html = '<main> | ||
| 79 | + <section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404" | ||
| 80 | + id="sectionIdyxqu938"> | ||
| 81 | + <div class="layout" data-unable="demo01-error404"> | ||
| 82 | + <img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" /> | ||
| 83 | + </div> | ||
| 84 | + <p style="text-align: center">SORRY. THE PAGE HAS EITHER MOVED OR CANNOT BE FOUND.</p> | ||
| 85 | + <style> | ||
| 86 | + .section-block-error404 .layout { | ||
| 87 | + height: 700px; | ||
| 88 | + display: flex; | ||
| 89 | + align-items: center; | ||
| 90 | + justify-content: center; | ||
| 91 | + } | ||
| 92 | + .section-block-error404 img { | ||
| 93 | + width: 400px; | ||
| 94 | + } | ||
| 95 | + @media only screen and (max-width:500) { | ||
| 96 | + .section-block-error404 img { | ||
| 97 | + max-width: 100%; | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + </style> | ||
| 101 | + <script> | ||
| 102 | + </script> | ||
| 103 | + </section> | ||
| 104 | + </main>'; | ||
| 105 | + $page->html_style = '<style id="globalsojs-styles"></style>'; | ||
| 106 | + $page->description = 'Sorry. The page has either moved or cannot be found.'; | ||
| 107 | + $page->title = '404-Page not found'; | ||
| 108 | + $page->save(); | ||
| 109 | + | ||
| 110 | + $domain = (new DomainInfo())->getDomain($project['deploy_optimize']['domain']); | ||
| 111 | + $url = $domain.'api/delHtml/?project_id='.$project->id.'&route=404'; | ||
| 112 | + curlGet($url); | ||
| 113 | + }catch (QueryException | \Exception $e){ | ||
| 114 | + echo '-->' . $e->getMessage() . PHP_EOL; | ||
| 115 | + continue; | ||
| 116 | + } | ||
| 117 | + echo '-->成功:' . PHP_EOL; | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | +} |
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | */ | 7 | */ |
| 8 | namespace App\Console\Commands\Test; | 8 | namespace App\Console\Commands\Test; |
| 9 | 9 | ||
| 10 | +use App\Helper\Common; | ||
| 10 | use App\Models\Blog\Blog; | 11 | use App\Models\Blog\Blog; |
| 11 | use App\Models\Devops\ServerConfig; | 12 | use App\Models\Devops\ServerConfig; |
| 12 | use App\Models\File\Image; | 13 | use App\Models\File\Image; |
| @@ -15,6 +16,7 @@ use App\Models\Manage\Dept; | @@ -15,6 +16,7 @@ use App\Models\Manage\Dept; | ||
| 15 | use App\Models\Manage\EntryPosition; | 16 | use App\Models\Manage\EntryPosition; |
| 16 | use App\Models\Manage\ManageHr; | 17 | use App\Models\Manage\ManageHr; |
| 17 | use App\Services\ProjectServer; | 18 | use App\Services\ProjectServer; |
| 19 | +use App\Services\SyncService; | ||
| 18 | use GuzzleHttp\Client; | 20 | use GuzzleHttp\Client; |
| 19 | use Illuminate\Console\Command; | 21 | use Illuminate\Console\Command; |
| 20 | use Illuminate\Support\Facades\DB; | 22 | use Illuminate\Support\Facades\DB; |
| @@ -75,6 +77,14 @@ class Demo extends Command | @@ -75,6 +77,14 @@ class Demo extends Command | ||
| 75 | */ | 77 | */ |
| 76 | public function handle() | 78 | public function handle() |
| 77 | { | 79 | { |
| 80 | + $result = app(SyncService::class)->projectAcceptAddress(1); | ||
| 81 | + dd($result); | ||
| 82 | + $data = [ | ||
| 83 | + 'key' => 'productkey_keyword', | ||
| 84 | + 'keywords' => 'apple watch' | ||
| 85 | + ]; | ||
| 86 | + $result = Common::send_openai_msg('v2/openai_chat', $data); | ||
| 87 | + dd(); | ||
| 78 | $string = 'demo.globalso.site/'; | 88 | $string = 'demo.globalso.site/'; |
| 79 | $domain_array = parse_url($string); | 89 | $domain_array = parse_url($string); |
| 80 | $domain = $domain_array['host'] ?? $domain_array['path']; | 90 | $domain = $domain_array['host'] ?? $domain_array['path']; |
app/Console/Commands/UpdateProgress.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :UpdateProgress.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/11/1 9:22 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands; | ||
| 11 | + | ||
| 12 | +use App\Models\Mail\Mail; | ||
| 13 | +use App\Models\User\User; | ||
| 14 | +use App\Services\ProjectServer; | ||
| 15 | +use Illuminate\Console\Command; | ||
| 16 | +use Illuminate\Support\Facades\DB; | ||
| 17 | +use Illuminate\Support\Facades\Redis; | ||
| 18 | +use App\Models\Com\UpdateProgress as UpdateProgressModel; | ||
| 19 | + | ||
| 20 | +class UpdateProgress extends Command | ||
| 21 | +{ | ||
| 22 | + /** | ||
| 23 | + * The name and signature of the console command. | ||
| 24 | + * | ||
| 25 | + * @var string | ||
| 26 | + */ | ||
| 27 | + protected $signature = 'update_progress'; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * The console command description. | ||
| 31 | + * | ||
| 32 | + * @var string | ||
| 33 | + */ | ||
| 34 | + protected $description = '守护进程--更新界面'; | ||
| 35 | + /** | ||
| 36 | + * @name :(定时执行)handle | ||
| 37 | + * @author :lyh | ||
| 38 | + * @method :post | ||
| 39 | + * @time :2023/5/12 14:48 | ||
| 40 | + */ | ||
| 41 | + public function handle() | ||
| 42 | + { | ||
| 43 | + while (true){ | ||
| 44 | + $project_id = Redis::rpop('updateProgress'); | ||
| 45 | + if(!$project_id){ | ||
| 46 | + sleep(2); | ||
| 47 | + continue; | ||
| 48 | + } | ||
| 49 | + echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL; | ||
| 50 | + try { | ||
| 51 | + ProjectServer::useProject($project_id); | ||
| 52 | + $this->getUpdateProgress($project_id); | ||
| 53 | + DB::disconnect('custom_mysql'); | ||
| 54 | + }catch (\Exception $e){ | ||
| 55 | + echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL; | ||
| 56 | + } | ||
| 57 | + echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * @remark :查看是否有为更新的记录 | ||
| 63 | + * @name :updateProgress | ||
| 64 | + * @author :lyh | ||
| 65 | + * @method :post | ||
| 66 | + * @time :2023/11/1 10:47 | ||
| 67 | + */ | ||
| 68 | + public function getUpdateProgress($project_id){ | ||
| 69 | + $info = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->first(); | ||
| 70 | + if(!empty($info)){ | ||
| 71 | + $time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60); | ||
| 72 | + if($time > date("Y-m-d H:i:s")){ | ||
| 73 | + DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]); | ||
| 74 | + //获取当前项目的用户 | ||
| 75 | + $user = new User(); | ||
| 76 | + $info = $user->read(['project_id'=>$project_id,'role'=>0]); | ||
| 77 | + //发送站内信,请重新更新 | ||
| 78 | + $data["title"] = "页面更新通知"; | ||
| 79 | + $data["user_list"] = $info['id']; | ||
| 80 | + $data["content"] = "部分页面更新超时,请重新更新,或联系管理员"; | ||
| 81 | + $mail = new Mail(); | ||
| 82 | + $mail->add($data); | ||
| 83 | + }else{ | ||
| 84 | + Redis::lpush('updateProgress', $project_id); | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + return true; | ||
| 88 | + } | ||
| 89 | +} |
app/Console/Commands/UpdateSeoTdk.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands; | ||
| 4 | + | ||
| 5 | +use App\Helper\Common; | ||
| 6 | +use App\Models\Ai\AiCommand; | ||
| 7 | +use App\Models\Project\DeployOptimize; | ||
| 8 | +use App\Services\ProjectServer; | ||
| 9 | +use Illuminate\Console\Command; | ||
| 10 | +use Illuminate\Support\Facades\DB; | ||
| 11 | +use Illuminate\Support\Facades\Redis; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 初始化项目 | ||
| 15 | + * Class InitProject | ||
| 16 | + * @package App\Console\Commands | ||
| 17 | + * @author zbj | ||
| 18 | + * @date 2023/10/8 | ||
| 19 | + */ | ||
| 20 | +class UpdateSeoTdk extends Command | ||
| 21 | +{ | ||
| 22 | + /** | ||
| 23 | + * The name and signature of the console command. | ||
| 24 | + * | ||
| 25 | + * @var string | ||
| 26 | + */ | ||
| 27 | + protected $signature = 'update_seo_tdk'; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * The console command description. | ||
| 31 | + * | ||
| 32 | + * @var string | ||
| 33 | + */ | ||
| 34 | + protected $description = '一键生成sdk'; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Create a new command instance. | ||
| 38 | + * | ||
| 39 | + * @return void | ||
| 40 | + */ | ||
| 41 | + public function __construct() | ||
| 42 | + { | ||
| 43 | + parent::__construct(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * @return bool | ||
| 48 | + */ | ||
| 49 | + public function handle() | ||
| 50 | + { | ||
| 51 | + while (true){ | ||
| 52 | + $project_id = Redis::rpop('updateSeoTdk'); | ||
| 53 | + if(!$project_id){ | ||
| 54 | + sleep(2); | ||
| 55 | + continue; | ||
| 56 | + } | ||
| 57 | + echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL; | ||
| 58 | + try { | ||
| 59 | + ProjectServer::useProject($project_id); | ||
| 60 | + $this->updateProduct($project_id); | ||
| 61 | + $this->updateProductCate($project_id); | ||
| 62 | + $this->updateBlogs($project_id); | ||
| 63 | + $this->updateBlogCate($project_id); | ||
| 64 | + $this->updateNews($project_id); | ||
| 65 | + $this->updateNewsCate($project_id); | ||
| 66 | + $this->updatePage($project_id); | ||
| 67 | + DB::disconnect('custom_mysql'); | ||
| 68 | + }catch (\Exception $e){ | ||
| 69 | + echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL; | ||
| 70 | + } | ||
| 71 | + echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL; | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + /** | ||
| 75 | + * @remark :更新产品tdk | ||
| 76 | + * @name :updateProduct | ||
| 77 | + * @author :lyh | ||
| 78 | + * @method :post | ||
| 79 | + * @time :2023/8/19 9:25 | ||
| 80 | + */ | ||
| 81 | + public function updateProduct($project_id){ | ||
| 82 | + echo date('Y-m-d H:i:s') . '更新产品--updateProduct: 项目id' . $project_id . PHP_EOL; | ||
| 83 | + $list = DB::connection('custom_mysql')->table('gl_product')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray(); | ||
| 84 | + if(!empty($list)){ | ||
| 85 | + foreach ($list as $v){ | ||
| 86 | + $v = (array)$v; | ||
| 87 | + echo date('Y-m-d H:i:s') . ' updateProduct: ' . $v['id'] . PHP_EOL; | ||
| 88 | + $seo_arr = json_decode($v['seo_mate'], true) ?: []; | ||
| 89 | + //更新seo_title | ||
| 90 | + if(!isset($seo_arr['title']) || empty($seo_arr['title'])){ | ||
| 91 | + //查看是否有指令 | ||
| 92 | + $aiCommandModel = new AiCommand(); | ||
| 93 | + $AiInfo = $aiCommandModel->read(['key'=>'product_seo_title'],['ai']); | ||
| 94 | + if(!empty($AiInfo['ai'])){ | ||
| 95 | + $seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']); | ||
| 96 | + }else { | ||
| 97 | + $seo_arr['title'] = $v['title']; | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + //更新seo_keyword | ||
| 101 | + if(!isset($seo_arr['keyword']) || empty($seo_arr['keyword'])){ | ||
| 102 | + $seo_arr['keyword'] = $this->ai_send('seo_keywords',$v['title']); | ||
| 103 | + } | ||
| 104 | + //更新seo_keyword | ||
| 105 | + if(!isset($seo_arr['description']) || empty($seo_arr['description'])){ | ||
| 106 | + $seo_arr['description'] = $this->ai_send('seo_meta_description',$v['title']); | ||
| 107 | + } | ||
| 108 | + $ser_str = json_encode($seo_arr,true); | ||
| 109 | + DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + } | ||
| 113 | + return true; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * @remark :更新产品tdk | ||
| 118 | + * @name :updateProduct | ||
| 119 | + * @author :lyh | ||
| 120 | + * @method :post | ||
| 121 | + * @time :2023/8/19 9:25 | ||
| 122 | + */ | ||
| 123 | + public function updateProductCate($project_id){ | ||
| 124 | + echo date('Y-m-d H:i:s') . '更新产品分类--updateProductCate: 项目id' . $project_id . PHP_EOL; | ||
| 125 | + $list = DB::connection('custom_mysql')->table('gl_product_category')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray(); | ||
| 126 | + if(!empty($list)){ | ||
| 127 | + foreach ($list as $v){ | ||
| 128 | + $v = (array)$v; | ||
| 129 | + echo date('Y-m-d H:i:s') . ' updateProductCate: ' . $v['id'] . PHP_EOL; | ||
| 130 | + $data = []; | ||
| 131 | + if(empty($v['seo_title'])){ | ||
| 132 | + $aiCommandModel = new AiCommand(); | ||
| 133 | + $AiInfo = $aiCommandModel->read(['key'=>'product_cate_seo_title'],['ai']); | ||
| 134 | + if(!empty($AiInfo['ai'])){ | ||
| 135 | + $data['seo_title'] = $this->ai_send('product_cate_seo_title',$v['title']); | ||
| 136 | + }else{ | ||
| 137 | + $data['seo_title'] = $v['title']; | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + if(empty($v['seo_keywords'])){ | ||
| 141 | + $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['title']); | ||
| 142 | + } | ||
| 143 | + if(empty($v['seo_des'])){ | ||
| 144 | + $name = $this->companyName($project_id); | ||
| 145 | + if(!empty($name)){ | ||
| 146 | + $data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name); | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + if(!$data){ | ||
| 150 | + continue; | ||
| 151 | + } | ||
| 152 | + DB::connection('custom_mysql')->table('gl_product_category')->where(['id'=>$v['id']])->update($data); | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + return true; | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + /** | ||
| 159 | + * @remark :更新新闻Tdk | ||
| 160 | + * @name :updateNews | ||
| 161 | + * @author :lyh | ||
| 162 | + * @method :post | ||
| 163 | + * @time :2023/8/19 10:06 | ||
| 164 | + */ | ||
| 165 | + public function updateNews($project_id){ | ||
| 166 | + echo date('Y-m-d H:i:s') . '更新新闻--updateNews: 项目id' . $project_id . PHP_EOL; | ||
| 167 | + $list = DB::connection('custom_mysql')->table('gl_news')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray(); | ||
| 168 | + if(!empty($list)){ | ||
| 169 | + foreach ($list as $k => $v){ | ||
| 170 | + $v = (array)$v; | ||
| 171 | + echo date('Y-m-d H:i:s') . ' updateNews: ' . $v['id'] . PHP_EOL; | ||
| 172 | + $data = []; | ||
| 173 | + if(empty($v['seo_title'])){ | ||
| 174 | + $aiCommandModel = new AiCommand(); | ||
| 175 | + $AiInfo = $aiCommandModel->read(['key'=>'news_seo_title'],['ai']); | ||
| 176 | + if(!empty($AiInfo['ai'])){ | ||
| 177 | + $data['seo_title'] = $this->ai_send('news_seo_title',$v['name']); | ||
| 178 | + }else{ | ||
| 179 | + $data['seo_title'] = $v['name']; | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + if(empty($v['seo_keywords'])){ | ||
| 183 | + $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']); | ||
| 184 | + } | ||
| 185 | + if(empty($v['seo_description'])){ | ||
| 186 | + $data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']); | ||
| 187 | + } | ||
| 188 | + if(!$data){ | ||
| 189 | + continue; | ||
| 190 | + } | ||
| 191 | + DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data); | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + return true; | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + /** | ||
| 198 | + * @remark :更新新闻Tdk | ||
| 199 | + * @name :updateNews | ||
| 200 | + * @author :lyh | ||
| 201 | + * @method :post | ||
| 202 | + * @time :2023/8/19 10:06 | ||
| 203 | + */ | ||
| 204 | + public function updateNewsCate($project_id){ | ||
| 205 | + echo date('Y-m-d H:i:s') . '更新新闻分类--updateNewsCate: 项目id' . $project_id . PHP_EOL; | ||
| 206 | + $list = DB::connection('custom_mysql')->table('gl_news_category')->where(['status'=>0,'project_id'=>$project_id])->get()->toArray(); | ||
| 207 | + if(!empty($list)){ | ||
| 208 | + foreach ($list as $k => $v){ | ||
| 209 | + $v = (array)$v; | ||
| 210 | + echo date('Y-m-d H:i:s') . ' updateNewsCate: ' . $v['id'] . PHP_EOL; | ||
| 211 | + $data = []; | ||
| 212 | + if(empty($v['seo_title'])){ | ||
| 213 | + $aiCommandModel = new AiCommand(); | ||
| 214 | + $AiInfo = $aiCommandModel->read(['key'=>'news_cate_seo_title'],['ai']); | ||
| 215 | + if(!empty($AiInfo['ai'])){ | ||
| 216 | + $data['seo_title'] = $this->ai_send('news_cate_seo_title',$v['name']); | ||
| 217 | + }else{ | ||
| 218 | + $data['seo_title'] = $v['name']; | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + if(empty($v['seo_keywords'])){ | ||
| 222 | + //获取核心关键词 | ||
| 223 | + $main_keyword = $this->mainKeywords($project_id); | ||
| 224 | + if(!empty($main_keyword)){ | ||
| 225 | + $data['seo_keywords'] = $this->ai_send('seo_keywords',$main_keyword); | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + if(empty($v['seo_des'])){ | ||
| 229 | + $name = $this->companyName($project_id); | ||
| 230 | + if(!empty($name)){ | ||
| 231 | + $data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name); | ||
| 232 | + } | ||
| 233 | + } | ||
| 234 | + if(!$data){ | ||
| 235 | + continue; | ||
| 236 | + } | ||
| 237 | + DB::connection('custom_mysql')->table('gl_news_category')->where(['id'=>$v['id']])->update($data); | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | + return true; | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + /** | ||
| 244 | + * @remark :更新blogTdk | ||
| 245 | + * @name :updateBlogs | ||
| 246 | + * @author :lyh | ||
| 247 | + * @method :post | ||
| 248 | + * @time :2023/8/19 10:07 | ||
| 249 | + */ | ||
| 250 | + public function updateBlogs($project_id){ | ||
| 251 | + echo date('Y-m-d H:i:s') . '更新博客--updateBlogs: 项目id' . $project_id . PHP_EOL; | ||
| 252 | + $list = DB::connection('custom_mysql')->table('gl_blog')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray(); | ||
| 253 | + if(!empty($list)){ | ||
| 254 | + foreach ($list as $k => $v){ | ||
| 255 | + $v = (array)$v; | ||
| 256 | + echo date('Y-m-d H:i:s') . ' updateBlogs: ' . $v['id'] . PHP_EOL; | ||
| 257 | + $data = []; | ||
| 258 | + if(empty($v['seo_title'])){ | ||
| 259 | + $aiCommandModel = new AiCommand(); | ||
| 260 | + $AiInfo = $aiCommandModel->read(['key'=>'blog_seo_title'],['ai']); | ||
| 261 | + if(!empty($AiInfo['ai'])){ | ||
| 262 | + $data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']); | ||
| 263 | + }else{ | ||
| 264 | + $data['seo_title'] = $v['name']; | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | + if(empty($v['seo_keywords'])){ | ||
| 268 | + $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']); | ||
| 269 | + } | ||
| 270 | + if(empty($v['seo_description'])){ | ||
| 271 | + $data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']); | ||
| 272 | + } | ||
| 273 | + if(!$data){ | ||
| 274 | + continue; | ||
| 275 | + } | ||
| 276 | + DB::connection('custom_mysql')->table('gl_blog')->where(['id'=>$v['id']])->update($data); | ||
| 277 | + } | ||
| 278 | + } | ||
| 279 | + return true; | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + /** | ||
| 283 | + * @remark :更新新闻Tdk | ||
| 284 | + * @name :updateNews | ||
| 285 | + * @author :lyh | ||
| 286 | + * @method :post | ||
| 287 | + * @time :2023/8/19 10:06 | ||
| 288 | + */ | ||
| 289 | + public function updateBlogCate($project_id){ | ||
| 290 | + echo date('Y-m-d H:i:s') . '更新博客分类--updateBlogCate: 项目id' . $project_id . PHP_EOL; | ||
| 291 | + $list = DB::connection('custom_mysql')->table('gl_blog_category')->where(['status'=>0,'project_id'=>$project_id])->get()->toArray(); | ||
| 292 | + if(!empty($list)){ | ||
| 293 | + foreach ($list as $k => $v){ | ||
| 294 | + $v = (array)$v; | ||
| 295 | + echo date('Y-m-d H:i:s') . ' updateBlogCate: ' . $v['id'] . PHP_EOL; | ||
| 296 | + $data = []; | ||
| 297 | + if(empty($v['seo_title'])){ | ||
| 298 | + $data['seo_title'] = $v['name']; | ||
| 299 | + } | ||
| 300 | + if(empty($v['seo_keywords'])){ | ||
| 301 | + //获取核心关键词 | ||
| 302 | + $main_keyword = $this->mainKeywords($project_id); | ||
| 303 | + if(!empty($main_keyword)){ | ||
| 304 | + $data['seo_keywords'] = $this->ai_send('seo_keywords',$main_keyword); | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + if(empty($v['seo_des'])){ | ||
| 308 | + $name = $this->companyName($project_id); | ||
| 309 | + $data['seo_des'] = $this->ai_send('page_meta_description',$v['name'],$name); | ||
| 310 | + } | ||
| 311 | + if(!$data){ | ||
| 312 | + continue; | ||
| 313 | + } | ||
| 314 | + DB::connection('custom_mysql')->table('gl_blog_category')->where(['id'=>$v['id']])->update($data); | ||
| 315 | + } | ||
| 316 | + } | ||
| 317 | + return true; | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + /** | ||
| 321 | + * @remark :单页面更新tdk | ||
| 322 | + * @name :updatePage | ||
| 323 | + * @author :lyh | ||
| 324 | + * @method :post | ||
| 325 | + * @time :2023/10/30 11:04 | ||
| 326 | + */ | ||
| 327 | + public function updatePage($project_id){ | ||
| 328 | + echo date('Y-m-d H:i:s') . '更新自定义界面--updatePage: 项目id' . $project_id . PHP_EOL; | ||
| 329 | + $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(); | ||
| 330 | + if(!empty($list)){ | ||
| 331 | + foreach ($list as $v){ | ||
| 332 | + $v = (array)$v; | ||
| 333 | + echo date('Y-m-d H:i:s') . ' updatePage: ' . $v['id'] . PHP_EOL; | ||
| 334 | + $data = []; | ||
| 335 | + if(empty($v['title'])){ | ||
| 336 | + //生成seo_title | ||
| 337 | + $data['title'] = $v['name']; | ||
| 338 | + } | ||
| 339 | + if(empty($v['keywords'])){ | ||
| 340 | + //获取核心关键词 | ||
| 341 | + $main_keyword = $this->mainKeywords($project_id); | ||
| 342 | + if(!empty($main_keyword)){ | ||
| 343 | + $data['keywords'] = $this->ai_send('seo_keywords',$main_keyword); | ||
| 344 | + } | ||
| 345 | + } | ||
| 346 | + if(empty($v['description'])){ | ||
| 347 | + $name = $this->companyName($project_id); | ||
| 348 | + if(!empty($name)){ | ||
| 349 | + $data['description'] = $this->ai_send('page_meta_description',$v['name'],$name); | ||
| 350 | + } | ||
| 351 | + } | ||
| 352 | + if(!$data){ | ||
| 353 | + continue; | ||
| 354 | + } | ||
| 355 | + DB::connection('custom_mysql')->table('gl_web_custom_template')->where(['id'=>$v['id']])->update($data); | ||
| 356 | + } | ||
| 357 | + } | ||
| 358 | + return true; | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + /** | ||
| 362 | + * @remark :获取公司英文名称 | ||
| 363 | + * @name :companyName | ||
| 364 | + * @author :lyh | ||
| 365 | + * @method :post | ||
| 366 | + * @time :2023/10/30 11:22 | ||
| 367 | + */ | ||
| 368 | + public function companyName($project_id,$key = ''){ | ||
| 369 | + $data = [ | ||
| 370 | + 'product_long_description', | ||
| 371 | + ]; | ||
| 372 | + $projectOptimizeModel = new DeployOptimize(); | ||
| 373 | + $info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','company_en_name','company_en_description']); | ||
| 374 | + if(in_array($key,$data)){ | ||
| 375 | + return $info['company_en_description']; | ||
| 376 | + }else{ | ||
| 377 | + return $info['company_en_name']; | ||
| 378 | + } | ||
| 379 | + } | ||
| 380 | + | ||
| 381 | + /** | ||
| 382 | + * @remark :获取公司核心关键词 | ||
| 383 | + * @name :mainKeywords | ||
| 384 | + * @author :lyh | ||
| 385 | + * @method :post | ||
| 386 | + * @time :2023/10/30 11:22 | ||
| 387 | + */ | ||
| 388 | + public function mainKeywords($project_id){ | ||
| 389 | + $str = ''; | ||
| 390 | + $projectOptimizeModel = new DeployOptimize(); | ||
| 391 | + $info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','main_keywords']); | ||
| 392 | + if($info !== false){ | ||
| 393 | + if(!empty($info['main_keywords'])){ | ||
| 394 | + $arr = explode(',',$info['main_keywords']); | ||
| 395 | + if(isset($arr[0])){ | ||
| 396 | + $str = $arr[0]; | ||
| 397 | + } | ||
| 398 | + } | ||
| 399 | + } | ||
| 400 | + return $str; | ||
| 401 | + } | ||
| 402 | + | ||
| 403 | + /** | ||
| 404 | + * @remark :AI发送 | ||
| 405 | + * @name :ai_send | ||
| 406 | + * @author :lyh | ||
| 407 | + * @method :post | ||
| 408 | + * @time :2023/8/19 10:40 | ||
| 409 | + */ | ||
| 410 | + public function ai_send($key,$keywords,$name = ''){ | ||
| 411 | + $chat_url = 'v2/openai_chat_qqs'; | ||
| 412 | + $param = [ | ||
| 413 | + 'key'=>$key, | ||
| 414 | + 'keywords'=>$keywords, | ||
| 415 | + ]; | ||
| 416 | + $data = Common::send_openai_msg($chat_url,$param,$name); | ||
| 417 | + $data['text'] = Common::deal_keywords($data['text']); | ||
| 418 | + $data['text'] = Common::deal_str($data['text']); | ||
| 419 | + return $data['text']; | ||
| 420 | + } | ||
| 421 | + | ||
| 422 | +} |
| @@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel | @@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel | ||
| 24 | $schedule->command('rank_data_indexed_pages')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次 | 24 | $schedule->command('rank_data_indexed_pages')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次 |
| 25 | $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 | 25 | $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 |
| 26 | $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 | 26 | $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 |
| 27 | - $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 | 27 | +// $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 |
| 28 | $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 | 28 | $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 |
| 29 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 | 29 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 |
| 30 | $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 | 30 | $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 |
| @@ -212,4 +212,21 @@ class Arr extends \Illuminate\Support\Arr | @@ -212,4 +212,21 @@ class Arr extends \Illuminate\Support\Arr | ||
| 212 | } | 212 | } |
| 213 | return $data; | 213 | return $data; |
| 214 | } | 214 | } |
| 215 | + | ||
| 216 | + /** | ||
| 217 | + * 根据列表查找指定id下的所有子id | ||
| 218 | + * @param $dataArray | ||
| 219 | + * @param $parentId | ||
| 220 | + * @param $resultArray | ||
| 221 | + * @author zbj | ||
| 222 | + * @date 2023/10/17 | ||
| 223 | + */ | ||
| 224 | + public static function findChildIds($dataArray, $parentId, &$resultArray) { | ||
| 225 | + foreach ($dataArray as $value) { | ||
| 226 | + if ($value['pid'] == $parentId) { | ||
| 227 | + $resultArray[] = $value['id']; | ||
| 228 | + self::findChildIds($dataArray, $value['id'], $resultArray); | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + } | ||
| 215 | } | 232 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Helper; | 3 | namespace App\Helper; |
| 4 | 4 | ||
| 5 | use App\Models\Ai\AiCommand as AiCommandModel; | 5 | use App\Models\Ai\AiCommand as AiCommandModel; |
| 6 | +use App\Models\Project\Project; | ||
| 6 | use App\Models\User\UserLog as UserLogModel; | 7 | use App\Models\User\UserLog as UserLogModel; |
| 7 | use App\Models\User\UserLogin as UserLoginModel; | 8 | use App\Models\User\UserLogin as UserLoginModel; |
| 8 | use Illuminate\Encryption\Encrypter; | 9 | use Illuminate\Encryption\Encrypter; |
| @@ -54,7 +55,7 @@ class Common | @@ -54,7 +55,7 @@ class Common | ||
| 54 | * @author :liyuhang | 55 | * @author :liyuhang |
| 55 | * @method | 56 | * @method |
| 56 | */ | 57 | */ |
| 57 | - public static function send_openai_msg($url,$param){ | 58 | + public static function send_openai_msg($url,$param,$name = ''){ |
| 58 | $url = HTTP_OPENAI_URL.$url; | 59 | $url = HTTP_OPENAI_URL.$url; |
| 59 | $aiCommandModel = New AiCommandModel(); | 60 | $aiCommandModel = New AiCommandModel(); |
| 60 | //指定库获取指令 | 61 | //指定库获取指令 |
| @@ -73,16 +74,19 @@ class Common | @@ -73,16 +74,19 @@ class Common | ||
| 73 | if (isset($result['texts']['sl']) && isset(Translate::$tls_list[$result['texts']['sl']])) { | 74 | if (isset($result['texts']['sl']) && isset(Translate::$tls_list[$result['texts']['sl']])) { |
| 74 | $lang = Translate::$tls_list[$result['texts']['sl']]['text']; | 75 | $lang = Translate::$tls_list[$result['texts']['sl']]['text']; |
| 75 | } else { | 76 | } else { |
| 76 | - $lang = '中文'; | 77 | + $lang = 'Chinese'; |
| 77 | } | 78 | } |
| 78 | } | 79 | } |
| 79 | - $str = ',请使用'.$lang.'回答'; | 80 | + $str = 'Please answer in '.$lang; |
| 80 | //替换关键字 | 81 | //替换关键字 |
| 81 | $content = str_replace('$keyword$', $param['keywords'], $info['ai']); | 82 | $content = str_replace('$keyword$', $param['keywords'], $info['ai']); |
| 83 | + //获取公司名称 | ||
| 84 | + //$company$变量时替换为公司名 | ||
| 85 | + $content = str_replace('$company$', $name , $content); | ||
| 82 | $data = [ | 86 | $data = [ |
| 83 | 'messages'=>[ | 87 | 'messages'=>[ |
| 84 | - ['role'=>'system','content'=>$info['scene']], | ||
| 85 | - ['role'=>'assistant','content'=>$content.$str], | 88 | +// ['role'=>'system','content'=>$info['scene']], |
| 89 | + ['role'=>'user','content'=>$content.$str], | ||
| 86 | ] | 90 | ] |
| 87 | ]; | 91 | ]; |
| 88 | return http_post($url,json_encode($data)); | 92 | return http_post($url,json_encode($data)); |
| @@ -183,4 +187,38 @@ class Common | @@ -183,4 +187,38 @@ class Common | ||
| 183 | return $crypt->decrypt($string); | 187 | return $crypt->decrypt($string); |
| 184 | } | 188 | } |
| 185 | 189 | ||
| 190 | + //处理关键词 | ||
| 191 | + public static function deal_keywords($data){ | ||
| 192 | + $str = ['1. ','2. ','3. ','4. ','5. ','6. ','7. ','8. ','1) ','2) ','3) ','4) ','5) ','6) ','7) ','7) ','8) ']; | ||
| 193 | + $ar_keywords_t = explode("\n",$data); | ||
| 194 | + $ar_keywords = []; | ||
| 195 | + foreach ($ar_keywords_t as $v){ | ||
| 196 | + if(trim($v)){ | ||
| 197 | + $keyword = trim($v); | ||
| 198 | + if(strpos($keyword,'search keyword') !== false){ | ||
| 199 | + $tmp_first = explode('1. ',$keyword); | ||
| 200 | + if(count($tmp_first) > 1){ | ||
| 201 | + $keyword = $tmp_first[1]; | ||
| 202 | + }else{ | ||
| 203 | + $tmp_first = explode('1) ',$keyword); | ||
| 204 | + if(count($tmp_first) > 1){ | ||
| 205 | + $keyword = $tmp_first[1]; | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + $keyword = str_replace($str,'',$keyword); | ||
| 210 | + $keyword = trim($keyword,'.'); | ||
| 211 | + 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 ){ | ||
| 212 | + $ar_keywords[] = $keyword; | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + return implode(',',$ar_keywords); | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + | ||
| 220 | +//过滤特殊字符 | ||
| 221 | + public static function deal_str($str){ | ||
| 222 | + return str_replace(['{','}','”','“','"'],'',$str); | ||
| 223 | + } | ||
| 186 | } | 224 | } |
| @@ -13,6 +13,7 @@ use App\Helper\Common; | @@ -13,6 +13,7 @@ use App\Helper\Common; | ||
| 13 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | use App\Services\ProjectServer; | 14 | use App\Services\ProjectServer; |
| 15 | use Illuminate\Support\Facades\DB; | 15 | use Illuminate\Support\Facades\DB; |
| 16 | +use Illuminate\Support\Facades\Redis; | ||
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| 18 | * @remark :b端网站更新相关 | 19 | * @remark :b端网站更新相关 |
| @@ -36,116 +37,7 @@ class UpdateController extends BaseController | @@ -36,116 +37,7 @@ class UpdateController extends BaseController | ||
| 36 | ],[ | 37 | ],[ |
| 37 | 'project_id.required' => 'project_id不能为空', | 38 | 'project_id.required' => 'project_id不能为空', |
| 38 | ]); | 39 | ]); |
| 39 | - ProjectServer::useProject($this->param['project_id']); | ||
| 40 | - $this->updateProduct($this->param['project_id']); | ||
| 41 | - $this->updateBlogs($this->param['project_id']); | ||
| 42 | - $this->updateNews($this->param['project_id']); | ||
| 43 | - DB::disconnect('custom_mysql'); | ||
| 44 | - $this->response('success'); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - /** | ||
| 48 | - * @remark :更新产品tdk | ||
| 49 | - * @name :updateProduct | ||
| 50 | - * @author :lyh | ||
| 51 | - * @method :post | ||
| 52 | - * @time :2023/8/19 9:25 | ||
| 53 | - */ | ||
| 54 | - public function updateProduct($project_id){ | ||
| 55 | - $list = DB::connection('custom_mysql')->table('gl_product')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray(); | ||
| 56 | - if(!empty($list)){ | ||
| 57 | - foreach ($list as $v){ | ||
| 58 | - if(!empty($v['seo_mate'])){ | ||
| 59 | - $seo_arr = $v['seo_mate']; | ||
| 60 | - //更新seo_title | ||
| 61 | - if(!isset($seo_arr['title'])){ | ||
| 62 | - //生成seo_title | ||
| 63 | - $seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']); | ||
| 64 | - } | ||
| 65 | - //更新seo_keyword | ||
| 66 | - if(!isset($seo_arr['keyword'])){ | ||
| 67 | - $seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']); | ||
| 68 | - } | ||
| 69 | - //更新seo_keyword | ||
| 70 | - if(!isset($seo_arr['description'])){ | ||
| 71 | - $seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']); | ||
| 72 | - } | ||
| 73 | - $ser_str = json_encode($seo_arr,true); | ||
| 74 | - DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]); | ||
| 75 | - } | ||
| 76 | - } | ||
| 77 | - } | ||
| 78 | - return true; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - /** | ||
| 82 | - * @remark :更新新闻Tdk | ||
| 83 | - * @name :updateNews | ||
| 84 | - * @author :lyh | ||
| 85 | - * @method :post | ||
| 86 | - * @time :2023/8/19 10:06 | ||
| 87 | - */ | ||
| 88 | - public function updateNews($project_id){ | ||
| 89 | - $list = DB::connection('custom_mysql')->table('gl_news')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray(); | ||
| 90 | - if(!empty($list)){ | ||
| 91 | - foreach ($list as $k => $v){ | ||
| 92 | - $data = []; | ||
| 93 | - if(empty($v['seo_title'])){ | ||
| 94 | - $data['seo_title'] = $this->ai_send('news_seo_title',$v['name']); | ||
| 95 | - } | ||
| 96 | - if(empty($v['seo_keywords'])){ | ||
| 97 | - $data['seo_keywords'] = $this->ai_send('news_seo_keyword',$v['name']); | ||
| 98 | - } | ||
| 99 | - if(empty($v['seo_description'])){ | ||
| 100 | - $data['seo_description'] = $this->ai_send('news_seo_description',$v['name']); | ||
| 101 | - } | ||
| 102 | - DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data); | ||
| 103 | - } | ||
| 104 | - } | ||
| 105 | - return true; | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - /** | ||
| 109 | - * @remark :更新blogTdk | ||
| 110 | - * @name :updateBlogs | ||
| 111 | - * @author :lyh | ||
| 112 | - * @method :post | ||
| 113 | - * @time :2023/8/19 10:07 | ||
| 114 | - */ | ||
| 115 | - public function updateBlogs($project_id){ | ||
| 116 | - $list = DB::connection('custom_mysql')->table('gl_blog')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray(); | ||
| 117 | - if(!empty($list)){ | ||
| 118 | - foreach ($list as $k => $v){ | ||
| 119 | - $data = []; | ||
| 120 | - if(empty($v['seo_title'])){ | ||
| 121 | - $data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']); | ||
| 122 | - } | ||
| 123 | - if(empty($v['seo_keywords'])){ | ||
| 124 | - $data['seo_keywords'] = $this->ai_send('blog_seo_keyword',$v['name']); | ||
| 125 | - } | ||
| 126 | - if(empty($v['seo_description'])){ | ||
| 127 | - $data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']); | ||
| 128 | - } | ||
| 129 | - DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update($data); | ||
| 130 | - } | ||
| 131 | - } | ||
| 132 | - return true; | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - /** | ||
| 136 | - * @remark :AI发送 | ||
| 137 | - * @name :ai_send | ||
| 138 | - * @author :lyh | ||
| 139 | - * @method :post | ||
| 140 | - * @time :2023/8/19 10:40 | ||
| 141 | - */ | ||
| 142 | - public function ai_send($key,$keywords){ | ||
| 143 | - $chat_url = 'v2/openai_chat'; | ||
| 144 | - $param = [ | ||
| 145 | - 'key'=>$key, | ||
| 146 | - 'keywords'=>$keywords, | ||
| 147 | - ]; | ||
| 148 | - $data = Common::send_openai_msg($chat_url,$param); | ||
| 149 | - return $data['text']; | 40 | + Redis::lpush('updateSeoTdk', $this->param['project_id']); |
| 41 | + $this->response('任务添加成功'); | ||
| 150 | } | 42 | } |
| 151 | } | 43 | } |
| @@ -5,7 +5,9 @@ namespace App\Http\Controllers\Aside; | @@ -5,7 +5,9 @@ namespace App\Http\Controllers\Aside; | ||
| 5 | 5 | ||
| 6 | use App\Enums\Common\Code; | 6 | use App\Enums\Common\Code; |
| 7 | use App\Http\Logic\Aside\LoginLogic; | 7 | use App\Http\Logic\Aside\LoginLogic; |
| 8 | +use App\Models\Domain\DomainInfo; | ||
| 8 | use App\Models\Manage\Manage; | 9 | use App\Models\Manage\Manage; |
| 10 | +use App\Models\Project\Project; | ||
| 9 | use App\Models\Sms\SmsLog; | 11 | use App\Models\Sms\SmsLog; |
| 10 | use App\Rules\Mobile; | 12 | use App\Rules\Mobile; |
| 11 | use Illuminate\Http\Request; | 13 | use Illuminate\Http\Request; |
| @@ -62,7 +64,7 @@ class LoginController extends BaseController | @@ -62,7 +64,7 @@ class LoginController extends BaseController | ||
| 62 | * @time :2023/8/7 9:07 | 64 | * @time :2023/8/7 9:07 |
| 63 | */ | 65 | */ |
| 64 | public function getAccessAddress(LoginLogic $logic){ | 66 | public function getAccessAddress(LoginLogic $logic){ |
| 65 | - $data = $logic->accessAddress(); | 67 | + $data = $logic->accessAddress($this->manage['id']); |
| 66 | return $this->response('success',Code::SUCCESS,$data); | 68 | return $this->response('success',Code::SUCCESS,$data); |
| 67 | } | 69 | } |
| 68 | 70 | ||
| @@ -98,5 +100,4 @@ class LoginController extends BaseController | @@ -98,5 +100,4 @@ class LoginController extends BaseController | ||
| 98 | SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN); | 100 | SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN); |
| 99 | $this->response('success'); | 101 | $this->response('success'); |
| 100 | } | 102 | } |
| 101 | - | ||
| 102 | } | 103 | } |
| @@ -144,12 +144,18 @@ class OnlineController extends BaseController | @@ -144,12 +144,18 @@ class OnlineController extends BaseController | ||
| 144 | */ | 144 | */ |
| 145 | public function setQuestion(){ | 145 | public function setQuestion(){ |
| 146 | $this->request->validate([ | 146 | $this->request->validate([ |
| 147 | - 'id'=>'required', | 147 | + 'project_id'=>'required', |
| 148 | ],[ | 148 | ],[ |
| 149 | - 'id.required' => 'ID不能为空', | 149 | + 'project_id.required' => 'project_id不能为空', |
| 150 | ]); | 150 | ]); |
| 151 | $onlineCheckModel = new OnlineCheck(); | 151 | $onlineCheckModel = new OnlineCheck(); |
| 152 | - $rs = $onlineCheckModel->edit($this->param,['id'=>$this->param['id']]); | 152 | + $info = $onlineCheckModel->read(['project_id'=>$this->param['project_id']]); |
| 153 | + if($info === false){ | ||
| 154 | + $this->param['created_manage_id'] = $this->manage['id']; | ||
| 155 | + $rs = $onlineCheckModel->add($this->param); | ||
| 156 | + }else{ | ||
| 157 | + $rs = $onlineCheckModel->edit($this->param,['project_id'=>$this->param['project_id']]); | ||
| 158 | + } | ||
| 153 | if($rs === false){ | 159 | if($rs === false){ |
| 154 | $this->response('error',Code::USER_ERROR); | 160 | $this->response('error',Code::USER_ERROR); |
| 155 | } | 161 | } |
| @@ -36,7 +36,7 @@ class OptimizeController extends BaseController | @@ -36,7 +36,7 @@ class OptimizeController extends BaseController | ||
| 36 | ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id') | 36 | ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id') |
| 37 | ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') | 37 | ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') |
| 38 | ->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id'); | 38 | ->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id'); |
| 39 | - $query = $this->searchParam($query); | 39 | + $query = $this->searchParam($query)->orderBy('gl_project_deploy_optimize.start_date','asc')->orderBy('gl_project_deploy_optimize.id','desc'); |
| 40 | $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray(); | 40 | $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray(); |
| 41 | if(!empty($lists) && !empty($lists['list'])){ | 41 | if(!empty($lists) && !empty($lists['list'])){ |
| 42 | $rankDataModel = new RankData(); | 42 | $rankDataModel = new RankData(); |
| @@ -127,6 +127,7 @@ class OptimizeController extends BaseController | @@ -127,6 +127,7 @@ class OptimizeController extends BaseController | ||
| 127 | 'gl_project_deploy_optimize.domain AS domain', | 127 | 'gl_project_deploy_optimize.domain AS domain', |
| 128 | 'gl_project_deploy_optimize.quality_mid AS quality_mid', | 128 | 'gl_project_deploy_optimize.quality_mid AS quality_mid', |
| 129 | 'gl_project_deploy_optimize.design_mid AS design_mid', | 129 | 'gl_project_deploy_optimize.design_mid AS design_mid', |
| 130 | + 'gl_project_deploy_optimize.start_date AS start_date', | ||
| 130 | ]; | 131 | ]; |
| 131 | return $select; | 132 | return $select; |
| 132 | } | 133 | } |
| @@ -161,10 +162,10 @@ class OptimizeController extends BaseController | @@ -161,10 +162,10 @@ class OptimizeController extends BaseController | ||
| 161 | if(isset($this->map['optimize_assist_mid']) && !empty($this->map['optimize_assist_mid'])){ | 162 | if(isset($this->map['optimize_assist_mid']) && !empty($this->map['optimize_assist_mid'])){ |
| 162 | $query = $query->where('gl_project_deploy_optimize.assist_mid','like','%'.$this->map['optimize_assist_mid'].'%'); | 163 | $query = $query->where('gl_project_deploy_optimize.assist_mid','like','%'.$this->map['optimize_assist_mid'].'%'); |
| 163 | } | 164 | } |
| 164 | - if(isset($this->map['user_id']) && !empty($this->map['user_id'])){ | 165 | + if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){ |
| 165 | $query->where(function ($subQuery) { | 166 | $query->where(function ($subQuery) { |
| 166 | - $subQuery->orWhere('gl_project.channel','like','%"user_id": "'.$this->map['user_id'].'"%') | ||
| 167 | - ->orWhere('gl_project.channel','like','%"user_id": '.$this->map['user_id'].'%'); | 167 | + $subQuery->orWhere('gl_project.channel','like','%"zone_id": "'.$this->map['channel_id'].'"%') |
| 168 | + ->orWhere('gl_project.channel','like','%"zone_id": '.$this->map['channel_id'].'%'); | ||
| 168 | }); | 169 | }); |
| 169 | } | 170 | } |
| 170 | if(isset($this->map['domain']) && !empty($this->map['domain'])){ | 171 | if(isset($this->map['domain']) && !empty($this->map['domain'])){ |
| @@ -199,7 +199,8 @@ class ProjectController extends BaseController | @@ -199,7 +199,8 @@ class ProjectController extends BaseController | ||
| 199 | $info = $managerHr->read(['manage_id'=>$this->manage['id']]); | 199 | $info = $managerHr->read(['manage_id'=>$this->manage['id']]); |
| 200 | //获取当前用户自己的项目 | 200 | //获取当前用户自己的项目 |
| 201 | $query->where(function ($subQuery) use ($info) { | 201 | $query->where(function ($subQuery) use ($info) { |
| 202 | - $subQuery->where('gl_project_deploy_build.leader_mid', $this->manage['id']) | 202 | + $subQuery->whereIn('gl_project.id',[1,3])//项目1+项目3默认显示 |
| 203 | + ->orWhere('gl_project_deploy_build.leader_mid', $this->manage['id']) | ||
| 203 | ->orWhere('gl_project_deploy_build.manager_mid', $this->manage['id']) | 204 | ->orWhere('gl_project_deploy_build.manager_mid', $this->manage['id']) |
| 204 | ->orWhere('gl_project_deploy_build.designer_mid', $this->manage['id']) | 205 | ->orWhere('gl_project_deploy_build.designer_mid', $this->manage['id']) |
| 205 | ->orWhere('gl_project_deploy_build.tech_mid', $this->manage['id']) | 206 | ->orWhere('gl_project_deploy_build.tech_mid', $this->manage['id']) |
| @@ -571,18 +572,36 @@ class ProjectController extends BaseController | @@ -571,18 +572,36 @@ class ProjectController extends BaseController | ||
| 571 | */ | 572 | */ |
| 572 | public function getProjectByChannel(){ | 573 | public function getProjectByChannel(){ |
| 573 | $id = $this->param['id'] ?? []; | 574 | $id = $this->param['id'] ?? []; |
| 574 | - $source_id = $this->param['channel_id']; //原系统渠道id | 575 | + $source_id = $this->param['channel_id'] ?? 0; //原系统渠道id |
| 575 | $size = $this->param['page_size'] ?? 20; | 576 | $size = $this->param['page_size'] ?? 20; |
| 576 | $type = $this->param['type'] ?? ''; | 577 | $type = $this->param['type'] ?? ''; |
| 577 | $company = $this->param['company'] ?? ''; | 578 | $company = $this->param['company'] ?? ''; |
| 579 | + | ||
| 580 | + if(!$source_id && !$id){ | ||
| 581 | + $this->response('参数异常',Code::SYSTEM_ERROR); | ||
| 582 | + } | ||
| 583 | + | ||
| 584 | + $channel_id = 0; | ||
| 585 | + if($source_id){ | ||
| 578 | $channel = Channel::where('source_id', $source_id)->first(); | 586 | $channel = Channel::where('source_id', $source_id)->first(); |
| 579 | if(!$channel){ | 587 | if(!$channel){ |
| 580 | $this->response('渠道不存在',Code::SYSTEM_ERROR); | 588 | $this->response('渠道不存在',Code::SYSTEM_ERROR); |
| 581 | } | 589 | } |
| 582 | - if ($id && FALSE == is_array($id)) | 590 | + $channel_id = $channel->id; |
| 591 | + } | ||
| 592 | + | ||
| 593 | + if ($id){ | ||
| 594 | + if(!is_array($id)){ | ||
| 583 | $id = explode(',', $id); | 595 | $id = explode(',', $id); |
| 596 | + } | ||
| 597 | + } | ||
| 584 | 598 | ||
| 585 | - $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){ | 599 | + $data = Project::with(['deploy_build', 'deploy_optimize', 'online_check']) |
| 600 | + ->where('delete_status', 0) | ||
| 601 | + ->where(function ($query) use ($channel_id, $type, $company, $id){ | ||
| 602 | + if ($channel_id) { | ||
| 603 | + $query->where('channel->channel_id', $channel_id); | ||
| 604 | + } | ||
| 586 | if ($type) { | 605 | if ($type) { |
| 587 | $query->where('type', $type); | 606 | $query->where('type', $type); |
| 588 | } | 607 | } |
| @@ -601,6 +620,7 @@ class ProjectController extends BaseController | @@ -601,6 +620,7 @@ class ProjectController extends BaseController | ||
| 601 | $domain_array = parse_url($domain_pro ? $domain_pro->domain : ''); | 620 | $domain_array = parse_url($domain_pro ? $domain_pro->domain : ''); |
| 602 | $domain = $domain_array['host'] ?? $domain_array['path']; | 621 | $domain = $domain_array['host'] ?? $domain_array['path']; |
| 603 | } | 622 | } |
| 623 | + $manage = new Manage(); | ||
| 604 | $param = [ | 624 | $param = [ |
| 605 | "id" => $item['id'], | 625 | "id" => $item['id'], |
| 606 | "title" => $item['title'], | 626 | "title" => $item['title'], |
| @@ -621,8 +641,11 @@ class ProjectController extends BaseController | @@ -621,8 +641,11 @@ class ProjectController extends BaseController | ||
| 621 | "test_domain" => $item['deploy_build']['test_domain'] ?? '', | 641 | "test_domain" => $item['deploy_build']['test_domain'] ?? '', |
| 622 | "online_time" => $item['online_check']['qa_check_time'] ?? '', | 642 | "online_time" => $item['online_check']['qa_check_time'] ?? '', |
| 623 | "cooperate_date" => $item['cooperate_date'], | 643 | "cooperate_date" => $item['cooperate_date'], |
| 644 | + "project_manager_name" => $manage->getName($item['deploy_build']['manager_mid']), //项目经理 | ||
| 645 | + "after_sales_manager_name" => $manage->getName($item['deploy_optimize']['manager_mid']), //售后服务经理 | ||
| 646 | + "leader_name" => $manage->getName($item['deploy_build']['leader_mid']), //组长 | ||
| 624 | ]; | 647 | ]; |
| 625 | - if ($item['type'] == 3) { | 648 | + if ($item['type'] == Project::TYPE_TWO) { |
| 626 | $param['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0; | 649 | $param['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0; |
| 627 | } else { | 650 | } else { |
| 628 | $param['is_compliance'] = 1; | 651 | $param['is_compliance'] = 1; |
| @@ -650,4 +673,6 @@ class ProjectController extends BaseController | @@ -650,4 +673,6 @@ class ProjectController extends BaseController | ||
| 650 | $lists = $renewLog->lists($this->map,$this->page,$this->row,$this->order); | 673 | $lists = $renewLog->lists($this->map,$this->page,$this->row,$this->order); |
| 651 | $this->response('success',Code::SUCCESS,$lists); | 674 | $this->response('success',Code::SUCCESS,$lists); |
| 652 | } | 675 | } |
| 676 | + | ||
| 677 | + | ||
| 653 | } | 678 | } |
| @@ -8,11 +8,13 @@ use App\Helper\Translate; | @@ -8,11 +8,13 @@ use App\Helper\Translate; | ||
| 8 | use App\Http\Controllers\Bside\BaseController; | 8 | use App\Http\Controllers\Bside\BaseController; |
| 9 | use App\Http\Controllers\Bside\:写入日志; | 9 | use App\Http\Controllers\Bside\:写入日志; |
| 10 | use App\Models\Ai\AiLog; | 10 | use App\Models\Ai\AiLog; |
| 11 | +use App\Models\Project\DeployOptimize; | ||
| 12 | +use App\Models\Project\Project; | ||
| 11 | 13 | ||
| 12 | class AiCommandController extends BaseController | 14 | class AiCommandController extends BaseController |
| 13 | { | 15 | { |
| 14 | //获取文本内容 | 16 | //获取文本内容 |
| 15 | - public $chat_url = 'v2/openai_chat'; | 17 | + public $chat_url = 'v2/openai_chat_qqs'; |
| 16 | /** | 18 | /** |
| 17 | * @name :ai生成 | 19 | * @name :ai生成 |
| 18 | * @author :liyuhang | 20 | * @author :liyuhang |
| @@ -27,7 +29,9 @@ class AiCommandController extends BaseController | @@ -27,7 +29,9 @@ class AiCommandController extends BaseController | ||
| 27 | 'key.required' => '场景不能为空', | 29 | 'key.required' => '场景不能为空', |
| 28 | ]); | 30 | ]); |
| 29 | #TODO 通过key获取到ai指令对象 | 31 | #TODO 通过key获取到ai指令对象 |
| 30 | - $data = Common::send_openai_msg($this->chat_url,$this->param); | 32 | + $data = Common::send_openai_msg($this->chat_url,$this->param,$this->companyName($this->param['key'],$this->user['project_id'])); |
| 33 | + $data['text'] = Common::deal_keywords($data['text']); | ||
| 34 | + $data['text'] = Common::deal_str($data['text']); | ||
| 31 | $param = [ | 35 | $param = [ |
| 32 | 'key'=>$this->param['key'], | 36 | 'key'=>$this->param['key'], |
| 33 | 'keywords'=>$this->param['keywords'], | 37 | 'keywords'=>$this->param['keywords'], |
| @@ -38,6 +42,28 @@ class AiCommandController extends BaseController | @@ -38,6 +42,28 @@ class AiCommandController extends BaseController | ||
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | /** | 44 | /** |
| 45 | + * @remark :获取公司英文名称 | ||
| 46 | + * @name :companyName | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2023/10/30 11:22 | ||
| 50 | + */ | ||
| 51 | + public function companyName($key,$project_id){ | ||
| 52 | + $data = [ | ||
| 53 | + 'news_remark', | ||
| 54 | + 'blog_remark', | ||
| 55 | + 'product_long_description' | ||
| 56 | + ]; | ||
| 57 | + $projectOptimizeModel = new DeployOptimize(); | ||
| 58 | + $info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','company_en_name','company_en_description']); | ||
| 59 | + if(in_array($key,$data)){ | ||
| 60 | + return $info['company_en_description']; | ||
| 61 | + }else{ | ||
| 62 | + return $info['company_en_name']; | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 41 | * @name :写入日志 | 67 | * @name :写入日志 |
| 42 | * @author :liyuhang | 68 | * @author :liyuhang |
| 43 | * @method | 69 | * @method |
| @@ -53,4 +79,5 @@ class AiCommandController extends BaseController | @@ -53,4 +79,5 @@ class AiCommandController extends BaseController | ||
| 53 | $aiLog = new AiLog(); | 79 | $aiLog = new AiLog(); |
| 54 | return $aiLog->add($param); | 80 | return $aiLog->add($param); |
| 55 | } | 81 | } |
| 82 | + | ||
| 56 | } | 83 | } |
| @@ -19,6 +19,7 @@ use App\Models\Project\Project; | @@ -19,6 +19,7 @@ use App\Models\Project\Project; | ||
| 19 | use App\Models\RouteMap\RouteMap; | 19 | use App\Models\RouteMap\RouteMap; |
| 20 | use App\Models\WebSetting\WebSettingCountry; | 20 | use App\Models\WebSetting\WebSettingCountry; |
| 21 | use Illuminate\Http\Request; | 21 | use Illuminate\Http\Request; |
| 22 | +use Illuminate\Support\Facades\Redis; | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * @remark :通知C端 | 25 | * @remark :通知C端 |
| @@ -139,7 +140,9 @@ class CNoticeController extends BaseController | @@ -139,7 +140,9 @@ class CNoticeController extends BaseController | ||
| 139 | 'created_at'=>date('Y-m-d H;i:s') | 140 | 'created_at'=>date('Y-m-d H;i:s') |
| 140 | ]; | 141 | ]; |
| 141 | $updateProgressModel = new UpdateProgress(); | 142 | $updateProgressModel = new UpdateProgress(); |
| 142 | - return $updateProgressModel->insert($data); | 143 | + $updateProgressModel->insert($data); |
| 144 | + Redis::lpush('updateProgress', $this->user['project_id']); | ||
| 145 | + return true; | ||
| 143 | } | 146 | } |
| 144 | 147 | ||
| 145 | /** | 148 | /** |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :PageSettingController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/10/21 15:25 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Bside\BCom; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Bside\BaseController; | ||
| 14 | +use App\Models\Project\PageSetting; | ||
| 15 | + | ||
| 16 | +class PageSettingController extends BaseController | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * @remark :根据项目设置获取页面是否使用公共头部底部 | ||
| 20 | + * @name :read | ||
| 21 | + * @author :lyh | ||
| 22 | + * @method :post | ||
| 23 | + * @time :2023/10/21 15:26 | ||
| 24 | + */ | ||
| 25 | + public function info(){ | ||
| 26 | + $pageSettingModel = new PageSetting(); | ||
| 27 | + $info = $pageSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 28 | + if($info === false){ | ||
| 29 | + $info = [ | ||
| 30 | + 'project_id'=>$this->user['project_id'], | ||
| 31 | + 'product_list'=>0, | ||
| 32 | + 'product_details'=>0, | ||
| 33 | + 'page_list'=>0, | ||
| 34 | + 'blog_list'=>0, | ||
| 35 | + 'blog_details'=>0, | ||
| 36 | + 'news_list'=>0, | ||
| 37 | + 'news_details'=>0, | ||
| 38 | + 'polymerization'=>0, | ||
| 39 | + ]; | ||
| 40 | + $pageSettingModel->add($info); | ||
| 41 | + } | ||
| 42 | + $this->response('success',Code::SUCCESS,$info); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * @remark :设置是否使用公共头和底 | ||
| 47 | + * @name :edit | ||
| 48 | + * @author :lyh | ||
| 49 | + * @method :post | ||
| 50 | + * @time :2023/10/21 15:36 | ||
| 51 | + */ | ||
| 52 | + public function edit(){ | ||
| 53 | + $pageSettingModel = new PageSetting(); | ||
| 54 | + $rs = $pageSettingModel->edit($this->param,['project_id'=>$this->user['project_id']]); | ||
| 55 | + if($rs === false){ | ||
| 56 | + $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR); | ||
| 57 | + } | ||
| 58 | + $this->response('success'); | ||
| 59 | + } | ||
| 60 | +} |
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * @remark : | ||
| 4 | - * @name :UpdateController.php | ||
| 5 | - * @author :lyh | ||
| 6 | - * @method :post | ||
| 7 | - * @time :2023/8/19 9:08 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -namespace App\Http\Controllers\Bside\BCom; | ||
| 11 | - | ||
| 12 | -use App\Helper\Common; | ||
| 13 | -use App\Http\Controllers\Bside\BaseController; | ||
| 14 | -use App\Models\Blog\Blog; | ||
| 15 | -use App\Models\News\News; | ||
| 16 | -use App\Models\Product\Product; | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * @remark :b端网站更新相关 | ||
| 20 | - * @name :UpdateController | ||
| 21 | - * @author :lyh | ||
| 22 | - * @method :post | ||
| 23 | - * @time :2023/8/19 9:08 | ||
| 24 | - */ | ||
| 25 | -class UpdateController extends BaseController | ||
| 26 | -{ | ||
| 27 | - /** | ||
| 28 | - * @remark :一键更新所有tdk | ||
| 29 | - * @name :updateSeoTdk | ||
| 30 | - * @author :lyh | ||
| 31 | - * @method :post | ||
| 32 | - * @time :2023/8/19 9:25 | ||
| 33 | - */ | ||
| 34 | - public function updateSeoTdk(){ | ||
| 35 | - $this->updateProduct(); | ||
| 36 | - $this->updateBlogs(); | ||
| 37 | - $this->updateNews(); | ||
| 38 | - $this->response('success'); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * @remark :更新产品tdk | ||
| 43 | - * @name :updateProduct | ||
| 44 | - * @author :lyh | ||
| 45 | - * @method :post | ||
| 46 | - * @time :2023/8/19 9:25 | ||
| 47 | - */ | ||
| 48 | - public function updateProduct(){ | ||
| 49 | - $productModel = new Product(); | ||
| 50 | - $list = $productModel->list(['status'=>Product::STATUS_ON,'project_id'=>$this->user['project_id']],'id',['id','seo_mate','title']); | ||
| 51 | - if(!empty($list)){ | ||
| 52 | - foreach ($list as $v){ | ||
| 53 | - if(!empty($v['seo_mate'])){ | ||
| 54 | - $seo_arr = $v['seo_mate']; | ||
| 55 | - //更新seo_title | ||
| 56 | - if(!isset($seo_arr['title'])){ | ||
| 57 | - //生成seo_title | ||
| 58 | - $seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']); | ||
| 59 | - } | ||
| 60 | - //更新seo_keyword | ||
| 61 | - if(!isset($seo_arr['keyword'])){ | ||
| 62 | - $seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']); | ||
| 63 | - } | ||
| 64 | - //更新seo_keyword | ||
| 65 | - if(!isset($seo_arr['description'])){ | ||
| 66 | - $seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']); | ||
| 67 | - } | ||
| 68 | - $ser_str = json_encode($seo_arr,true); | ||
| 69 | - $productModel->edit(['seo_mate'=>$ser_str],['id'=>$v['id']]); | ||
| 70 | - } | ||
| 71 | - } | ||
| 72 | - } | ||
| 73 | - return true; | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - /** | ||
| 77 | - * @remark :更新新闻Tdk | ||
| 78 | - * @name :updateNews | ||
| 79 | - * @author :lyh | ||
| 80 | - * @method :post | ||
| 81 | - * @time :2023/8/19 10:06 | ||
| 82 | - */ | ||
| 83 | - public function updateNews(){ | ||
| 84 | - $newsModel = new News(); | ||
| 85 | - $list = $newsModel->list(['status'=>$newsModel::STATUS_ONE],'id',['id','name','seo_title','seo_keywords','seo_description']); | ||
| 86 | - if(!empty($list)){ | ||
| 87 | - foreach ($list as $k => $v){ | ||
| 88 | - $data = []; | ||
| 89 | - if(empty($v['seo_title'])){ | ||
| 90 | - $data['seo_title'] = $this->ai_send('news_seo_title',$v['name']); | ||
| 91 | - } | ||
| 92 | - if(empty($v['seo_keywords'])){ | ||
| 93 | - $data['seo_keywords'] = $this->ai_send('news_seo_keyword',$v['name']); | ||
| 94 | - } | ||
| 95 | - if(empty($v['seo_description'])){ | ||
| 96 | - $data['seo_description'] = $this->ai_send('news_seo_description',$v['name']); | ||
| 97 | - } | ||
| 98 | - $newsModel->edit($data,['id'=>$v['id']]); | ||
| 99 | - } | ||
| 100 | - } | ||
| 101 | - return true; | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - /** | ||
| 105 | - * @remark :更新blogTdk | ||
| 106 | - * @name :updateBlogs | ||
| 107 | - * @author :lyh | ||
| 108 | - * @method :post | ||
| 109 | - * @time :2023/8/19 10:07 | ||
| 110 | - */ | ||
| 111 | - public function updateBlogs(){ | ||
| 112 | - $blogModel = new Blog(); | ||
| 113 | - $list = $blogModel->list(['status'=>$blogModel::STATUS_ONE]); | ||
| 114 | - if(!empty($list)){ | ||
| 115 | - foreach ($list as $k => $v){ | ||
| 116 | - $data = []; | ||
| 117 | - if(empty($v['seo_title'])){ | ||
| 118 | - $data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']); | ||
| 119 | - } | ||
| 120 | - if(empty($v['seo_keywords'])){ | ||
| 121 | - $data['seo_keywords'] = $this->ai_send('blog_seo_keyword',$v['name']); | ||
| 122 | - } | ||
| 123 | - if(empty($v['seo_description'])){ | ||
| 124 | - $data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']); | ||
| 125 | - } | ||
| 126 | - $blogModel->edit($data,['id'=>$v['id']]); | ||
| 127 | - } | ||
| 128 | - } | ||
| 129 | - return true; | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - /** | ||
| 133 | - * @remark :AI发送 | ||
| 134 | - * @name :ai_send | ||
| 135 | - * @author :lyh | ||
| 136 | - * @method :post | ||
| 137 | - * @time :2023/8/19 10:40 | ||
| 138 | - */ | ||
| 139 | - public function ai_send($key,$keywords){ | ||
| 140 | - $chat_url = 'v2/openai_chat'; | ||
| 141 | - $param = [ | ||
| 142 | - 'key'=>$key, | ||
| 143 | - 'keywords'=>$keywords, | ||
| 144 | - ]; | ||
| 145 | - $data = Common::send_openai_msg($chat_url,$param); | ||
| 146 | - return $data['text']; | ||
| 147 | - } | ||
| 148 | -} |
| @@ -20,19 +20,42 @@ class BlogCategoryController extends BaseController | @@ -20,19 +20,42 @@ class BlogCategoryController extends BaseController | ||
| 20 | public function lists(BlogCategoryModel $blogCategoryModel){ | 20 | public function lists(BlogCategoryModel $blogCategoryModel){ |
| 21 | //搜索条件 | 21 | //搜索条件 |
| 22 | $this->map['project_id'] = $this->user['project_id']; | 22 | $this->map['project_id'] = $this->user['project_id']; |
| 23 | - $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order, | ||
| 24 | - ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']); | ||
| 25 | - if(!empty($lists['list'])){ | 23 | + $filed = ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']; |
| 24 | + $lists = $blogCategoryModel->list($this->map,$this->order = ['sort','id'],$filed); | ||
| 25 | + $data = []; | ||
| 26 | + if(!empty($lists)){ | ||
| 26 | $blogModel = new BlogModel(); | 27 | $blogModel = new BlogModel(); |
| 27 | - foreach ($lists['list'] as $k => $v){ | 28 | + foreach ($lists as $k => $v){ |
| 28 | $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); | 29 | $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); |
| 29 | - $v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $v['id'], $this->user['project_id']); | ||
| 30 | - $v['url'] = $this->user['domain'] . RouteMap::PATH_BLOG_CATE . '/' . $v['alias']; | ||
| 31 | - $v['hasChildren'] = (($blogCategoryModel->read(['pid'=>$v['id']])) != false) ? true : false; | ||
| 32 | - $lists['list'][$k] = $v; | 30 | + $v['url'] = $this->user['domain'] . $v['alias'].'/'; |
| 31 | + $lists[$k] = $v; | ||
| 33 | } | 32 | } |
| 33 | + if(!isset($this->map['name'])){ | ||
| 34 | + $data = $this->getListSon($lists); | ||
| 35 | + }else{ | ||
| 36 | + $data = $lists; | ||
| 34 | } | 37 | } |
| 35 | - $this->response('success',Code::SUCCESS,$lists); | 38 | + } |
| 39 | + $this->response('success',Code::SUCCESS,$data); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * @remark :无分页子集处理 | ||
| 44 | + * @name :getListSon | ||
| 45 | + * @author :lyh | ||
| 46 | + * @method :post | ||
| 47 | + * @time :2023/8/17 11:12 | ||
| 48 | + */ | ||
| 49 | + public function getListSon($list){ | ||
| 50 | + $data = array(); | ||
| 51 | + foreach ($list as $v){ | ||
| 52 | + $v = (array)$v; | ||
| 53 | + if ($v['pid'] == 0) { | ||
| 54 | + $v['sub'] = _get_child($v['id'], $list); | ||
| 55 | + $data[] = $v; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + return $data; | ||
| 36 | } | 59 | } |
| 37 | 60 | ||
| 38 | /** | 61 | /** |
| @@ -4,13 +4,12 @@ namespace App\Http\Controllers\Bside\Blog; | @@ -4,13 +4,12 @@ namespace App\Http\Controllers\Bside\Blog; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | -use App\Http\Logic\Bside\Blog\BlogCategoryLogic; | ||
| 8 | -use App\Http\Logic\Bside\Blog\BlogLabelLogic; | ||
| 9 | use App\Http\Logic\Bside\Blog\BlogLogic; | 7 | use App\Http\Logic\Bside\Blog\BlogLogic; |
| 10 | use App\Http\Requests\Bside\Blog\BlogRequest; | 8 | use App\Http\Requests\Bside\Blog\BlogRequest; |
| 11 | use App\Models\Blog\Blog as BlogModel; | 9 | use App\Models\Blog\Blog as BlogModel; |
| 12 | use App\Models\Blog\BlogCategory; | 10 | use App\Models\Blog\BlogCategory; |
| 13 | -use App\Models\RouteMap\RouteMap; | 11 | +use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| 12 | +use App\Models\Product\Category; | ||
| 14 | use App\Models\User\User; | 13 | use App\Models\User\User; |
| 15 | 14 | ||
| 16 | class BlogController extends BaseController | 15 | class BlogController extends BaseController |
| @@ -23,16 +22,20 @@ class BlogController extends BaseController | @@ -23,16 +22,20 @@ class BlogController extends BaseController | ||
| 23 | * @method :post | 22 | * @method :post |
| 24 | * @time :2023/9/14 10:45 | 23 | * @time :2023/9/14 10:45 |
| 25 | */ | 24 | */ |
| 26 | - public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){ | ||
| 27 | - $this->map = $this->searchParam(); | ||
| 28 | - $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']); | ||
| 29 | - if(!empty($lists) && !empty($lists['list'])){ | ||
| 30 | - //获取当前项目的所有分类 | 25 | + public function lists(BlogModel $blogModel){ |
| 26 | + $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']; | ||
| 27 | + $this->order = 'sort'; | ||
| 28 | + $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc'); | ||
| 29 | + $query = $this->searchParam($query); | ||
| 30 | + $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); | ||
| 31 | + if(!empty($lists)){ | ||
| 32 | + $lists = $lists->toArray(); | ||
| 33 | +// //获取当前项目的所有分类 | ||
| 31 | $data = $this->getCategoryList(); | 34 | $data = $this->getCategoryList(); |
| 32 | $user = new User(); | 35 | $user = new User(); |
| 33 | foreach ($lists['list'] as $k => $v){ | 36 | foreach ($lists['list'] as $k => $v){ |
| 34 | $v['category_name'] = $this->categoryName($v['category_id'],$data); | 37 | $v['category_name'] = $this->categoryName($v['category_id'],$data); |
| 35 | - $v['url'] = $this->user['domain'] .$v['url']; | 38 | + $v['url'] = $this->user['domain'] .$v['url'].'/'; |
| 36 | $v['image_link'] = getImageUrl($v['image']); | 39 | $v['image_link'] = getImageUrl($v['image']); |
| 37 | $v['operator_name'] = $user->getName($v['operator_id']); | 40 | $v['operator_name'] = $user->getName($v['operator_id']); |
| 38 | $lists['list'][$k] = $v; | 41 | $lists['list'][$k] = $v; |
| @@ -48,16 +51,52 @@ class BlogController extends BaseController | @@ -48,16 +51,52 @@ class BlogController extends BaseController | ||
| 48 | * @method :post | 51 | * @method :post |
| 49 | * @time :2023/9/14 10:01 | 52 | * @time :2023/9/14 10:01 |
| 50 | */ | 53 | */ |
| 51 | - public function searchParam(){ | ||
| 52 | - $this->map['project_id'] = $this->user['project_id']; | ||
| 53 | - if(isset($this->map['category_id']) && !empty($this->map['category_id'])){ | ||
| 54 | - $this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%']; | 54 | + public function searchParam(&$query){ |
| 55 | + $query = $query->where('project_id',$this->user['project_id']); | ||
| 56 | + if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { | ||
| 57 | + $str = []; | ||
| 58 | + $this->getLastLevelIds($this->map['category_id'],$str); | ||
| 59 | + $query->where(function ($subQuery) use ($str) { | ||
| 60 | + foreach ($str as $v) { | ||
| 61 | + $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]); | ||
| 62 | + } | ||
| 63 | + }); | ||
| 64 | + } | ||
| 65 | + if(isset($this->map['status'])){ | ||
| 66 | + $query = $query->where('status',$this->map['status']); | ||
| 55 | } | 67 | } |
| 56 | - return $this->map; | 68 | + if(isset($this->map['name']) && !empty($this->map['name'])){ |
| 69 | + $query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%'); | ||
| 70 | + } | ||
| 71 | + if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){ | ||
| 72 | + $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]); | ||
| 73 | + } | ||
| 74 | + return $query; | ||
| 57 | } | 75 | } |
| 58 | 76 | ||
| 59 | /** | 77 | /** |
| 60 | - * @remark :获取所有分类 | 78 | + * @remark :获取当前分类的最后一级id |
| 79 | + * @name :getLastLevelIds | ||
| 80 | + * @author :lyh | ||
| 81 | + * @method :post | ||
| 82 | + * @time :2023/10/20 15:02 | ||
| 83 | + */ | ||
| 84 | + public function getLastLevelIds($id, &$str = []) { | ||
| 85 | + $cateModel = new BlogCategoryModel(); | ||
| 86 | + $subList = $cateModel->where('pid', $id)->get(); | ||
| 87 | + if ($subList->isEmpty()) { | ||
| 88 | + // 如果没有子集,将当前 ID 添加到最后一级 ID 数组 | ||
| 89 | + $str[] = $id; | ||
| 90 | + } else { | ||
| 91 | + // 如果有子集,继续向下遍历 | ||
| 92 | + foreach ($subList as $v) { | ||
| 93 | + $this->getLastLevelIds($v->id, $str); | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * @remark :获取所有分类名称 | ||
| 61 | * @name :getCategoryList | 100 | * @name :getCategoryList |
| 62 | * @author :lyh | 101 | * @author :lyh |
| 63 | * @method :post | 102 | * @method :post |
| @@ -109,13 +148,28 @@ class BlogController extends BaseController | @@ -109,13 +148,28 @@ class BlogController extends BaseController | ||
| 109 | } | 148 | } |
| 110 | 149 | ||
| 111 | /** | 150 | /** |
| 112 | - * @name :获取分页列表 | ||
| 113 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 114 | - * @author :liyuhang | ||
| 115 | - * @method | 151 | + * @remark :(搜索)获取分类 |
| 152 | + * @name :get_category_list | ||
| 153 | + * @author :lyh | ||
| 154 | + * @method :post | ||
| 155 | + * @time :2023/10/19 15:08 | ||
| 116 | */ | 156 | */ |
| 117 | - public function get_category_list(BlogLogic $blogLogic){ | ||
| 118 | - $list = $blogLogic->blog_get_category_list(); | 157 | + public function get_category_list(){ |
| 158 | + $this->map['status'] = 0; | ||
| 159 | + $this->map['project_id'] = $this->user['project_id']; | ||
| 160 | + $blogCategoryModel = new BlogCategoryModel(); | ||
| 161 | + $cate_list = $blogCategoryModel->list($this->map,'sort'); | ||
| 162 | + if($cate_list === false){ | ||
| 163 | + $this->fail('error',Code::USER_ERROR); | ||
| 164 | + } | ||
| 165 | + $list = []; | ||
| 166 | + foreach ($cate_list as $v){ | ||
| 167 | + $v = (array)$v; | ||
| 168 | + if ($v['pid'] == 0) { | ||
| 169 | + $v['sub'] = _get_child($v['id'], $cate_list); | ||
| 170 | + $list[] = $v; | ||
| 171 | + } | ||
| 172 | + } | ||
| 119 | $this->response('success',Code::SUCCESS,$list); | 173 | $this->response('success',Code::SUCCESS,$list); |
| 120 | } | 174 | } |
| 121 | 175 |
| @@ -16,6 +16,7 @@ use App\Helper\Common; | @@ -16,6 +16,7 @@ use App\Helper\Common; | ||
| 16 | use App\Helper\Translate; | 16 | use App\Helper\Translate; |
| 17 | use App\Helper\Wechat; | 17 | use App\Helper\Wechat; |
| 18 | use App\Http\Logic\Bside\User\UserLoginLogic; | 18 | use App\Http\Logic\Bside\User\UserLoginLogic; |
| 19 | +use App\Models\Domain\DomainInfo; | ||
| 19 | use App\Models\Project\Project; | 20 | use App\Models\Project\Project; |
| 20 | use App\Models\Service\Service; | 21 | use App\Models\Service\Service; |
| 21 | use App\Models\Sms\SmsLog; | 22 | use App\Models\Sms\SmsLog; |
| @@ -293,5 +294,4 @@ class LoginController extends BaseController | @@ -293,5 +294,4 @@ class LoginController extends BaseController | ||
| 293 | } | 294 | } |
| 294 | return $data; | 295 | return $data; |
| 295 | } | 296 | } |
| 296 | - | ||
| 297 | } | 297 | } |
| @@ -29,7 +29,7 @@ class NavController extends BaseController | @@ -29,7 +29,7 @@ class NavController extends BaseController | ||
| 29 | */ | 29 | */ |
| 30 | public function index(BNav $nav){ | 30 | public function index(BNav $nav){ |
| 31 | $this->map['project_id'] = $this->user['project_id']; | 31 | $this->map['project_id'] = $this->user['project_id']; |
| 32 | - $lists = $nav->list($this->map,$this->order = 'sort'); | 32 | + $lists = $nav->list($this->map,$this->order = ['sort','id']); |
| 33 | $data = array(); | 33 | $data = array(); |
| 34 | foreach ($lists as $v){ | 34 | foreach ($lists as $v){ |
| 35 | $v = (array)$v; | 35 | $v = (array)$v; |
| @@ -20,19 +20,42 @@ class NewsCategoryController extends BaseController | @@ -20,19 +20,42 @@ class NewsCategoryController extends BaseController | ||
| 20 | public function lists(NewsCategoryModel $newsCategory){ | 20 | public function lists(NewsCategoryModel $newsCategory){ |
| 21 | //搜索条件 | 21 | //搜索条件 |
| 22 | $this->map['project_id'] = $this->user['project_id']; | 22 | $this->map['project_id'] = $this->user['project_id']; |
| 23 | - $lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order = 'sort', | ||
| 24 | - ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']); | ||
| 25 | - if(!empty($lists['list'])){ | 23 | + $filed = ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']; |
| 24 | + $lists = $newsCategory->list($this->map,$this->order = ['sort','id'],$filed); | ||
| 25 | + $data = []; | ||
| 26 | + if(!empty($lists)){ | ||
| 26 | $newsModel = new NewsModel(); | 27 | $newsModel = new NewsModel(); |
| 27 | - foreach ($lists['list'] as $k => $v){ | 28 | + foreach ($lists as $k => $v){ |
| 28 | $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); | 29 | $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); |
| 29 | - $v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $v['id'], $this->user['project_id']); | ||
| 30 | - $v['url'] = $this->user['domain'] . RouteMap::PATH_NEWS_CATE . '/' . $v['alias']; | ||
| 31 | - $v['hasChildren'] = (($newsCategory->read(['pid'=>$v['id']])) != false) ? true : false; | ||
| 32 | - $lists['list'][$k] = $v; | 30 | + $v['url'] = $this->user['domain'] . $v['alias'].'/'; |
| 31 | + $lists[$k] = $v; | ||
| 33 | } | 32 | } |
| 33 | + if(!isset($this->map['name'])){ | ||
| 34 | + $data = $this->getListSon($lists); | ||
| 35 | + }else{ | ||
| 36 | + $data = $lists; | ||
| 34 | } | 37 | } |
| 35 | - $this->response('success',Code::SUCCESS,$lists); | 38 | + } |
| 39 | + $this->response('success',Code::SUCCESS,$data); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * @remark :无分页子集处理 | ||
| 44 | + * @name :getListSon | ||
| 45 | + * @author :lyh | ||
| 46 | + * @method :post | ||
| 47 | + * @time :2023/8/17 11:12 | ||
| 48 | + */ | ||
| 49 | + public function getListSon($list){ | ||
| 50 | + $data = array(); | ||
| 51 | + foreach ($list as $v){ | ||
| 52 | + $v = (array)$v; | ||
| 53 | + if ($v['pid'] == 0) { | ||
| 54 | + $v['sub'] = _get_child($v['id'], $list); | ||
| 55 | + $data[] = $v; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + return $data; | ||
| 36 | } | 59 | } |
| 37 | 60 | ||
| 38 | /** | 61 | /** |
| @@ -58,7 +81,6 @@ class NewsCategoryController extends BaseController | @@ -58,7 +81,6 @@ class NewsCategoryController extends BaseController | ||
| 58 | 'id.required' => 'ID不能为空' | 81 | 'id.required' => 'ID不能为空' |
| 59 | ]); | 82 | ]); |
| 60 | $info = $newsCategoryLogic->info_news_category(); | 83 | $info = $newsCategoryLogic->info_news_category(); |
| 61 | - $info['url'] = $this->user['domain'] . $info['alias']; | ||
| 62 | $this->response('success',Code::SUCCESS,$info); | 84 | $this->response('success',Code::SUCCESS,$info); |
| 63 | } | 85 | } |
| 64 | 86 |
| @@ -4,12 +4,10 @@ namespace App\Http\Controllers\Bside\News; | @@ -4,12 +4,10 @@ namespace App\Http\Controllers\Bside\News; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | -use App\Http\Logic\Bside\News\NewsCategoryLogic; | ||
| 8 | use App\Http\Logic\Bside\News\NewsLogic; | 7 | use App\Http\Logic\Bside\News\NewsLogic; |
| 9 | use App\Http\Requests\Bside\News\NewsRequest; | 8 | use App\Http\Requests\Bside\News\NewsRequest; |
| 10 | use App\Models\News\News as NewsModel; | 9 | use App\Models\News\News as NewsModel; |
| 11 | use App\Models\News\NewsCategory; | 10 | use App\Models\News\NewsCategory; |
| 12 | -use App\Models\RouteMap\RouteMap; | ||
| 13 | use App\Models\User\User; | 11 | use App\Models\User\User; |
| 14 | 12 | ||
| 15 | 13 | ||
| @@ -24,17 +22,20 @@ class NewsController extends BaseController | @@ -24,17 +22,20 @@ class NewsController extends BaseController | ||
| 24 | * @author :liyuhang | 22 | * @author :liyuhang |
| 25 | * @method | 23 | * @method |
| 26 | */ | 24 | */ |
| 27 | - public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){ | ||
| 28 | - $this->map = $this->searchParam(); | ||
| 29 | - $lists = $news->lists($this->map,$this->page,$this->row,$this->order = 'sort', | ||
| 30 | - ['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']); | ||
| 31 | - if(!empty($lists) && !empty($lists['list'])){ | ||
| 32 | - //获取当前项目的所有分类 | 25 | + public function lists(NewsModel $news){ |
| 26 | + $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url']; | ||
| 27 | + $this->order = 'sort'; | ||
| 28 | + $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc'); | ||
| 29 | + $query = $this->searchParam($query); | ||
| 30 | + $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); | ||
| 31 | + if(!empty($lists)){ | ||
| 32 | + $lists = $lists->toArray(); | ||
| 33 | +// //获取当前项目的所有分类 | ||
| 33 | $data = $this->getCategoryList(); | 34 | $data = $this->getCategoryList(); |
| 34 | $user = new User(); | 35 | $user = new User(); |
| 35 | foreach ($lists['list'] as $k => $v){ | 36 | foreach ($lists['list'] as $k => $v){ |
| 36 | $v['category_name'] = $this->categoryName($v['category_id'],$data); | 37 | $v['category_name'] = $this->categoryName($v['category_id'],$data); |
| 37 | - $v['url'] = $this->user['domain'] . $v['url']; | 38 | + $v['url'] = $this->user['domain'] .$v['url'].'/'; |
| 38 | $v['image_link'] = getImageUrl($v['image']); | 39 | $v['image_link'] = getImageUrl($v['image']); |
| 39 | $v['operator_name'] = $user->getName($v['operator_id']); | 40 | $v['operator_name'] = $user->getName($v['operator_id']); |
| 40 | $lists['list'][$k] = $v; | 41 | $lists['list'][$k] = $v; |
| @@ -50,12 +51,48 @@ class NewsController extends BaseController | @@ -50,12 +51,48 @@ class NewsController extends BaseController | ||
| 50 | * @method :post | 51 | * @method :post |
| 51 | * @time :2023/9/14 10:01 | 52 | * @time :2023/9/14 10:01 |
| 52 | */ | 53 | */ |
| 53 | - public function searchParam(){ | ||
| 54 | - $this->map['project_id'] = $this->user['project_id']; | ||
| 55 | - if(isset($this->map['category_id']) && !empty($this->map['category_id'])){ | ||
| 56 | - $this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%']; | 54 | + public function searchParam(&$query){ |
| 55 | + $query = $query->where('project_id',$this->user['project_id']); | ||
| 56 | + if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { | ||
| 57 | + $str = []; | ||
| 58 | + $this->getLastLevelIds($this->map['category_id'],$str); | ||
| 59 | + $query->where(function ($subQuery) use ($str) { | ||
| 60 | + foreach ($str as $v) { | ||
| 61 | + $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]); | ||
| 62 | + } | ||
| 63 | + }); | ||
| 64 | + } | ||
| 65 | + if(isset($this->map['status'])){ | ||
| 66 | + $query = $query->where('status',$this->map['status']); | ||
| 67 | + } | ||
| 68 | + if(isset($this->map['name']) && !empty($this->map['name'])){ | ||
| 69 | + $query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%'); | ||
| 70 | + } | ||
| 71 | + if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){ | ||
| 72 | + $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]); | ||
| 73 | + } | ||
| 74 | + return $query; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * @remark :获取当前分类的最后一级id | ||
| 79 | + * @name :getLastLevelIds | ||
| 80 | + * @author :lyh | ||
| 81 | + * @method :post | ||
| 82 | + * @time :2023/10/20 15:02 | ||
| 83 | + */ | ||
| 84 | + public function getLastLevelIds($id, &$str = []) { | ||
| 85 | + $cateModel = new NewsCategory(); | ||
| 86 | + $subList = $cateModel->where('pid', $id)->get(); | ||
| 87 | + if ($subList->isEmpty()) { | ||
| 88 | + // 如果没有子集,将当前 ID 添加到最后一级 ID 数组 | ||
| 89 | + $str[] = $id; | ||
| 90 | + } else { | ||
| 91 | + // 如果有子集,继续向下遍历 | ||
| 92 | + foreach ($subList as $v) { | ||
| 93 | + $this->getLastLevelIds($v->id, $str); | ||
| 94 | + } | ||
| 57 | } | 95 | } |
| 58 | - return $this->map; | ||
| 59 | } | 96 | } |
| 60 | 97 | ||
| 61 | /** | 98 | /** |
| @@ -132,7 +169,6 @@ class NewsController extends BaseController | @@ -132,7 +169,6 @@ class NewsController extends BaseController | ||
| 132 | 'id.required' => 'ID不能为空', | 169 | 'id.required' => 'ID不能为空', |
| 133 | ]); | 170 | ]); |
| 134 | $info = $newsLogic->newsInfo(); | 171 | $info = $newsLogic->newsInfo(); |
| 135 | - | ||
| 136 | $this->response('success',Code::SUCCESS,$info); | 172 | $this->response('success',Code::SUCCESS,$info); |
| 137 | } | 173 | } |
| 138 | 174 |
| @@ -37,12 +37,16 @@ class CategoryController extends BaseController | @@ -37,12 +37,16 @@ class CategoryController extends BaseController | ||
| 37 | $data = []; | 37 | $data = []; |
| 38 | if(!empty($list)){ | 38 | if(!empty($list)){ |
| 39 | foreach ($list as $k =>$v){ | 39 | foreach ($list as $k =>$v){ |
| 40 | - $v['url'] = $this->user['domain'] . $v['route']; | ||
| 41 | - $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->where(['status'=>1])->count(); | 40 | + $v['url'] = $this->user['domain'] . $v['route'].'/'; |
| 41 | + $v['product_num'] = Category::getProductNum($v['id']); | ||
| 42 | $v['image_link'] = getImageUrl($v['image']); | 42 | $v['image_link'] = getImageUrl($v['image']); |
| 43 | $list[$k] = $v; | 43 | $list[$k] = $v; |
| 44 | } | 44 | } |
| 45 | + if(!isset($this->map['title'])){ | ||
| 45 | $data = $this->getListSon($list); | 46 | $data = $this->getListSon($list); |
| 47 | + }else{ | ||
| 48 | + $data = $list; | ||
| 49 | + } | ||
| 46 | } | 50 | } |
| 47 | return $this->response('success',Code::SUCCESS,$data); | 51 | return $this->response('success',Code::SUCCESS,$data); |
| 48 | } | 52 | } |
| @@ -58,10 +62,6 @@ class CategoryController extends BaseController | @@ -58,10 +62,6 @@ class CategoryController extends BaseController | ||
| 58 | if(!empty($this->map['title'])){ | 62 | if(!empty($this->map['title'])){ |
| 59 | $this->map['title'] = ['like','%'.$this->map['title'].'%']; | 63 | $this->map['title'] = ['like','%'.$this->map['title'].'%']; |
| 60 | } | 64 | } |
| 61 | - if(!empty($this->map['search'])){ | ||
| 62 | - $this->map['title'] = ['like','%'.$this->map['search'].'%']; | ||
| 63 | - } | ||
| 64 | - unset($this->map['search']); | ||
| 65 | $this->map['project_id'] = $this->user['project_id']; | 65 | $this->map['project_id'] = $this->user['project_id']; |
| 66 | return $this->map; | 66 | return $this->map; |
| 67 | } | 67 | } |
| @@ -79,10 +79,6 @@ class CategoryController extends BaseController | @@ -79,10 +79,6 @@ class CategoryController extends BaseController | ||
| 79 | $v = (array)$v; | 79 | $v = (array)$v; |
| 80 | if ($v['pid'] == 0) { | 80 | if ($v['pid'] == 0) { |
| 81 | $v['sub'] = _get_child($v['id'], $list); | 81 | $v['sub'] = _get_child($v['id'], $list); |
| 82 | - foreach ($v['sub'] as $sub){ | ||
| 83 | - $v['product_num'] += $sub['product_num']; | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | $data[] = $v; | 82 | $data[] = $v; |
| 87 | } | 83 | } |
| 88 | } | 84 | } |
| @@ -90,6 +86,17 @@ class CategoryController extends BaseController | @@ -90,6 +86,17 @@ class CategoryController extends BaseController | ||
| 90 | } | 86 | } |
| 91 | 87 | ||
| 92 | /** | 88 | /** |
| 89 | + * @name :(添加/编辑时获取顶级分类)topList | ||
| 90 | + * @author :lyh | ||
| 91 | + * @method :post | ||
| 92 | + * @time :2023/6/13 9:03 | ||
| 93 | + */ | ||
| 94 | + public function categoryTopList(CategoryLogic $logic){ | ||
| 95 | + $list = $logic->categoryTopList(); | ||
| 96 | + $this->response('success',Code::SUCCESS,$list); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 93 | * @remark :获取详情 | 100 | * @remark :获取详情 |
| 94 | * @name :info | 101 | * @name :info |
| 95 | * @author :lyh | 102 | * @author :lyh |
| @@ -46,7 +46,7 @@ class KeywordController extends BaseController | @@ -46,7 +46,7 @@ class KeywordController extends BaseController | ||
| 46 | }else{ | 46 | }else{ |
| 47 | $v['tdk'] = 0; | 47 | $v['tdk'] = 0; |
| 48 | } | 48 | } |
| 49 | - $v['url'] = $this->user['domain'] . $v['route']; | 49 | + $v['url'] = $this->user['domain'] . $v['route'].'/'; |
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| 52 | return $this->response('success',Code::SUCCESS,$data); | 52 | return $this->response('success',Code::SUCCESS,$data); |
| @@ -65,8 +65,8 @@ class KeywordController extends BaseController | @@ -65,8 +65,8 @@ class KeywordController extends BaseController | ||
| 65 | ],[ | 65 | ],[ |
| 66 | 'id.required' => 'ID不能为空' | 66 | 'id.required' => 'ID不能为空' |
| 67 | ]); | 67 | ]); |
| 68 | - $data = $logic->getInfo($this->param['id']); | ||
| 69 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at', 'route', 'url'])); | 68 | + $data = $logic->getKeywordInfo(); |
| 69 | + return $this->success($data); | ||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | /** | 72 | /** |
| @@ -40,11 +40,14 @@ class ProductController extends BaseController | @@ -40,11 +40,14 @@ class ProductController extends BaseController | ||
| 40 | */ | 40 | */ |
| 41 | public function index(Product $product) | 41 | public function index(Product $product) |
| 42 | { | 42 | { |
| 43 | - $this->map = $this->searchParam(); | ||
| 44 | $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' , | 43 | $filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' , |
| 45 | 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']; | 44 | 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']; |
| 46 | - $lists = $product->lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed); | ||
| 47 | - if(!empty($lists) && !empty($lists['list'])){ | 45 | + $this->order = 'sort'; |
| 46 | + $query = $product->orderBy($this->order ,'desc')->orderBy('id','desc'); | ||
| 47 | + $query = $this->searchParam($query); | ||
| 48 | + $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); | ||
| 49 | + if(!empty($lists)){ | ||
| 50 | + $lists = $lists->toArray(); | ||
| 48 | $cate_data = $this->getCategoryList();//分类 | 51 | $cate_data = $this->getCategoryList();//分类 |
| 49 | $key_data = $this->getKeywordsList();//关键字 | 52 | $key_data = $this->getKeywordsList();//关键字 |
| 50 | //获取当前用户选择的模版 | 53 | //获取当前用户选择的模版 |
| @@ -56,7 +59,7 @@ class ProductController extends BaseController | @@ -56,7 +59,7 @@ class ProductController extends BaseController | ||
| 56 | $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data); | 59 | $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data); |
| 57 | $v['created_uid_text'] = $userModel->getName($v['created_uid']); | 60 | $v['created_uid_text'] = $userModel->getName($v['created_uid']); |
| 58 | $v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']); | 61 | $v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']); |
| 59 | - $v['url'] = $this->user['domain'].$v['route']; | 62 | + $v['url'] = $this->user['domain'].$v['route'].'/'; |
| 60 | $lists['list'][$k] = $v; | 63 | $lists['list'][$k] = $v; |
| 61 | } | 64 | } |
| 62 | } | 65 | } |
| @@ -64,21 +67,54 @@ class ProductController extends BaseController | @@ -64,21 +67,54 @@ class ProductController extends BaseController | ||
| 64 | } | 67 | } |
| 65 | 68 | ||
| 66 | /** | 69 | /** |
| 67 | - * @remark :搜索参数处理 | ||
| 68 | - * @name :searchParam | 70 | + * @remark :处理列表返回参数 |
| 71 | + * @name :handleReturnParam | ||
| 69 | * @author :lyh | 72 | * @author :lyh |
| 70 | * @method :post | 73 | * @method :post |
| 71 | - * @time :2023/9/14 14:32 | 74 | + * @time :2023/9/14 10:01 |
| 72 | */ | 75 | */ |
| 73 | - public function searchParam(){ | 76 | + public function searchParam(&$query){ |
| 77 | + $query = $query->where('project_id',$this->user['project_id']); | ||
| 78 | + if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { | ||
| 79 | + $str = []; | ||
| 80 | + $this->getLastLevelIds($this->map['category_id'],$str); | ||
| 81 | + $query->where(function ($subQuery) use ($str) { | ||
| 82 | + foreach ($str as $v) { | ||
| 83 | + $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]); | ||
| 84 | + } | ||
| 85 | + }); | ||
| 86 | + } | ||
| 74 | if(isset($this->map['title']) && !empty($this->map['title'])){ | 87 | if(isset($this->map['title']) && !empty($this->map['title'])){ |
| 75 | - $this->map['title'] = ['like','%'.$this->map['title'].'%']; | 88 | + $query = $query->where('title','like','%'.$this->map['title'].'%'); |
| 89 | + } | ||
| 90 | + if(isset($this->map['status'])){ | ||
| 91 | + $query = $query->where('status',$this->map['status']); | ||
| 92 | + } | ||
| 93 | + if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){ | ||
| 94 | + $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]); | ||
| 95 | + } | ||
| 96 | + return $query; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * @remark :获取当前分类的最后一级id | ||
| 101 | + * @name :getLastLevelIds | ||
| 102 | + * @author :lyh | ||
| 103 | + * @method :post | ||
| 104 | + * @time :2023/10/20 15:02 | ||
| 105 | + */ | ||
| 106 | + public function getLastLevelIds($id, &$str = []) { | ||
| 107 | + $cateModel = new Category(); | ||
| 108 | + $subList = $cateModel->where('pid', $id)->get(); | ||
| 109 | + if ($subList->isEmpty()) { | ||
| 110 | + // 如果没有子集,将当前 ID 添加到最后一级 ID 数组 | ||
| 111 | + $str[] = $id; | ||
| 112 | + } else { | ||
| 113 | + // 如果有子集,继续向下遍历 | ||
| 114 | + foreach ($subList as $v) { | ||
| 115 | + $this->getLastLevelIds($v->id, $str); | ||
| 76 | } | 116 | } |
| 77 | - if(isset($this->map['category_id']) && !empty($this->map['category_id'])){ | ||
| 78 | - $this->map['category_id'] = ['like','%'.$this->map['category_id'].'%']; | ||
| 79 | } | 117 | } |
| 80 | - $this->map['project_id'] = $this->user['project_id']; | ||
| 81 | - return $this->map; | ||
| 82 | } | 118 | } |
| 83 | 119 | ||
| 84 | /** | 120 | /** |
| @@ -217,16 +253,7 @@ class ProductController extends BaseController | @@ -217,16 +253,7 @@ class ProductController extends BaseController | ||
| 217 | * @time :2023/8/17 9:15 | 253 | * @time :2023/8/17 9:15 |
| 218 | */ | 254 | */ |
| 219 | public function handleParam($v){ | 255 | public function handleParam($v){ |
| 220 | - $v['category_id_text'] = ''; | ||
| 221 | $v['keyword_id_text'] = ''; | 256 | $v['keyword_id_text'] = ''; |
| 222 | - if(!empty($v['category_id'])){ | ||
| 223 | - $categoryModel = new Category(); | ||
| 224 | - $category_data = $categoryModel->list(['id'=>['in',$v['category_id']]],'id',['title']); | ||
| 225 | - foreach ($category_data as $v1){ | ||
| 226 | - $v['category_id_text'] .= $v1['title'].','; | ||
| 227 | - } | ||
| 228 | - $v['category_id_text'] = trim($v['category_id_text'],','); | ||
| 229 | - } | ||
| 230 | if(!empty($v['keyword_id'])){ | 257 | if(!empty($v['keyword_id'])){ |
| 231 | $keywordModel = new Keyword(); | 258 | $keywordModel = new Keyword(); |
| 232 | $keyword_data = $keywordModel->list(['id'=>['in',$v['keyword_id']]]); | 259 | $keyword_data = $keywordModel->list(['id'=>['in',$v['keyword_id']]]); |
| @@ -260,6 +287,18 @@ class ProductController extends BaseController | @@ -260,6 +287,18 @@ class ProductController extends BaseController | ||
| 260 | } | 287 | } |
| 261 | 288 | ||
| 262 | /** | 289 | /** |
| 290 | + * @remark :直接编辑列表数据 | ||
| 291 | + * @name :editList | ||
| 292 | + * @author :lyh | ||
| 293 | + * @method :post | ||
| 294 | + * @time :2023/10/26 9:48 | ||
| 295 | + */ | ||
| 296 | + public function editList(ProductLogic $logic){ | ||
| 297 | + $logic->editList(); | ||
| 298 | + $this->response('success'); | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + /** | ||
| 263 | * @remark :删除 | 302 | * @remark :删除 |
| 264 | * @name :delete | 303 | * @name :delete |
| 265 | * @author :lyh | 304 | * @author :lyh |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AggregationSettingController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/10/23 11:06 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Bside\Setting; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Helper\Arr; | ||
| 14 | +use App\Http\Controllers\Bside\BaseController; | ||
| 15 | +use App\Models\WebSetting\AggregationSetting; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * @remark :聚合页 | ||
| 19 | + * @name :AggregationSettingController | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2023/10/23 11:06 | ||
| 23 | + */ | ||
| 24 | +class AggregationSettingController extends BaseController | ||
| 25 | +{ | ||
| 26 | + /** | ||
| 27 | + * @remark :获取聚合页设置详情 | ||
| 28 | + * @name :info | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2023/10/23 11:08 | ||
| 32 | + */ | ||
| 33 | + public function info(){ | ||
| 34 | + $aggSettingModel = new AggregationSetting(); | ||
| 35 | + $info = $aggSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 36 | + if($info === false){ | ||
| 37 | + $data = [ | ||
| 38 | + 'title'=>'', | ||
| 39 | + 'content'=>'', | ||
| 40 | + 'top_banner'=>json_encode([]), | ||
| 41 | + 'foot_banner'=>json_encode([]), | ||
| 42 | + 'video_url'=>json_encode([]), | ||
| 43 | + 'project_id'=>$this->user['project_id'] | ||
| 44 | + ]; | ||
| 45 | + $aggSettingModel->add($data); | ||
| 46 | + $info = $data; | ||
| 47 | + } | ||
| 48 | + $this->response('success',Code::SUCCESS,$info); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @remark :修改聚合页设置 | ||
| 53 | + * @name :edit | ||
| 54 | + * @author :lyh | ||
| 55 | + * @method :post | ||
| 56 | + * @time :2023/10/23 11:11 | ||
| 57 | + */ | ||
| 58 | + public function edit(){ | ||
| 59 | + $aggSettingModel = new AggregationSetting(); | ||
| 60 | + if(isset($this->param['top_banner']) && !empty($this->param['top_banner'])){ | ||
| 61 | + $this->param['top_banner'] = Arr::a2s($this->param['top_banner']); | ||
| 62 | + } | ||
| 63 | + if(isset($this->param['foot_banner']) && !empty($this->param['foot_banner'])){ | ||
| 64 | + $this->param['foot_banner'] = Arr::a2s($this->param['foot_banner']); | ||
| 65 | + } | ||
| 66 | + if(isset($this->param['video_url']) && !empty($this->param['video_url'])){ | ||
| 67 | + $this->param['video_url'] = Arr::a2s($this->param['video_url']); | ||
| 68 | + } | ||
| 69 | + $rs = $aggSettingModel->edit($this->param,['project_id'=>$this->user['project_id']]); | ||
| 70 | + if($rs === false){ | ||
| 71 | + $this->response('系统错误请联系管理员',Code::SYSTEM_ERROR); | ||
| 72 | + } | ||
| 73 | + $this->response('success'); | ||
| 74 | + } | ||
| 75 | +} |
| @@ -7,6 +7,7 @@ use App\Http\Controllers\Bside\BaseController; | @@ -7,6 +7,7 @@ use App\Http\Controllers\Bside\BaseController; | ||
| 7 | use App\Http\Logic\Bside\BTemplate\BTemplateLogic; | 7 | use App\Http\Logic\Bside\BTemplate\BTemplateLogic; |
| 8 | use App\Http\Requests\Bside\Template\TemplateRequest; | 8 | use App\Http\Requests\Bside\Template\TemplateRequest; |
| 9 | use App\Models\Template\BTemplate; | 9 | use App\Models\Template\BTemplate; |
| 10 | +use App\Models\Template\BTemplateMain; | ||
| 10 | use App\Models\Template\Template; | 11 | use App\Models\Template\Template; |
| 11 | 12 | ||
| 12 | class BTemplateController extends BaseController | 13 | class BTemplateController extends BaseController |
| @@ -141,4 +142,28 @@ class BTemplateController extends BaseController | @@ -141,4 +142,28 @@ class BTemplateController extends BaseController | ||
| 141 | $BTemplateLogic->savePublicTemplateHtml(); | 142 | $BTemplateLogic->savePublicTemplateHtml(); |
| 142 | $this->response('模板保存成功'); | 143 | $this->response('模板保存成功'); |
| 143 | } | 144 | } |
| 145 | + | ||
| 146 | + /** | ||
| 147 | + * @remark :获取可视化详情页模板数据 | ||
| 148 | + * @name :getDetailInfo | ||
| 149 | + * @author :lyh | ||
| 150 | + * @method :post | ||
| 151 | + * @time :2023/10/24 11:27 | ||
| 152 | + */ | ||
| 153 | + public function getDetailInfo(BTemplateLogic $BTemplateLogic){ | ||
| 154 | + $html = $BTemplateLogic->getDetail(); | ||
| 155 | + $this->response('success',Code::SUCCESS,['html'=>$html]); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + /** | ||
| 159 | + * @remark :保存详情页模板数据 | ||
| 160 | + * @name :saveDetail | ||
| 161 | + * @author :lyh | ||
| 162 | + * @method :post | ||
| 163 | + * @time :2023/10/24 14:47 | ||
| 164 | + */ | ||
| 165 | + public function saveDetail(BTemplateLogic $BTemplateLogic){ | ||
| 166 | + $BTemplateLogic->saveDetail(); | ||
| 167 | + $this->response('success'); | ||
| 168 | + } | ||
| 144 | } | 169 | } |
| @@ -33,6 +33,7 @@ class BTemplateLogController extends BaseController | @@ -33,6 +33,7 @@ class BTemplateLogController extends BaseController | ||
| 33 | * @time :2023/8/23 11:05 | 33 | * @time :2023/8/23 11:05 |
| 34 | */ | 34 | */ |
| 35 | public function lists(BTemplateLog $bTemplateLog){ | 35 | public function lists(BTemplateLog $bTemplateLog){ |
| 36 | + unset($this->map['template_id']); | ||
| 36 | $this->map['project_id'] = $this->user['project_id']; | 37 | $this->map['project_id'] = $this->user['project_id']; |
| 37 | $this->map['source'] = 1; | 38 | $this->map['source'] = 1; |
| 38 | $lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']); | 39 | $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 | @@ -26,6 +26,7 @@ class CustomTemplateController extends BaseController | ||
| 26 | $lists = $customTemplateLogic->customTemplateLists($this->map,$this->page,$this->row,$this->order); | 26 | $lists = $customTemplateLogic->customTemplateLists($this->map,$this->page,$this->row,$this->order); |
| 27 | if (!empty($lists)){ | 27 | if (!empty($lists)){ |
| 28 | foreach ($lists['list'] as $k => $v){ | 28 | foreach ($lists['list'] as $k => $v){ |
| 29 | + $v['url'] = $v['url'].'/'; | ||
| 29 | $lists['list'][$k] = $v; | 30 | $lists['list'][$k] = $v; |
| 30 | } | 31 | } |
| 31 | } | 32 | } |
| @@ -94,9 +94,6 @@ class FileController | @@ -94,9 +94,6 @@ class FileController | ||
| 94 | if ($type == 'multi') { | 94 | if ($type == 'multi') { |
| 95 | return $this->multi($files); | 95 | return $this->multi($files); |
| 96 | } else { | 96 | } else { |
| 97 | - $size = $files->getSize(); | ||
| 98 | - $file_type = $files->getClientOriginalExtension(); | ||
| 99 | - $mime = $files->getMimeType(); | ||
| 100 | return $this->single($files); | 97 | return $this->single($files); |
| 101 | } | 98 | } |
| 102 | } | 99 | } |
| @@ -113,7 +110,12 @@ class FileController | @@ -113,7 +110,12 @@ class FileController | ||
| 113 | $name = $files->getClientOriginalName(); | 110 | $name = $files->getClientOriginalName(); |
| 114 | //查看文件是否存在 | 111 | //查看文件是否存在 |
| 115 | $fileModel = new File(); | 112 | $fileModel = new File(); |
| 116 | - $file_hash = $fileModel->read(['hash'=>$hash]); | 113 | + //查看图片是否已上传 |
| 114 | + $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0]; | ||
| 115 | + if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){ | ||
| 116 | + $param['project_id'] = $this->cache['project_id']; | ||
| 117 | + } | ||
| 118 | + $file_hash = $fileModel->read($param); | ||
| 117 | if($file_hash !== false){ | 119 | if($file_hash !== false){ |
| 118 | return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name)); | 120 | return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name)); |
| 119 | } | 121 | } |
| @@ -150,6 +152,7 @@ class FileController | @@ -150,6 +152,7 @@ class FileController | ||
| 150 | 'refer'=>$this->param['refer'] ?? 1, | 152 | 'refer'=>$this->param['refer'] ?? 1, |
| 151 | 'is_cos'=>$is_cos, | 153 | 'is_cos'=>$is_cos, |
| 152 | 'mime'=>$mime, | 154 | 'mime'=>$mime, |
| 155 | + 'project_id'=>$this->cache['project_id'] ?? 0, | ||
| 153 | 'name'=>$name, | 156 | 'name'=>$name, |
| 154 | ]; | 157 | ]; |
| 155 | $rs = $fileModel->add($data); | 158 | $rs = $fileModel->add($data); |
| @@ -172,7 +175,11 @@ class FileController | @@ -172,7 +175,11 @@ class FileController | ||
| 172 | $fileModel = new File(); | 175 | $fileModel = new File(); |
| 173 | $name = $file->getClientOriginalName(); | 176 | $name = $file->getClientOriginalName(); |
| 174 | $hash = hash_file('md5', $file->getPathname()); | 177 | $hash = hash_file('md5', $file->getPathname()); |
| 175 | - $file_hash = $fileModel->read(['hash'=>$hash]); | 178 | + $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0]; |
| 179 | + if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){ | ||
| 180 | + $param['project_id'] = $this->cache['project_id']; | ||
| 181 | + } | ||
| 182 | + $file_hash = $fileModel->read($param); | ||
| 176 | if($file_hash !== false){ | 183 | if($file_hash !== false){ |
| 177 | $data[] = $this->responseData($file_hash['path'], $name); | 184 | $data[] = $this->responseData($file_hash['path'], $name); |
| 178 | continue; | 185 | continue; |
| @@ -162,7 +162,7 @@ class ImageController extends Controller | @@ -162,7 +162,7 @@ class ImageController extends Controller | ||
| 162 | $this->response('没有上传的文件!', Code::USER_ERROR); | 162 | $this->response('没有上传的文件!', Code::USER_ERROR); |
| 163 | } | 163 | } |
| 164 | $type = $this->request->post('type','single'); | 164 | $type = $this->request->post('type','single'); |
| 165 | - $this->setUrl(); | 165 | + $this->setUrl($files); |
| 166 | if ($type == 'multi') { | 166 | if ($type == 'multi') { |
| 167 | return $this->multi($files); | 167 | return $this->multi($files); |
| 168 | }else{ | 168 | }else{ |
| @@ -298,7 +298,6 @@ class ImageController extends Controller | @@ -298,7 +298,6 @@ class ImageController extends Controller | ||
| 298 | */ | 298 | */ |
| 299 | public function download(){ | 299 | public function download(){ |
| 300 | $imageModel = new ImageModel(); | 300 | $imageModel = new ImageModel(); |
| 301 | - ; | ||
| 302 | $info = $imageModel->read(['path' => str_replace_url($this->param['path'])]); | 301 | $info = $imageModel->read(['path' => str_replace_url($this->param['path'])]); |
| 303 | if ($info === false) { | 302 | if ($info === false) { |
| 304 | $this->response('指定文件不存在!', Code::USER_ERROR); | 303 | $this->response('指定文件不存在!', Code::USER_ERROR); |
| @@ -371,11 +370,24 @@ class ImageController extends Controller | @@ -371,11 +370,24 @@ class ImageController extends Controller | ||
| 371 | * @method :post | 370 | * @method :post |
| 372 | * @time :2023/7/18 15:36 | 371 | * @time :2023/7/18 15:36 |
| 373 | */ | 372 | */ |
| 374 | - public function setUrl(){ | 373 | + public function setUrl($files){ |
| 375 | //A端上传 | 374 | //A端上传 |
| 376 | if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){ | 375 | if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){ |
| 377 | $this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); | 376 | $this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m'); |
| 378 | }else{ | 377 | }else{ |
| 378 | + //TODO::设置上传文件大小(B端上传) | ||
| 379 | + $max = config('upload.default_b_image')['size']['max']; | ||
| 380 | + if(is_array($files)){ | ||
| 381 | + foreach ($files as $file){ | ||
| 382 | + if ($file->getSize() > $max) { | ||
| 383 | + return $this->response('图片最大为500K',Code::SYSTEM_ERROR); | ||
| 384 | + } | ||
| 385 | + } | ||
| 386 | + }else{ | ||
| 387 | + if ($files->getSize() > $max) { | ||
| 388 | + return $this->response('图片最大为500K',Code::SYSTEM_ERROR); | ||
| 389 | + } | ||
| 390 | + } | ||
| 379 | if(!isset($this->param['upload_method'])){ | 391 | if(!isset($this->param['upload_method'])){ |
| 380 | //根据项目上传标识区分上传到cos/本地 | 392 | //根据项目上传标识区分上传到cos/本地 |
| 381 | $projectModel = new Project(); | 393 | $projectModel = new Project(); |
| @@ -35,7 +35,7 @@ class DomainInfoLogic extends BaseLogic | @@ -35,7 +35,7 @@ class DomainInfoLogic extends BaseLogic | ||
| 35 | { | 35 | { |
| 36 | $domain = parse_url($this->param['domain'], PHP_URL_HOST); | 36 | $domain = parse_url($this->param['domain'], PHP_URL_HOST); |
| 37 | if(!empty($domain)){ | 37 | if(!empty($domain)){ |
| 38 | - $this->param['domain'] = $domain['host']; | 38 | + $this->param['domain'] = trim($domain['host']); |
| 39 | } | 39 | } |
| 40 | //验证域名 | 40 | //验证域名 |
| 41 | $this->verifyDomain($this->param['domain'],isset($this->param['id']) ?? ''); | 41 | $this->verifyDomain($this->param['domain'],isset($this->param['id']) ?? ''); |
| @@ -193,6 +193,7 @@ class DomainInfoLogic extends BaseLogic | @@ -193,6 +193,7 @@ class DomainInfoLogic extends BaseLogic | ||
| 193 | 193 | ||
| 194 | try { | 194 | try { |
| 195 | $rs = HttpUtils::get($api_url, $api_param); | 195 | $rs = HttpUtils::get($api_url, $api_param); |
| 196 | + $rs = json_decode($rs, true); | ||
| 196 | if(isset($rs['status']) && $rs['status'] == 200){ | 197 | if(isset($rs['status']) && $rs['status'] == 200){ |
| 197 | return $this->success(); | 198 | return $this->success(); |
| 198 | }else{ | 199 | }else{ |
| @@ -8,8 +8,10 @@ use App\Models\Manage\LoginLog; | @@ -8,8 +8,10 @@ use App\Models\Manage\LoginLog; | ||
| 8 | use App\Models\Manage\Manage; | 8 | use App\Models\Manage\Manage; |
| 9 | use App\Models\Manage\ManageHr; | 9 | use App\Models\Manage\ManageHr; |
| 10 | use App\Models\Manage\MenuSpecial; | 10 | use App\Models\Manage\MenuSpecial; |
| 11 | +use App\Models\Project\Project; | ||
| 11 | use App\Models\Service\Service; | 12 | use App\Models\Service\Service; |
| 12 | use App\Models\Sms\SmsLog; | 13 | use App\Models\Sms\SmsLog; |
| 14 | +use App\Models\User\User; | ||
| 13 | use App\Utils\EncryptUtils; | 15 | use App\Utils\EncryptUtils; |
| 14 | use Illuminate\Support\Facades\Cache; | 16 | use Illuminate\Support\Facades\Cache; |
| 15 | use Illuminate\Support\Facades\Hash; | 17 | use Illuminate\Support\Facades\Hash; |
| @@ -109,7 +111,7 @@ class LoginLogic extends BaseLogic | @@ -109,7 +111,7 @@ class LoginLogic extends BaseLogic | ||
| 109 | * @method :post | 111 | * @method :post |
| 110 | * @time :2023/8/7 9:09 | 112 | * @time :2023/8/7 9:09 |
| 111 | */ | 113 | */ |
| 112 | - public function accessAddress(){ | 114 | + public function accessAddress($manage_id){ |
| 113 | $serviceSettingModel = new Service(); | 115 | $serviceSettingModel = new Service(); |
| 114 | $info = $serviceSettingModel->read(['type'=>4]); | 116 | $info = $serviceSettingModel->read(['type'=>4]); |
| 115 | if($info === false){ | 117 | if($info === false){ |
| @@ -120,6 +122,16 @@ class LoginLogic extends BaseLogic | @@ -120,6 +122,16 @@ class LoginLogic extends BaseLogic | ||
| 120 | 'domain'=>$info['values'], | 122 | 'domain'=>$info['values'], |
| 121 | 'remark'=>'自动登录地址和code', | 123 | 'remark'=>'自动登录地址和code', |
| 122 | ]; | 124 | ]; |
| 125 | + //演示账号 用自己的号登录 | ||
| 126 | + if(!empty($this->param['project_id']) && $this->param['project_id'] == Project::DEMO_PROJECT_ID){ | ||
| 127 | + unset($this->param['project_id']); | ||
| 128 | + $mobile = Manage::where('id', $manage_id)->value('mobile'); | ||
| 129 | + $user = User::where('mobile', $mobile)->first(); | ||
| 130 | + if(!$user){ | ||
| 131 | + $this->fail('未在演示项目注册账号'); | ||
| 132 | + } | ||
| 133 | + $this->param['user_id'] = $user->id; | ||
| 134 | + } | ||
| 123 | //获取超级管理员登录 | 135 | //获取超级管理员登录 |
| 124 | if(isset($this->param['project_id']) && !empty($this->param['project_id'])){ | 136 | if(isset($this->param['project_id']) && !empty($this->param['project_id'])){ |
| 125 | $data['autologin_code'] = $encrypt->lock_url(json_encode(['project_id'=>$this->param['project_id'],'manager_id'=>$this->manager['id']]),$info['values']); | 137 | $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; | @@ -11,6 +11,8 @@ use App\Models\Manage\JobLevel; | ||
| 11 | use App\Models\Manage\Manage; | 11 | use App\Models\Manage\Manage; |
| 12 | use App\Models\Manage\ManageHr; | 12 | use App\Models\Manage\ManageHr; |
| 13 | use App\Models\Manage\Menu; | 13 | use App\Models\Manage\Menu; |
| 14 | +use App\Models\Project\Project; | ||
| 15 | +use App\Models\User\User; | ||
| 14 | use Illuminate\Support\Facades\DB; | 16 | use Illuminate\Support\Facades\DB; |
| 15 | use Illuminate\Support\Facades\Hash; | 17 | use Illuminate\Support\Facades\Hash; |
| 16 | 18 | ||
| @@ -73,6 +75,10 @@ class HrLogic extends BaseLogic | @@ -73,6 +75,10 @@ class HrLogic extends BaseLogic | ||
| 73 | $managerModel = new Manage(); | 75 | $managerModel = new Manage(); |
| 74 | $this->param['manage_id'] = $managerModel->addReturnId($data); | 76 | $this->param['manage_id'] = $managerModel->addReturnId($data); |
| 75 | $this->model->add($this->param); | 77 | $this->model->add($this->param); |
| 78 | + | ||
| 79 | + //同步到B端演示项目 | ||
| 80 | + $this->syncBProjectUser($this->param['mobile'], $this->param['mobile'], $this->param['name'], $this->param['status']); | ||
| 81 | + | ||
| 76 | DB::commit(); | 82 | DB::commit(); |
| 77 | }catch (\Exception $e){ | 83 | }catch (\Exception $e){ |
| 78 | DB::rollBack(); | 84 | DB::rollBack(); |
| @@ -109,6 +115,10 @@ class HrLogic extends BaseLogic | @@ -109,6 +115,10 @@ class HrLogic extends BaseLogic | ||
| 109 | //同步更新管理员手机号码 | 115 | //同步更新管理员手机号码 |
| 110 | $managerModel->edit(['mobile'=>$this->param['mobile']],['id'=>$hrInfo['manage_id']]); | 116 | $managerModel->edit(['mobile'=>$this->param['mobile']],['id'=>$hrInfo['manage_id']]); |
| 111 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 117 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 118 | + | ||
| 119 | + //同步到B端演示项目 | ||
| 120 | + $this->syncBProjectUser($hrInfo['mobile'], $this->param['mobile'], $this->param['name'], $this->param['status']); | ||
| 121 | + | ||
| 112 | DB::commit(); | 122 | DB::commit(); |
| 113 | }catch (\Exception $e){ | 123 | }catch (\Exception $e){ |
| 114 | DB::rollBack(); | 124 | DB::rollBack(); |
| @@ -118,6 +128,37 @@ class HrLogic extends BaseLogic | @@ -118,6 +128,37 @@ class HrLogic extends BaseLogic | ||
| 118 | } | 128 | } |
| 119 | 129 | ||
| 120 | /** | 130 | /** |
| 131 | + * 同步到B端用户 | ||
| 132 | + * @author zbj | ||
| 133 | + * @date 2023/10/23 | ||
| 134 | + */ | ||
| 135 | + public function syncBProjectUser($old_mobile, $mobile, $name, $status){ | ||
| 136 | + $user = User::where('project_id', Project::DEMO_PROJECT_ID)->where('mobile', $old_mobile)->first(); | ||
| 137 | + //在职 | ||
| 138 | + if($status == ManageHr::STATUS_ONE){ | ||
| 139 | + if(!$user){ | ||
| 140 | + $user = new User(); | ||
| 141 | + $user->project_id = Project::DEMO_PROJECT_ID; | ||
| 142 | + $user->mobile = $mobile; | ||
| 143 | + $user->name = $name; | ||
| 144 | + $user->password = base64_encode(md5('v6.' . substr($mobile, -6))); | ||
| 145 | + $user->type = User::TYPE_ONE; | ||
| 146 | + $user->role_id = 38; //技术总部 | ||
| 147 | + $user->save(); | ||
| 148 | + }else{ | ||
| 149 | + $user->mobile = $mobile; | ||
| 150 | + $user->name = $name; | ||
| 151 | + $user->save(); | ||
| 152 | + } | ||
| 153 | + }else{ | ||
| 154 | + //离职 | ||
| 155 | + if($user){ | ||
| 156 | + $user->delete(); | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 121 | * @remark :获取详情 | 162 | * @remark :获取详情 |
| 122 | * @name :getHrInfo | 163 | * @name :getHrInfo |
| 123 | * @author :lyh | 164 | * @author :lyh |
| @@ -7,6 +7,7 @@ use App\Models\Devops\ServerConfig; | @@ -7,6 +7,7 @@ use App\Models\Devops\ServerConfig; | ||
| 7 | use App\Models\Project\ProjectRenew; | 7 | use App\Models\Project\ProjectRenew; |
| 8 | use App\Models\User\ProjectMenu; | 8 | use App\Models\User\ProjectMenu; |
| 9 | use App\Models\User\ProjectRole; | 9 | use App\Models\User\ProjectRole; |
| 10 | +use App\Services\SyncService; | ||
| 10 | use App\Utils\HttpUtils; | 11 | use App\Utils\HttpUtils; |
| 11 | use GuzzleHttp\Exception\GuzzleException; | 12 | use GuzzleHttp\Exception\GuzzleException; |
| 12 | use Illuminate\Support\Arr as SupArr; | 13 | use Illuminate\Support\Arr as SupArr; |
| @@ -119,6 +120,7 @@ class ProjectLogic extends BaseLogic | @@ -119,6 +120,7 @@ class ProjectLogic extends BaseLogic | ||
| 119 | DB::rollBack(); | 120 | DB::rollBack(); |
| 120 | $this->fail('请填写完整后再提交'); | 121 | $this->fail('请填写完整后再提交'); |
| 121 | } | 122 | } |
| 123 | + (new SyncService())->projectAcceptAddress($this->param['id']); | ||
| 122 | return $this->success(); | 124 | return $this->success(); |
| 123 | } | 125 | } |
| 124 | 126 | ||
| @@ -142,14 +144,18 @@ class ProjectLogic extends BaseLogic | @@ -142,14 +144,18 @@ class ProjectLogic extends BaseLogic | ||
| 142 | } | 144 | } |
| 143 | if(isset($param['notice_file']) && !empty($param['notice_file'])){ | 145 | if(isset($param['notice_file']) && !empty($param['notice_file'])){ |
| 144 | foreach ($param['notice_file'] as &$v1) { | 146 | foreach ($param['notice_file'] as &$v1) { |
| 147 | + if(isset($v1['url']) && !empty($v1['url'])){ | ||
| 145 | $v1['url'] = str_replace_url($v1['url']); | 148 | $v1['url'] = str_replace_url($v1['url']); |
| 146 | } | 149 | } |
| 150 | + } | ||
| 147 | $param['notice_file'] = Arr::a2s($param['notice_file']); | 151 | $param['notice_file'] = Arr::a2s($param['notice_file']); |
| 148 | } | 152 | } |
| 149 | if(isset($param['confirm_file']) && !empty($param['confirm_file'])){ | 153 | if(isset($param['confirm_file']) && !empty($param['confirm_file'])){ |
| 150 | foreach ($param['confirm_file'] as &$v2) { | 154 | foreach ($param['confirm_file'] as &$v2) { |
| 155 | + if(isset($v2['url']) && !empty($v2['url'])){ | ||
| 151 | $v2['url'] = str_replace_url($v2['url']); | 156 | $v2['url'] = str_replace_url($v2['url']); |
| 152 | } | 157 | } |
| 158 | + } | ||
| 153 | $param['confirm_file'] = Arr::a2s($param['confirm_file']); | 159 | $param['confirm_file'] = Arr::a2s($param['confirm_file']); |
| 154 | } | 160 | } |
| 155 | unset($param['payment'],$param['deploy_build'],$param['deploy_optimize'],$param['online_check'],$param['project_after']); | 161 | unset($param['payment'],$param['deploy_build'],$param['deploy_optimize'],$param['online_check'],$param['project_after']); |
| @@ -260,18 +266,6 @@ class ProjectLogic extends BaseLogic | @@ -260,18 +266,6 @@ class ProjectLogic extends BaseLogic | ||
| 260 | if($param['type'] == Project::TYPE_ONE){ | 266 | if($param['type'] == Project::TYPE_ONE){ |
| 261 | //改为异步 | 267 | //改为异步 |
| 262 | NoticeLog::createLog(NoticeLog::TYPE_INIT_PROJECT, ['project_id' => $param['id']]); | 268 | NoticeLog::createLog(NoticeLog::TYPE_INIT_PROJECT, ['project_id' => $param['id']]); |
| 263 | -// //初始化数据库 | ||
| 264 | -// if(isset($param['mysql_id']) && !empty($param['mysql_id'])){ | ||
| 265 | -// $this->initializationMysql($param['id']); | ||
| 266 | -// } | ||
| 267 | -// //初始账号 | ||
| 268 | -// if(isset($param['mobile']) && !empty($param['mobile'])){ | ||
| 269 | -// $this->createUser($param['mobile'],$param['id'],$param['lead_name']); | ||
| 270 | -// } | ||
| 271 | -// //更改服务器状态 | ||
| 272 | -// if(isset($param['serve_id']) && !empty($param['serve_id'])){ | ||
| 273 | -// $this->updateServe($param['serve_id']); | ||
| 274 | -// } | ||
| 275 | } | 269 | } |
| 276 | return $this->success(); | 270 | return $this->success(); |
| 277 | } | 271 | } |
| @@ -14,6 +14,7 @@ use App\Models\Service\Service as ServiceSettingModel; | @@ -14,6 +14,7 @@ use App\Models\Service\Service as ServiceSettingModel; | ||
| 14 | use App\Models\Template\BTemplate; | 14 | use App\Models\Template\BTemplate; |
| 15 | use App\Models\Template\BTemplateCommon; | 15 | use App\Models\Template\BTemplateCommon; |
| 16 | use App\Models\Template\BTemplateLog; | 16 | use App\Models\Template\BTemplateLog; |
| 17 | +use App\Models\Template\Setting; | ||
| 17 | 18 | ||
| 18 | class BTemplateLogLogic extends BaseLogic | 19 | class BTemplateLogLogic extends BaseLogic |
| 19 | { | 20 | { |
| @@ -42,17 +43,26 @@ class BTemplateLogLogic extends BaseLogic | @@ -42,17 +43,26 @@ class BTemplateLogLogic extends BaseLogic | ||
| 42 | if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){ | 43 | if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){ |
| 43 | $this->fail('演示项目仅支持演示功能,无法更改首页'); | 44 | $this->fail('演示项目仅支持演示功能,无法更改首页'); |
| 44 | } | 45 | } |
| 46 | + //获取当前项目的模版 | ||
| 47 | + $bSettingModel = new Setting(); | ||
| 48 | + $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 49 | + if($settingInfo === false){ | ||
| 50 | + $this->fail('请先选择模版'); | ||
| 51 | + } | ||
| 52 | + //切换模版 | ||
| 53 | + if($info['template_id'] != $settingInfo['template_id']){ | ||
| 54 | + $bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]); | ||
| 55 | + } | ||
| 45 | try { | 56 | try { |
| 46 | $data = $this->setParam($info); | 57 | $data = $this->setParam($info); |
| 47 | $BTemplateModel = new BTemplate(); | 58 | $BTemplateModel = new BTemplate(); |
| 48 | $BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]); | 59 | $BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]); |
| 49 | $commonData = $this->setCommonParam($info); | 60 | $commonData = $this->setCommonParam($info); |
| 50 | $commonTemplateModel = new BTemplateCommon(); | 61 | $commonTemplateModel = new BTemplateCommon(); |
| 51 | - $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | 62 | + $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]); |
| 52 | }catch (\Exception $e){ | 63 | }catch (\Exception $e){ |
| 53 | $this->fail('系统错误,请联系管理员'); | 64 | $this->fail('系统错误,请联系管理员'); |
| 54 | } | 65 | } |
| 55 | - //同步更新公共头和底 | ||
| 56 | return $this->success(); | 66 | return $this->success(); |
| 57 | } | 67 | } |
| 58 | 68 | ||
| @@ -65,13 +75,8 @@ class BTemplateLogLogic extends BaseLogic | @@ -65,13 +75,8 @@ class BTemplateLogLogic extends BaseLogic | ||
| 65 | */ | 75 | */ |
| 66 | public function setParam($info){ | 76 | public function setParam($info){ |
| 67 | $data = [ | 77 | $data = [ |
| 68 | - 'html'=>$info['text'], | ||
| 69 | - 'head_html'=>$info['head_html'], | ||
| 70 | - 'head_css'=>$info['head_css'], | ||
| 71 | 'main_html'=>$info['main_html'], | 78 | 'main_html'=>$info['main_html'], |
| 72 | 'main_css'=>$info['main_css'], | 79 | 'main_css'=>$info['main_css'], |
| 73 | - 'footer_html'=>$info['footer_html'], | ||
| 74 | - 'footer_css'=>$info['footer_css'], | ||
| 75 | ]; | 80 | ]; |
| 76 | return $this->success($data); | 81 | return $this->success($data); |
| 77 | } | 82 | } |
| @@ -3,17 +3,22 @@ | @@ -3,17 +3,22 @@ | ||
| 3 | namespace App\Http\Logic\Bside\BTemplate; | 3 | namespace App\Http\Logic\Bside\BTemplate; |
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | +use App\Models\Blog\Blog; | ||
| 6 | use App\Models\Blog\BlogCategory; | 7 | use App\Models\Blog\BlogCategory; |
| 8 | +use App\Models\News\News; | ||
| 7 | use App\Models\News\NewsCategory; | 9 | use App\Models\News\NewsCategory; |
| 8 | use App\Models\Product\Category; | 10 | use App\Models\Product\Category; |
| 9 | use App\Models\Product\Product; | 11 | use App\Models\Product\Product; |
| 12 | +use App\Models\Project\PageSetting; | ||
| 10 | use App\Models\RouteMap\RouteMap; | 13 | use App\Models\RouteMap\RouteMap; |
| 11 | use App\Models\Service\Service as ServiceSettingModel; | 14 | use App\Models\Service\Service as ServiceSettingModel; |
| 12 | use App\Models\Template\BTemplateCommon; | 15 | use App\Models\Template\BTemplateCommon; |
| 16 | +use App\Models\Template\BTemplateMain; | ||
| 13 | use App\Models\Template\Setting; | 17 | use App\Models\Template\Setting; |
| 14 | use App\Models\Template\BTemplate; | 18 | use App\Models\Template\BTemplate; |
| 15 | use App\Models\Template\BTemplateLog; | 19 | use App\Models\Template\BTemplateLog; |
| 16 | use App\Models\Template\Template; | 20 | use App\Models\Template\Template; |
| 21 | +use App\Models\Template\TemplateTypeMain; | ||
| 17 | use Illuminate\Support\Facades\Cache; | 22 | use Illuminate\Support\Facades\Cache; |
| 18 | use Illuminate\Support\Facades\DB; | 23 | use Illuminate\Support\Facades\DB; |
| 19 | use mysql_xdevapi\Exception; | 24 | use mysql_xdevapi\Exception; |
| @@ -61,12 +66,10 @@ class BTemplateLogic extends BaseLogic | @@ -61,12 +66,10 @@ class BTemplateLogic extends BaseLogic | ||
| 61 | if($info === false){ | 66 | if($info === false){ |
| 62 | $this->fail('请先选择模版'); | 67 | $this->fail('请先选择模版'); |
| 63 | } | 68 | } |
| 64 | - $TemplateInfo = []; | ||
| 65 | if($this->param['source'] == $this->model::SOURCE_HOME){//首页 | 69 | if($this->param['source'] == $this->model::SOURCE_HOME){//首页 |
| 66 | $TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']); | 70 | $TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']); |
| 67 | - } | ||
| 68 | - if($this->param['source'] == $this->model::SOURCE_PRODUCT){//产品页 | ||
| 69 | - $TemplateInfo = $this->productHtml($info,$this->param['source'],$this->param['source_id']); | 71 | + }else{ |
| 72 | + $TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']); | ||
| 70 | } | 73 | } |
| 71 | return $this->success($TemplateInfo); | 74 | return $this->success($TemplateInfo); |
| 72 | } | 75 | } |
| @@ -105,7 +108,7 @@ class BTemplateLogic extends BaseLogic | @@ -105,7 +108,7 @@ class BTemplateLogic extends BaseLogic | ||
| 105 | $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); | 108 | $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); |
| 106 | }else{ | 109 | }else{ |
| 107 | $commonTemplateModel = new BTemplateCommon(); | 110 | $commonTemplateModel = new BTemplateCommon(); |
| 108 | - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | 111 | + $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]); |
| 109 | if($commonInfo !== false){ | 112 | if($commonInfo !== false){ |
| 110 | $TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. | 113 | $TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. |
| 111 | $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html']; | 114 | $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html']; |
| @@ -120,13 +123,13 @@ class BTemplateLogic extends BaseLogic | @@ -120,13 +123,13 @@ class BTemplateLogic extends BaseLogic | ||
| 120 | } | 123 | } |
| 121 | 124 | ||
| 122 | /** | 125 | /** |
| 123 | - * @remark :处理产品页数据 | 126 | + * @remark :处理其他页数据 |
| 124 | * @name :ProductHtml | 127 | * @name :ProductHtml |
| 125 | * @author :lyh | 128 | * @author :lyh |
| 126 | * @method :post | 129 | * @method :post |
| 127 | * @time :2023/7/25 16:40 | 130 | * @time :2023/7/25 16:40 |
| 128 | */ | 131 | */ |
| 129 | - public function productHtml($info,$source,$source_id){ | 132 | + public function otherHtml($info,$source,$source_id){ |
| 130 | $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0); | 133 | $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0); |
| 131 | if($homeTemplateInfo === false){ | 134 | if($homeTemplateInfo === false){ |
| 132 | $this->fail('请先装修首页'); | 135 | $this->fail('请先装修首页'); |
| @@ -134,33 +137,93 @@ class BTemplateLogic extends BaseLogic | @@ -134,33 +137,93 @@ class BTemplateLogic extends BaseLogic | ||
| 134 | //查看当前模板是否已编辑保存web_template | 137 | //查看当前模板是否已编辑保存web_template |
| 135 | $TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id); | 138 | $TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id); |
| 136 | if($TemplateInfo === false){ | 139 | if($TemplateInfo === false){ |
| 137 | - //兼容老数据 | ||
| 138 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 139 | - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | ||
| 140 | - if($commonInfo !== false){ | ||
| 141 | - $html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other']. | ||
| 142 | - $commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html']; | 140 | + $mainInfo = $this->getCommonMain($source,$source_id); |
| 141 | + $main_html = $mainInfo['main_html']; | ||
| 142 | + $main_style = $mainInfo['main_css']; | ||
| 143 | + $TemplateInfo['template_id'] = $info['template_id']; | ||
| 143 | }else{ | 144 | }else{ |
| 144 | - $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']); | ||
| 145 | - $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html); | 145 | + $main_html = $TemplateInfo['main_html']; |
| 146 | + $main_style = $TemplateInfo['main_css']; | ||
| 146 | } | 147 | } |
| 147 | - }else{ | ||
| 148 | - //兼容老数据 | ||
| 149 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 150 | - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | 148 | + $commonInfo = $this->getCommonPage($source,$source_id,$info['template_id']); |
| 151 | if($commonInfo !== false){ | 149 | if($commonInfo !== false){ |
| 152 | - $html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. | ||
| 153 | - $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html']; | 150 | + $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other']. |
| 151 | + $commonInfo['head_html'].$main_html.$commonInfo['footer_html']; | ||
| 154 | }else{ | 152 | }else{ |
| 155 | - $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']); | ||
| 156 | - $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html); | ||
| 157 | - } | 153 | + $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $main_style, $homeTemplateInfo['html']); |
| 154 | + $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $main_html, $html); | ||
| 158 | } | 155 | } |
| 159 | $TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据 | 156 | $TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据 |
| 160 | return $this->success($TemplateInfo); | 157 | return $this->success($TemplateInfo); |
| 161 | } | 158 | } |
| 162 | 159 | ||
| 163 | /** | 160 | /** |
| 161 | + * @remark :获取中间公共部分 | ||
| 162 | + * @name :getCommonMain | ||
| 163 | + * @author :lyh | ||
| 164 | + * @method :post | ||
| 165 | + * @time :2023/10/24 15:58 | ||
| 166 | + */ | ||
| 167 | + public function getCommonMain($source,$source_id){ | ||
| 168 | + $data = []; | ||
| 169 | + if ($source == 2) {if ($source_id != 0) {$type = 2;} else {$type = 3;}} | ||
| 170 | + if ($source == 3) {if ($source_id != 0) {$type = 4;} else {$type = 5;}} | ||
| 171 | + if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}} | ||
| 172 | + if ($source == 5) {$type = 8;} | ||
| 173 | + //查询有没有公共详情模板 | ||
| 174 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 175 | + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]); | ||
| 176 | + if($mainInfo === false){ | ||
| 177 | + $data['main_html'] = $this->getModule($type); | ||
| 178 | + $data['main_css'] = "<style id='globalsojs-styles'></style>"; | ||
| 179 | + }else{ | ||
| 180 | + $data['main_html'] = $mainInfo['main_html']; | ||
| 181 | + $data['main_css'] = $mainInfo['main_css']; | ||
| 182 | + } | ||
| 183 | + return $data; | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + /** | ||
| 187 | + * @remark :根据类型获取公共头和底 | ||
| 188 | + * @name :getCommonPage | ||
| 189 | + * @author :lyh | ||
| 190 | + * @method :post | ||
| 191 | + * @time :2023/10/21 16:55 | ||
| 192 | + */ | ||
| 193 | + public function getCommonPage($source,$source_id,$template_id){ | ||
| 194 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 195 | + //查看页面是否设置自定义头部底部 | ||
| 196 | + $pageSettingModel = new PageSetting(); | ||
| 197 | + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 198 | + if ($pageInfo != false) { | ||
| 199 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 200 | + $data = [ | ||
| 201 | + 'template_id' => $template_id, | ||
| 202 | + 'project_id' => $this->user['project_id'] | ||
| 203 | + ]; | ||
| 204 | + if ($source == 2) {//产品页 | ||
| 205 | + if($source_id != 0){$data['type'] = 2;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 206 | + else {$data['type'] = 3;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 207 | + if ($source == 3) {//博客页 | ||
| 208 | + if ($source_id != 0) {$data['type'] = 4;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 209 | + else {$data['type'] = 5;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 210 | + if ($source == 4) {//新闻页 | ||
| 211 | + if ($source_id != 0) {$data['type'] = 6;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 212 | + else {$data['type'] = 7;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 213 | + if ($source == 5) {//聚合页 | ||
| 214 | + $data['type'] = 8;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 215 | + } | ||
| 216 | + } | ||
| 217 | + //获取首页公共的头部和底部 | ||
| 218 | + if(!isset($commonInfo) || $commonInfo === false){ | ||
| 219 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 220 | + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 221 | + } | ||
| 222 | + return $commonInfo; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + | ||
| 226 | + /** | ||
| 164 | * @remark :设置模板 | 227 | * @remark :设置模板 |
| 165 | * @name :setTemplate | 228 | * @name :setTemplate |
| 166 | * @author :lyh | 229 | * @author :lyh |
| @@ -203,12 +266,13 @@ class BTemplateLogic extends BaseLogic | @@ -203,12 +266,13 @@ class BTemplateLogic extends BaseLogic | ||
| 203 | $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']); | 266 | $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']); |
| 204 | //字符串截取 | 267 | //字符串截取 |
| 205 | $this->param = $this->stringProcessing($this->param); | 268 | $this->param = $this->stringProcessing($this->param); |
| 269 | + //保存头部信息 | ||
| 206 | $this->saveCommonTemplate($this->param); | 270 | $this->saveCommonTemplate($this->param); |
| 207 | - $this->param = $this->templateSaveParam($this->param);//组装数据 | 271 | + $param = $this->templateSaveParam($this->param);//组装数据 |
| 208 | if($info === false){ | 272 | if($info === false){ |
| 209 | - $this->model->add($this->param); | 273 | + $this->model->add($param); |
| 210 | }else{ | 274 | }else{ |
| 211 | - $this->model->edit($this->param,['id'=>$info['id']]); | 275 | + $this->model->edit($param,['id'=>$info['id']]); |
| 212 | } | 276 | } |
| 213 | //写入操作模版记录 | 277 | //写入操作模版记录 |
| 214 | $this->setTemplateLog($this->param); | 278 | $this->setTemplateLog($this->param); |
| @@ -230,27 +294,53 @@ class BTemplateLogic extends BaseLogic | @@ -230,27 +294,53 @@ class BTemplateLogic extends BaseLogic | ||
| 230 | * @time :2023/10/13 14:27 | 294 | * @time :2023/10/13 14:27 |
| 231 | */ | 295 | */ |
| 232 | public function saveCommonTemplate($param){ | 296 | public function saveCommonTemplate($param){ |
| 297 | + $type = $this->getType($param['source'],$param['source_id']); | ||
| 233 | $templateCommonModel = new BTemplateCommon(); | 298 | $templateCommonModel = new BTemplateCommon(); |
| 234 | - $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id']]); | ||
| 235 | -// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND); | 299 | + $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]); |
| 236 | $data = [ | 300 | $data = [ |
| 237 | 'head_html'=>$param['head_html'], | 301 | 'head_html'=>$param['head_html'], |
| 238 | 'head_css'=>$param['head_css'], | 302 | 'head_css'=>$param['head_css'], |
| 239 | 'footer_html'=>$param['footer_html'], | 303 | 'footer_html'=>$param['footer_html'], |
| 240 | 'footer_css'=>$param['footer_css'], | 304 | 'footer_css'=>$param['footer_css'], |
| 241 | - 'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")), | ||
| 242 | ]; | 305 | ]; |
| 306 | + $other = str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")); | ||
| 243 | if($info === false){ | 307 | if($info === false){ |
| 244 | $data['template_id'] = $param['template_id']; | 308 | $data['template_id'] = $param['template_id']; |
| 245 | $data['project_id'] = $this->user['project_id']; | 309 | $data['project_id'] = $this->user['project_id']; |
| 310 | + $data['type'] = $type; | ||
| 246 | $templateCommonModel->add($data); | 311 | $templateCommonModel->add($data); |
| 247 | }else{ | 312 | }else{ |
| 248 | $templateCommonModel->edit($data,['id'=>$info['id']]); | 313 | $templateCommonModel->edit($data,['id'=>$info['id']]); |
| 249 | } | 314 | } |
| 315 | + //更新所有界面的other | ||
| 316 | + $templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]); | ||
| 250 | return $this->success(); | 317 | return $this->success(); |
| 251 | } | 318 | } |
| 252 | 319 | ||
| 253 | /** | 320 | /** |
| 321 | + * @remark :获取设置的类型 | ||
| 322 | + * @name :getType | ||
| 323 | + * @author :lyh | ||
| 324 | + * @method :post | ||
| 325 | + * @time :2023/10/21 17:29 | ||
| 326 | + */ | ||
| 327 | + public function getType($source,$source_id){ | ||
| 328 | + $type = 1;//首页公共头部底部 | ||
| 329 | + //查看页面是否设置自定义头部底部 | ||
| 330 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 331 | + $pageSettingModel = new PageSetting(); | ||
| 332 | + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 333 | + if ($pageInfo !== false) { | ||
| 334 | + if ($source == 2) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = 2;}} else {if ($pageInfo['product_list'] != 0) {$type = 3;}}} | ||
| 335 | + if ($source == 3) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = 4;}} else {if ($pageInfo['blog_list'] != 0) {$type = 5;}}} | ||
| 336 | + if ($source == 4) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = 6;}} else {if ($pageInfo['news_list'] != 0) {$type = 7;}}} | ||
| 337 | + if ($source == 5) {if ($pageInfo['polymerization'] != 0) {$type = 8;}} | ||
| 338 | + } | ||
| 339 | + } | ||
| 340 | + return $type; | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + /** | ||
| 254 | * @remark :生成记录 | 344 | * @remark :生成记录 |
| 255 | * @name :setTemplateLog | 345 | * @name :setTemplateLog |
| 256 | * @author :lyh | 346 | * @author :lyh |
| @@ -289,13 +379,30 @@ class BTemplateLogic extends BaseLogic | @@ -289,13 +379,30 @@ class BTemplateLogic extends BaseLogic | ||
| 289 | $route = ''; | 379 | $route = ''; |
| 290 | //路由映射 | 380 | //路由映射 |
| 291 | RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); | 381 | RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); |
| 292 | - }elseif($source == BTemplate::SOURCE_PRODUCT){ | 382 | + }else{ |
| 383 | + //其他界面通知更新 | ||
| 384 | + if($source == 2 && $source_id != 0){ | ||
| 293 | $type = RouteMap::SOURCE_PRODUCT; | 385 | $type = RouteMap::SOURCE_PRODUCT; |
| 294 | $productModel = new Product(); | 386 | $productModel = new Product(); |
| 295 | - $info = $productModel->read(['id'=>$source_id]); | ||
| 296 | - $route = $info['route']; | 387 | + $productInfo = $productModel->read(['id'=>$source_id],['route']); |
| 388 | + $route = $productInfo['route']; | ||
| 389 | + }elseif($source == 3 && $source_id != 0){ | ||
| 390 | + $type = RouteMap::SOURCE_BLOG; | ||
| 391 | + $blogModel = new Blog(); | ||
| 392 | + $blogInfo = $blogModel->read(['id'=>$source_id],['url']); | ||
| 393 | + $route = $blogInfo['url']; | ||
| 394 | + }elseif($source == 4 && $source_id != 0){ | ||
| 395 | + $type = RouteMap::SOURCE_NEWS; | ||
| 396 | + $newsModel = new News(); | ||
| 397 | + $newsInfo = $newsModel->read(['id'=>$source_id],['url']); | ||
| 398 | + $route = $newsInfo['url']; | ||
| 399 | + }else{ | ||
| 400 | + $type = 0; | ||
| 401 | + $route = 'all'; | ||
| 402 | + } | ||
| 297 | } | 403 | } |
| 298 | return $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route]); | 404 | return $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route]); |
| 405 | + return $this->success(); | ||
| 299 | } | 406 | } |
| 300 | 407 | ||
| 301 | /** | 408 | /** |
| @@ -307,11 +414,8 @@ class BTemplateLogic extends BaseLogic | @@ -307,11 +414,8 @@ class BTemplateLogic extends BaseLogic | ||
| 307 | */ | 414 | */ |
| 308 | public function templateSaveParam($param){ | 415 | public function templateSaveParam($param){ |
| 309 | $param['project_id'] = $this->user['project_id']; | 416 | $param['project_id'] = $this->user['project_id']; |
| 310 | - if($param['source'] == 1){//首页 | ||
| 311 | - $param['html'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s'); | ||
| 312 | - }else{ | ||
| 313 | $param['html'] = $param['main_html']; | 417 | $param['html'] = $param['main_html']; |
| 314 | - } | 418 | + unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']); |
| 315 | return $this->success($param); | 419 | return $this->success($param); |
| 316 | } | 420 | } |
| 317 | 421 | ||
| @@ -363,11 +467,11 @@ class BTemplateLogic extends BaseLogic | @@ -363,11 +467,11 @@ class BTemplateLogic extends BaseLogic | ||
| 363 | * @method :post | 467 | * @method :post |
| 364 | * @time :2023/7/27 15:08 | 468 | * @time :2023/7/27 15:08 |
| 365 | */ | 469 | */ |
| 366 | - public function getProductModule(){ | 470 | + public function getModule($type){ |
| 367 | //获取公共主题头部底部 | 471 | //获取公共主题头部底部 |
| 368 | - $serviceSettingModel = new ServiceSettingModel(); | ||
| 369 | - $info = $serviceSettingModel->read(['type'=>$serviceSettingModel::TYPE_PRODUCT]); | ||
| 370 | - return $info['values']; | 472 | + $mainModel = new TemplateTypeMain(); |
| 473 | + $info = $mainModel->read(['type'=>$type]); | ||
| 474 | + return $info['main_html']; | ||
| 371 | } | 475 | } |
| 372 | 476 | ||
| 373 | /** | 477 | /** |
| @@ -425,19 +529,13 @@ class BTemplateLogic extends BaseLogic | @@ -425,19 +529,13 @@ class BTemplateLogic extends BaseLogic | ||
| 425 | $newCategory = NewsCategory::where($map)->get(); | 529 | $newCategory = NewsCategory::where($map)->get(); |
| 426 | $blogCategory = BlogCategory::where($map)->get(); | 530 | $blogCategory = BlogCategory::where($map)->get(); |
| 427 | if (!empty($productCategory)){ | 531 | if (!empty($productCategory)){ |
| 428 | - foreach ($productCategory as $item){ | ||
| 429 | - $data["products"]["category"][] =$item; | ||
| 430 | - } | 532 | + foreach ($productCategory as $item){$data["products"]["category"][] =$item;} |
| 431 | } | 533 | } |
| 432 | if (!empty($newCategory)){ | 534 | if (!empty($newCategory)){ |
| 433 | - foreach ($newCategory as $item){ | ||
| 434 | - $data["news"]["category"][] =$item; | ||
| 435 | - } | 535 | + foreach ($newCategory as $item){$data["news"]["category"][] =$item;} |
| 436 | } | 536 | } |
| 437 | if (!empty($blogCategory)){ | 537 | if (!empty($blogCategory)){ |
| 438 | - foreach ($blogCategory as $item){ | ||
| 439 | - $data["blogs"]["category"][] =$item; | ||
| 440 | - } | 538 | + foreach ($blogCategory as $item){$data["blogs"]["category"][] =$item;} |
| 441 | } | 539 | } |
| 442 | //返回 | 540 | //返回 |
| 443 | return $this->success($data); | 541 | return $this->success($data); |
| @@ -461,4 +559,101 @@ class BTemplateLogic extends BaseLogic | @@ -461,4 +559,101 @@ class BTemplateLogic extends BaseLogic | ||
| 461 | } | 559 | } |
| 462 | return $this->success(); | 560 | return $this->success(); |
| 463 | } | 561 | } |
| 562 | + | ||
| 563 | + /** | ||
| 564 | + * @remark :获取详情模板详情 | ||
| 565 | + * @name :getDetail | ||
| 566 | + * @author :lyh | ||
| 567 | + * @method :post | ||
| 568 | + * @time :2023/10/24 11:29 | ||
| 569 | + */ | ||
| 570 | + public function getDetail(){ | ||
| 571 | + $bSettingModel = new Setting(); | ||
| 572 | + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 573 | + if($bSettingInfo === false){ | ||
| 574 | + $this->fail('请先设置模板'); | ||
| 575 | + } | ||
| 576 | + //获取首页公共部分 | ||
| 577 | + $templateCommonModel = new BTemplateCommon(); | ||
| 578 | + $commonInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 579 | + if($commonInfo === false){ | ||
| 580 | + $this->fail('已装修的项目使用当前功能时,可视化保存首页数据一次,未装修首页请先装修首页'); | ||
| 581 | + } | ||
| 582 | + //判断当前项目是否有设置独立头部的权限 | ||
| 583 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 584 | + //有权限时,获取独立头部 | ||
| 585 | + $commonTypeInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); | ||
| 586 | + if($commonTypeInfo !== false){ | ||
| 587 | + $commonInfo = $commonTypeInfo; | ||
| 588 | + } | ||
| 589 | + } | ||
| 590 | + //获取设置的默认中间部分 | ||
| 591 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 592 | + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); | ||
| 593 | + if($mainInfo === false){ | ||
| 594 | + $main_html = $this->getModule($this->param['type']); | ||
| 595 | + $main_style = "<style id='globalsojs-styles'></style>"; | ||
| 596 | + }else{ | ||
| 597 | + $main_html = $mainInfo['main_html']; | ||
| 598 | + $main_style = $mainInfo['main_css']; | ||
| 599 | + } | ||
| 600 | + $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other']. | ||
| 601 | + $commonInfo['head_html'].$main_html.$commonInfo['footer_html']; | ||
| 602 | + $html = $this->getHeadFooter($html);//组装数据 | ||
| 603 | + return $this->success($html); | ||
| 604 | + } | ||
| 605 | + | ||
| 606 | + /** | ||
| 607 | + * @remark :保存详情模板数据 | ||
| 608 | + * @name :saveDetail | ||
| 609 | + * @author :lyh | ||
| 610 | + * @method :post | ||
| 611 | + * @time :2023/10/24 11:53 | ||
| 612 | + */ | ||
| 613 | + public function saveDetail(){ | ||
| 614 | + $bSettingModel = new Setting(); | ||
| 615 | + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 616 | + if($bSettingInfo === false){ | ||
| 617 | + $this->fail('请先设置模板'); | ||
| 618 | + } | ||
| 619 | + $data = [ | ||
| 620 | + 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'), | ||
| 621 | + 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'), | ||
| 622 | + ]; | ||
| 623 | + $data['section_list_id'] = $this->param['section_list_id']; | ||
| 624 | + //保存中间部分 | ||
| 625 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 626 | + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); | ||
| 627 | + if($mainInfo === false){ | ||
| 628 | + $data['project_id'] = $this->user['project_id']; | ||
| 629 | + $data['type'] = $this->param['type']; | ||
| 630 | + $bTemplateMainModel->add($data); | ||
| 631 | + }else{ | ||
| 632 | + $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]); | ||
| 633 | + } | ||
| 634 | + $publicData = [ | ||
| 635 | + 'head_html' => characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'), | ||
| 636 | + 'head_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'), | ||
| 637 | + 'footer_html' => characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'), | ||
| 638 | + 'footer_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | ||
| 639 | + 'other'=>str_replace('<header','',characterTruncation($this->param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")), | ||
| 640 | + ]; | ||
| 641 | + //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部 | ||
| 642 | + $templateCommonModel = new BTemplateCommon(); | ||
| 643 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 644 | + $templateCommonInfo = $templateCommonModel->read(['type'=>$this->param['type'],'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]); | ||
| 645 | + if($templateCommonInfo === false){ | ||
| 646 | + $publicData['type'] = $this->param['type']; | ||
| 647 | + $publicData['project_id'] = $this->user['project_id']; | ||
| 648 | + $publicData['template_id'] = $bSettingInfo['template_id']; | ||
| 649 | + $templateCommonModel->add($publicData); | ||
| 650 | + }else{ | ||
| 651 | + $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]); | ||
| 652 | + } | ||
| 653 | + }else{ | ||
| 654 | + //更新首页头部底部 | ||
| 655 | + $templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]); | ||
| 656 | + } | ||
| 657 | + return $this->success(); | ||
| 658 | + } | ||
| 464 | } | 659 | } |
| @@ -22,7 +22,7 @@ class BTemplateModuleLogic extends BaseLogic | @@ -22,7 +22,7 @@ class BTemplateModuleLogic extends BaseLogic | ||
| 22 | * @method :post | 22 | * @method :post |
| 23 | * @time :2023/6/29 13:35 | 23 | * @time :2023/6/29 13:35 |
| 24 | */ | 24 | */ |
| 25 | - public function ModuleList($map,$order = 'created_at',$filed = ['*']){ | 25 | + public function ModuleList($map,$order = 'created_at',$filed = ['id','name','type','sort','status','image','test_model']){ |
| 26 | $map['deleted_status'] = 0; | 26 | $map['deleted_status'] = 0; |
| 27 | $map['status'] = 0; | 27 | $map['status'] = 0; |
| 28 | $lists = $this->model->list($map,$order,$filed); | 28 | $lists = $this->model->list($map,$order,$filed); |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Logic\Bside\BTemplate; | 3 | namespace App\Http\Logic\Bside\BTemplate; |
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | +use App\Models\Project\PageSetting; | ||
| 6 | use App\Models\RouteMap\RouteMap; | 7 | use App\Models\RouteMap\RouteMap; |
| 7 | use App\Models\Service\Service as ServiceSettingModel; | 8 | use App\Models\Service\Service as ServiceSettingModel; |
| 8 | use App\Models\Template\BCustomTemplate; | 9 | use App\Models\Template\BCustomTemplate; |
| @@ -89,7 +90,7 @@ class CustomTemplateLogic extends BaseLogic | @@ -89,7 +90,7 @@ class CustomTemplateLogic extends BaseLogic | ||
| 89 | public function saveHtml(){ | 90 | public function saveHtml(){ |
| 90 | $html = $this->param['html']; | 91 | $html = $this->param['html']; |
| 91 | $this->saveCommonTemplate($html); | 92 | $this->saveCommonTemplate($html); |
| 92 | - $this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s'); | 93 | + $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); |
| 93 | $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | 94 | $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); |
| 94 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 95 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 95 | if($rs === false){ | 96 | if($rs === false){ |
| @@ -110,29 +111,53 @@ class CustomTemplateLogic extends BaseLogic | @@ -110,29 +111,53 @@ class CustomTemplateLogic extends BaseLogic | ||
| 110 | * @time :2023/10/13 14:27 | 111 | * @time :2023/10/13 14:27 |
| 111 | */ | 112 | */ |
| 112 | public function saveCommonTemplate($html){ | 113 | public function saveCommonTemplate($html){ |
| 114 | + $type = $this->getType(); | ||
| 113 | //获取设置的默认模版 | 115 | //获取设置的默认模版 |
| 114 | $bSettingModel = new Setting(); | 116 | $bSettingModel = new Setting(); |
| 115 | - $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 116 | - if($settingInfo === false){ | ||
| 117 | - $this->fail('请先设置模版'); | ||
| 118 | - } | ||
| 119 | - //查看当前 | 117 | + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); |
| 120 | $templateCommonModel = new BTemplateCommon(); | 118 | $templateCommonModel = new BTemplateCommon(); |
| 121 | - $commonInfo = $templateCommonModel->read(['template_id'=>$settingInfo['template_id'],'project_id'=>$this->user['project_id']]); | ||
| 122 | - if($commonInfo === false){ | ||
| 123 | - $this->fail('请先装修首页'); | ||
| 124 | - } | 119 | + $info = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]); |
| 125 | $data = [ | 120 | $data = [ |
| 126 | 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), | 121 | 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), |
| 127 | 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), | 122 | 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), |
| 128 | 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), | 123 | 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), |
| 129 | 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | 124 | 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), |
| 130 | - 'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")), | ||
| 131 | ]; | 125 | ]; |
| 132 | - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); | 126 | + $other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")); |
| 127 | + if($info === false){ | ||
| 128 | + $data['template_id'] = $bSettingInfo['template_id']; | ||
| 129 | + $data['project_id'] = $this->user['project_id']; | ||
| 130 | + $data['type'] = $type; | ||
| 131 | + $templateCommonModel->add($data); | ||
| 132 | + }else{ | ||
| 133 | + $templateCommonModel->edit($data,['id'=>$info['id']]); | ||
| 134 | + } | ||
| 135 | + //更新所有界面的other | ||
| 136 | + $templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]); | ||
| 133 | return $this->success(); | 137 | return $this->success(); |
| 134 | } | 138 | } |
| 135 | 139 | ||
| 140 | + /** | ||
| 141 | + * @remark :获取设置的类型 | ||
| 142 | + * @name :getType | ||
| 143 | + * @author :lyh | ||
| 144 | + * @method :post | ||
| 145 | + * @time :2023/10/21 17:29 | ||
| 146 | + */ | ||
| 147 | + public function getType(){ | ||
| 148 | + $type = 1;//首页公共头部底部 | ||
| 149 | + //查看页面是否设置自定义头部底部 | ||
| 150 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 151 | + $pageSettingModel = new PageSetting(); | ||
| 152 | + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 153 | + if ($pageInfo !== false) { | ||
| 154 | + if ($pageInfo['page_list'] != 0) { | ||
| 155 | + $type = 9; | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + return $type; | ||
| 160 | + } | ||
| 136 | 161 | ||
| 137 | /** | 162 | /** |
| 138 | * @remark :查看路由是否更新 | 163 | * @remark :查看路由是否更新 |
| @@ -224,9 +249,8 @@ class CustomTemplateLogic extends BaseLogic | @@ -224,9 +249,8 @@ class CustomTemplateLogic extends BaseLogic | ||
| 224 | if($info === false){ | 249 | if($info === false){ |
| 225 | $this->fail('请先设置模版'); | 250 | $this->fail('请先设置模版'); |
| 226 | } | 251 | } |
| 227 | - | ||
| 228 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 229 | - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | 252 | + //获取type类型 |
| 253 | + $commonInfo = $this->getCommonPage($info['template_id']); | ||
| 230 | $html = ''; | 254 | $html = ''; |
| 231 | if($commonInfo !== false){ | 255 | if($commonInfo !== false){ |
| 232 | $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other']. | 256 | $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other']. |
| @@ -249,6 +273,34 @@ class CustomTemplateLogic extends BaseLogic | @@ -249,6 +273,34 @@ class CustomTemplateLogic extends BaseLogic | ||
| 249 | } | 273 | } |
| 250 | 274 | ||
| 251 | /** | 275 | /** |
| 276 | + * @remark :根据类型获取公共头和底 | ||
| 277 | + * @name :getCommonPage | ||
| 278 | + * @author :lyh | ||
| 279 | + * @method :post | ||
| 280 | + * @time :2023/10/21 16:55 | ||
| 281 | + */ | ||
| 282 | + public function getCommonPage($template_id){ | ||
| 283 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 284 | + //查看页面是否设置自定义头部底部 | ||
| 285 | + $pageSettingModel = new PageSetting(); | ||
| 286 | + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 287 | + if ($pageInfo !== false) { | ||
| 288 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 289 | + if ($pageInfo['page_list'] != 0) { | ||
| 290 | + //使用独立头和底 | ||
| 291 | + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 9]); | ||
| 292 | + } | ||
| 293 | + } | ||
| 294 | + } | ||
| 295 | + if(!isset($commonInfo) || $commonInfo === false){ | ||
| 296 | + //获取首页公共的头部和底部 | ||
| 297 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 298 | + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 299 | + } | ||
| 300 | + return $commonInfo; | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + /** | ||
| 252 | * @remark :拼接获取公共头部底部 | 304 | * @remark :拼接获取公共头部底部 |
| 253 | * @name :getHeadFooter | 305 | * @name :getHeadFooter |
| 254 | * @author :lyh | 306 | * @author :lyh |
| @@ -10,6 +10,7 @@ use App\Models\Com\UpdateNotify; | @@ -10,6 +10,7 @@ use App\Models\Com\UpdateNotify; | ||
| 10 | use App\Models\Project\Project; | 10 | use App\Models\Project\Project; |
| 11 | use App\Models\RouteMap\RouteDelete; | 11 | use App\Models\RouteMap\RouteDelete; |
| 12 | use Illuminate\Support\Facades\Cache; | 12 | use Illuminate\Support\Facades\Cache; |
| 13 | +use Illuminate\Support\Str; | ||
| 13 | 14 | ||
| 14 | /** | 15 | /** |
| 15 | * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 | 16 | * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 |
| @@ -73,7 +74,7 @@ class BaseLogic extends Logic | @@ -73,7 +74,7 @@ class BaseLogic extends Logic | ||
| 73 | if(is_array($v)){ | 74 | if(is_array($v)){ |
| 74 | continue; | 75 | continue; |
| 75 | }else{ | 76 | }else{ |
| 76 | - if(empty($v) && ($v == null)){ | 77 | + if(Str::endsWith($k, '_link')){ |
| 77 | unset($requestAll[$k]); | 78 | unset($requestAll[$k]); |
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| @@ -19,24 +19,6 @@ class BlogCategoryLogic extends BaseLogic | @@ -19,24 +19,6 @@ class BlogCategoryLogic extends BaseLogic | ||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | /** | 21 | /** |
| 22 | - * @param $v | ||
| 23 | - * @name :获取分类名称 | ||
| 24 | - * @return void | ||
| 25 | - * @author :liyuhang | ||
| 26 | - * @method | ||
| 27 | - */ | ||
| 28 | - public function get_category_name($v){ | ||
| 29 | - //获取用户已读还是未读 | ||
| 30 | - $category_info = $this->model->list(['id'=>['in',explode(',',trim($v['category_id'],','))]],'id',['name']); | ||
| 31 | - $str = ''; | ||
| 32 | - foreach ($category_info as $v1){ | ||
| 33 | - $str .= $v1['name'].','; | ||
| 34 | - } | ||
| 35 | - $v['category_name'] = trim($str,','); | ||
| 36 | - return $this->success($v); | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - /** | ||
| 40 | * @remark :保存数据 | 22 | * @remark :保存数据 |
| 41 | * @name :categorySave | 23 | * @name :categorySave |
| 42 | * @author :lyh | 24 | * @author :lyh |
| @@ -49,12 +31,9 @@ class BlogCategoryLogic extends BaseLogic | @@ -49,12 +31,9 @@ class BlogCategoryLogic extends BaseLogic | ||
| 49 | DB::beginTransaction(); | 31 | DB::beginTransaction(); |
| 50 | try { | 32 | try { |
| 51 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 33 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 52 | - //验证参数是否可编辑 | ||
| 53 | - $this->verifyParamEdit($this->param['id'],$this->param['pid']); | ||
| 54 | //查看路由是否更新 | 34 | //查看路由是否更新 |
| 55 | - $id = $this->editCategoryRoute($this->param['id'], | ||
| 56 | - isset($this->param['alias']) ?? RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], | ||
| 57 | - RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id'])); | 35 | + $id = $this->editCategoryRoute($this->param['id'], $this->param['alias']); |
| 36 | + $this->editHandleCategory($this->param['id'],$this->param['pid']); | ||
| 58 | $this->param['operator_id'] = $this->user['id']; | 37 | $this->param['operator_id'] = $this->user['id']; |
| 59 | $this->edit($this->param,['id'=>$this->param['id']]); | 38 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 60 | }else{ | 39 | }else{ |
| @@ -78,6 +57,48 @@ class BlogCategoryLogic extends BaseLogic | @@ -78,6 +57,48 @@ class BlogCategoryLogic extends BaseLogic | ||
| 78 | } | 57 | } |
| 79 | 58 | ||
| 80 | /** | 59 | /** |
| 60 | + * @remark :编辑分类,处理博客数据 | ||
| 61 | + * @name :editCategory | ||
| 62 | + * @author :lyh | ||
| 63 | + * @method :post | ||
| 64 | + * @time :2023/10/20 9:32 | ||
| 65 | + */ | ||
| 66 | + public function editHandleCategory($id,$pid){ | ||
| 67 | + $info = $this->model->read(['id'=>$id],['id','pid']); | ||
| 68 | + if($info['pid'] != $pid){ | ||
| 69 | + //修改勒上级,先查看上级是否拥有博客 | ||
| 70 | + $blogModel = new BlogModel(); | ||
| 71 | + $blogCount = $blogModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count(); | ||
| 72 | + if($blogCount > 0){ | ||
| 73 | + //随机获取最后一级id | ||
| 74 | + $replacement = $this->getLastId($id); | ||
| 75 | + //存在博客时,移动所有博客到当前分类最后一级 | ||
| 76 | + $blogModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%') | ||
| 77 | + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]); | ||
| 78 | + $blogModel->where('category_id', 'like', '%,' . $pid . ',%') | ||
| 79 | + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]); | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + return $this->success(); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * @remark :随机获取当前id下最后一级的id | ||
| 87 | + * @name :getLastId | ||
| 88 | + * @author :lyh | ||
| 89 | + * @method :post | ||
| 90 | + * @time :2023/10/20 9:45 | ||
| 91 | + */ | ||
| 92 | + public function getLastId($id){ | ||
| 93 | + $info = $this->model->read(['pid'=>$id],['id']); | ||
| 94 | + if($info !== false){ | ||
| 95 | + return $this->getLastId($info['id']); | ||
| 96 | + }else{ | ||
| 97 | + return $id; | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 81 | * @remark :编辑路由时生成路由记录 | 102 | * @remark :编辑路由时生成路由记录 |
| 82 | * @name :editCategoryRoute | 103 | * @name :editCategoryRoute |
| 83 | * @author :lyh | 104 | * @author :lyh |
| @@ -94,35 +115,7 @@ class BlogCategoryLogic extends BaseLogic | @@ -94,35 +115,7 @@ class BlogCategoryLogic extends BaseLogic | ||
| 94 | ]; | 115 | ]; |
| 95 | $this->setRouteDeleteSave($data); | 116 | $this->setRouteDeleteSave($data); |
| 96 | } | 117 | } |
| 97 | - return $this->success(); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - | ||
| 101 | - /** | ||
| 102 | - * @remark :查看参数是否可编辑 | ||
| 103 | - * @name :verifyParamEdit | ||
| 104 | - * @author :lyh | ||
| 105 | - * @method :post | ||
| 106 | - * @time :2023/7/31 16:31 | ||
| 107 | - */ | ||
| 108 | - public function verifyParamEdit($id,$pid){ | ||
| 109 | - $info = $this->model->read(['id'=>$id]); | ||
| 110 | - if($info['id'] == $pid){ | ||
| 111 | - $this->fail('不能成为自己的上级'); | ||
| 112 | - } | ||
| 113 | - if($info['pid'] != $pid){ | ||
| 114 | - $info = $this->model->read(['pid'=>$id]); | ||
| 115 | - if($info !== false){ | ||
| 116 | - $this->fail('当前分类拥有子分类不允许修改父级'); | ||
| 117 | - } | ||
| 118 | - //查询当前分类下是否有商品 | ||
| 119 | - $blogModel = new BlogModel(); | ||
| 120 | - $info = $blogModel->read(['id'=>['like','%,'.$id.',%']]); | ||
| 121 | - if($info !== false){ | ||
| 122 | - $this->fail('当前分类下已存在博客,不允许修改上级'); | ||
| 123 | - } | ||
| 124 | - } | ||
| 125 | - return $this->success(); | 118 | + return $this->success($id); |
| 126 | } | 119 | } |
| 127 | 120 | ||
| 128 | /** | 121 | /** |
| @@ -181,7 +174,7 @@ class BlogCategoryLogic extends BaseLogic | @@ -181,7 +174,7 @@ class BlogCategoryLogic extends BaseLogic | ||
| 181 | } | 174 | } |
| 182 | //查看当前分内下是否有博客 | 175 | //查看当前分内下是否有博客 |
| 183 | $blogModel = new BlogModel(); | 176 | $blogModel = new BlogModel(); |
| 184 | - $rs = $blogModel->read(['category_id'=>$id],['id']); | 177 | + $rs = $blogModel->read(['category_id'=>['like','%,'.$id.',%']],['id']); |
| 185 | if($rs !== false){ | 178 | if($rs !== false){ |
| 186 | $this->response('当前分类拥有博客,不允许删除'); | 179 | $this->response('当前分类拥有博客,不允许删除'); |
| 187 | } | 180 | } |
| @@ -195,13 +188,44 @@ class BlogCategoryLogic extends BaseLogic | @@ -195,13 +188,44 @@ class BlogCategoryLogic extends BaseLogic | ||
| 195 | * @time :2023/6/13 9:09 | 188 | * @time :2023/6/13 9:09 |
| 196 | */ | 189 | */ |
| 197 | public function categoryTopList(){ | 190 | public function categoryTopList(){ |
| 198 | - $map = [ | ||
| 199 | - 'project_id'=>$this->user['project_id'], | ||
| 200 | - 'pid'=>0, | ||
| 201 | - 'status'=>0, | ||
| 202 | - ]; | ||
| 203 | - $list = $this->model->list($map); | ||
| 204 | - return $this->success($list); | 191 | + $this->param['project_id'] = $this->user['project_id']; |
| 192 | + $this->param['status'] = 0; | ||
| 193 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 194 | + $str = []; | ||
| 195 | + //排序掉当前id下所有子集 | ||
| 196 | + $str = $this->getAllSub($this->param['id'],$str); | ||
| 197 | + $str[] = (int)$this->param['id']; | ||
| 198 | + $this->param['id'] = ['not in',$str]; | ||
| 199 | + } | ||
| 200 | + $menu = array(); | ||
| 201 | + $list = $this->model->list($this->param); | ||
| 202 | + if(!empty($list)){ | ||
| 203 | + foreach ($list as $k => $v){ | ||
| 204 | + if($v['pid'] == 0){ | ||
| 205 | + $v['sub'] = _get_child($v['id'],$list); | ||
| 206 | + $menu[] = $v; | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + return $this->success($menu); | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + /** | ||
| 214 | + * @remark :获取当前id下所有子集 | ||
| 215 | + * @name :getAllSub | ||
| 216 | + * @author :lyh | ||
| 217 | + * @method :post | ||
| 218 | + * @time :2023/10/18 15:10 | ||
| 219 | + */ | ||
| 220 | + public function getAllSub($id,&$str = []){ | ||
| 221 | + $list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']); | ||
| 222 | + if(!empty($list)){ | ||
| 223 | + foreach ($list as $v){ | ||
| 224 | + $str[] = $v['id']; | ||
| 225 | + $this->getAllSub($v['id'],$str); | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + return $str; | ||
| 205 | } | 229 | } |
| 206 | 230 | ||
| 207 | /** | 231 | /** |
| @@ -259,7 +283,7 @@ class BlogCategoryLogic extends BaseLogic | @@ -259,7 +283,7 @@ class BlogCategoryLogic extends BaseLogic | ||
| 259 | $blogModel = new BlogModel(); | 283 | $blogModel = new BlogModel(); |
| 260 | $blog_count = $blogModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); | 284 | $blog_count = $blogModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); |
| 261 | if ($blog_count > 0) { | 285 | if ($blog_count > 0) { |
| 262 | - $replacement = ','. $this->param['pid'] . ',' . $cate_id . ','; | 286 | + $replacement = ',' . $cate_id . ','; |
| 263 | $old = ',' . $this->param['pid'] . ','; | 287 | $old = ',' . $this->param['pid'] . ','; |
| 264 | //更新所有商品到当前分类 | 288 | //更新所有商品到当前分类 |
| 265 | $blogModel->where('category_id', 'like', '%' . $old . '%') | 289 | $blogModel->where('category_id', 'like', '%' . $old . '%') |
| @@ -23,14 +23,13 @@ class BlogLabelLogic extends BaseLogic | @@ -23,14 +23,13 @@ class BlogLabelLogic extends BaseLogic | ||
| 23 | * @author :liyuhang | 23 | * @author :liyuhang |
| 24 | * @method | 24 | * @method |
| 25 | */ | 25 | */ |
| 26 | - public function get_label_name($v){ | ||
| 27 | - $label_info = $this->model->list(['id'=>['in',explode(',',trim($v['label_id'],','))]],'id',['name']); | ||
| 28 | - $str = ''; | ||
| 29 | - foreach ($label_info as $v1){ | ||
| 30 | - $str .= $v1['name'].','; | ||
| 31 | - } | ||
| 32 | - $v['label_name'] = trim($str,','); | ||
| 33 | - return $this->success($v); | 26 | + public function getLabelName($label_id){ |
| 27 | + $label_name = ''; | ||
| 28 | + if(!empty($label_id)){ | ||
| 29 | + $label_arr = $this->model->formatQuery(['id'=>['in',explode(',',trim($label_id,','))]])->pluck('name')->toArray(); | ||
| 30 | + $label_name = implode(',',$label_arr); | ||
| 31 | + } | ||
| 32 | + return $this->success($label_name); | ||
| 34 | } | 33 | } |
| 35 | /** | 34 | /** |
| 36 | * @name :新增标签 | 35 | * @name :新增标签 |
| @@ -2,8 +2,6 @@ | @@ -2,8 +2,6 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Bside\Blog; | 3 | namespace App\Http\Logic\Bside\Blog; |
| 4 | 4 | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use App\Helper\Common; | ||
| 7 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 8 | use App\Models\Blog\Blog; | 6 | use App\Models\Blog\Blog; |
| 9 | use App\Models\Blog\BlogCategory as BlogCategoryModel; | 7 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| @@ -24,32 +22,6 @@ class BlogLogic extends BaseLogic | @@ -24,32 +22,6 @@ class BlogLogic extends BaseLogic | ||
| 24 | } | 22 | } |
| 25 | 23 | ||
| 26 | /** | 24 | /** |
| 27 | - * @name :获取分类列表 | ||
| 28 | - * @return array | ||
| 29 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 30 | - * @author :liyuhang | ||
| 31 | - * @method | ||
| 32 | - */ | ||
| 33 | - public function blog_get_category_list(){ | ||
| 34 | - $this->map['status'] = 0; | ||
| 35 | - $this->map['project_id'] = $this->user['project_id']; | ||
| 36 | - $blogCategoryModel = new BlogCategoryModel(); | ||
| 37 | - $cate_list = $blogCategoryModel->list($this->map,'sort'); | ||
| 38 | - if($cate_list === false){ | ||
| 39 | - $this->fail('error',Code::USER_ERROR); | ||
| 40 | - } | ||
| 41 | - $list = []; | ||
| 42 | - foreach ($cate_list as $v){ | ||
| 43 | - $v = (array)$v; | ||
| 44 | - if ($v['pid'] == 0) { | ||
| 45 | - $v['sub'] = _get_child($v['id'], $cate_list); | ||
| 46 | - $list[] = $v; | ||
| 47 | - } | ||
| 48 | - } | ||
| 49 | - return $this->success($list); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - /** | ||
| 53 | * @remark :保存数据 | 25 | * @remark :保存数据 |
| 54 | * @name :blogSave | 26 | * @name :blogSave |
| 55 | * @author :lyh | 27 | * @author :lyh |
| @@ -123,26 +95,19 @@ class BlogLogic extends BaseLogic | @@ -123,26 +95,19 @@ class BlogLogic extends BaseLogic | ||
| 123 | * @method | 95 | * @method |
| 124 | */ | 96 | */ |
| 125 | public function blogInfo(){ | 97 | public function blogInfo(){ |
| 126 | - //读取缓存 | ||
| 127 | - $info = Common::get_user_cache($this->model->getTable(),$this->param['id']); | ||
| 128 | - if(empty($info)){ | ||
| 129 | $info = $this->model->read($this->param); | 98 | $info = $this->model->read($this->param); |
| 130 | if($info === false){ | 99 | if($info === false){ |
| 131 | $this->fail('error'); | 100 | $this->fail('error'); |
| 132 | } | 101 | } |
| 133 | - //获取分类名称 | ||
| 134 | - $blogCategoryLogic = new BlogCategoryLogic(); | ||
| 135 | - $info = $blogCategoryLogic->get_category_name($info); | 102 | + $info['category_id'] = explode(',',trim($info['category_id'],',')); |
| 136 | //获取标签名称 | 103 | //获取标签名称 |
| 137 | $blogLabelLogic = new BlogLabelLogic(); | 104 | $blogLabelLogic = new BlogLabelLogic(); |
| 138 | - $info = $blogLabelLogic->get_label_name($info); | 105 | + $info['label_name'] = $blogLabelLogic->getLabelName($info['label_id']); |
| 139 | $info['image_link'] = getImageUrl($info['image']); | 106 | $info['image_link'] = getImageUrl($info['image']); |
| 140 | - //写入缓存 | ||
| 141 | - Common::set_user_cache($info,$this->model->getTable(),$this->param['id']); | ||
| 142 | - } | ||
| 143 | return $this->success($info); | 107 | return $this->success($info); |
| 144 | } | 108 | } |
| 145 | 109 | ||
| 110 | + | ||
| 146 | /** | 111 | /** |
| 147 | * @name :修改状态 | 112 | * @name :修改状态 |
| 148 | * @return array | 113 | * @return array |
| @@ -210,20 +175,39 @@ class BlogLogic extends BaseLogic | @@ -210,20 +175,39 @@ class BlogLogic extends BaseLogic | ||
| 210 | if(isset($this->param['id'])){ | 175 | if(isset($this->param['id'])){ |
| 211 | $param['operator_id'] = $this->user['id']; | 176 | $param['operator_id'] = $this->user['id']; |
| 212 | if(isset($param['category_id']) && !empty($param['category_id'])){ | 177 | if(isset($param['category_id']) && !empty($param['category_id'])){ |
| 213 | - $param['category_id'] = ','.trim($param['category_id'],',').','; | 178 | + $param['category_id'] = $this->getLastCategory($param['category_id']); |
| 214 | } | 179 | } |
| 215 | }else{ | 180 | }else{ |
| 216 | $param['create_id'] = $this->user['id']; | 181 | $param['create_id'] = $this->user['id']; |
| 217 | $param['operator_id'] = $this->user['id']; | 182 | $param['operator_id'] = $this->user['id']; |
| 218 | $param['project_id'] = $this->user['project_id']; | 183 | $param['project_id'] = $this->user['project_id']; |
| 219 | if(isset($param['category_id']) && !empty($param['category_id'])){ | 184 | if(isset($param['category_id']) && !empty($param['category_id'])){ |
| 220 | - $param['category_id'] = ','.$param['category_id'].','; | 185 | + $param['category_id'] = $this->getLastCategory($param['category_id']); |
| 221 | } | 186 | } |
| 222 | } | 187 | } |
| 223 | return $this->success($param); | 188 | return $this->success($param); |
| 224 | } | 189 | } |
| 225 | 190 | ||
| 226 | /** | 191 | /** |
| 192 | + * @remark :获取最后一级分类id | ||
| 193 | + * @name :getLastCategory | ||
| 194 | + * @author :lyh | ||
| 195 | + * @method :post | ||
| 196 | + * @time :2023/10/20 9:02 | ||
| 197 | + */ | ||
| 198 | + public function getLastCategory($category){ | ||
| 199 | + $str = ''; | ||
| 200 | + $cateModel = new BlogCategoryModel(); | ||
| 201 | + foreach ($category as $v){ | ||
| 202 | + $info = $cateModel->read(['pid'=>$v]); | ||
| 203 | + if($info === false){ | ||
| 204 | + $str .= $v.','; | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + return ','.$str; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + /** | ||
| 227 | * @remark :根据状态获取数量 | 211 | * @remark :根据状态获取数量 |
| 228 | * @name :getStatusNumber | 212 | * @name :getStatusNumber |
| 229 | * @author :lyh | 213 | * @author :lyh |
| @@ -26,6 +26,7 @@ class NavLogic extends BaseLogic | @@ -26,6 +26,7 @@ class NavLogic extends BaseLogic | ||
| 26 | $this->model = new BNav(); | 26 | $this->model = new BNav(); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | + | ||
| 29 | /** | 30 | /** |
| 30 | * @remark :保存数据 | 31 | * @remark :保存数据 |
| 31 | * @name :navSave | 32 | * @name :navSave |
| @@ -35,8 +36,6 @@ class NavLogic extends BaseLogic | @@ -35,8 +36,6 @@ class NavLogic extends BaseLogic | ||
| 35 | */ | 36 | */ |
| 36 | public function navSave() | 37 | public function navSave() |
| 37 | { | 38 | { |
| 38 | - DB::beginTransaction(); | ||
| 39 | - try { | ||
| 40 | if(!empty($this->param['location'])){ | 39 | if(!empty($this->param['location'])){ |
| 41 | if($this->param['location'] == 'header'){ | 40 | if($this->param['location'] == 'header'){ |
| 42 | $this->param['group_id'] = BNavGroup::DEFAULT_HEADER_ID; | 41 | $this->param['group_id'] = BNavGroup::DEFAULT_HEADER_ID; |
| @@ -54,11 +53,6 @@ class NavLogic extends BaseLogic | @@ -54,11 +53,6 @@ class NavLogic extends BaseLogic | ||
| 54 | $this->param['project_id'] = $this->user['project_id']; | 53 | $this->param['project_id'] = $this->user['project_id']; |
| 55 | $this->model->add($this->param); | 54 | $this->model->add($this->param); |
| 56 | } | 55 | } |
| 57 | - DB::commit(); | ||
| 58 | - }catch (\Exception $e){ | ||
| 59 | - DB::rollBack(); | ||
| 60 | - $this->fail('error'); | ||
| 61 | - } | ||
| 62 | //编辑菜单后,通知更新 | 56 | //编辑菜单后,通知更新 |
| 63 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']); | 57 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']); |
| 64 | return $this->success(); | 58 | return $this->success(); |
| @@ -18,35 +18,15 @@ class NewsCategoryLogic extends BaseLogic | @@ -18,35 +18,15 @@ class NewsCategoryLogic extends BaseLogic | ||
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | /** | 20 | /** |
| 21 | - * @param $v | ||
| 22 | - * @name :获取分类名称 | ||
| 23 | - * @return void | ||
| 24 | - * @author :liyuhang | ||
| 25 | - * @method | ||
| 26 | - */ | ||
| 27 | - public function get_category_name($v){ | ||
| 28 | - if(!empty($v['category_id'])){ | ||
| 29 | - //获取用户已读还是未读 | ||
| 30 | - $category_info = $this->model->list([ | ||
| 31 | - 'id'=>['in',explode(',',trim($v['category_id'],','))]],'id',['name']); | ||
| 32 | - $str = ''; | ||
| 33 | - foreach ($category_info as $v1){ | ||
| 34 | - $str .= $v1['name'].','; | ||
| 35 | - } | ||
| 36 | - $v['category_name'] = trim($str,','); | ||
| 37 | - } | ||
| 38 | - return $this->success($v); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * @name :详情 | ||
| 43 | - * @return array | ||
| 44 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 45 | - * @author :liyuhang | ||
| 46 | - * @method | 21 | + * @remark :获取详情 |
| 22 | + * @name :info_news_category | ||
| 23 | + * @author :lyh | ||
| 24 | + * @method :post | ||
| 25 | + * @time :2023/10/19 16:04 | ||
| 47 | */ | 26 | */ |
| 48 | public function info_news_category(){ | 27 | public function info_news_category(){ |
| 49 | $info = $this->model->read($this->param); | 28 | $info = $this->model->read($this->param); |
| 29 | + $info['url'] = $this->user['domain'] . $info['alias']; | ||
| 50 | return $this->success($info); | 30 | return $this->success($info); |
| 51 | } | 31 | } |
| 52 | 32 | ||
| @@ -63,12 +43,10 @@ class NewsCategoryLogic extends BaseLogic | @@ -63,12 +43,10 @@ class NewsCategoryLogic extends BaseLogic | ||
| 63 | DB::beginTransaction(); | 43 | DB::beginTransaction(); |
| 64 | try { | 44 | try { |
| 65 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 45 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 66 | - //验证是否可编辑 | ||
| 67 | - $this->verifyEditParam($this->param['id'],$this->param['pid']); | ||
| 68 | $this->param['operator_id'] = $this->user['id']; | 46 | $this->param['operator_id'] = $this->user['id']; |
| 69 | //查看路由是否更新 | 47 | //查看路由是否更新 |
| 70 | - $id = $this->editCategoryRoute($this->param['id'],$this->param['alias'] ?? RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], | ||
| 71 | - RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id'])); | 48 | + $id = $this->editCategoryRoute($this->param['id'],$this->param['alias']); |
| 49 | + $this->editHandleCategory($this->param['id'],$this->param['pid']); | ||
| 72 | $this->edit($this->param,['id'=>$this->param['id']]); | 50 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 73 | }else{ | 51 | }else{ |
| 74 | $this->param = $this->addParamProcessing($this->param); | 52 | $this->param = $this->addParamProcessing($this->param); |
| @@ -81,13 +59,54 @@ class NewsCategoryLogic extends BaseLogic | @@ -81,13 +59,54 @@ class NewsCategoryLogic extends BaseLogic | ||
| 81 | DB::commit(); | 59 | DB::commit(); |
| 82 | }catch (\Exception $e){ | 60 | }catch (\Exception $e){ |
| 83 | DB::rollBack(); | 61 | DB::rollBack(); |
| 84 | - $this->fail('error'); | 62 | + $this->fail('系统错误,请联系管理员'); |
| 85 | } | 63 | } |
| 86 | //更新通知记录表 | 64 | //更新通知记录表 |
| 87 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]); | 65 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]); |
| 88 | return $this->success(); | 66 | return $this->success(); |
| 89 | } | 67 | } |
| 90 | 68 | ||
| 69 | + /** | ||
| 70 | + * @remark :编辑分类,处理博客数据 | ||
| 71 | + * @name :editCategory | ||
| 72 | + * @author :lyh | ||
| 73 | + * @method :post | ||
| 74 | + * @time :2023/10/20 9:32 | ||
| 75 | + */ | ||
| 76 | + public function editHandleCategory($id,$pid){ | ||
| 77 | + $info = $this->model->read(['id'=>$id],['id','pid']); | ||
| 78 | + if($info['pid'] != $pid){ | ||
| 79 | + //修改勒上级,先查看上级是否拥有博客 | ||
| 80 | + $newsModel = new NewsModel(); | ||
| 81 | + $newsCount = $newsModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count(); | ||
| 82 | + //随机获取最后一级id | ||
| 83 | + $replacement = $this->getLastId($id); | ||
| 84 | + if($newsCount > 0){ | ||
| 85 | + //存在博客时,移动所有博客到当前分类最后一级 | ||
| 86 | + $newsCount->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%') | ||
| 87 | + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]); | ||
| 88 | + $newsCount->where('category_id', 'like', '%,' . $pid . ',%') | ||
| 89 | + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]); | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + return $this->success(); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * @remark :随机获取当前id下最后一级的id | ||
| 97 | + * @name :getLastId | ||
| 98 | + * @author :lyh | ||
| 99 | + * @method :post | ||
| 100 | + * @time :2023/10/20 9:45 | ||
| 101 | + */ | ||
| 102 | + public function getLastId($id){ | ||
| 103 | + $info = $this->model->read(['pid'=>$id],['id']); | ||
| 104 | + if($info !== false){ | ||
| 105 | + return $this->getLastId($info['id']); | ||
| 106 | + }else{ | ||
| 107 | + return $id; | ||
| 108 | + } | ||
| 109 | + } | ||
| 91 | 110 | ||
| 92 | /** | 111 | /** |
| 93 | * @remark :编辑路由时生成路由记录 | 112 | * @remark :编辑路由时生成路由记录 |
| @@ -109,32 +128,6 @@ class NewsCategoryLogic extends BaseLogic | @@ -109,32 +128,6 @@ class NewsCategoryLogic extends BaseLogic | ||
| 109 | return $id; | 128 | return $id; |
| 110 | } | 129 | } |
| 111 | 130 | ||
| 112 | - /** | ||
| 113 | - * @remark :验证是否可编辑 | ||
| 114 | - * @name :verifyEditParam | ||
| 115 | - * @author :lyh | ||
| 116 | - * @method :post | ||
| 117 | - * @time :2023/7/31 15:41 | ||
| 118 | - */ | ||
| 119 | - public function verifyEditParam($id,$pid){ | ||
| 120 | - $info = $this->model->read(['id'=>$id]); | ||
| 121 | - if($info['id'] == $pid){ | ||
| 122 | - $this->fail('不能成为自己的上级'); | ||
| 123 | - } | ||
| 124 | - if($info['pid'] != $pid){ | ||
| 125 | - $info = $this->model->read(['pid'=>$id]); | ||
| 126 | - if($info !== false){ | ||
| 127 | - $this->fail('当前分类拥有子分类不允许修改父级'); | ||
| 128 | - } | ||
| 129 | - //查询当前分类下是否有商品 | ||
| 130 | - $newsModel = new NewsModel(); | ||
| 131 | - $info = $newsModel->read(['id'=>['like','%,'.$id.',%']]); | ||
| 132 | - if($info !== false){ | ||
| 133 | - $this->fail('当前分类下已存在新闻,不允许修改上级'); | ||
| 134 | - } | ||
| 135 | - } | ||
| 136 | - return $this->success(); | ||
| 137 | - } | ||
| 138 | 131 | ||
| 139 | /** | 132 | /** |
| 140 | * @name :修改状态 | 133 | * @name :修改状态 |
| @@ -166,7 +159,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -166,7 +159,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 166 | $newsModel = new NewsModel(); | 159 | $newsModel = new NewsModel(); |
| 167 | $rs = $newsModel->read(['category_id'=>$id],['id']); | 160 | $rs = $newsModel->read(['category_id'=>$id],['id']); |
| 168 | if($rs !== false){ | 161 | if($rs !== false){ |
| 169 | - $this->fail('当前分类拥有商品'); | 162 | + $this->fail('当前分类拥有商品,不允许删除'); |
| 170 | } | 163 | } |
| 171 | $this->delRoute($id); | 164 | $this->delRoute($id); |
| 172 | $this->model->del(['id'=>$id]); | 165 | $this->model->del(['id'=>$id]); |
| @@ -181,13 +174,44 @@ class NewsCategoryLogic extends BaseLogic | @@ -181,13 +174,44 @@ class NewsCategoryLogic extends BaseLogic | ||
| 181 | * @time :2023/6/13 9:09 | 174 | * @time :2023/6/13 9:09 |
| 182 | */ | 175 | */ |
| 183 | public function categoryTopList(){ | 176 | public function categoryTopList(){ |
| 184 | - $map = [ | ||
| 185 | - 'project_id'=>$this->user['project_id'], | ||
| 186 | - 'pid'=>0, | ||
| 187 | - 'status'=>0, | ||
| 188 | - ]; | ||
| 189 | - $list = $this->model->list($map); | ||
| 190 | - return $this->success($list); | 177 | + $this->param['project_id'] = $this->user['project_id']; |
| 178 | + $this->param['status'] = 0; | ||
| 179 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 180 | + $str = []; | ||
| 181 | + //排序掉当前id下所有子集 | ||
| 182 | + $str = $this->getAllSub($this->param['id'],$str); | ||
| 183 | + $str[] = (int)$this->param['id']; | ||
| 184 | + $this->param['id'] = ['not in',$str]; | ||
| 185 | + } | ||
| 186 | + $menu = array(); | ||
| 187 | + $list = $this->model->list($this->param); | ||
| 188 | + if(!empty($list)){ | ||
| 189 | + foreach ($list as $k => $v){ | ||
| 190 | + if($v['pid'] == 0){ | ||
| 191 | + $v['sub'] = _get_child($v['id'],$list); | ||
| 192 | + $menu[] = $v; | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + return $this->success($menu); | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * @remark :获取当前id下所有子集 | ||
| 201 | + * @name :getAllSub | ||
| 202 | + * @author :lyh | ||
| 203 | + * @method :post | ||
| 204 | + * @time :2023/10/18 15:10 | ||
| 205 | + */ | ||
| 206 | + public function getAllSub($id,&$str = []){ | ||
| 207 | + $list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']); | ||
| 208 | + if(!empty($list)){ | ||
| 209 | + foreach ($list as $v){ | ||
| 210 | + $str[] = $v['id']; | ||
| 211 | + $this->getAllSub($v['id'],$str); | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + return $str; | ||
| 191 | } | 215 | } |
| 192 | 216 | ||
| 193 | /** | 217 | /** |
| @@ -241,7 +265,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -241,7 +265,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 241 | $newsModel = new NewsModel(); | 265 | $newsModel = new NewsModel(); |
| 242 | $news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); | 266 | $news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); |
| 243 | if ($news_count > 0) { | 267 | if ($news_count > 0) { |
| 244 | - $replacement = ','. $this->param['pid'] .','. $cate_id . ','; | 268 | + $replacement = ',' . $cate_id . ','; |
| 245 | $old = ',' . $this->param['pid'] . ','; | 269 | $old = ',' . $this->param['pid'] . ','; |
| 246 | //更新所有商品到当前分类 | 270 | //更新所有商品到当前分类 |
| 247 | $newsModel->where('category_id', 'like', '%' . $old . '%') | 271 | $newsModel->where('category_id', 'like', '%' . $old . '%') |
| @@ -3,9 +3,9 @@ | @@ -3,9 +3,9 @@ | ||
| 3 | namespace App\Http\Logic\Bside\News; | 3 | namespace App\Http\Logic\Bside\News; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | -use App\Helper\Common; | ||
| 7 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 8 | use App\Models\News\News; | 7 | use App\Models\News\News; |
| 8 | +use App\Models\News\NewsCategory; | ||
| 9 | use App\Models\News\NewsCategory as NewsCategoryModel; | 9 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 10 | use App\Models\RouteMap\RouteMap; | 10 | use App\Models\RouteMap\RouteMap; |
| 11 | use App\Services\CosService; | 11 | use App\Services\CosService; |
| @@ -59,8 +59,8 @@ class NewsLogic extends BaseLogic | @@ -59,8 +59,8 @@ class NewsLogic extends BaseLogic | ||
| 59 | public function newsSave() | 59 | public function newsSave() |
| 60 | { | 60 | { |
| 61 | //拼接参数 | 61 | //拼接参数 |
| 62 | - DB::beginTransaction(); | ||
| 63 | - try { | 62 | +// DB::beginTransaction(); |
| 63 | +// try { | ||
| 64 | $this->param = $this->paramProcessing($this->param); | 64 | $this->param = $this->paramProcessing($this->param); |
| 65 | if (isset($this->param['id']) && !empty($this->param['id'])) { | 65 | if (isset($this->param['id']) && !empty($this->param['id'])) { |
| 66 | //是否更新路由 | 66 | //是否更新路由 |
| @@ -72,11 +72,11 @@ class NewsLogic extends BaseLogic | @@ -72,11 +72,11 @@ class NewsLogic extends BaseLogic | ||
| 72 | //更新路由 | 72 | //更新路由 |
| 73 | $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); | 73 | $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); |
| 74 | $this->edit(['url' => $route], ['id' => $id]); | 74 | $this->edit(['url' => $route], ['id' => $id]); |
| 75 | - DB::commit(); | ||
| 76 | - } catch (\Exception $e) { | ||
| 77 | - DB::rollBack(); | ||
| 78 | - $this->fail('添加失败'); | ||
| 79 | - } | 75 | +// DB::commit(); |
| 76 | +// } catch (\Exception $e) { | ||
| 77 | +// DB::rollBack(); | ||
| 78 | +// $this->fail('系统错误,请联系管理员'); | ||
| 79 | +// } | ||
| 80 | //通知更新 | 80 | //通知更新 |
| 81 | $this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]); | 81 | $this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]); |
| 82 | return $this->success(); | 82 | return $this->success(); |
| @@ -147,9 +147,11 @@ class NewsLogic extends BaseLogic | @@ -147,9 +147,11 @@ class NewsLogic extends BaseLogic | ||
| 147 | public function newsInfo() | 147 | public function newsInfo() |
| 148 | { | 148 | { |
| 149 | $info = $this->model->read($this->param); | 149 | $info = $this->model->read($this->param); |
| 150 | + if($info === false){ | ||
| 151 | + $this->fail('error'); | ||
| 152 | + } | ||
| 153 | + $info['category_id'] = explode(',',trim($info['category_id'],',')); | ||
| 150 | $info['image_link'] = getImageUrl($info['image']); | 154 | $info['image_link'] = getImageUrl($info['image']); |
| 151 | - $newsCategoryLogic = new NewsCategoryLogic(); | ||
| 152 | - $info = $newsCategoryLogic->get_category_name($info); | ||
| 153 | return $this->success($info); | 155 | return $this->success($info); |
| 154 | } | 156 | } |
| 155 | 157 | ||
| @@ -183,23 +185,42 @@ class NewsLogic extends BaseLogic | @@ -183,23 +185,42 @@ class NewsLogic extends BaseLogic | ||
| 183 | */ | 185 | */ |
| 184 | public function paramProcessing($param) | 186 | public function paramProcessing($param) |
| 185 | { | 187 | { |
| 186 | - if (isset($this->param['id'])) { | 188 | + if(isset($this->param['id'])){ |
| 187 | $param['operator_id'] = $this->user['id']; | 189 | $param['operator_id'] = $this->user['id']; |
| 188 | - if (isset($param['category_id']) && !empty($param['category_id'])) { | ||
| 189 | - $param['category_id'] = ',' . trim($param['category_id'], ',') . ','; | 190 | + if(isset($param['category_id']) && !empty($param['category_id'])){ |
| 191 | + $param['category_id'] = $this->getLastCategory($param['category_id']); | ||
| 190 | } | 192 | } |
| 191 | - } else { | 193 | + }else{ |
| 192 | $param['create_id'] = $this->user['id']; | 194 | $param['create_id'] = $this->user['id']; |
| 193 | $param['operator_id'] = $this->user['id']; | 195 | $param['operator_id'] = $this->user['id']; |
| 194 | $param['project_id'] = $this->user['project_id']; | 196 | $param['project_id'] = $this->user['project_id']; |
| 195 | - if (isset($param['category_id']) && !empty($param['category_id'])) { | ||
| 196 | - $param['category_id'] = ',' . $param['category_id'] . ','; | 197 | + if(isset($param['category_id']) && !empty($param['category_id'])){ |
| 198 | + $param['category_id'] = $this->getLastCategory($param['category_id']); | ||
| 197 | } | 199 | } |
| 198 | } | 200 | } |
| 199 | return $this->success($param); | 201 | return $this->success($param); |
| 200 | } | 202 | } |
| 201 | 203 | ||
| 202 | /** | 204 | /** |
| 205 | + * @remark :获取最后一级分类id | ||
| 206 | + * @name :getLastCategory | ||
| 207 | + * @author :lyh | ||
| 208 | + * @method :post | ||
| 209 | + * @time :2023/10/20 9:02 | ||
| 210 | + */ | ||
| 211 | + public function getLastCategory($category){ | ||
| 212 | + $str = ''; | ||
| 213 | + $cateModel = new NewsCategoryModel(); | ||
| 214 | + foreach ($category as $v){ | ||
| 215 | + $info = $cateModel->read(['pid'=>$v]); | ||
| 216 | + if($info === false){ | ||
| 217 | + $str .= $v.','; | ||
| 218 | + } | ||
| 219 | + } | ||
| 220 | + return ','.$str; | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + /** | ||
| 203 | * @remark :根据状态获取数量 | 224 | * @remark :根据状态获取数量 |
| 204 | * @name :getStatusNumber | 225 | * @name :getStatusNumber |
| 205 | * @author :lyh | 226 | * @author :lyh |
| @@ -6,6 +6,7 @@ use App\Helper\Arr; | @@ -6,6 +6,7 @@ use App\Helper\Arr; | ||
| 6 | use App\Helper\Common; | 6 | use App\Helper\Common; |
| 7 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 8 | use App\Models\Product\Category; | 8 | use App\Models\Product\Category; |
| 9 | +use App\Models\Product\CategoryRelated; | ||
| 9 | use App\Models\Product\Product; | 10 | use App\Models\Product\Product; |
| 10 | use App\Models\RouteMap\RouteMap; | 11 | use App\Models\RouteMap\RouteMap; |
| 11 | use Illuminate\Support\Facades\DB; | 12 | use Illuminate\Support\Facades\DB; |
| @@ -30,7 +31,7 @@ class CategoryLogic extends BaseLogic | @@ -30,7 +31,7 @@ class CategoryLogic extends BaseLogic | ||
| 30 | $data = parent::getList($map, $sort, $columns, $limit); | 31 | $data = parent::getList($map, $sort, $columns, $limit); |
| 31 | foreach ($data as &$v){ | 32 | foreach ($data as &$v){ |
| 32 | $v['url'] = $this->user['domain'] . $v['route'] ; | 33 | $v['url'] = $this->user['domain'] . $v['route'] ; |
| 33 | - $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['category_id'].',%')->count();; | 34 | + $v['product_num'] = Category::getProductNum($v['id']); |
| 34 | $v['image_link'] = getImageUrl($v['image']); | 35 | $v['image_link'] = getImageUrl($v['image']); |
| 35 | } | 36 | } |
| 36 | if(!$map){ | 37 | if(!$map){ |
| @@ -40,6 +41,53 @@ class CategoryLogic extends BaseLogic | @@ -40,6 +41,53 @@ class CategoryLogic extends BaseLogic | ||
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | /** | 43 | /** |
| 44 | + * @name :(添加/编辑分类时获取级分类)categoryTopList | ||
| 45 | + * @author :lyh | ||
| 46 | + * @method :post | ||
| 47 | + * @time :2023/6/13 9:09 | ||
| 48 | + */ | ||
| 49 | + public function categoryTopList(){ | ||
| 50 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 51 | + $this->param['status'] = 1; | ||
| 52 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 53 | + $str = []; | ||
| 54 | + //排序掉当前id下所有子集 | ||
| 55 | + $str = $this->getAllSub($this->param['id'],$str); | ||
| 56 | + $str[] = (int)$this->param['id']; | ||
| 57 | + $this->param['id'] = ['not in',$str]; | ||
| 58 | + } | ||
| 59 | + $menu = array(); | ||
| 60 | + $list = $this->model->list($this->param); | ||
| 61 | + if(!empty($list)){ | ||
| 62 | + foreach ($list as $k => $v){ | ||
| 63 | + if($v['pid'] == 0){ | ||
| 64 | + $v['sub'] = _get_child($v['id'],$list); | ||
| 65 | + $menu[] = $v; | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + return $this->success($menu); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * @remark :获取当前id下所有子集 | ||
| 74 | + * @name :getAllSub | ||
| 75 | + * @author :lyh | ||
| 76 | + * @method :post | ||
| 77 | + * @time :2023/10/18 15:10 | ||
| 78 | + */ | ||
| 79 | + public function getAllSub($id,&$str = []){ | ||
| 80 | + $list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']); | ||
| 81 | + if(!empty($list)){ | ||
| 82 | + foreach ($list as $v){ | ||
| 83 | + $str[] = $v['id']; | ||
| 84 | + $this->getAllSub($v['id'],$str); | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + return $str; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 43 | * @remark :获取详情 | 91 | * @remark :获取详情 |
| 44 | * @name :getInfo | 92 | * @name :getInfo |
| 45 | * @author :lyh | 93 | * @author :lyh |
| @@ -51,8 +99,6 @@ class CategoryLogic extends BaseLogic | @@ -51,8 +99,6 @@ class CategoryLogic extends BaseLogic | ||
| 51 | $info = $this->model->read(['id'=>$id]); | 99 | $info = $this->model->read(['id'=>$id]); |
| 52 | $info['url'] = $info['route']; | 100 | $info['url'] = $info['route']; |
| 53 | $info['image_link'] = getImageUrl($info['image']); | 101 | $info['image_link'] = getImageUrl($info['image']); |
| 54 | - //获取当前分类子集 | ||
| 55 | - $info['sub'] = $this->model->read(['pid'=>$info['id']]); | ||
| 56 | return $this->success($info); | 102 | return $this->success($info); |
| 57 | } | 103 | } |
| 58 | 104 | ||
| @@ -67,13 +113,15 @@ class CategoryLogic extends BaseLogic | @@ -67,13 +113,15 @@ class CategoryLogic extends BaseLogic | ||
| 67 | DB::beginTransaction(); | 113 | DB::beginTransaction(); |
| 68 | try { | 114 | try { |
| 69 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 115 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 70 | - $this->handleEditParam($this->param); | ||
| 71 | //是否编辑路由 | 116 | //是否编辑路由 |
| 72 | $id = $this->editCategoryRoute($this->param['id'],$this->param['route']); | 117 | $id = $this->editCategoryRoute($this->param['id'],$this->param['route']); |
| 118 | + $this->editHandleCategory($this->param['id'],$this->param['pid']); | ||
| 73 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 119 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 74 | }else{ | 120 | }else{ |
| 75 | $this->param['project_id'] = $this->user['project_id']; | 121 | $this->param['project_id'] = $this->user['project_id']; |
| 76 | $id = $this->model->addReturnId($this->param); | 122 | $id = $this->model->addReturnId($this->param); |
| 123 | + //处理子集 | ||
| 124 | + $this->addProcessingSon($id); | ||
| 77 | } | 125 | } |
| 78 | //路由映射 | 126 | //路由映射 |
| 79 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); | 127 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); |
| @@ -92,6 +140,79 @@ class CategoryLogic extends BaseLogic | @@ -92,6 +140,79 @@ class CategoryLogic extends BaseLogic | ||
| 92 | } | 140 | } |
| 93 | 141 | ||
| 94 | /** | 142 | /** |
| 143 | + * @param $cate_id | ||
| 144 | + * @name :(处理子集)addProcessingSon | ||
| 145 | + * @author :lyh | ||
| 146 | + * @method :post | ||
| 147 | + * @time :2023/6/13 11:59 | ||
| 148 | + */ | ||
| 149 | + public function addProcessingSon($cate_id){ | ||
| 150 | + if(!isset($this->param['pid'])){ | ||
| 151 | + $this->param['pid'] = 0; | ||
| 152 | + } | ||
| 153 | + //判断为子分类时 | ||
| 154 | + if($this->param['pid'] != 0){ | ||
| 155 | + //查看当前上级分类下是否有其他子分类 | ||
| 156 | + $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]); | ||
| 157 | + if ($cate_info === false) { | ||
| 158 | + //查看当前上一级分类下是否有新闻 | ||
| 159 | + $productModel = new Product(); | ||
| 160 | + $blog_count = $productModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); | ||
| 161 | + if ($blog_count > 0) { | ||
| 162 | + $replacement = ',' . $cate_id . ','; | ||
| 163 | + $old = ',' . $this->param['pid'] . ','; | ||
| 164 | + //更新所有商品到当前分类 | ||
| 165 | + $productModel->where('category_id', 'like', '%' . $old . '%') | ||
| 166 | + ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); | ||
| 167 | + } | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + return $this->success(); | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * @remark :编辑分类,处理博客数据 | ||
| 175 | + * @name :editCategory | ||
| 176 | + * @author :lyh | ||
| 177 | + * @method :post | ||
| 178 | + * @time :2023/10/20 9:32 | ||
| 179 | + */ | ||
| 180 | + public function editHandleCategory($id,$pid){ | ||
| 181 | + $info = $this->model->read(['id'=>$id],['id','pid']); | ||
| 182 | + if($info['pid'] != $pid){ | ||
| 183 | + //修改勒上级,先查看上级是否拥有博客 | ||
| 184 | + $productModel = new Product(); | ||
| 185 | + $blogCount = $productModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count(); | ||
| 186 | + if($blogCount > 0){ | ||
| 187 | + //随机获取最后一级id | ||
| 188 | + $replacement = $this->getLastId($id); | ||
| 189 | + //存在博客时,移动所有博客到当前分类最后一级 | ||
| 190 | + $productModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%') | ||
| 191 | + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]); | ||
| 192 | + $productModel->where('category_id', 'like', '%,' . $pid . ',%') | ||
| 193 | + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]); | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + return $this->success(); | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * @remark :随机获取当前id下最后一级的id | ||
| 201 | + * @name :getLastId | ||
| 202 | + * @author :lyh | ||
| 203 | + * @method :post | ||
| 204 | + * @time :2023/10/20 9:45 | ||
| 205 | + */ | ||
| 206 | + public function getLastId($id){ | ||
| 207 | + $info = $this->model->read(['pid'=>$id],['id']); | ||
| 208 | + if($info !== false){ | ||
| 209 | + return $this->getLastId($info['id']); | ||
| 210 | + }else{ | ||
| 211 | + return $id; | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 95 | * @remark :编辑路由时生成路由记录 | 216 | * @remark :编辑路由时生成路由记录 |
| 96 | * @name :editCategoryRoute | 217 | * @name :editCategoryRoute |
| 97 | * @author :lyh | 218 | * @author :lyh |
| @@ -112,31 +233,6 @@ class CategoryLogic extends BaseLogic | @@ -112,31 +233,6 @@ class CategoryLogic extends BaseLogic | ||
| 112 | } | 233 | } |
| 113 | 234 | ||
| 114 | /** | 235 | /** |
| 115 | - * @remark :验证编辑时是否可修改pid | ||
| 116 | - * @name :handleEditParam | ||
| 117 | - * @author :lyh | ||
| 118 | - * @method :post | ||
| 119 | - * @time :2023/8/21 17:43 | ||
| 120 | - */ | ||
| 121 | - public function handleEditParam(&$param){ | ||
| 122 | - if($param['pid'] == $param['id']){ | ||
| 123 | - $this->fail('上级分类不能是本分类'); | ||
| 124 | - } | ||
| 125 | -// $info = $this->model->read(['id'=>$param['id']]); | ||
| 126 | -// $sub_info = $this->model->read(['pid'=>$param['id']]); | ||
| 127 | -// if(($info['pid'] != $param['pid']) && ($sub_info != false)){ | ||
| 128 | -// $this->fail('当前分类拥有子分类,不允许修改上级分类'); | ||
| 129 | -// } | ||
| 130 | -// $productModel = new Product(); | ||
| 131 | -// $product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]); | ||
| 132 | -// if(($product_info !== false) && ($info['pid'] != $param['pid'])){ | ||
| 133 | -// $this->fail('当前产品分类拥有产品不允许编辑上级分类'); | ||
| 134 | -// } | ||
| 135 | - return $this->success(); | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - | ||
| 139 | - /** | ||
| 140 | * @remark :删除 | 236 | * @remark :删除 |
| 141 | * @name :delete | 237 | * @name :delete |
| 142 | * @author :lyh | 238 | * @author :lyh |
| @@ -145,10 +241,12 @@ class CategoryLogic extends BaseLogic | @@ -145,10 +241,12 @@ class CategoryLogic extends BaseLogic | ||
| 145 | */ | 241 | */ |
| 146 | public function categoryDelete(){ | 242 | public function categoryDelete(){ |
| 147 | $ids = $this->param['ids']; | 243 | $ids = $this->param['ids']; |
| 148 | - DB::beginTransaction(); | ||
| 149 | - try { | ||
| 150 | - $productModel = new Product(); | ||
| 151 | foreach ($ids as $id){ | 244 | foreach ($ids as $id){ |
| 245 | + $info = $this->model->read(['pid'=>$id],['id']); | ||
| 246 | + if($info !== false){ | ||
| 247 | + $this->fail('分类id:'.$id.'拥有子集不允许删除'); | ||
| 248 | + } | ||
| 249 | + $productModel = new Product(); | ||
| 152 | $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]); | 250 | $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]); |
| 153 | if($product_info !== false){ | 251 | if($product_info !== false){ |
| 154 | $this->fail('当前分类拥有产品不允许删除'); | 252 | $this->fail('当前分类拥有产品不允许删除'); |
| @@ -159,11 +257,6 @@ class CategoryLogic extends BaseLogic | @@ -159,11 +257,6 @@ class CategoryLogic extends BaseLogic | ||
| 159 | } | 257 | } |
| 160 | //清除缓存 | 258 | //清除缓存 |
| 161 | Common::del_user_cache('product_category',$this->user['project_id']); | 259 | Common::del_user_cache('product_category',$this->user['project_id']); |
| 162 | - DB::commit(); | ||
| 163 | - }catch (\Exception $e){ | ||
| 164 | - DB::rollBack(); | ||
| 165 | - $this->fail('删除失败'); | ||
| 166 | - } | ||
| 167 | return $this->success(); | 260 | return $this->success(); |
| 168 | } | 261 | } |
| 169 | 262 |
| @@ -34,9 +34,9 @@ class KeywordLogic extends BaseLogic | @@ -34,9 +34,9 @@ class KeywordLogic extends BaseLogic | ||
| 34 | * @method :post | 34 | * @method :post |
| 35 | * @time :2023/8/23 16:50 | 35 | * @time :2023/8/23 16:50 |
| 36 | */ | 36 | */ |
| 37 | - public function getInfo($id) | 37 | + public function getKeywordInfo() |
| 38 | { | 38 | { |
| 39 | - $info = parent::getInfo($id); | 39 | + $info = $this->model->read($this->param); |
| 40 | $info['url'] = $this->user['domain'] . $info['route']; | 40 | $info['url'] = $this->user['domain'] . $info['route']; |
| 41 | return $this->success($info); | 41 | return $this->success($info); |
| 42 | } | 42 | } |
| @@ -51,6 +51,7 @@ class KeywordLogic extends BaseLogic | @@ -51,6 +51,7 @@ class KeywordLogic extends BaseLogic | ||
| 51 | public function keywordSave(){ | 51 | public function keywordSave(){ |
| 52 | DB::beginTransaction(); | 52 | DB::beginTransaction(); |
| 53 | try { | 53 | try { |
| 54 | + $this->param = $this->handleSaveParam($this->param); | ||
| 54 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 55 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 55 | $info = $this->model->read(['id'=>$this->param['id']],['id','route']); | 56 | $info = $this->model->read(['id'=>$this->param['id']],['id','route']); |
| 56 | $route = $info['route']; | 57 | $route = $info['route']; |
| @@ -77,6 +78,26 @@ class KeywordLogic extends BaseLogic | @@ -77,6 +78,26 @@ class KeywordLogic extends BaseLogic | ||
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | /** | 80 | /** |
| 81 | + * @remark :保存数据时参数处理 | ||
| 82 | + * @name :handleSaveParam | ||
| 83 | + * @author :lyh | ||
| 84 | + * @method :post | ||
| 85 | + * @time :2023/10/23 14:47 | ||
| 86 | + */ | ||
| 87 | + public function handleSaveParam($param){ | ||
| 88 | + if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){ | ||
| 89 | + $param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner']); | ||
| 90 | + } | ||
| 91 | + if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){ | ||
| 92 | + $param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner']); | ||
| 93 | + } | ||
| 94 | + if(isset($param['keyword_video']) && !empty($param['keyword_video'])){ | ||
| 95 | + $param['keyword_video'] = Arr::a2s($param['keyword_video']); | ||
| 96 | + } | ||
| 97 | + return $param; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /** | ||
| 80 | * @remark :批量添加数据 | 101 | * @remark :批量添加数据 |
| 81 | * @name :batchAdd | 102 | * @name :batchAdd |
| 82 | * @author :lyh | 103 | * @author :lyh |
| @@ -91,7 +112,8 @@ class KeywordLogic extends BaseLogic | @@ -91,7 +112,8 @@ class KeywordLogic extends BaseLogic | ||
| 91 | $param['updated_at'] = $param['created_at']; | 112 | $param['updated_at'] = $param['created_at']; |
| 92 | $param['title'] = $v; | 113 | $param['title'] = $v; |
| 93 | $id = $this->model->insertGetId($param); | 114 | $id = $this->model->insertGetId($param); |
| 94 | - RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 115 | + $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 116 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 95 | } | 117 | } |
| 96 | } | 118 | } |
| 97 | return $this->success(); | 119 | return $this->success(); |
| @@ -3,8 +3,11 @@ | @@ -3,8 +3,11 @@ | ||
| 3 | namespace App\Http\Logic\Bside\Product; | 3 | namespace App\Http\Logic\Bside\Product; |
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | +use App\Helper\Common; | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 8 | +use App\Models\Product\Category; | ||
| 7 | use App\Models\Product\CategoryRelated; | 9 | use App\Models\Product\CategoryRelated; |
| 10 | +use App\Models\Product\Keyword; | ||
| 8 | use App\Models\Product\Product; | 11 | use App\Models\Product\Product; |
| 9 | use App\Models\RouteMap\RouteMap; | 12 | use App\Models\RouteMap\RouteMap; |
| 10 | use App\Models\Template\BTemplate; | 13 | use App\Models\Template\BTemplate; |
| @@ -34,10 +37,11 @@ class ProductLogic extends BaseLogic | @@ -34,10 +37,11 @@ class ProductLogic extends BaseLogic | ||
| 34 | * @time :2023/8/21 18:35 | 37 | * @time :2023/8/21 18:35 |
| 35 | */ | 38 | */ |
| 36 | public function productSave(){ | 39 | public function productSave(){ |
| 40 | +// $category_ids = $this->param['category_id'] ?? []; | ||
| 37 | //参数处理 | 41 | //参数处理 |
| 38 | $this->param = $this->handleSaveParam($this->param); | 42 | $this->param = $this->handleSaveParam($this->param); |
| 39 | - DB::beginTransaction(); | ||
| 40 | - try { | 43 | +// DB::connection('custom_mysql')->beginTransaction(); |
| 44 | +// try { | ||
| 41 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 45 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 42 | //查看路由是否更新 | 46 | //查看路由是否更新 |
| 43 | $id = $this->editProductRoute($this->param['id'],$this->param['route']); | 47 | $id = $this->editProductRoute($this->param['id'],$this->param['route']); |
| @@ -51,17 +55,68 @@ class ProductLogic extends BaseLogic | @@ -51,17 +55,68 @@ class ProductLogic extends BaseLogic | ||
| 51 | //路由映射 | 55 | //路由映射 |
| 52 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); | 56 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); |
| 53 | $this->model->edit(['route'=>$route],['id'=>$id]); | 57 | $this->model->edit(['route'=>$route],['id'=>$id]); |
| 54 | - DB::commit(); | ||
| 55 | - }catch (\Exception $e){ | ||
| 56 | - DB::rollBack(); | ||
| 57 | - $this->fail('系统错误请联系管理员'); | ||
| 58 | - } | 58 | + //产品分类关联 |
| 59 | +// CategoryRelated::saveRelated($id, $category_ids); | ||
| 60 | +// DB::connection('custom_mysql')->commit(); | ||
| 61 | +// }catch (\Exception $e){ | ||
| 62 | +// DB::connection('custom_mysql')->rollBack(); | ||
| 63 | +// $this->fail('系统错误请联系管理员'); | ||
| 64 | +// } | ||
| 59 | //通知更新 | 65 | //通知更新 |
| 60 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]); | 66 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]); |
| 61 | return $this->success(); | 67 | return $this->success(); |
| 62 | } | 68 | } |
| 63 | 69 | ||
| 64 | /** | 70 | /** |
| 71 | + * @remark :编辑列表数据 | ||
| 72 | + * @name :editList | ||
| 73 | + * @author :lyh | ||
| 74 | + * @method :post | ||
| 75 | + * @time :2023/10/26 9:49 | ||
| 76 | + */ | ||
| 77 | + public function editList(){ | ||
| 78 | + $this->param['category_id'] = $this->getLastCategory($this->param['category_id']); | ||
| 79 | + $this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']); | ||
| 80 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 81 | + return $this->success(); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * @remark :保存关键字标签处理 | ||
| 86 | + * @name :saveKeyword | ||
| 87 | + * @author :lyh | ||
| 88 | + * @method :post | ||
| 89 | + * @time :2023/10/26 9:51 | ||
| 90 | + */ | ||
| 91 | + public function saveKeyword($keyword){ | ||
| 92 | + $str = ''; | ||
| 93 | + if(isset($keyword) && !empty($keyword)){ | ||
| 94 | + $arr = []; | ||
| 95 | + $keywordModel = new Keyword(); | ||
| 96 | + foreach ($keyword as $v){ | ||
| 97 | + //查询当前关键字是否存在 | ||
| 98 | + $info = $keywordModel->read(['title'=>$v],['id']); | ||
| 99 | + if($info === false){ | ||
| 100 | + $param['project_id'] = $this->user['project_id']; | ||
| 101 | + $param['created_at'] = date('Y-m-d H:i:s'); | ||
| 102 | + $param['updated_at'] = $param['created_at']; | ||
| 103 | + $param['title'] = $v; | ||
| 104 | + $id = $keywordModel->insertGetId($param); | ||
| 105 | + $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | ||
| 106 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 107 | + //清除缓存 | ||
| 108 | + Common::del_user_cache('product_keyword',$this->user['project_id']); | ||
| 109 | + $arr[] = $id; | ||
| 110 | + }else{ | ||
| 111 | + $arr[] = $info['id']; | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + $str = ','.implode(',',$arr).','; | ||
| 115 | + } | ||
| 116 | + return $str; | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + /** | ||
| 65 | * @remark :不使用save处理参数 | 120 | * @remark :不使用save处理参数 |
| 66 | * @name :handleSaveParam | 121 | * @name :handleSaveParam |
| 67 | * @author :lyh | 122 | * @author :lyh |
| @@ -80,8 +135,8 @@ class ProductLogic extends BaseLogic | @@ -80,8 +135,8 @@ class ProductLogic extends BaseLogic | ||
| 80 | } | 135 | } |
| 81 | $param['attrs'] = Arr::a2s($param['attrs'] ?? ''); | 136 | $param['attrs'] = Arr::a2s($param['attrs'] ?? ''); |
| 82 | $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); | 137 | $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); |
| 83 | - if(isset($param['category_id']) && !empty($param['category_id'])){ | ||
| 84 | - $param['category_id'] = ','.Arr::arrToSet($param['category_id']).','; | 138 | + if(isset($param['category_id']) && !empty($param['category_id'])) { |
| 139 | + $param['category_id'] = $this->getLastCategory($param['category_id']); | ||
| 85 | } | 140 | } |
| 86 | if(isset($param['keyword_id']) && !empty($param['keyword_id'])){ | 141 | if(isset($param['keyword_id']) && !empty($param['keyword_id'])){ |
| 87 | $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).','; | 142 | $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).','; |
| @@ -101,6 +156,27 @@ class ProductLogic extends BaseLogic | @@ -101,6 +156,27 @@ class ProductLogic extends BaseLogic | ||
| 101 | } | 156 | } |
| 102 | 157 | ||
| 103 | /** | 158 | /** |
| 159 | + * @remark :获取最后一级分类id | ||
| 160 | + * @name :getLastCategory | ||
| 161 | + * @author :lyh | ||
| 162 | + * @method :post | ||
| 163 | + * @time :2023/10/20 9:02 | ||
| 164 | + */ | ||
| 165 | + public function getLastCategory($category){ | ||
| 166 | + $str = ''; | ||
| 167 | + if(isset($category) && !empty($category)){ | ||
| 168 | + $cateModel = new Category(); | ||
| 169 | + foreach ($category as $v){ | ||
| 170 | + $info = $cateModel->read(['pid'=>$v]); | ||
| 171 | + if($info === false){ | ||
| 172 | + $str .= $v.','; | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + return ','.$str; | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + /** | ||
| 104 | * @remark :编辑产品 | 180 | * @remark :编辑产品 |
| 105 | * @name :editProduct | 181 | * @name :editProduct |
| 106 | * @author :lyh | 182 | * @author :lyh |
| @@ -128,7 +204,7 @@ class ProductLogic extends BaseLogic | @@ -128,7 +204,7 @@ class ProductLogic extends BaseLogic | ||
| 128 | * @time :2023/8/21 17:11 | 204 | * @time :2023/8/21 17:11 |
| 129 | */ | 205 | */ |
| 130 | public function productDelete(){ | 206 | public function productDelete(){ |
| 131 | - DB::beginTransaction(); | 207 | + DB::connection('custom_mysql')->beginTransaction(); |
| 132 | try { | 208 | try { |
| 133 | foreach ($this->param['ids'] as $id) { | 209 | foreach ($this->param['ids'] as $id) { |
| 134 | $info = $this->model->read(['id'=>$id],['id','status']); | 210 | $info = $this->model->read(['id'=>$id],['id','status']); |
| @@ -142,9 +218,9 @@ class ProductLogic extends BaseLogic | @@ -142,9 +218,9 @@ class ProductLogic extends BaseLogic | ||
| 142 | $this->model->edit(['status'=>Product::STATUS_RECYCLE],['id'=>$id]); | 218 | $this->model->edit(['status'=>Product::STATUS_RECYCLE],['id'=>$id]); |
| 143 | } | 219 | } |
| 144 | } | 220 | } |
| 145 | - DB::commit(); | 221 | + DB::connection('custom_mysql')->commit(); |
| 146 | }catch (\Exception $e){ | 222 | }catch (\Exception $e){ |
| 147 | - DB::rollBack(); | 223 | + DB::connection('custom_mysql')->rollBack(); |
| 148 | $this->fail('删除失败'); | 224 | $this->fail('删除失败'); |
| 149 | } | 225 | } |
| 150 | return $this->success(); | 226 | return $this->success(); |
| @@ -334,7 +410,7 @@ class ProductLogic extends BaseLogic | @@ -334,7 +410,7 @@ class ProductLogic extends BaseLogic | ||
| 334 | * @time :2023/8/15 17:53 | 410 | * @time :2023/8/15 17:53 |
| 335 | */ | 411 | */ |
| 336 | public function batchSetCategory(){ | 412 | public function batchSetCategory(){ |
| 337 | - DB::beginTransaction(); | 413 | + DB::connection('custom_mysql')->beginTransaction(); |
| 338 | try { | 414 | try { |
| 339 | //批量 | 415 | //批量 |
| 340 | $param = [ | 416 | $param = [ |
| @@ -342,10 +418,14 @@ class ProductLogic extends BaseLogic | @@ -342,10 +418,14 @@ class ProductLogic extends BaseLogic | ||
| 342 | 'status'=>$this->param['status'] | 418 | 'status'=>$this->param['status'] |
| 343 | ]; | 419 | ]; |
| 344 | $this->model->edit($param,['id'=>['in',$this->param['id']]]); | 420 | $this->model->edit($param,['id'=>['in',$this->param['id']]]); |
| 345 | - DB::commit(); | 421 | + //分类关联 |
| 422 | + foreach ($this->param['id'] as $id){ | ||
| 423 | + CategoryRelated::saveRelated($id, $this->param['category_id']); | ||
| 424 | + } | ||
| 425 | + DB::connection('custom_mysql')->commit(); | ||
| 346 | //对应添加关联表 | 426 | //对应添加关联表 |
| 347 | }catch (\Exception $e){ | 427 | }catch (\Exception $e){ |
| 348 | - DB::rollBack(); | 428 | + DB::connection('custom_mysql')->rollBack(); |
| 349 | $this->fail('系统错误,请联系管理员'); | 429 | $this->fail('系统错误,请联系管理员'); |
| 350 | } | 430 | } |
| 351 | return $this->success(); | 431 | return $this->success(); |
| @@ -461,7 +461,7 @@ class RankDataLogic extends BaseLogic | @@ -461,7 +461,7 @@ class RankDataLogic extends BaseLogic | ||
| 461 | //保证关键词数 | 461 | //保证关键词数 |
| 462 | $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num'); | 462 | $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num'); |
| 463 | $type = Project::where('id', $project_id)->value('type'); | 463 | $type = Project::where('id', $project_id)->value('type'); |
| 464 | - if($keyword_num && $type == 2 && $first_page_num >= $keyword_num){ | 464 | + if($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num){ |
| 465 | $model->compliance_day = $model->compliance_day + 1; | 465 | $model->compliance_day = $model->compliance_day + 1; |
| 466 | $model->is_compliance = 1; | 466 | $model->is_compliance = 1; |
| 467 | 467 |
| @@ -35,6 +35,10 @@ class ProjectCountryLogic extends BaseLogic | @@ -35,6 +35,10 @@ class ProjectCountryLogic extends BaseLogic | ||
| 35 | * @time :2023/4/28 17:42 | 35 | * @time :2023/4/28 17:42 |
| 36 | */ | 36 | */ |
| 37 | public function country_save(){ | 37 | public function country_save(){ |
| 38 | + //处理数据 | ||
| 39 | + if(!isset($this->param['country_lists']) || empty($this->param['country_lists'])){ | ||
| 40 | + $this->param['country_lists'] = ''; | ||
| 41 | + } | ||
| 38 | $info = $this->model->read(['project_id'=>$this->user['project_id']]); | 42 | $info = $this->model->read(['project_id'=>$this->user['project_id']]); |
| 39 | if($info === false){ | 43 | if($info === false){ |
| 40 | $this->param['project_id'] = $this->user['project_id']; | 44 | $this->param['project_id'] = $this->user['project_id']; |
| @@ -45,7 +49,6 @@ class ProjectCountryLogic extends BaseLogic | @@ -45,7 +49,6 @@ class ProjectCountryLogic extends BaseLogic | ||
| 45 | if($rs === false){ | 49 | if($rs === false){ |
| 46 | $this->fail('当前数据不存在'); | 50 | $this->fail('当前数据不存在'); |
| 47 | } | 51 | } |
| 48 | - //TODO::配置多语言翻译api接口 | ||
| 49 | return $this->success(); | 52 | return $this->success(); |
| 50 | } | 53 | } |
| 51 | } | 54 | } |
| @@ -14,7 +14,6 @@ class WebSettingLogic extends BaseLogic | @@ -14,7 +14,6 @@ class WebSettingLogic extends BaseLogic | ||
| 14 | public function __construct() | 14 | public function __construct() |
| 15 | { | 15 | { |
| 16 | parent::__construct(); | 16 | parent::__construct(); |
| 17 | - | ||
| 18 | $this->model = new WebSetting(); | 17 | $this->model = new WebSetting(); |
| 19 | $this->param = $this->requestAll; | 18 | $this->param = $this->requestAll; |
| 20 | } | 19 | } |
| @@ -26,14 +25,10 @@ class WebSettingLogic extends BaseLogic | @@ -26,14 +25,10 @@ class WebSettingLogic extends BaseLogic | ||
| 26 | * @time :2023/4/28 15:14 | 25 | * @time :2023/4/28 15:14 |
| 27 | */ | 26 | */ |
| 28 | public function setting_read(){ | 27 | public function setting_read(){ |
| 29 | - $info = CommonHelper::get_user_cache($this->model->getTable(),$this->user['project_id']); | ||
| 30 | - if(empty($info)){ | ||
| 31 | $info = $this->model->read(['project_id'=>$this->user['project_id']]); | 28 | $info = $this->model->read(['project_id'=>$this->user['project_id']]); |
| 32 | if($info === false){ | 29 | if($info === false){ |
| 33 | $info = []; | 30 | $info = []; |
| 34 | } | 31 | } |
| 35 | - CommonHelper::set_user_cache($info,$this->model->getTable(),$this->user['project_id']); | ||
| 36 | - } | ||
| 37 | return $this->success($info); | 32 | return $this->success($info); |
| 38 | } | 33 | } |
| 39 | 34 |
| @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Setting; | @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Setting; | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | use App\Models\WebSetting\WebSettingReceiving; | 6 | use App\Models\WebSetting\WebSettingReceiving; |
| 7 | use App\Models\WebSetting\WebSettingText; | 7 | use App\Models\WebSetting\WebSettingText; |
| 8 | +use App\Services\SyncService; | ||
| 8 | 9 | ||
| 9 | class WebSettingReceivingLogic extends BaseLogic | 10 | class WebSettingReceivingLogic extends BaseLogic |
| 10 | { | 11 | { |
| @@ -45,6 +46,7 @@ class WebSettingReceivingLogic extends BaseLogic | @@ -45,6 +46,7 @@ class WebSettingReceivingLogic extends BaseLogic | ||
| 45 | }catch (\Exception $e){ | 46 | }catch (\Exception $e){ |
| 46 | $this->fail('error'); | 47 | $this->fail('error'); |
| 47 | } | 48 | } |
| 49 | + app(SyncService::class)->projectAcceptAddress($this->user['project_id']); | ||
| 48 | return $this->success(); | 50 | return $this->success(); |
| 49 | } | 51 | } |
| 50 | } | 52 | } |
| @@ -44,7 +44,7 @@ class WebSettingSeoLogic extends BaseLogic | @@ -44,7 +44,7 @@ class WebSettingSeoLogic extends BaseLogic | ||
| 44 | * @time :2023/9/11 16:34 | 44 | * @time :2023/9/11 16:34 |
| 45 | */ | 45 | */ |
| 46 | public function seoSave(){ | 46 | public function seoSave(){ |
| 47 | -// try { | 47 | + try { |
| 48 | $info = $this->model->read(['project_id'=>$this->user['project_id']]); | 48 | $info = $this->model->read(['project_id'=>$this->user['project_id']]); |
| 49 | if($info === false){ | 49 | if($info === false){ |
| 50 | $this->param['project_id'] = $this->user['project_id']; | 50 | $this->param['project_id'] = $this->user['project_id']; |
| @@ -52,9 +52,9 @@ class WebSettingSeoLogic extends BaseLogic | @@ -52,9 +52,9 @@ class WebSettingSeoLogic extends BaseLogic | ||
| 52 | }else{ | 52 | }else{ |
| 53 | $this->model->edit($this->param,['project_id'=>$this->user['project_id']]); | 53 | $this->model->edit($this->param,['project_id'=>$this->user['project_id']]); |
| 54 | } | 54 | } |
| 55 | -// }catch (\Exception $e){ | ||
| 56 | -// $this->fail('error'); | ||
| 57 | -// } | 55 | + }catch (\Exception $e){ |
| 56 | + $this->fail('error'); | ||
| 57 | + } | ||
| 58 | return $this->success(); | 58 | return $this->success(); |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| @@ -4,7 +4,9 @@ namespace App\Http\Logic\Bside\Setting; | @@ -4,7 +4,9 @@ namespace App\Http\Logic\Bside\Setting; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Common; | 5 | use App\Helper\Common; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | +use App\Models\Domain\DomainInfo; | ||
| 7 | use App\Models\File\Image; | 8 | use App\Models\File\Image; |
| 9 | +use App\Models\Project\Project; | ||
| 8 | use App\Models\WebSetting\WebSettingService; | 10 | use App\Models\WebSetting\WebSettingService; |
| 9 | use Illuminate\Support\Facades\DB; | 11 | use Illuminate\Support\Facades\DB; |
| 10 | 12 |
| @@ -115,14 +115,12 @@ class UserLoginLogic | @@ -115,14 +115,12 @@ class UserLoginLogic | ||
| 115 | $this->fail('该项目未找到注册账号'); | 115 | $this->fail('该项目未找到注册账号'); |
| 116 | } | 116 | } |
| 117 | $info = $this->autoAssembleParam($has_user); | 117 | $info = $this->autoAssembleParam($has_user); |
| 118 | - if(!Cache::get($info['token'])){ | ||
| 119 | //生成新token | 118 | //生成新token |
| 120 | $token = md5(uniqid().$info['id']); | 119 | $token = md5(uniqid().$info['id']); |
| 121 | //存储缓存 | 120 | //存储缓存 |
| 122 | $info['token'] = $token; | 121 | $info['token'] = $token; |
| 123 | $info['manager_id'] = $data['manager_id'];//代表自动登录写入日志 | 122 | $info['manager_id'] = $data['manager_id'];//代表自动登录写入日志 |
| 124 | Cache::add($token,$info,3600 * 12); | 123 | Cache::add($token,$info,3600 * 12); |
| 125 | - } | ||
| 126 | Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip(), | 124 | Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip(), |
| 127 | 'project_id'=>$info['project_id'], 'type'=>1 ,'remark' => '自动登录,操作管理员为:'.$data['manager_id']]); | 125 | 'project_id'=>$info['project_id'], 'type'=>1 ,'remark' => '自动登录,操作管理员为:'.$data['manager_id']]); |
| 128 | return $info; | 126 | return $info; |
| @@ -168,6 +166,7 @@ class UserLoginLogic | @@ -168,6 +166,7 @@ class UserLoginLogic | ||
| 168 | $info['is_customized'] = $project['is_customized']; | 166 | $info['is_customized'] = $project['is_customized']; |
| 169 | $info['is_upload_manage'] = $project['is_upload_manage']; | 167 | $info['is_upload_manage'] = $project['is_upload_manage']; |
| 170 | $info['upload_config'] = $project['upload_config']; | 168 | $info['upload_config'] = $project['upload_config']; |
| 169 | + $info['configuration'] = $project['deploy_build']['configuration']; | ||
| 171 | //保存项目缓存 | 170 | //保存项目缓存 |
| 172 | Cache::put('user-'.$info['project_id'],$project,$minutes = null); | 171 | Cache::put('user-'.$info['project_id'],$project,$minutes = null); |
| 173 | return $this->success($info); | 172 | return $this->success($info); |
| @@ -196,6 +195,7 @@ class UserLoginLogic | @@ -196,6 +195,7 @@ class UserLoginLogic | ||
| 196 | $info['is_customized'] = $project['is_customized']; | 195 | $info['is_customized'] = $project['is_customized']; |
| 197 | $info['is_upload_manage'] = $project['is_upload_manage']; | 196 | $info['is_upload_manage'] = $project['is_upload_manage']; |
| 198 | $info['upload_config'] = $project['upload_config']; | 197 | $info['upload_config'] = $project['upload_config']; |
| 198 | + $info['configuration'] = $project['deploy_build']['configuration']; | ||
| 199 | //保存项目缓存 | 199 | //保存项目缓存 |
| 200 | Cache::put('user-'.$info['project_id'],$project,$minutes = null); | 200 | Cache::put('user-'.$info['project_id'],$project,$minutes = null); |
| 201 | return $this->success($info); | 201 | return $this->success($info); |
| @@ -213,10 +213,18 @@ class UserLoginLogic | @@ -213,10 +213,18 @@ class UserLoginLogic | ||
| 213 | public function getProjectInfo($id){ | 213 | public function getProjectInfo($id){ |
| 214 | $projectModel = new Project(); | 214 | $projectModel = new Project(); |
| 215 | $info = $projectModel->with('payment')->with('deploy_build') | 215 | $info = $projectModel->with('payment')->with('deploy_build') |
| 216 | - ->with('deploy_optimize')->with('online_check')->where(['id'=>$id])->first(); | 216 | + ->with('deploy_optimize')->with('online_check')->where(['id'=>$id])->first()->toArray(); |
| 217 | if($info['extend_type'] != 0){ | 217 | if($info['extend_type'] != 0){ |
| 218 | $info['type'] = $info['extend_type']; | 218 | $info['type'] = $info['extend_type']; |
| 219 | } | 219 | } |
| 220 | + if($info['deploy_build']['configuration'] == null){ | ||
| 221 | + $info['deploy_build']['configuration'] = ["is_SEO" => "0", "is_head"=> "0", "is_home"=> "0", "build_status"=> "0"]; | ||
| 222 | + }else{ | ||
| 223 | + if(!isset($info['deploy_build']['configuration']['is_SEO'])){$info['deploy_build']['configuration']['is_SEO'] = "0";} | ||
| 224 | + if(!isset($info['deploy_build']['configuration']['is_head'])){$info['deploy_build']['configuration']['is_head'] = "0";} | ||
| 225 | + if(!isset($info['deploy_build']['configuration']['is_home'])){$info['deploy_build']['configuration']['is_home'] = "0";} | ||
| 226 | + if(!isset($info['deploy_build']['configuration']['build_status'])){$info['deploy_build']['configuration']['build_status'] = "0";} | ||
| 227 | + } | ||
| 220 | return $this->success($info); | 228 | return $this->success($info); |
| 221 | } | 229 | } |
| 222 | 230 |
| @@ -35,6 +35,7 @@ class NavRequest extends FormRequest | @@ -35,6 +35,7 @@ class NavRequest extends FormRequest | ||
| 35 | // 'group_id' => ['required','integer'], | 35 | // 'group_id' => ['required','integer'], |
| 36 | 'pid' => ['required','integer'], | 36 | 'pid' => ['required','integer'], |
| 37 | 'name' => ['required','max:100'], | 37 | 'name' => ['required','max:100'], |
| 38 | + 'url' => ['required'], | ||
| 38 | ]; | 39 | ]; |
| 39 | return $rule; | 40 | return $rule; |
| 40 | } | 41 | } |
| @@ -49,6 +50,7 @@ class NavRequest extends FormRequest | @@ -49,6 +50,7 @@ class NavRequest extends FormRequest | ||
| 49 | 'pid.integer' => '上级选择错误', | 50 | 'pid.integer' => '上级选择错误', |
| 50 | 'name.required' => '名称必须', | 51 | 'name.required' => '名称必须', |
| 51 | 'name.max' => '名称不能超过100个字符', | 52 | 'name.max' => '名称不能超过100个字符', |
| 53 | + 'url.required' => '链接不能为空', | ||
| 52 | ]; | 54 | ]; |
| 53 | } | 55 | } |
| 54 | } | 56 | } |
| @@ -24,7 +24,7 @@ class NewsRequest extends FormRequest | @@ -24,7 +24,7 @@ class NewsRequest extends FormRequest | ||
| 24 | public function rules() | 24 | public function rules() |
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | - 'name'=>'required|max:100', | 27 | + 'name'=>'required|max:200', |
| 28 | 'url'=>'required', | 28 | 'url'=>'required', |
| 29 | ]; | 29 | ]; |
| 30 | } | 30 | } |
| @@ -33,7 +33,7 @@ class NewsRequest extends FormRequest | @@ -33,7 +33,7 @@ class NewsRequest extends FormRequest | ||
| 33 | { | 33 | { |
| 34 | return [ | 34 | return [ |
| 35 | 'name.required'=>'请填写名称', | 35 | 'name.required'=>'请填写名称', |
| 36 | - 'name.max'=>'名称最大100字', | 36 | + 'name.max'=>'名称最大200字', |
| 37 | 'url.required'=>'新闻链接不能为空' | 37 | 'url.required'=>'新闻链接不能为空' |
| 38 | ]; | 38 | ]; |
| 39 | } | 39 | } |
| @@ -30,7 +30,7 @@ class CategoryRequest extends FormRequest | @@ -30,7 +30,7 @@ class CategoryRequest extends FormRequest | ||
| 30 | public function rules() | 30 | public function rules() |
| 31 | { | 31 | { |
| 32 | return [ | 32 | return [ |
| 33 | - 'title'=>'required|max:50', | 33 | + 'title'=>'required|max:200', |
| 34 | 'route'=>'required', | 34 | 'route'=>'required', |
| 35 | // 'image'=>'required', | 35 | // 'image'=>'required', |
| 36 | // 'keywords'=>'max:50', | 36 | // 'keywords'=>'max:50', |
| @@ -42,7 +42,7 @@ class CategoryRequest extends FormRequest | @@ -42,7 +42,7 @@ class CategoryRequest extends FormRequest | ||
| 42 | { | 42 | { |
| 43 | return [ | 43 | return [ |
| 44 | 'title.required' => '请输入分类名称', | 44 | 'title.required' => '请输入分类名称', |
| 45 | - 'title.max' => '分类名称不能超过50个字符', | 45 | + 'title.max' => '分类名称不能超过200个字符', |
| 46 | 'route.required' => '路由不能为空', | 46 | 'route.required' => '路由不能为空', |
| 47 | // 'image.required' => '请上传分类图片', | 47 | // 'image.required' => '请上传分类图片', |
| 48 | // 'keywords.max' => '分类关键词不能超过50个字符', | 48 | // 'keywords.max' => '分类关键词不能超过50个字符', |
| @@ -23,6 +23,8 @@ class FileManage extends Base | @@ -23,6 +23,8 @@ class FileManage extends Base | ||
| 23 | public $appends = ['url']; | 23 | public $appends = ['url']; |
| 24 | 24 | ||
| 25 | public function getUrlAttribute($value){ | 25 | public function getUrlAttribute($value){ |
| 26 | - return getImageUrl($this->path); | 26 | + $cosCdn = 'https://file.globalso.com'; |
| 27 | + $value = $cosCdn.$this->path; | ||
| 28 | + return $value; | ||
| 27 | } | 29 | } |
| 28 | } | 30 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Models\Product; | 3 | namespace App\Models\Product; |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | +use App\Helper\Arr; | ||
| 6 | use App\Models\Base; | 7 | use App\Models\Base; |
| 7 | use Illuminate\Database\Eloquent\SoftDeletes; | 8 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 8 | 9 | ||
| @@ -21,4 +22,35 @@ class Category extends Base | @@ -21,4 +22,35 @@ class Category extends Base | ||
| 21 | 22 | ||
| 22 | const STATUS_ACTIVE = 1; | 23 | const STATUS_ACTIVE = 1; |
| 23 | 24 | ||
| 25 | + /** | ||
| 26 | + * 获取指定分类的所有子分类IDS(包括自己) | ||
| 27 | + * @param $id | ||
| 28 | + * @return array | ||
| 29 | + * @author zbj | ||
| 30 | + * @date 2023/10/17 | ||
| 31 | + */ | ||
| 32 | + public static function getChildIdsArr($id) | ||
| 33 | + { | ||
| 34 | + if(!$id){ | ||
| 35 | + return []; | ||
| 36 | + } | ||
| 37 | + $list = self::where('status', self::STATUS_ACTIVE)->select(['id','pid'])->get()->toArray(); | ||
| 38 | + $ids = []; | ||
| 39 | + Arr::findChildIds($list, $id, $ids); | ||
| 40 | + $ids[] = $id; //包含自己 | ||
| 41 | + return $ids; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * 关联产品数量 | ||
| 46 | + * @param $cate_id | ||
| 47 | + * @return mixed | ||
| 48 | + * @author zbj | ||
| 49 | + * @date 2023/4/28 | ||
| 50 | + */ | ||
| 51 | + public static function getProductNum($cate_id){ | ||
| 52 | + $cate_ids = self::getChildIdsArr($cate_id); | ||
| 53 | + $product_ids = CategoryRelated::whereIn('cate_id', $cate_ids)->groupBy('product_id')->select(['product_id'])->get(); | ||
| 54 | + return count($product_ids); | ||
| 55 | + } | ||
| 24 | } | 56 | } |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Models\Product; | 3 | namespace App\Models\Product; |
| 4 | 4 | ||
| 5 | +use App\Helper\Arr; | ||
| 5 | use App\Models\Base; | 6 | use App\Models\Base; |
| 6 | use Illuminate\Database\Eloquent\SoftDeletes; | 7 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 7 | 8 | ||
| @@ -19,4 +20,40 @@ class Keyword extends Base | @@ -19,4 +20,40 @@ class Keyword extends Base | ||
| 19 | // public function getRouteAttribute(){ | 20 | // public function getRouteAttribute(){ |
| 20 | // return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id); | 21 | // return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id); |
| 21 | // } | 22 | // } |
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * @remark :图 | ||
| 26 | + * @name :getKeywordTopBannerAttribute | ||
| 27 | + * @author :lyh | ||
| 28 | + * @method :post | ||
| 29 | + * @time :2023/7/21 11:11 | ||
| 30 | + */ | ||
| 31 | + public function getKeywordTopBannerAttribute($value){ | ||
| 32 | + return getImageUrl($value); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * @remark :图 | ||
| 37 | + * @name :getKeywordTopBannerAttribute | ||
| 38 | + * @author :lyh | ||
| 39 | + * @method :post | ||
| 40 | + * @time :2023/7/21 11:11 | ||
| 41 | + */ | ||
| 42 | + public function getKeywordFootBannerAttribute($value){ | ||
| 43 | + return getImageUrl($value); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * @remark :视频 | ||
| 48 | + * @name :getKeywordVideoAttribute | ||
| 49 | + * @author :lyh | ||
| 50 | + * @method :post | ||
| 51 | + * @time :2023/10/31 11:26 | ||
| 52 | + */ | ||
| 53 | + public function getKeywordVideoAttribute($value){ | ||
| 54 | + if(!empty($value)){ | ||
| 55 | + $value = Arr::s2a($value); | ||
| 56 | + } | ||
| 57 | + return $value; | ||
| 58 | + } | ||
| 22 | } | 59 | } |
| @@ -40,6 +40,44 @@ class Product extends Base | @@ -40,6 +40,44 @@ class Product extends Base | ||
| 40 | ]; | 40 | ]; |
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | + /** | ||
| 44 | + * 产品列表 | ||
| 45 | + * @param $map | ||
| 46 | + * @param $page | ||
| 47 | + * @param $row | ||
| 48 | + * @param string $order | ||
| 49 | + * @param string[] $fields | ||
| 50 | + * @param string $sort | ||
| 51 | + * @return array | ||
| 52 | + * @author zbj | ||
| 53 | + * @date 2023/10/17 | ||
| 54 | + */ | ||
| 55 | + public function product_lists($map, $page, $row, $order = 'id', $fields = ['*'], $sort = 'desc'): array | ||
| 56 | + { | ||
| 57 | + $category_id = $map['category_id'] ?? 0; | ||
| 58 | + $query = $this->where(function ($query) use ($category_id) { | ||
| 59 | + if ($category_id) { | ||
| 60 | + $category_ids = Category::getChildIdsArr($category_id); | ||
| 61 | + $query->whereIn('id', function ($subQuery) use ($category_ids) { | ||
| 62 | + $subQuery->select('product_id') | ||
| 63 | + ->from('gl_product_category_related') | ||
| 64 | + ->whereIn('cate_id', $category_ids) | ||
| 65 | + ->groupBy('product_id'); | ||
| 66 | + }); | ||
| 67 | + } | ||
| 68 | + }); | ||
| 69 | + unset($map['category_id']); | ||
| 70 | + $query = $this->formatQuery($map, $query); | ||
| 71 | + $query = $this->sortOrder($query,$order,$sort); | ||
| 72 | + $lists = $query->select($fields)->paginate($row, ['*'], 'page', $page); | ||
| 73 | + if (empty($lists)) { | ||
| 74 | + return []; | ||
| 75 | + } | ||
| 76 | + $lists = $lists->toArray(); | ||
| 77 | + return $lists; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + | ||
| 43 | public function getThumbAttribute($value){ | 81 | public function getThumbAttribute($value){ |
| 44 | if(!empty($value)){ | 82 | if(!empty($value)){ |
| 45 | $value = json_decode($value,true); | 83 | $value = json_decode($value,true); |
app/Models/Project/PageSetting.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :PageSetting.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/10/21 15:24 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Project; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @remark :项目页面头部底部设置 | ||
| 16 | + * @name :PageSetting | ||
| 17 | + * @author :lyh | ||
| 18 | + * @method :post | ||
| 19 | + * @time :2023/10/21 15:24 | ||
| 20 | + */ | ||
| 21 | +class PageSetting extends Base | ||
| 22 | +{ | ||
| 23 | + protected $table = 'gl_project_page_setting'; | ||
| 24 | +} |
app/Models/Template/BTemplateMain.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :BTemplateMain.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/10/24 11:19 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Template; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class BTemplateMain extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_web_template_main'; | ||
| 17 | + //连接数据库 | ||
| 18 | + protected $connection = 'custom_mysql'; | ||
| 19 | +} |
app/Models/Template/TemplateTypeMain.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :TemplateTypeMain.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/10/27 17:49 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Template; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @remark :默认数据main详情表 | ||
| 16 | + * @name :TemplateTypeMain | ||
| 17 | + * @author :lyh | ||
| 18 | + * @method :post | ||
| 19 | + * @time :2023/10/27 17:49 | ||
| 20 | + */ | ||
| 21 | +class TemplateTypeMain extends Base | ||
| 22 | +{ | ||
| 23 | + protected $table = 'gl_template_type_main'; | ||
| 24 | +} |
app/Models/WebSetting/AggregationSetting.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AggregationSetting.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/10/23 10:45 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\WebSetting; | ||
| 11 | + | ||
| 12 | +use App\Helper\Arr; | ||
| 13 | +use App\Models\Base; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * @remark :产品关键字聚合页设置 | ||
| 17 | + * @name :AggregationSetting | ||
| 18 | + * @author :lyh | ||
| 19 | + * @method :post | ||
| 20 | + * @time :2023/10/23 10:48 | ||
| 21 | + */ | ||
| 22 | +class AggregationSetting extends Base | ||
| 23 | +{ | ||
| 24 | + //设置关联表名 | ||
| 25 | + protected $table = 'gl_aggregation_setting'; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @remark :顶部banner获取器 | ||
| 29 | + * @name :getGalleryAttribute | ||
| 30 | + * @author :lyh | ||
| 31 | + * @method :post | ||
| 32 | + * @time :2023/7/21 11:11 | ||
| 33 | + */ | ||
| 34 | + public function getTopBannerAttribute($value){ | ||
| 35 | + if(!empty($value)){ | ||
| 36 | + $value = Arr::s2a($value); | ||
| 37 | + foreach ($value as $k => $v){ | ||
| 38 | + $v = getImageUrl($v); | ||
| 39 | + $value[$k] = $v; | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + return $value; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * @remark :底部banner获取器 | ||
| 47 | + * @name :getGalleryAttribute | ||
| 48 | + * @author :lyh | ||
| 49 | + * @method :post | ||
| 50 | + * @time :2023/7/21 11:11 | ||
| 51 | + */ | ||
| 52 | + public function getFootBannerAttribute($value){ | ||
| 53 | + if(!empty($value)){ | ||
| 54 | + $value = Arr::s2a($value); | ||
| 55 | + foreach ($value as $k => $v){ | ||
| 56 | + $v = getImageUrl($v); | ||
| 57 | + $value[$k] = $v; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + return $value; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * @remark :视频 | ||
| 65 | + * @name :getVideoUrlAttribute | ||
| 66 | + * @author :lyh | ||
| 67 | + * @method :post | ||
| 68 | + * @time :2023/10/31 11:23 | ||
| 69 | + */ | ||
| 70 | + public function getVideoUrlAttribute($value){ | ||
| 71 | + if(!empty($value)){ | ||
| 72 | + $value = Arr::s2a($value); | ||
| 73 | + } | ||
| 74 | + return $value; | ||
| 75 | + } | ||
| 76 | +} |
| @@ -136,6 +136,7 @@ class ProjectServer extends BaseService | @@ -136,6 +136,7 @@ class ProjectServer extends BaseService | ||
| 136 | <div class="layout" data-unable="demo01-error404"> | 136 | <div class="layout" data-unable="demo01-error404"> |
| 137 | <img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" /> | 137 | <img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" /> |
| 138 | </div> | 138 | </div> |
| 139 | + <p style="text-align: center">SORRY. THE PAGE HAS EITHER MOVED OR CANNOT BE FOUND.</p> | ||
| 139 | <style> | 140 | <style> |
| 140 | .section-block-error404 .layout { | 141 | .section-block-error404 .layout { |
| 141 | height: 700px; | 142 | height: 700px; |
| @@ -155,7 +156,7 @@ class ProjectServer extends BaseService | @@ -155,7 +156,7 @@ class ProjectServer extends BaseService | ||
| 155 | <script> | 156 | <script> |
| 156 | </script> | 157 | </script> |
| 157 | </section> | 158 | </section> |
| 158 | - </main>', 'html_style' => '<style id="globalsojs-styles"></style>','created_at' => $created_at, 'updated_at' => $created_at]; | 159 | + </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]; |
| 159 | $id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data); | 160 | $id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data); |
| 160 | //路由 | 161 | //路由 |
| 161 | $info = DB::connection('custom_mysql')->table('gl_route_map')->first(); | 162 | $info = DB::connection('custom_mysql')->table('gl_route_map')->first(); |
app/Services/SyncService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2023/10/26 | ||
| 6 | + * Time: 17:19 | ||
| 7 | + */ | ||
| 8 | +namespace App\Services; | ||
| 9 | + | ||
| 10 | +use App\Models\Domain\DomainInfo; | ||
| 11 | +use App\Models\Project\Project; | ||
| 12 | +use App\Models\WebSetting\WebSettingReceiving; | ||
| 13 | +use Illuminate\Support\Facades\Log; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * TODO 同步数据到其他平台 | ||
| 17 | + * Class SyncService | ||
| 18 | + * @package App\Services | ||
| 19 | + */ | ||
| 20 | +class SyncService extends BaseService | ||
| 21 | +{ | ||
| 22 | + /** | ||
| 23 | + * 同步信息到表单系统 | ||
| 24 | + * TODO 已经有正式域名 | ||
| 25 | + * 项目已经上线 && 已经有正式域名 && 用户设置收件邮箱或者手机号码 | ||
| 26 | + * @param int $project_id | ||
| 27 | + * @return mixed | ||
| 28 | + */ | ||
| 29 | + public function projectAcceptAddress($project_id = 0) | ||
| 30 | + { | ||
| 31 | + try { | ||
| 32 | + $url = 'https://form.globalso.com/api/globalsov6'; | ||
| 33 | + // 项目信息 | ||
| 34 | + $project = Project::with('deploy_build')->with('deploy_optimize')->where(['id'=>$project_id])->first(); | ||
| 35 | + | ||
| 36 | + // 不满足条件 不同步到表单系统 | ||
| 37 | + if (empty($project->deploy_optimize->domain)) { | ||
| 38 | + return false; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + // 生产域名 | ||
| 42 | + $domain = (new DomainInfo())->getDomain($project->deploy_optimize->domain); | ||
| 43 | + | ||
| 44 | + // 收件设置信息 | ||
| 45 | + ProjectServer::useProject($project_id); | ||
| 46 | + $receive = WebSettingReceiving::where(['project_id' => $project_id])->get(); | ||
| 47 | + // 处理收件信息 | ||
| 48 | + $email = $phone = []; | ||
| 49 | + foreach ($receive as $value) { | ||
| 50 | + if ($value->type == 1) | ||
| 51 | + array_push($email, $value->values); | ||
| 52 | + if ($value->type == 2) | ||
| 53 | + array_push($phone, $value->values); | ||
| 54 | + } | ||
| 55 | + // 请求参数 | ||
| 56 | + $data = [ | ||
| 57 | + 'id' => $project_id, | ||
| 58 | + 'company_name' => $project->company, | ||
| 59 | + 'plan' => Project::planMap()[$project->deploy_build->plan], | ||
| 60 | + 'emails' => implode(',', $email), | ||
| 61 | + 'phones' => implode(',', $phone), | ||
| 62 | + 'main_url' => $domain, | ||
| 63 | + 'test_url' => $project->deploy_build->test_domain, | ||
| 64 | + 'token' => md5($project_id . 'qqs' . date('Y-m-d')) | ||
| 65 | + ]; | ||
| 66 | + list($code, $result) = $this->curlRequest($url, $data); | ||
| 67 | + Log::info('同步收件信息至表单系统: 项目ID:' . $project_id . ', data: ' . var_export($data, true) . ', result: ' . $result); | ||
| 68 | + return true; | ||
| 69 | + } catch (\Exception $e) { | ||
| 70 | + Log::info('同步收件信息至表单系统: 项目ID:' . $project_id . ', error: ' . $e->getMessage()); | ||
| 71 | + return false; | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * @param $url | ||
| 77 | + * @param $data | ||
| 78 | + * @param string $method | ||
| 79 | + * @param array $header | ||
| 80 | + * @param int $time_out | ||
| 81 | + * @return array | ||
| 82 | + */ | ||
| 83 | + public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60) | ||
| 84 | + { | ||
| 85 | + $ch = curl_init(); | ||
| 86 | + curl_setopt($ch, CURLOPT_TIMEOUT, $time_out); | ||
| 87 | + curl_setopt($ch, CURLOPT_URL, $url); | ||
| 88 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
| 89 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | ||
| 90 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); | ||
| 91 | + if ($data) | ||
| 92 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); | ||
| 93 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([ | ||
| 94 | + 'Expect:', | ||
| 95 | + 'Content-type: application/json', | ||
| 96 | + 'Accept: application/json', | ||
| 97 | + ], $header) | ||
| 98 | + ); | ||
| 99 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); | ||
| 100 | + $response = curl_exec($ch); | ||
| 101 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
| 102 | + curl_close($ch); | ||
| 103 | + return [$code, $response]; | ||
| 104 | + } | ||
| 105 | +} |
| @@ -22,10 +22,18 @@ return [ | @@ -22,10 +22,18 @@ return [ | ||
| 22 | 'path_b' => '/upload/p', | 22 | 'path_b' => '/upload/p', |
| 23 | 'path_a' => '/upload/m', | 23 | 'path_a' => '/upload/m', |
| 24 | ], | 24 | ], |
| 25 | + //默认 | ||
| 26 | + 'default_b_image' =>[ | ||
| 27 | + 'size' => [ | ||
| 28 | + 'max' => 500 * 1024, // 2M | ||
| 29 | + ], | ||
| 30 | + 'path_b' => '/upload/p', | ||
| 31 | + 'path_a' => '/upload/m', | ||
| 32 | + ], | ||
| 25 | //默认视频 | 33 | //默认视频 |
| 26 | 'default_file' =>[ | 34 | 'default_file' =>[ |
| 27 | 'size' => [ | 35 | 'size' => [ |
| 28 | - 'max' => 1024*1024*20, // 20M | 36 | + 'max' => 1024*1024*50, // 50M |
| 29 | ], | 37 | ], |
| 30 | 'path_b' => '/upload/p', | 38 | 'path_b' => '/upload/p', |
| 31 | 'path_a' => '/upload/m', | 39 | 'path_a' => '/upload/m', |
| @@ -26,7 +26,11 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -26,7 +26,11 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 26 | Route::any('/role_list', [\App\Http\Controllers\Bside\User\UserController::class, 'role_list'])->name('user_role_list'); | 26 | Route::any('/role_list', [\App\Http\Controllers\Bside\User\UserController::class, 'role_list'])->name('user_role_list'); |
| 27 | Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del'); | 27 | Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del'); |
| 28 | }); | 28 | }); |
| 29 | - | 29 | + //项目独立头部和底部设置 |
| 30 | + Route::prefix('pageSetting')->group(function () { | ||
| 31 | + Route::any('/info', [\App\Http\Controllers\Bside\BCom\PageSettingController::class, 'info'])->name('pageSetting_info'); | ||
| 32 | + Route::any('/edit',[\App\Http\Controllers\Bside\BCom\PageSettingController::class, 'edit'])->name('pageSetting_edit'); | ||
| 33 | + }); | ||
| 30 | //站内信 | 34 | //站内信 |
| 31 | Route::prefix('mail')->group(function () { | 35 | Route::prefix('mail')->group(function () { |
| 32 | Route::any('/', [\App\Http\Controllers\Bside\Mail\MailController::class, 'lists'])->name('mail_lists'); | 36 | Route::any('/', [\App\Http\Controllers\Bside\Mail\MailController::class, 'lists'])->name('mail_lists'); |
| @@ -178,6 +182,12 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -178,6 +182,12 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 178 | Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingImageController::class, 'save'])->name('web_image_save'); | 182 | Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingImageController::class, 'save'])->name('web_image_save'); |
| 179 | }); | 183 | }); |
| 180 | 184 | ||
| 185 | + //聚合页相关配置 | ||
| 186 | + Route::prefix('aggregation')->group(function () { | ||
| 187 | + Route::any('/info', [\App\Http\Controllers\Bside\Setting\AggregationSettingController::class, 'info'])->name('aggregation_info'); | ||
| 188 | + Route::any('/edit',[\App\Http\Controllers\Bside\Setting\AggregationSettingController::class, 'edit'])->name('aggregation_edit'); | ||
| 189 | + }); | ||
| 190 | + | ||
| 181 | }); | 191 | }); |
| 182 | //产品 | 192 | //产品 |
| 183 | Route::prefix('product')->group(function () { | 193 | Route::prefix('product')->group(function () { |
| @@ -185,6 +195,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -185,6 +195,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 185 | Route::get('/', [\App\Http\Controllers\Bside\Product\ProductController::class, 'index'])->name('product'); | 195 | Route::get('/', [\App\Http\Controllers\Bside\Product\ProductController::class, 'index'])->name('product'); |
| 186 | Route::get('/info', [\App\Http\Controllers\Bside\Product\ProductController::class, 'info'])->name('product_info'); | 196 | Route::get('/info', [\App\Http\Controllers\Bside\Product\ProductController::class, 'info'])->name('product_info'); |
| 187 | Route::post('/save', [\App\Http\Controllers\Bside\Product\ProductController::class, 'save'])->name('product_save'); | 197 | Route::post('/save', [\App\Http\Controllers\Bside\Product\ProductController::class, 'save'])->name('product_save'); |
| 198 | + Route::post('/editList', [\App\Http\Controllers\Bside\Product\ProductController::class, 'editList'])->name('product_editList'); | ||
| 188 | Route::post('/sort', [\App\Http\Controllers\Bside\Product\ProductController::class, 'sort'])->name('product_sort'); | 199 | Route::post('/sort', [\App\Http\Controllers\Bside\Product\ProductController::class, 'sort'])->name('product_sort'); |
| 189 | Route::any('/delete', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delete'])->name('product_delete'); | 200 | Route::any('/delete', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delete'])->name('product_delete'); |
| 190 | Route::any('/statusNum', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getStatusNumber'])->name('product_statusNum'); | 201 | Route::any('/statusNum', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getStatusNumber'])->name('product_statusNum'); |
| @@ -193,6 +204,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -193,6 +204,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 193 | //产品分类 | 204 | //产品分类 |
| 194 | Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category'); | 205 | Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category'); |
| 195 | Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info'); | 206 | Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info'); |
| 207 | + Route::any('category/categoryTopList', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'categoryTopList'])->name('product_category_categoryTopList'); | ||
| 196 | Route::post('category/save', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'save'])->name('product_category_save'); | 208 | Route::post('category/save', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'save'])->name('product_category_save'); |
| 197 | Route::post('category/sort', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'sort'])->name('product_category_sort'); | 209 | Route::post('category/sort', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'sort'])->name('product_category_sort'); |
| 198 | Route::any('category/delete', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'delete'])->name('product_category_delete'); | 210 | 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 () { | @@ -290,6 +302,8 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 290 | Route::any('/getHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getHeadFooter'])->name('template_getHeadFooter'); | 302 | Route::any('/getHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getHeadFooter'])->name('template_getHeadFooter'); |
| 291 | Route::any('/setHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setHeadFooter'])->name('template_setHeadFooter'); | 303 | Route::any('/setHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setHeadFooter'])->name('template_setHeadFooter'); |
| 292 | Route::any('/savePublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'savePublicTemplate'])->name('template_savePublicTemplate'); | 304 | Route::any('/savePublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'savePublicTemplate'])->name('template_savePublicTemplate'); |
| 305 | + Route::any('/getDetailInfo', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getDetailInfo'])->name('template_getDetailInfo'); | ||
| 306 | + Route::any('/saveDetail', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'saveDetail'])->name('template_saveDetail'); | ||
| 293 | // 模板 | 307 | // 模板 |
| 294 | Route::prefix('module')->group(function () { | 308 | Route::prefix('module')->group(function () { |
| 295 | //获取所有左侧模版 | 309 | //获取所有左侧模版 |
-
请 注册 或 登录 后发表评论