作者 刘锟

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

@@ -38,6 +38,7 @@ class SyncFile extends Command @@ -38,6 +38,7 @@ class SyncFile extends Command
38 echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL; 38 echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
39 $errorFileModel->edit(['status'=>1],['id'=>$v['id']]); 39 $errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
40 } 40 }
  41 + gc_collect_cycles();
41 } 42 }
42 echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL; 43 echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
43 return true; 44 return true;
@@ -315,7 +315,10 @@ class WebTraffic extends Command @@ -315,7 +315,10 @@ class WebTraffic extends Command
315 $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); 315 $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
316 $query->where('pdo.start_date', '<', $startTime); 316 $query->where('pdo.start_date', '<', $startTime);
317 } 317 }
318 - })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); 318 + })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])
  319 + ->forPage($page, 500)
  320 + ->orderBy('project_id')
  321 + ->get();
319 //其他地方在引流的域名 322 //其他地方在引流的域名
320 $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); 323 $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
321 $data = []; 324 $data = [];
@@ -405,6 +408,9 @@ class WebTraffic extends Command @@ -405,6 +408,9 @@ class WebTraffic extends Command
405 $query->whereNotIn('ip_area', $main_countries); 408 $query->whereNotIn('ip_area', $main_countries);
406 } 409 }
407 })->inRandomOrder()->first(); 410 })->inRandomOrder()->first();
  411 + if(!$ipdata){
  412 + continue;
  413 + }
408 $ipdata = (array)$ipdata ?: []; 414 $ipdata = (array)$ipdata ?: [];
409 $ipdata['diff'] = $time_zones[$ipdata['ip_area']]; 415 $ipdata['diff'] = $time_zones[$ipdata['ip_area']];
410 $data[] = $ipdata; 416 $data[] = $ipdata;
@@ -348,7 +348,7 @@ class WebTrafficRussia extends Command @@ -348,7 +348,7 @@ class WebTrafficRussia extends Command
348 $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); 348 $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
349 $query->where('pdo.start_date', '<', $startTime); 349 $query->where('pdo.start_date', '<', $startTime);
350 } 350 }
351 - })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); 351 + })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->orderBy('project_id')->get();
352 //其他地方在引流的域名 352 //其他地方在引流的域名
353 $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); 353 $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
354 $data = []; 354 $data = [];
@@ -454,6 +454,9 @@ class WebTrafficRussia extends Command @@ -454,6 +454,9 @@ class WebTrafficRussia extends Command
454 } 454 }
455 $ip_area = $this->get_rand($project_country); 455 $ip_area = $this->get_rand($project_country);
456 $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first(); 456 $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first();
  457 + if(!$res){
  458 + continue;
  459 + }
457 $res = (array)$res ?: []; 460 $res = (array)$res ?: [];
458 $res['diff'] = $time_zones[$res['ip_area']]; 461 $res['diff'] = $time_zones[$res['ip_area']];
459 $data[] = $res; 462 $data[] = $res;
@@ -329,7 +329,7 @@ class WebTrafficRussiaSpecial extends Command @@ -329,7 +329,7 @@ class WebTrafficRussiaSpecial extends Command
329 ->where('gl_project.is_upgrade', 0) //非升级项目 329 ->where('gl_project.is_upgrade', 0) //非升级项目
330 ->where('gl_project.main_lang_id', $ru_lang_id)// 俄语站 330 ->where('gl_project.main_lang_id', $ru_lang_id)// 俄语站
331 ->whereIn('gl_project.id', array_keys($projects)) 331 ->whereIn('gl_project.id', array_keys($projects))
332 - ->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); 332 + ->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->orderBy('project_id')->get();
333 //其他地方在引流的域名 333 //其他地方在引流的域名
334 // $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); 334 // $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
335 $other = []; 335 $other = [];
@@ -445,6 +445,9 @@ class WebTrafficRussiaSpecial extends Command @@ -445,6 +445,9 @@ class WebTrafficRussiaSpecial extends Command
445 } 445 }
446 $ip_area = $this->get_rand($project_country); 446 $ip_area = $this->get_rand($project_country);
447 $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first(); 447 $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first();
  448 + if(!$res){
  449 + continue;
  450 + }
448 $res = (array)$res ?: []; 451 $res = (array)$res ?: [];
449 $res['diff'] = $time_zones[$res['ip_area']]; 452 $res['diff'] = $time_zones[$res['ip_area']];
450 $data[] = $res; 453 $data[] = $res;
@@ -295,7 +295,7 @@ class WebTrafficSpecial extends Command @@ -295,7 +295,7 @@ class WebTrafficSpecial extends Command
295 ->where('gl_project.is_upgrade', 0) //非升级项目 295 ->where('gl_project.is_upgrade', 0) //非升级项目
296 ->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站 296 ->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站
297 ->whereIn('gl_project.id', array_keys($projects)) 297 ->whereIn('gl_project.id', array_keys($projects))
298 - ->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); 298 + ->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->orderBy('project_id')->get();
299 //其他地方在引流的域名 299 //其他地方在引流的域名
300 // $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); 300 // $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
301 $other = []; 301 $other = [];
@@ -395,6 +395,9 @@ class WebTrafficSpecial extends Command @@ -395,6 +395,9 @@ class WebTrafficSpecial extends Command
395 $query->whereNotIn('ip_area', $main_countries); 395 $query->whereNotIn('ip_area', $main_countries);
396 } 396 }
397 })->inRandomOrder()->first(); 397 })->inRandomOrder()->first();
  398 + if(!$ipdata){
  399 + continue;
  400 + }
398 $ipdata = (array)$ipdata ?: []; 401 $ipdata = (array)$ipdata ?: [];
399 $ipdata['diff'] = $time_zones[$ipdata['ip_area']]; 402 $ipdata['diff'] = $time_zones[$ipdata['ip_area']];
400 $data[] = $ipdata; 403 $data[] = $ipdata;
@@ -61,6 +61,7 @@ class ProjectController extends BaseController @@ -61,6 +61,7 @@ class ProjectController extends BaseController
61 ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id') 61 ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
62 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') 62 ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
63 ->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id') 63 ->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id')
  64 + ->leftJoin('gl_web_setting_template', 'gl_project.id', '=', 'gl_web_setting_template.project_id')
64 ->where('gl_project.delete_status',Project::TYPE_ZERO) 65 ->where('gl_project.delete_status',Project::TYPE_ZERO)
65 ->where('gl_project.extend_type',Project::TYPE_ZERO); 66 ->where('gl_project.extend_type',Project::TYPE_ZERO);
66 $query = $this->searchParam($query); 67 $query = $this->searchParam($query);
@@ -115,6 +116,7 @@ class ProjectController extends BaseController @@ -115,6 +116,7 @@ class ProjectController extends BaseController
115 'gl_project_deploy_optimize.quality_mid AS quality_mid', 116 'gl_project_deploy_optimize.quality_mid AS quality_mid',
116 'gl_project_deploy_optimize.design_mid AS design_mid', 117 'gl_project_deploy_optimize.design_mid AS design_mid',
117 'gl_project_deploy_optimize.api_no AS api_no', 118 'gl_project_deploy_optimize.api_no AS api_no',
  119 + 'gl_web_setting_template.template_id AS template_id',
118 ]; 120 ];
119 return $select; 121 return $select;
120 } 122 }
@@ -6,6 +6,8 @@ use App\Enums\Common\Code; @@ -6,6 +6,8 @@ use App\Enums\Common\Code;
6 use App\Helper\Translate; 6 use App\Helper\Translate;
7 use App\Http\Controllers\Controller; 7 use App\Http\Controllers\Controller;
8 use App\Http\Controllers\type; 8 use App\Http\Controllers\type;
  9 +use App\Jobs\CopyProjectJob;
  10 +use App\Jobs\SyncImageFileJob;
9 use App\Models\File\ErrorFile; 11 use App\Models\File\ErrorFile;
10 use App\Models\File\Image as ImageModel; 12 use App\Models\File\Image as ImageModel;
11 use App\Models\Project\Project; 13 use App\Models\Project\Project;
@@ -262,14 +264,14 @@ class ImageController extends Controller @@ -262,14 +264,14 @@ class ImageController extends Controller
262 * @time :2024/4/8 11:10 264 * @time :2024/4/8 11:10
263 */ 265 */
264 public function synchronizationImage($fileName){ 266 public function synchronizationImage($fileName){
265 - //同步到大文件  
266 - $file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);  
267 - $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';  
268 - $code = shell_exec($cmd);  
269 - if(200 != (int)$code){  
270 - $errorFileModel = new ErrorFile();  
271 - $errorFileModel->add(['path'=>$this->path.'/'.$fileName]);  
272 - } 267 + SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName]);
  268 +// $file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
  269 +// $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
  270 +// $code = shell_exec($cmd);
  271 +// if(200 != (int)$code){
  272 +// $errorFileModel = new ErrorFile();
  273 +// $errorFileModel->add(['path'=>$this->path.'/'.$fileName]);
  274 +// }
273 return true; 275 return true;
274 } 276 }
275 277
  1 +<?php
  2 +
  3 +namespace App\Jobs;
  4 +
  5 +use App\Events\CopyImageFile;
  6 +use App\Models\File\ErrorFile;
  7 +use App\Models\File\File as FileModel;
  8 +use App\Models\File\Image as ImageModel;
  9 +use App\Services\AmazonS3Service;
  10 +use Illuminate\Bus\Queueable;
  11 +use Illuminate\Contracts\Queue\ShouldQueue;
  12 +use Illuminate\Foundation\Bus\Dispatchable;
  13 +use Illuminate\Queue\InteractsWithQueue;
  14 +use Illuminate\Queue\SerializesModels;
  15 +
  16 +class SyncImageFileJob implements ShouldQueue
  17 +{
  18 + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  19 + public $tries = 3; // 可配置任务重试次数
  20 +
  21 + protected $param;
  22 +
  23 + /**
  24 + * Create a new job instance.
  25 + *
  26 + * @param CopyImageFile $event
  27 + * @return void
  28 + */
  29 + public function __construct($data)
  30 + {
  31 + $this->param = $data;
  32 + }
  33 +
  34 + /**
  35 + * Execute the job.
  36 + *
  37 + * @return void
  38 + */
  39 + public function handle()
  40 + {
  41 + $file_path = getImageUrl($this->param['path'].'/'.$this->param['name'], 0);
  42 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
  43 + $code = shell_exec($cmd);
  44 + if(200 != (int)$code){
  45 + $errorFileModel = new ErrorFile();
  46 + $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
  47 + }
  48 + return true;
  49 + }
  50 +}
@@ -60,6 +60,10 @@ class RouteMap extends Base @@ -60,6 +60,10 @@ class RouteMap extends Base
60 } 60 }
61 $i=1; 61 $i=1;
62 $sign = generateRoute($title); 62 $sign = generateRoute($title);
  63 + $length = strlen($sign);
  64 + if($length > 100){
  65 + $sign = trim(mb_substr($sign, 0, 100, 'UTF-8'),'-');
  66 + }
63 $info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first(); 67 $info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first();
64 $suffix = ''; 68 $suffix = '';
65 if(empty($info)){ 69 if(empty($info)){