作者 Your Name
... ... @@ -9,6 +9,7 @@
namespace App\Console\Commands\TemplateLabel;
use App\Models\Template\TemplateModule;
use Illuminate\Console\Command;
use App\Models\Template\TemplateLabel as TemplateLabelModel;
... ... @@ -41,9 +42,18 @@ class TemplateLabel extends Command
//获取最近5天左侧的记录
$start_time = now()->subDays(7)->startOfDay()->toDateString();
$end_time = now()->startOfDay()->toDateString();
$info = $labelModel->read(['created_at'=>['between',[$start_time,$end_time]]]);
if($info === false){
$templateModuleModel = new TemplateModule();
$moduleInfo = $templateModuleModel->list(['created_at'=>['between',[$start_time,$end_time]],'type'=>1]);
if($moduleInfo === false){
return false;
}else{
$data = [];
foreach ($moduleInfo as $k => $v){
$data[] = [
'name'=>'最新',
];
}
//设置为最新
}
//清空所有的最近标签
}
... ...
... ... @@ -72,70 +72,70 @@ class Demo extends Command
// return true;
// }
// public function handle(){
// $keywordVideoModel = new KeywordVideoTask();
// $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();
// $projectModel = new Project();
// $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);
// $data = [];
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
// $this->saveKeyword();
// DB::disconnect('custom_mysql');
// }
// echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
// }
//
// /**
// * @remark :关键字有视频的改为1
// * @name :getProductKeywordInfo
// * @author :lyh
// * @method :post
// * @time :2024/5/31 9:54
// */
// public function saveKeyword(){
// $keywordModel = new Keyword();
// $rs = $keywordModel->edit(['is_video_keyword'=>1],['video'=>['!=',null]]);
// echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;
// return true;
// }
public function handle(){
//切换数据库配置
ProjectServer::useProject(1862);
return $this->initTable(1380,1862);
$keywordVideoModel = new KeywordVideoTask();
$project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();
$projectModel = new Project();
$list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->saveKeyword();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
public function initTable($project_id, $news_project_id)
{
config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
$database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
$tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
$tables = array_column($tables, 'Tables_in_' . $database_name);
foreach ($tables as $table) {
$has_table = Schema::connection('custom_mysql')->hasTable($table);
if (!$has_table) {
$sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式
}
if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {
continue;
}
DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
DB::connection('custom_mysql')->table($table)->insertUsing(
[], // 列名数组,留空表示插入所有列
function ($query) use ($table, $project_id) {
$name = 'gl_data_' . $project_id . '.' . $table;
$query->select('*')->from("{$name}");
}
);
if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
}
}
/**
* @remark :关键字有视频的改为1
* @name :getProductKeywordInfo
* @author :lyh
* @method :post
* @time :2024/5/31 9:54
*/
public function saveKeyword(){
$keywordModel = new Keyword();
$rs = $keywordModel->edit(['is_video_keyword'=>0],['video'=>null]);
echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;
return true;
}
// public function handle(){
// //切换数据库配置
// ProjectServer::useProject(1862);
// return $this->initTable(1380,1862);
// }
//
// public function initTable($project_id, $news_project_id)
// {
// config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
// $database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
// $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
// $tables = array_column($tables, 'Tables_in_' . $database_name);
// foreach ($tables as $table) {
// $has_table = Schema::connection('custom_mysql')->hasTable($table);
// if (!$has_table) {
// $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
// DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式
// }
//
// if ($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form') {
// continue;
// }
// DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
// DB::connection('custom_mysql')->table($table)->insertUsing(
// [], // 列名数组,留空表示插入所有列
// function ($query) use ($table, $project_id) {
// $name = 'gl_data_' . $project_id . '.' . $table;
// $query->select('*')->from("{$name}");
// }
// );
//
// if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) {
// DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]);
// }
// }
// return true;
// }
}
... ...
... ... @@ -55,7 +55,7 @@ class ProductController extends BaseController
if(!empty($lists)){
$lists = $lists->toArray();
$cate_data = $this->getCategoryList();//分类
$key_data = $this->getKeywordsList();//关键字
$key_data = $this->keywordNameLists($lists['list']);//关键字
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
$userModel = new User();
foreach ($lists['list'] as $k=>$v){
... ... @@ -72,6 +72,30 @@ class ProductController extends BaseController
}
/**
* @remark :获取当前页的所有关键字名称
* @name :keywordNameLists
* @author :lyh
* @method :post
* @time :2024/6/3 14:24
*/
public function keywordNameLists($lists){
$keywordId = [];
foreach ($lists as $v){
$keywordId = array_merge($keywordId,$v['keyword_id']);
}
$keywordId = array_values(array_unique($keywordId));
$keywordModel = new Keyword();
$data = [];
$cateList = $keywordModel->list(['id' => ['in',$keywordId]], ['id', 'title']);
if (!empty($cateList)) {
foreach ($cateList as $value) {
$data[$value['id']] = $value['title'];
}
}
return $data;
}
/**
* @remark :不分页产品列表
* @name :productNoPage
* @author :lyh
... ...
... ... @@ -244,12 +244,6 @@ class CategoryLogic extends BaseLogic
$str = ','.implode(',',$category).',';
}
return $str;
// if(isset($category) && !empty($category)){
// foreach ($category as $v){
// $str .= $v.',';
// }
// }
// return !empty(trim($str,',')) ? ','.$str.',' : '';
}
/**
... ...