作者 zhl

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

... ... @@ -33,11 +33,16 @@ class SyncFile extends Command
$errorFileModel = new ErrorFile();
$lists = $errorFileModel->list(['status'=>0]);//未同步成功的图片及文件
foreach ($lists as $k => $v){
$code = $this->synchronizationFile($v['path']);
if(strpos($v['path'], '/181/') !== false ){
$code = $this->synchronizationFiles($v['path']);
}else{
$code = $this->synchronizationFile($v['path']);
}
if((int)$code == 200){
echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
$errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
}
}
echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
return true;
... ... @@ -57,4 +62,13 @@ class SyncFile extends Command
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
return shell_exec($cmd);
}
public function synchronizationFiles($path_name){
//同步到大文件
$file_path = config('filesystems.disks.s3')['cdn'].$path_name;
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
return shell_exec($cmd);
}
}
... ...
... ... @@ -19,6 +19,7 @@ use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class Demo extends Command
... ... @@ -71,32 +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(){
$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;
//切换数据库配置
ProjectServer::useProject(1862);
return $this->initTable(1380,1862);
}
/**
* @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;
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;
}
}
... ...
... ... @@ -39,7 +39,7 @@ class Kernel extends ConsoleKernel
$schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
$schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
$schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
$schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
// $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
$schedule->command('update_seo_tdk_crontab')->dailyAt('20:00')->withoutOverlapping(1); //更新上线项目TDK
$schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
... ...
... ... @@ -69,10 +69,11 @@ class CopyProjectJob implements ShouldQueue
$settingTemplateModel = new Setting();
$settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first();
if(!empty($settingData)){
$settingData = $settingData->getAttributes();
unset($settingData['id']);
$settingData['project_id'] = $project_id;
$settingTemplateModel->insert($settingData);
$data = [
'template_id' =>$settingData['template_id'],
'project_id' => $project_id
];
$settingTemplateModel->add($data);
}
//复制部署表
$buildModel = new DeployBuild();
... ...
... ... @@ -51,7 +51,7 @@ return [
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'cdn'=>'https://v6-file.globalso.com'
'cdn'=>'https://globalso-v6.s3.us-west-2.amazonaws.com'
],
'upload' => [
... ...