作者 lyh

更新脚本demo

@@ -59,102 +59,4 @@ class Demo extends Command @@ -59,102 +59,4 @@ class Demo extends Command
59 } 59 }
60 return true; 60 return true;
61 } 61 }
62 -  
63 -// public function handle(){  
64 -// $keywordVideoModel = new KeywordVideoTask();  
65 -// $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();  
66 -// //查看是否有子记录  
67 -// foreach ($project_id_arr as $values){  
68 -// $logModel = new KeywordVideoTaskLog();  
69 -// $logInfo = $logModel->read(['project_id'=>$values]);  
70 -// if($logInfo === false){  
71 -// echo date('Y-m-d H:i:s') . '开启的项目project_id:'.$values . PHP_EOL;  
72 -// $keywordVideoModel->edit(['status'=>0],['project_id'=>$values]);  
73 -// }  
74 -// }  
75 -// $projectModel = new Project();  
76 -// $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);  
77 -// $data = [];  
78 -// foreach ($list as $v){  
79 -// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;  
80 -// ProjectServer::useProject($v['id']);  
81 -// $this->getProductList();  
82 -// DB::disconnect('custom_mysql');  
83 -// }  
84 -// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;  
85 -// }  
86 -  
87 -// public function getProductList(){  
88 -// $productModel = new Product();  
89 -// $product_all_id = $productModel::whereRaw('LENGTH(keyword_id) > 50')->pluck('id')->toArray();  
90 -// if(empty($product_all_id)){  
91 -// return true;  
92 -// }  
93 -// $lists = $productModel->whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get()->toArray();  
94 -// foreach ($lists as $k => $v){  
95 -// echo date('Y-m-d H:i:s') . '项目id:'.$v['project_id'].'+产品product_id:'.$v['id'] . PHP_EOL;  
96 -// $str = ',';  
97 -// shuffle($v['keyword_id']);  
98 -// foreach ($v['keyword_id'] as $key => $value){  
99 -// if($key == 6){  
100 -// break;  
101 -// }  
102 -// $str .= $value.',';  
103 -// }  
104 -// $productModel->edit(['keyword_id'=>$str],['id'=>$v['id']]);  
105 -// }  
106 -// return true;  
107 -// }  
108 -//  
109 -// /**  
110 -// * @remark :关键字有视频的改为1  
111 -// * @name :getProductKeywordInfo  
112 -// * @author :lyh  
113 -// * @method :post  
114 -// * @time :2024/5/31 9:54  
115 -// */  
116 -// public function saveKeyword(){  
117 -// $keywordModel = new Keyword();  
118 -// $rs = $keywordModel->edit(['is_video_keyword'=>0],['video'=>'']);  
119 -// echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;  
120 -// return true;  
121 -// }  
122 -  
123 -// public function handle(){  
124 -// //切换数据库配置  
125 -// ProjectServer::useProject(1862);  
126 -// return $this->initTable(1380,1862);  
127 -// }  
128 -//  
129 -// public function initTable($project_id, $news_project_id)  
130 -// {  
131 -// config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);  
132 -// $database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();  
133 -// $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();  
134 -// $tables = array_column($tables, 'Tables_in_' . $database_name);  
135 -// foreach ($tables as $table) {  
136 -// $has_table = Schema::connection('custom_mysql')->hasTable($table);  
137 -// if (!$has_table) {  
138 -// $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");  
139 -// DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式  
140 -// }  
141 -//  
142 -// if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {  
143 -// continue;  
144 -// }  
145 -// DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据  
146 -// DB::connection('custom_mysql')->table($table)->insertUsing(  
147 -// [], // 列名数组,留空表示插入所有列  
148 -// function ($query) use ($table, $project_id) {  
149 -// $name = 'gl_data_' . $project_id . '.' . $table;  
150 -// $query->select('*')->from("{$name}");  
151 -// }  
152 -// );  
153 -//  
154 -// if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {  
155 -// DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);  
156 -// }  
157 -// }  
158 -// return true;  
159 -// }  
160 } 62 }