作者 刘锟

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

@@ -446,6 +446,8 @@ class SyncProject extends Command @@ -446,6 +446,8 @@ class SyncProject extends Command
446 ProjectServer::createDatabase($project); 446 ProjectServer::createDatabase($project);
447 //创建表 447 //创建表
448 ProjectServer::initTable(); 448 ProjectServer::initTable();
  449 + //初始数据
  450 + ProjectServer::saveInitParam($project_id);
449 } 451 }
450 452
451 /** 453 /**
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :PopularTemplateLabel.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/6/3 17:00
  8 + */
  9 +
  10 +namespace App\Console\Commands\TemplateLabel;
  11 +
  12 +use App\Models\Template\Template;
  13 +use App\Models\Template\TemplateLabel as TemplateLabelModel;
  14 +use App\Models\Template\TemplateModule;
  15 +use Illuminate\Console\Command;
  16 +
  17 +class PopularTemplateLabel extends Command
  18 +{
  19 + /**
  20 + * The name and signature of the console command.
  21 + *
  22 + * @var string
  23 + */
  24 + protected $signature = 'popular_template_label';
  25 +
  26 + /**
  27 + * The console command description.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $description = '设置热门label';
  32 +
  33 + /**
  34 + * @remark :执行脚本
  35 + * @name :handle
  36 + * @author :lyh
  37 + * @method :post
  38 + * @time :2024/6/3 17:01
  39 + */
  40 + public function handle(){
  41 + $this->setTemplate();
  42 + $this->setTemplateModule();
  43 + return true;
  44 + }
  45 +
  46 + /**
  47 + * @remark :公共模块热门模块
  48 + * @name :setTemplate
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2024/6/3 15:56
  52 + */
  53 + public function setTemplate(){
  54 + $templateModel = new Template();
  55 + $info = $templateModel->list(['test_model'=>0,'number'=>['<>',0]],'number',['id'],'desc',50);
  56 + if(empty($info)){
  57 + return true;
  58 + }else{
  59 + //清除当前所有最新标签
  60 + $labelModel = new TemplateLabelModel();
  61 + $labelModel->del(['name'=>'热门','type'=>1]);
  62 + $data = [];
  63 + foreach ($info as $v){
  64 + $data[] = [
  65 + 'name'=>'热门',
  66 + 'type'=>1,
  67 + 'template_id'=>$v['id'],
  68 + 'manager_id'=>0,
  69 + 'created_at'=>date('Y-m-d H:i:s'),
  70 + 'updated_at'=>date('Y-m-d H:i:s')
  71 + ];
  72 + }
  73 + //设置为最新
  74 + $labelModel->insert($data);
  75 + }
  76 + return true;
  77 + }
  78 +
  79 + /**
  80 + * @remark :左侧模块
  81 + * @name :templateModule
  82 + * @author :lyh
  83 + * @method :post
  84 + * @time :2024/6/3 15:54
  85 + */
  86 + public function setTemplateModule(){
  87 + $templateModuleModel = new TemplateModule();
  88 + $moduleInfo = $templateModuleModel->list(['test_model'=>0,'number'=>['<>',0]],'id',['id']);
  89 + if(empty($moduleInfo)){
  90 + return true;
  91 + }else{
  92 + //清除当前所有最新标签
  93 + $labelModel = new TemplateLabelModel();
  94 + $labelModel->del(['name'=>'热门','type'=>2]);
  95 + $moduleData = [];
  96 + foreach ($moduleInfo as $k => $v){
  97 + $moduleData[] = [
  98 + 'name'=>'热门',
  99 + 'type'=>2,
  100 + 'template_id'=>$v['id'],
  101 + 'manager_id'=>0,
  102 + 'created_at'=>date('Y-m-d H:i:s'),
  103 + 'updated_at'=>date('Y-m-d H:i:s')
  104 + ];
  105 + }
  106 + //设置为最新
  107 + $labelModel->insert($moduleData);
  108 + }
  109 + return true;
  110 + }
  111 +
  112 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TemplateLabel.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/6/3 11:33
  8 + */
  9 +
  10 +namespace App\Console\Commands\TemplateLabel;
  11 +
  12 +use App\Models\Template\Template;
  13 +use App\Models\Template\TemplateModule;
  14 +use Illuminate\Console\Command;
  15 +use App\Models\Template\TemplateLabel as TemplateLabelModel;
  16 +
  17 +class TemplateLabel extends Command
  18 +{
  19 + /**
  20 + * The name and signature of the console command.
  21 + *
  22 + * @var string
  23 + */
  24 + protected $signature = 'template_label';
  25 +
  26 + /**
  27 + * The console command description.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $description = '设置label';
  32 +
  33 + /**
  34 + * @remark :执行脚本
  35 + * @name :handle
  36 + * @author :lyh
  37 + * @method :post
  38 + * @time :2024/6/3 11:35
  39 + */
  40 + public function handle(){
  41 + //获取最近7天模版的记录
  42 + $start_time = now()->subDays(90)->startOfDay()->toDateString();
  43 + $end_time = now()->startOfDay()->toDateString();
  44 + $this->setTemplateModule($start_time,$end_time);
  45 + $this->setTemplate($start_time,$end_time);
  46 + return true;
  47 + }
  48 +
  49 + /**
  50 + * @remark :公共模块
  51 + * @name :setTemplate
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2024/6/3 15:56
  55 + */
  56 + public function setTemplate($start_time,$end_time){
  57 + $templateModel = new Template();
  58 + $info = $templateModel->list(['created_at'=>['between',[$start_time,$end_time]],'test_model'=>0],'id',['id']);
  59 + if(empty($info)){
  60 + return true;
  61 + }else{
  62 + //清除当前所有最新标签
  63 + $labelModel = new TemplateLabelModel();
  64 + $labelModel->del(['name'=>'最新','type'=>1]);
  65 + $data = [];
  66 + foreach ($info as $k => $v){
  67 + $data[] = [
  68 + 'name'=>'最新',
  69 + 'type'=>1,
  70 + 'template_id'=>$v['id'],
  71 + 'manager_id'=>0,
  72 + 'created_at'=>date('Y-m-d H:i:s'),
  73 + 'updated_at'=>date('Y-m-d H:i:s')
  74 + ];
  75 + }
  76 + //设置为最新
  77 + $labelModel->insert($data);
  78 + }
  79 + return true;
  80 + }
  81 +
  82 + /**
  83 + * @remark :左侧模块
  84 + * @name :templateModule
  85 + * @author :lyh
  86 + * @method :post
  87 + * @time :2024/6/3 15:54
  88 + */
  89 + public function setTemplateModule($start_time,$end_time){
  90 + $templateModuleModel = new TemplateModule();
  91 + $moduleInfo = $templateModuleModel->list(['created_at'=>['between',[$start_time,$end_time]],'test_model'=>0],'id',['id']);
  92 + if(empty($moduleInfo)){
  93 + return true;
  94 + }else{
  95 + //清除当前所有最新标签
  96 + $labelModel = new TemplateLabelModel();
  97 + $labelModel->del(['name'=>'最新','type'=>2]);
  98 + $moduleData = [];
  99 + foreach ($moduleInfo as $k => $v){
  100 + $moduleData[] = [
  101 + 'name'=>'最新',
  102 + 'type'=>2,
  103 + 'template_id'=>$v['id'],
  104 + 'manager_id'=>0,
  105 + 'created_at'=>date('Y-m-d H:i:s'),
  106 + 'updated_at'=>date('Y-m-d H:i:s')
  107 + ];
  108 + }
  109 + //设置为最新
  110 + $labelModel->insert($moduleData);
  111 + }
  112 + return true;
  113 + }
  114 +}
@@ -72,70 +72,70 @@ class Demo extends Command @@ -72,70 +72,70 @@ class Demo extends Command
72 // return true; 72 // return true;
73 // } 73 // }
74 74
75 -// public function handle(){  
76 -// $keywordVideoModel = new KeywordVideoTask();  
77 -// $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();  
78 -// $projectModel = new Project();  
79 -// $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);  
80 -// $data = [];  
81 -// foreach ($list as $v){  
82 -// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;  
83 -// ProjectServer::useProject($v['id']);  
84 -// $this->saveKeyword();  
85 -// DB::disconnect('custom_mysql');  
86 -// }  
87 -// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;  
88 -// }  
89 -//  
90 -// /**  
91 -// * @remark :关键字有视频的改为1  
92 -// * @name :getProductKeywordInfo  
93 -// * @author :lyh  
94 -// * @method :post  
95 -// * @time :2024/5/31 9:54  
96 -// */  
97 -// public function saveKeyword(){  
98 -// $keywordModel = new Keyword();  
99 -// $rs = $keywordModel->edit(['is_video_keyword'=>1],['video'=>['!=',null]]);  
100 -// echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;  
101 -// return true;  
102 -// }  
103 -  
104 public function handle(){ 75 public function handle(){
105 - //切换数据库配置  
106 - ProjectServer::useProject(1862);  
107 - return $this->initTable(1380,1862); 76 + $keywordVideoModel = new KeywordVideoTask();
  77 + $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();
  78 + $projectModel = new Project();
  79 + $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);
  80 + $data = [];
  81 + foreach ($list as $v){
  82 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  83 + ProjectServer::useProject($v['id']);
  84 + $this->saveKeyword();
  85 + DB::disconnect('custom_mysql');
  86 + }
  87 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
108 } 88 }
109 89
110 - public function initTable($project_id, $news_project_id)  
111 - {  
112 - config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);  
113 - $database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();  
114 - $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();  
115 - $tables = array_column($tables, 'Tables_in_' . $database_name);  
116 - foreach ($tables as $table) {  
117 - $has_table = Schema::connection('custom_mysql')->hasTable($table);  
118 - if (!$has_table) {  
119 - $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");  
120 - DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式  
121 - }  
122 -  
123 - if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {  
124 - continue;  
125 - }  
126 - DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据  
127 - DB::connection('custom_mysql')->table($table)->insertUsing(  
128 - [], // 列名数组,留空表示插入所有列  
129 - function ($query) use ($table, $project_id) {  
130 - $name = 'gl_data_' . $project_id . '.' . $table;  
131 - $query->select('*')->from("{$name}");  
132 - }  
133 - );  
134 -  
135 - if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {  
136 - DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);  
137 - }  
138 - } 90 + /**
  91 + * @remark :关键字有视频的改为1
  92 + * @name :getProductKeywordInfo
  93 + * @author :lyh
  94 + * @method :post
  95 + * @time :2024/5/31 9:54
  96 + */
  97 + public function saveKeyword(){
  98 + $keywordModel = new Keyword();
  99 + $rs = $keywordModel->edit(['is_video_keyword'=>0],['video'=>'']);
  100 + echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;
139 return true; 101 return true;
140 } 102 }
  103 +
  104 +// public function handle(){
  105 +// //切换数据库配置
  106 +// ProjectServer::useProject(1862);
  107 +// return $this->initTable(1380,1862);
  108 +// }
  109 +//
  110 +// public function initTable($project_id, $news_project_id)
  111 +// {
  112 +// config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
  113 +// $database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
  114 +// $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
  115 +// $tables = array_column($tables, 'Tables_in_' . $database_name);
  116 +// foreach ($tables as $table) {
  117 +// $has_table = Schema::connection('custom_mysql')->hasTable($table);
  118 +// if (!$has_table) {
  119 +// $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
  120 +// DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式
  121 +// }
  122 +//
  123 +// if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {
  124 +// continue;
  125 +// }
  126 +// DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
  127 +// DB::connection('custom_mysql')->table($table)->insertUsing(
  128 +// [], // 列名数组,留空表示插入所有列
  129 +// function ($query) use ($table, $project_id) {
  130 +// $name = 'gl_data_' . $project_id . '.' . $table;
  131 +// $query->select('*')->from("{$name}");
  132 +// }
  133 +// );
  134 +//
  135 +// if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
  136 +// DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
  137 +// }
  138 +// }
  139 +// return true;
  140 +// }
141 } 141 }
@@ -50,7 +50,7 @@ class UpdateProductCategory extends Command @@ -50,7 +50,7 @@ class UpdateProductCategory extends Command
50 public function handle(){ 50 public function handle(){
51 //获取所有项目 51 //获取所有项目
52 $projectModel = new Project(); 52 $projectModel = new Project();
53 - $list = $projectModel->list(['id'=>['in',[621]]],'id',['id']); 53 + $list = $projectModel->list(['id'=>['in',[1077]]],'id',['id']);
54 echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL; 54 echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL;
55 try { 55 try {
56 foreach ($list as $v) { 56 foreach ($list as $v) {
@@ -15,6 +15,9 @@ class Kernel extends ConsoleKernel @@ -15,6 +15,9 @@ class Kernel extends ConsoleKernel
15 */ 15 */
16 protected function schedule(Schedule $schedule) 16 protected function schedule(Schedule $schedule)
17 { 17 {
  18 + // 每日更新最新模块
  19 +// $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
  20 +// $schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
18 // $schedule->command('inspire')->hourly(); 21 // $schedule->command('inspire')->hourly();
19 $schedule->command('remain_day')->dailyAt('09:00')->withoutOverlapping(1); // 项目剩余服务时长 22 $schedule->command('remain_day')->dailyAt('09:00')->withoutOverlapping(1); // 项目剩余服务时长
20 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 23 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
@@ -37,10 +37,12 @@ class V6UpdateLogController extends BaseController @@ -37,10 +37,12 @@ class V6UpdateLogController extends BaseController
37 */ 37 */
38 public function save(V6UpdateLogLogic $logic){ 38 public function save(V6UpdateLogLogic $logic){
39 $this->request->validate([ 39 $this->request->validate([
  40 + 'title' => 'required',
40 'version_id' => 'required', 41 'version_id' => 'required',
41 'remark' => 'required', 42 'remark' => 'required',
42 'updated_date' => 'required', 43 'updated_date' => 'required',
43 ], [ 44 ], [
  45 + 'title.required' => 'title不能为空',
44 'version_id.required' => '版本号version_id不能为空', 46 'version_id.required' => '版本号version_id不能为空',
45 'remark.required' => '更新内容不能为空', 47 'remark.required' => '更新内容不能为空',
46 'updated_date.required' => '更新时间不能为空', 48 'updated_date.required' => '更新时间不能为空',
@@ -331,6 +331,9 @@ class OptimizeController extends BaseController @@ -331,6 +331,9 @@ class OptimizeController extends BaseController
331 'project_id.required' => 'project_id不能为空', 331 'project_id.required' => 'project_id不能为空',
332 ]); 332 ]);
333 $projectModel = new Project(); 333 $projectModel = new Project();
  334 + if($this->param['robots'] != $projectModel::STATUS_ONE){
  335 + $this->response('robots只能开启不能关闭',Code::SYSTEM_ERROR);
  336 + }
334 $rs = $projectModel->edit(['robots'=>$this->param['robots']],['id'=>$this->param['project_id']]); 337 $rs = $projectModel->edit(['robots'=>$this->param['robots']],['id'=>$this->param['project_id']]);
335 if($rs === false){ 338 if($rs === false){
336 $this->response('执行错误,请联系开发人员',Code::SYSTEM_ERROR); 339 $this->response('执行错误,请联系开发人员',Code::SYSTEM_ERROR);
@@ -25,17 +25,14 @@ class ATemplateController extends BaseController @@ -25,17 +25,14 @@ class ATemplateController extends BaseController
25 * @method :post 25 * @method :post
26 * @time :2023/6/28 16:34 26 * @time :2023/6/28 16:34
27 */ 27 */
28 - public function lists(ATemplateLogic $aTemplateLogic,TemplateLabel $templateLabel){  
29 - if(isset($this->map['label_name']) && !empty($this->map['label_name'])){  
30 - $id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%']])->pluck('template_id')->toArray();  
31 - $this->map['id'] = ['in',$id_arr];  
32 - unset($this->map['label_name']);  
33 - } 28 + public function lists(ATemplateLogic $aTemplateLogic){
  29 + $templateLabel = new TemplateLabel();
  30 + $this->searchLabelName($templateLabel);
34 $filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id']; 31 $filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
35 $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed); 32 $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
36 if(!empty($lists) && !empty($lists['list'])){ 33 if(!empty($lists) && !empty($lists['list'])){
37 foreach ($lists['list'] as $k => $v){ 34 foreach ($lists['list'] as $k => $v){
38 - $v['label'] = $templateLabel->list(['template_id'=>$v['id']],'id',['id','name'],'desc',5); 35 + $v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>1],'id',['id','name'],'desc',5);
39 $v['image_link'] = getImageUrl($v['image']); 36 $v['image_link'] = getImageUrl($v['image']);
40 $lists['list'][$k] = $v; 37 $lists['list'][$k] = $v;
41 } 38 }
@@ -44,6 +41,22 @@ class ATemplateController extends BaseController @@ -44,6 +41,22 @@ class ATemplateController extends BaseController
44 } 41 }
45 42
46 /** 43 /**
  44 + * @remark :搜索label
  45 + * @name :searchLabelName
  46 + * @author :lyh
  47 + * @method :post
  48 + * @time :2024/6/3 11:11
  49 + */
  50 + public function searchLabelName($templateLabel){
  51 + if(isset($this->map['label_name']) && !empty($this->map['label_name'])){
  52 + $id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%'],'type'=>1])->pluck('template_id')->toArray();
  53 + $this->map['id'] = ['in',$id_arr];
  54 + unset($this->map['label_name']);
  55 + }
  56 + return true;
  57 + }
  58 +
  59 + /**
47 * @remark :获取选择的模版 60 * @remark :获取选择的模版
48 * @name :getTemplateInfo 61 * @name :getTemplateInfo
49 * @author :lyh 62 * @author :lyh
@@ -8,6 +8,8 @@ use App\Http\Logic\Aside\Template\ATemplateLogic; @@ -8,6 +8,8 @@ use App\Http\Logic\Aside\Template\ATemplateLogic;
8 use App\Http\Logic\Aside\Template\ATemplateModuleLogic; 8 use App\Http\Logic\Aside\Template\ATemplateModuleLogic;
9 use App\Http\Requests\Aside\Template\ATemplateModuleRequest; 9 use App\Http\Requests\Aside\Template\ATemplateModuleRequest;
10 use App\Models\Project\Project; 10 use App\Models\Project\Project;
  11 +use App\Models\Template\TemplateLabel;
  12 +use App\Models\Template\TemplateModule;
11 13
12 /** 14 /**
13 * @remark :左侧模块管理 15 * @remark :左侧模块管理
@@ -24,12 +26,38 @@ class ATemplateModuleController extends BaseController @@ -24,12 +26,38 @@ class ATemplateModuleController extends BaseController
24 * @method :post 26 * @method :post
25 * @time :2023/6/28 16:54 27 * @time :2023/6/28 16:54
26 */ 28 */
27 - public function lists(ATemplateModuleLogic $ATemplateModuleLogic){  
28 - $lists = $ATemplateModuleLogic->aTemplateModuleLists($this->map,$this->page,$this->row,$this->order); 29 + public function lists(TemplateModule $templateModule){
  30 + $templateLabel = new TemplateLabel();
  31 + $this->map['deleted_status'] = 0;
  32 + $this->searchLabelName($templateLabel);
  33 + $lists = $templateModule->lists($this->map,$this->page,$this->row,$this->order);
  34 + if(!empty($lists) && !empty($lists['list'])){
  35 + foreach ($lists['list'] as $k => $v){
  36 + $v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>2],'id',['id','name'],'desc',5);
  37 + $lists['list'][$k] = $v;
  38 + }
  39 + }
29 $this->response('success',Code::SUCCESS,$lists); 40 $this->response('success',Code::SUCCESS,$lists);
30 } 41 }
31 42
32 /** 43 /**
  44 + * @remark :搜索label
  45 + * @name :searchLabelName
  46 + * @author :lyh
  47 + * @method :post
  48 + * @time :2024/6/3 11:11
  49 + */
  50 + public function searchLabelName($templateLabel){
  51 + if(isset($this->map['label_name']) && !empty($this->map['label_name'])){
  52 + $id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%'],'type'=>2])->pluck('template_id')->toArray();
  53 + $this->map['id'] = ['in',$id_arr];
  54 + unset($this->map['label_name']);
  55 + }
  56 + return true;
  57 + }
  58 +
  59 +
  60 + /**
33 * @remark :左侧模块保存 61 * @remark :左侧模块保存
34 * @name :save 62 * @name :save
35 * @author :lyh 63 * @author :lyh
@@ -34,8 +34,10 @@ class TemplateLabelController extends BaseController @@ -34,8 +34,10 @@ class TemplateLabelController extends BaseController
34 public function getUserLists(TemplateLabel $templateLabel){ 34 public function getUserLists(TemplateLabel $templateLabel){
35 $this->request->validate([ 35 $this->request->validate([
36 'template_id'=>'required', 36 'template_id'=>'required',
  37 + 'type'=>'required',
37 ],[ 38 ],[
38 'template_id.required' => '模版id不能为空', 39 'template_id.required' => '模版id不能为空',
  40 + 'type.required' => '模版类型不能为空不能为空',
39 ]); 41 ]);
40 $data = $templateLabel->list($this->map); 42 $data = $templateLabel->list($this->map);
41 $this->response('success',Code::SUCCESS,$data); 43 $this->response('success',Code::SUCCESS,$data);
@@ -55,12 +55,12 @@ class ProductController extends BaseController @@ -55,12 +55,12 @@ class ProductController extends BaseController
55 if(!empty($lists)){ 55 if(!empty($lists)){
56 $lists = $lists->toArray(); 56 $lists = $lists->toArray();
57 $cate_data = $this->getCategoryList();//分类 57 $cate_data = $this->getCategoryList();//分类
58 - $key_data = $this->getKeywordsList();//关键字 58 + $key_data = $this->keywordNameLists($lists['list']);//关键字
59 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id 59 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
60 $userModel = new User(); 60 $userModel = new User();
61 foreach ($lists['list'] as $k=>$v){ 61 foreach ($lists['list'] as $k=>$v){
62 $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);; 62 $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);;
63 - $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data); 63 + $v['category_id_text'] = $this->categoryName($v['id'],$cate_data);
64 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data); 64 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
65 $v['created_uid_text'] = $userModel->getName($v['created_uid']); 65 $v['created_uid_text'] = $userModel->getName($v['created_uid']);
66 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']); 66 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
@@ -72,6 +72,30 @@ class ProductController extends BaseController @@ -72,6 +72,30 @@ class ProductController extends BaseController
72 } 72 }
73 73
74 /** 74 /**
  75 + * @remark :获取当前页的所有关键字名称
  76 + * @name :keywordNameLists
  77 + * @author :lyh
  78 + * @method :post
  79 + * @time :2024/6/3 14:24
  80 + */
  81 + public function keywordNameLists($lists){
  82 + $keywordId = [];
  83 + foreach ($lists as $v){
  84 + $keywordId = array_merge($keywordId,$v['keyword_id']);
  85 + }
  86 + $keywordId = array_values(array_unique($keywordId));
  87 + $keywordModel = new Keyword();
  88 + $data = [];
  89 + $cateList = $keywordModel->list(['id' => ['in',$keywordId]], ['id', 'title']);
  90 + if (!empty($cateList)) {
  91 + foreach ($cateList as $value) {
  92 + $data[$value['id']] = $value['title'];
  93 + }
  94 + }
  95 + return $data;
  96 + }
  97 +
  98 + /**
75 * @remark :不分页产品列表 99 * @remark :不分页产品列表
76 * @name :productNoPage 100 * @name :productNoPage
77 * @author :lyh 101 * @author :lyh
@@ -220,7 +244,9 @@ class ProductController extends BaseController @@ -220,7 +244,9 @@ class ProductController extends BaseController
220 * @method :post 244 * @method :post
221 * @time :2023/9/14 13:58 245 * @time :2023/9/14 13:58
222 */ 246 */
223 - public function categoryName($category_id,$data){ 247 + public function categoryName($product_id,$data){
  248 + $cateRelatedModel = new CategoryRelated();
  249 + $category_id = $cateRelatedModel->where('product_id',$product_id)->pluck('cate_id')->toArray();
224 $category_name = ''; 250 $category_name = '';
225 if(!empty($category_id) && !empty($data)){ 251 if(!empty($category_id) && !empty($data)){
226 foreach ($category_id as $v){ 252 foreach ($category_id as $v){
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TemplateLabelController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/16 9:51
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Template;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\BTemplate\BTemplateLabelLogic;
  15 +use App\Models\Template\TemplateLabel;
  16 +
  17 +/**
  18 + * @remark :
  19 + * @name :TemplateLabelController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2024/5/16 9:51
  23 + */
  24 +class BTemplateLabelController extends BaseController
  25 +{
  26 + /**
  27 + * @remark :获取模版的标签
  28 + * @name :lists
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2024/5/16 10:15
  32 + */
  33 + public function getUserLists(TemplateLabel $templateLabel){
  34 + $this->request->validate([
  35 + 'template_id'=>'required',
  36 + 'type'=>'required',
  37 + ],[
  38 + 'template_id.required' => '模版id不能为空',
  39 + 'type.required' => '模版类型不能为空不能为空',
  40 + ]);
  41 + $data = $templateLabel->list($this->map);
  42 + $this->response('success',Code::SUCCESS,$data);
  43 + }
  44 +
  45 + /**
  46 + * @remark :保存标签
  47 + * @name :save
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2024/5/16 9:53
  51 + */
  52 + public function save(BTemplateLabelLogic $labelLogic){
  53 + $this->request->validate([
  54 + 'name'=>'required | max:200',
  55 + 'type'=>'required',
  56 + 'template_id'=>'required',
  57 + ],[
  58 + 'name.required' => '标签名称不能为空',
  59 + 'type.required' => '模版类型不能为空不能为空',
  60 + 'template_id.required' => '模版ID不能为空不能为空',
  61 + ]);
  62 + $data = $labelLogic->saveLabel();
  63 + $this->response('success',Code::SUCCESS,$data);
  64 + }
  65 +
  66 + /**
  67 + * @remark :删除数据
  68 + * @name :del
  69 + * @author :lyh
  70 + * @method :post
  71 + * @time :2024/5/16 10:08
  72 + */
  73 + public function del(BTemplateLabelLogic $labelLogic){
  74 + $this->request->validate([
  75 + 'id'=>'required',
  76 + ],[
  77 + 'id.required' => '主键不能为空',
  78 + ]);
  79 + $data = $labelLogic->delLabel();
  80 + $this->response('success',Code::SUCCESS,$data);
  81 + }
  82 +}
@@ -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\BTemplateModuleLogic; 7 use App\Http\Logic\Bside\BTemplate\BTemplateModuleLogic;
8 use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic; 8 use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic;
9 use App\Models\Template\BModuleProject; 9 use App\Models\Template\BModuleProject;
  10 +use App\Models\Template\TemplateLabel;
10 11
11 /** 12 /**
12 * @remark :左侧模块管理 13 * @remark :左侧模块管理
@@ -62,4 +63,21 @@ class BTemplateModuleController extends BaseController @@ -62,4 +63,21 @@ class BTemplateModuleController extends BaseController
62 $list = $BTemplateModuleLogic->ModuleType($this->map); 63 $list = $BTemplateModuleLogic->ModuleType($this->map);
63 $this->response('success',Code::SUCCESS,$list); 64 $this->response('success',Code::SUCCESS,$list);
64 } 65 }
  66 +
  67 + /**
  68 + * @remark :设置数量
  69 + * @name :setModuleNumber
  70 + * @author :lyh
  71 + * @method :post
  72 + * @time :2024/6/3 16:50
  73 + */
  74 + public function setModuleNumber(){
  75 + $this->request->validate([
  76 + 'id'=>'required',
  77 + ],[
  78 + 'id.required' => 'id不能为空',
  79 + ]);
  80 + $this->model->where('id', $this->param['id'])->increment('number');
  81 + $this->response('success');
  82 + }
65 } 83 }
@@ -22,19 +22,6 @@ class ATemplateModuleLogic extends BaseLogic @@ -22,19 +22,6 @@ class ATemplateModuleLogic extends BaseLogic
22 } 22 }
23 23
24 /** 24 /**
25 - * @remark :左侧模块列表  
26 - * @name :aTemplateModuleLists  
27 - * @author :lyh  
28 - * @method :post  
29 - * @time :2023/6/28 18:01  
30 - */  
31 - public function aTemplateModuleLists($map,$page,$row,$order = 'created_at',$filed = ['*']){  
32 - $map['deleted_status'] = 0;  
33 - $lists = $this->model->lists($map,$page,$row,$order,$filed);  
34 - return $this->success($lists);  
35 - }  
36 -  
37 - /**  
38 * @remark :保存左侧模块 25 * @remark :保存左侧模块
39 * @name :aTemplateModuleSave 26 * @name :aTemplateModuleSave
40 * @author :lyh 27 * @author :lyh
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TemplateLabelLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/16 9:54
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\BTemplate;
  11 +
  12 +use App\Http\Logic\Aside\BaseLogic;
  13 +use App\Models\Template\TemplateLabel;
  14 +
  15 +/**
  16 + * @remark :模版标签
  17 + * @name :TemplateLabelLogic
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2024/5/16 9:54
  21 + */
  22 +class BTemplateLabelLogic extends BaseLogic
  23 +{
  24 + /**
  25 + * 初始化数据
  26 + */
  27 + public function __construct()
  28 + {
  29 + parent::__construct();
  30 + $this->model = new TemplateLabel();
  31 + $this->param = $this->requestAll;
  32 + }
  33 +
  34 +
  35 + /**
  36 + * @remark :保存标签
  37 + * @name :saveLabel
  38 + * @author :lyh
  39 + * @method :post
  40 + * @time :2024/5/16 9:55
  41 + */
  42 + public function saveLabel(){
  43 + if(isset($this->param['id']) && !empty($this->param['id'])){
  44 + $id = $this->param['id'];
  45 + $info = $this->model->read(['name'=>$this->param['name'],'template_id'=>$this->param['template_id'],'id'=>['!=',$id]],['id']);
  46 + if($info === false){
  47 + $this->model->edit($this->param,['id'=>$id]);
  48 + }
  49 + }else{
  50 + $info = $this->model->read(['name'=>$this->param['name'],'template_id'=>$this->param['template_id']],['id']);
  51 + if($info === false){
  52 + $this->param['manager_id'] = $this->manager['id'];
  53 + $id = $this->model->addReturnId($this->param);
  54 + }else{
  55 + $id = $info['id'];
  56 + }
  57 + }
  58 + return $this->success(['id'=>$id]);
  59 + }
  60 +
  61 + /**
  62 + * @remark :删除标签
  63 + * @name :delLabel
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2024/5/16 10:03
  67 + */
  68 + public function delLabel(){
  69 + $rs = $this->model->del($this->param);
  70 + if($rs === false){
  71 + $this->fail('删除失败,请联系管理员');
  72 + }
  73 + return $this->success();
  74 + }
  75 +}
@@ -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\Template\TemplateLabel;
6 use App\Models\Template\TemplateModule; 7 use App\Models\Template\TemplateModule;
7 use App\Models\Template\TemplateType; 8 use App\Models\Template\TemplateType;
8 9
@@ -25,8 +26,13 @@ class BTemplateModuleLogic extends BaseLogic @@ -25,8 +26,13 @@ class BTemplateModuleLogic extends BaseLogic
25 public function ModuleList($map,$order = 'created_at',$filed = ['id','name','type','sort','status','image','test_model']){ 26 public function ModuleList($map,$order = 'created_at',$filed = ['id','name','type','sort','status','image','test_model']){
26 $map['deleted_status'] = 0; 27 $map['deleted_status'] = 0;
27 $map['status'] = 0; 28 $map['status'] = 0;
28 - $lists = $this->model->list($map,$order,$filed);  
29 - return $this->success($lists); 29 + $list = $this->model->list($map,$order,$filed);
  30 + $templateLabel = new TemplateLabel();
  31 + foreach ($list as $k => $v){
  32 + $v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>2],'id',['id','name'],'desc',5);
  33 + $list[$k] = $v;
  34 + }
  35 + return $this->success($list);
30 } 36 }
31 37
32 /** 38 /**
@@ -244,12 +244,6 @@ class CategoryLogic extends BaseLogic @@ -244,12 +244,6 @@ class CategoryLogic extends BaseLogic
244 $str = ','.implode(',',$category).','; 244 $str = ','.implode(',',$category).',';
245 } 245 }
246 return $str; 246 return $str;
247 -// if(isset($category) && !empty($category)){  
248 -// foreach ($category as $v){  
249 -// $str .= $v.',';  
250 -// }  
251 -// }  
252 -// return !empty(trim($str,',')) ? ','.$str.',' : '';  
253 } 247 }
254 248
255 /** 249 /**
@@ -21,7 +21,7 @@ class Visit extends Base @@ -21,7 +21,7 @@ class Visit extends Base
21 //连接数据库 21 //连接数据库
22 protected $connection = 'custom_mysql'; 22 protected $connection = 'custom_mysql';
23 protected $appends = ['device_text']; 23 protected $appends = ['device_text'];
24 - protected $fillable = ['id','ip','device_port','country','city','url','referrer_url','depth','domain','is_inquiry','original_id','updated_date', 'created_at']; 24 + protected $fillable = ['id','ip','device_port','country','city','url','referrer_url','depth','domain','is_inquiry','original_id','updated_date', 'created_at', 'user_agent'];
25 25
26 const DEVICE_PC = 1; 26 const DEVICE_PC = 1;
27 const DEVICE_MOBILE = 2; 27 const DEVICE_MOBILE = 2;
@@ -17,6 +17,6 @@ class VisitItem extends Base @@ -17,6 +17,6 @@ class VisitItem extends Base
17 //连接数据库 17 //连接数据库
18 protected $connection = 'custom_mysql'; 18 protected $connection = 'custom_mysql';
19 19
20 - protected $fillable = ['ip','customer_visit_id','device_port','country','city','url','referrer_url','domain','updated_date','created_at']; 20 + protected $fillable = ['ip','customer_visit_id','device_port','country','city','url','referrer_url','domain','updated_date','created_at', 'user_agent'];
21 21
22 } 22 }
@@ -132,6 +132,7 @@ class SyncSubmitTaskService @@ -132,6 +132,7 @@ class SyncSubmitTaskService
132 $visit_data['country'] = $data['country']; 132 $visit_data['country'] = $data['country'];
133 $visit_data['updated_date'] = $data['submit_at']->toDateString(); 133 $visit_data['updated_date'] = $data['submit_at']->toDateString();
134 $visit_data['created_at'] = $data['submit_at']; 134 $visit_data['created_at'] = $data['submit_at'];
  135 + $visit_data['user_agent'] = $data['user_agent'];
135 Visit::saveData($visit_data, $date); 136 Visit::saveData($visit_data, $date);
136 137
137 return true; 138 return true;
@@ -369,6 +369,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -369,6 +369,7 @@ Route::middleware(['bloginauth'])->group(function () {
369 Route::any('/', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'lists'])->name('template_module_lists'); 369 Route::any('/', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'lists'])->name('template_module_lists');
370 Route::any('/read', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'read'])->name('template_module_read'); 370 Route::any('/read', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'read'])->name('template_module_read');
371 Route::any('/type', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'getType'])->name('template_module_getType'); 371 Route::any('/type', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'getType'])->name('template_module_getType');
  372 + Route::any('/setModuleNumber', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'setModuleNumber'])->name('template_module_setModuleNumber');
372 }); 373 });
373 374
374 // 保存私有模块 375 // 保存私有模块
@@ -537,6 +538,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -537,6 +538,12 @@ Route::middleware(['bloginauth'])->group(function () {
537 Route::prefix('tutorial')->group(function () { 538 Route::prefix('tutorial')->group(function () {
538 Route::any('/', [\App\Http\Controllers\Bside\BCom\TutorialController::class, 'lists'])->name('tutorial_lists'); 539 Route::any('/', [\App\Http\Controllers\Bside\BCom\TutorialController::class, 'lists'])->name('tutorial_lists');
539 }); 540 });
  541 + //oa教程
  542 + Route::prefix('template_label')->group(function () {
  543 + Route::any('/getUserLists', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'getUserLists'])->name('template_label_getUserLists');
  544 + Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'save'])->name('template_label_save');
  545 + Route::any('/del', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'del'])->name('template_label_del');
  546 + });
540 }); 547 });
541 //无需登录验证的路由组 548 //无需登录验证的路由组
542 Route::group([], function () { 549 Route::group([], function () {