作者 zhl

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

@@ -33,11 +33,16 @@ class SyncFile extends Command @@ -33,11 +33,16 @@ class SyncFile extends Command
33 $errorFileModel = new ErrorFile(); 33 $errorFileModel = new ErrorFile();
34 $lists = $errorFileModel->list(['status'=>0]);//未同步成功的图片及文件 34 $lists = $errorFileModel->list(['status'=>0]);//未同步成功的图片及文件
35 foreach ($lists as $k => $v){ 35 foreach ($lists as $k => $v){
  36 + if(strpos($v['path'], '/181/') !== false ){
  37 + $code = $this->synchronizationFiles($v['path']);
  38 + }else{
36 $code = $this->synchronizationFile($v['path']); 39 $code = $this->synchronizationFile($v['path']);
  40 + }
37 if((int)$code == 200){ 41 if((int)$code == 200){
38 echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL; 42 echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
39 $errorFileModel->edit(['status'=>1],['id'=>$v['id']]); 43 $errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
40 } 44 }
  45 +
41 } 46 }
42 echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL; 47 echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
43 return true; 48 return true;
@@ -57,4 +62,13 @@ class SyncFile extends Command @@ -57,4 +62,13 @@ class SyncFile extends Command
57 $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php'; 62 $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
58 return shell_exec($cmd); 63 return shell_exec($cmd);
59 } 64 }
  65 +
  66 +
  67 + public function synchronizationFiles($path_name){
  68 + //同步到大文件
  69 + $file_path = config('filesystems.disks.s3')['cdn'].$path_name;
  70 + $directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
  71 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
  72 + return shell_exec($cmd);
  73 + }
60 } 74 }
@@ -19,6 +19,7 @@ use App\Services\AmazonS3Service; @@ -19,6 +19,7 @@ use App\Services\AmazonS3Service;
19 use App\Services\ProjectServer; 19 use App\Services\ProjectServer;
20 use Illuminate\Console\Command; 20 use Illuminate\Console\Command;
21 use Illuminate\Support\Facades\DB; 21 use Illuminate\Support\Facades\DB;
  22 +use Illuminate\Support\Facades\Schema;
22 23
23 24
24 class Demo extends Command 25 class Demo extends Command
@@ -71,32 +72,70 @@ class Demo extends Command @@ -71,32 +72,70 @@ class Demo extends Command
71 // return true; 72 // return true;
72 // } 73 // }
73 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 +
74 public function handle(){ 104 public function handle(){
75 - $keywordVideoModel = new KeywordVideoTask();  
76 - $project_id_arr = $keywordVideoModel::where('id','>',0)->pluck('project_id')->toArray();  
77 - $projectModel = new Project();  
78 - $list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0,'id'=>['in',$project_id_arr]]);  
79 - $data = [];  
80 - foreach ($list as $v){  
81 - echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;  
82 - ProjectServer::useProject($v['id']);  
83 - $this->saveKeyword();  
84 - DB::disconnect('custom_mysql'); 105 + //切换数据库配置
  106 + ProjectServer::useProject(1862);
  107 + return $this->initTable(1380,1862);
85 } 108 }
86 - echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 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语句获取方式
87 } 121 }
88 122
89 - /**  
90 - * @remark :关键字有视频的改为1  
91 - * @name :getProductKeywordInfo  
92 - * @author :lyh  
93 - * @method :post  
94 - * @time :2024/5/31 9:54  
95 - */  
96 - public function saveKeyword(){  
97 - $keywordModel = new Keyword();  
98 - $rs = $keywordModel->edit(['is_video_keyword'=>1],['video'=>['!=',null]]);  
99 - echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL; 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 + }
100 return true; 139 return true;
101 } 140 }
102 } 141 }
@@ -39,7 +39,7 @@ class Kernel extends ConsoleKernel @@ -39,7 +39,7 @@ class Kernel extends ConsoleKernel
39 $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录 39 $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
40 $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次 40 $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
41 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次 41 $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
42 - $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次 42 +// $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
43 $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息 43 $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
44 $schedule->command('update_seo_tdk_crontab')->dailyAt('20:00')->withoutOverlapping(1); //更新上线项目TDK 44 $schedule->command('update_seo_tdk_crontab')->dailyAt('20:00')->withoutOverlapping(1); //更新上线项目TDK
45 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次 45 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
@@ -69,10 +69,11 @@ class CopyProjectJob implements ShouldQueue @@ -69,10 +69,11 @@ class CopyProjectJob implements ShouldQueue
69 $settingTemplateModel = new Setting(); 69 $settingTemplateModel = new Setting();
70 $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first(); 70 $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first();
71 if(!empty($settingData)){ 71 if(!empty($settingData)){
72 - $settingData = $settingData->getAttributes();  
73 - unset($settingData['id']);  
74 - $settingData['project_id'] = $project_id;  
75 - $settingTemplateModel->insert($settingData); 72 + $data = [
  73 + 'template_id' =>$settingData['template_id'],
  74 + 'project_id' => $project_id
  75 + ];
  76 + $settingTemplateModel->add($data);
76 } 77 }
77 //复制部署表 78 //复制部署表
78 $buildModel = new DeployBuild(); 79 $buildModel = new DeployBuild();
@@ -51,7 +51,7 @@ return [ @@ -51,7 +51,7 @@ return [
51 'url' => env('AWS_URL'), 51 'url' => env('AWS_URL'),
52 'endpoint' => env('AWS_ENDPOINT'), 52 'endpoint' => env('AWS_ENDPOINT'),
53 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 53 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
54 - 'cdn'=>'https://v6-file.globalso.com' 54 + 'cdn'=>'https://globalso-v6.s3.us-west-2.amazonaws.com'
55 ], 55 ],
56 56
57 'upload' => [ 57 'upload' => [