作者 Your Name
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 namespace App\Console\Commands\TemplateLabel; 10 namespace App\Console\Commands\TemplateLabel;
11 11
  12 +use App\Models\Template\TemplateModule;
12 use Illuminate\Console\Command; 13 use Illuminate\Console\Command;
13 use App\Models\Template\TemplateLabel as TemplateLabelModel; 14 use App\Models\Template\TemplateLabel as TemplateLabelModel;
14 15
@@ -41,9 +42,18 @@ class TemplateLabel extends Command @@ -41,9 +42,18 @@ class TemplateLabel extends Command
41 //获取最近5天左侧的记录 42 //获取最近5天左侧的记录
42 $start_time = now()->subDays(7)->startOfDay()->toDateString(); 43 $start_time = now()->subDays(7)->startOfDay()->toDateString();
43 $end_time = now()->startOfDay()->toDateString(); 44 $end_time = now()->startOfDay()->toDateString();
44 - $info = $labelModel->read(['created_at'=>['between',[$start_time,$end_time]]]);  
45 - if($info === false){ 45 + $templateModuleModel = new TemplateModule();
  46 + $moduleInfo = $templateModuleModel->list(['created_at'=>['between',[$start_time,$end_time]],'type'=>1]);
  47 + if($moduleInfo === false){
46 return false; 48 return false;
  49 + }else{
  50 + $data = [];
  51 + foreach ($moduleInfo as $k => $v){
  52 + $data[] = [
  53 + 'name'=>'最新',
  54 + ];
  55 + }
  56 + //设置为最新
47 } 57 }
48 //清空所有的最近标签 58 //清空所有的最近标签
49 } 59 }
@@ -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);  
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; 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');
125 } 86 }
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}"); 87 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
132 } 88 }
133 - );  
134 89
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'=>null]);
  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 }
@@ -55,7 +55,7 @@ class ProductController extends BaseController @@ -55,7 +55,7 @@ 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){
@@ -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
@@ -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 /**