作者 刘锟

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

... ... @@ -7,39 +7,14 @@
*/
namespace App\Console\Commands\Test;
use App\Helper\Common;
use App\Models\Blog\Blog;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\File\File;
use App\Models\File\File as FileModel;
use App\Models\File\Image;
use App\Models\File\Image as ImageModel;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Dept;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\ManageHr;
use App\Models\Nav\BNav;
use App\Models\Nav\BNavGroup;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Setting;
use App\Models\WebSetting\WebSettingService;
use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
use App\Services\SyncService;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class Demo extends Command
{
... ... @@ -56,6 +31,8 @@ class Demo extends Command
* @var string
*/
protected $description = 'demo';
/**
* Execute the job.
*
... ... @@ -63,77 +40,30 @@ class Demo extends Command
*/
public function handle()
{
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
DB::table('gl_web_template_com')->truncate();
$templateComModel = new BTemplateCom();
$templateComModel->truncate();
$this->saveTemplateCom($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
$this->param['project_id'] = 181;
$imageModel = new ImageModel();
// //获取当前项目的所有图片
// $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);
// if(!empty($imageList)){
// $amazonS3Service = new AmazonS3Service();
// foreach ($imageList as $k => $v){
// $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
// $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
// }
// }
public function saveTemplateCom($project_id){
//获取当前项目选择的模版
$settingModel = new Setting();
$settingInfo = $settingModel->read(['project_id'=>$project_id]);
echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;
if($settingInfo !== false){
$templateCommonModel = new BTemplateCommon();
$commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
if(!empty($commonList)){
foreach ($commonList as $v){
$typeArr = [1, 2, 3];
foreach ($typeArr as $type){
if($type == 1){
$headData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>1,
'template_id'=>$v['template_id'],
'html'=>$v['head_html'],
'html_style'=>$v['head_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($headData);
}elseif ($type == 2){
$footerData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>2,
'template_id'=>$v['template_id'],
'html'=>$v['footer_html'],
'html_style'=>$v['footer_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($footerData);
}elseif ($type == 3){
$otherData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>3,
'template_id'=>$v['template_id'],
'html'=>$v['other'],
'html_style'=>null,
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($otherData);
}
}
}
$fileModel = new FileModel();
$fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);
if(!empty($fileList)){
$amazonS3Service = new AmazonS3Service();
foreach ($fileList as $k => $v){
echo date('Y-m-d H:i:s') . '执行的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;
$amazonS3Service->syncImageFiles(getFileUrl($v['path']));
$fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);
gc_collect_cycles();
}
}
return true;
}
}
... ...
<?php
/**
* @remark :
* @name :HeaderFooter.php
* @author :lyh
* @method :post
* @time :2024/5/21 9:42
*/
namespace App\Console\Commands\Test;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Setting;
use Illuminate\Console\Command;
/**
* @remark :头部底部分开 脚本数据
* @name :HeaderFooter
* @author :lyh
* @method :post
* @time :2024/5/21 9:42
*/
class HeaderFooter extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'common_header';
/**
* The console command description.
*
* @var string
*/
protected $description = 'common_header';
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
DB::table('gl_web_template_com')->truncate();
$templateComModel = new BTemplateCom();
$templateComModel->truncate();
$this->saveTemplateCom($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
public function saveTemplateCom($project_id){
//获取当前项目选择的模版
$settingModel = new Setting();
$settingInfo = $settingModel->read(['project_id'=>$project_id]);
echo date('Y-m-d H:i:s') . '设置的模版:'.json_encode($settingInfo) . PHP_EOL;
if($settingInfo !== false){
$templateCommonModel = new BTemplateCommon();
$commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
if(!empty($commonList)){
foreach ($commonList as $v){
$typeArr = [1, 2, 3];
foreach ($typeArr as $type){
if($type == 1){
$headData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>1,
'template_id'=>$v['template_id'],
'html'=>$v['head_html'],
'html_style'=>$v['head_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($headData);
}elseif ($type == 2){
$footerData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>2,
'template_id'=>$v['template_id'],
'html'=>$v['footer_html'],
'html_style'=>$v['footer_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($footerData);
}elseif ($type == 3){
$otherData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>3,
'template_id'=>$v['template_id'],
'html'=>$v['other'],
'html_style'=>null,
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($otherData);
}
}
}
}
}
return true;
}
}
... ...
<?php
/**
* @remark :
* @name :Translate.php
* @author :lyh
* @method :post
* @time :2024/5/21 9:32
*/
namespace App\Console\Commands\Test;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Setting;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class Translate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'translate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'translate';
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0],'id'=>['<=',1194]]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$translateModel = new \App\Models\WebSetting\Translate();
$translateList = $translateModel->list([],'id',['id','url']);
foreach ($translateList as $value){
echo date('Y-m-d H:i:s') . '数据路由:'.$value['url'] . PHP_EOL;
$data = $this->getRouteSource($value['url']);
if($data === false){
continue;
}
$rs = $translateModel->edit($data,['id'=>$value['id']]);
gc_collect_cycles();
}
DB::disconnect('custom_mysql');
}
DB::disconnect('custom_mysql');
}
/**
* @remark :根据路由获取source+source_id
* @name :getRouteSource
* @author :lyh
* @method :post
* @time :2024/5/17 15:11
*/
public function getRouteSource($route){
$data = ['source'=>0,'source_id'=>0,'is_list'=>0,'is_custom'=>0];
if(strtolower($route) == 'all'){
return $data;
}
if($route == '/'){
$data['source'] = 1;
return $data;
}
$route = basename($route);
$routeModel = new RouteMap();
$routeInfo = $routeModel->read(['route'=>$route]);
if($routeInfo === false){
return false;
}
return $this->resultData($routeInfo,$data);
}
/**
* @remark :返回数据
* @name :resultData
* @author :lyh
* @method :post
* @time :2024/5/20 11:54
*/
public function resultData($routeInfo,$data){
if($routeInfo['source'] == RouteMap::SOURCE_PAGE){
if($routeInfo['source_id']){
$data = ['source'=>9,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT){
if($routeInfo['source_id']){
$data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT_CATE){
if($routeInfo['source_id']){
$data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_BLOG){
if($routeInfo['source_id']){
$data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_BLOG_CATE){
if($routeInfo['source_id']){
$data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_NEWS){
if($routeInfo['source_id']){
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_NEWS_CATE){
if($routeInfo['source_id']){
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_MODULE){
if($routeInfo['source_id']){
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>1];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_MODULE_CATE){
if($routeInfo['source_id']){
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>1];
}
}
return $data;
}
}
... ...
... ... @@ -683,8 +683,9 @@ if (!function_exists('str_replace_url')) {
$cos = config('filesystems.disks.cos');
$cosCdn = $cos['cdn'];
$cosCdn1 = $cos['cdn1'];
$cosCdn2 = config('filesystems.disks.s3')['cdn'];
if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false))){
$cosCdn2 = $cos['cdn2'];
$cosCdn3 = config('filesystems.disks.s3')['cdn'];
if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false) || (strpos($url,$cosCdn3) !== false))){
// 外部URL无需解析
// 使用 parse_url 函数来解析 URL
$urlParts = parse_url($url);
... ...
... ... @@ -48,6 +48,7 @@ class AyrReleaseController extends BaseController
$info = $ayrShareLogic->ayr_share_info($this->param['share_id']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :(发布社交)send_post
* @author :lyh
... ... @@ -88,7 +89,9 @@ class AyrReleaseController extends BaseController
//发送请求发布社交文章
$res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
//保存数据库
$ayrReleaseLogic->release_add($res);
if($res){
$ayrReleaseLogic->release_add($res);
}
//保存返回的内容
$this->response('success',Code::SUCCESS,json_decode($res));
}
... ...
... ... @@ -43,7 +43,7 @@ class ServerConfigLogic extends BaseLogic
$projectModel = new Project();
foreach ($lists['list'] as $k => $v){
if($v['type'] == $this->model::TYPE_SERVER){
$v['count'] = $projectModel->where(['serve_id'=>$v['id']])->count();
$v['count'] = $projectModel->where(['serve_id'=>$v['id'],'delete_status'=>0])->count();
}
$lists['list'][$k] = $v;
}
... ...
... ... @@ -143,7 +143,7 @@ class ProjectLogic extends BaseLogic
public function projectSave(){
DB::beginTransaction();
try {
$this->param['project_location'] = 0;//TODO::图片文件存储不同地方,上线后删除
// $this->param['project_location'] = 0;//TODO::图片文件存储不同地方,上线后删除
if($this->param['type'] == Project::TYPE_SEVEN){
//错误单直接返回,单独处理
$this->setTypeSevenEdit($this->param);
... ...
... ... @@ -259,12 +259,17 @@ class TranslateLogic extends BaseLogic
// try {
$info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
if($info === false){
$sourceInfo = $this->getRouteSource($this->param['url']);
$param = [
'type'=>$this->param['type'],
'project_id'=>$this->user['project_id'],
'url'=>str_replace_url($this->param['url']),
'language_id'=>$this->param['language_id'],
'alias'=>$this->param['alias'],
'source'=>$sourceInfo['source'],
'source_id'=>$sourceInfo['source_id'],
'is_list'=>$sourceInfo['is_list'],
'is_custom'=>$sourceInfo['is_custom']
];
$param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$rs = $this->model->add($param);
... ... @@ -303,16 +308,63 @@ class TranslateLogic extends BaseLogic
$route = basename($route);
$routeModel = new RouteMap();
$routeInfo = $routeModel->read(['route'=>$route]);
return $this->resultData($routeInfo,$data);
}
/**
* @remark :返回数据
* @name :resultData
* @author :lyh
* @method :post
* @time :2024/5/20 11:54
*/
public function resultData($routeInfo,$data){
if($routeInfo['source'] == RouteMap::SOURCE_PAGE){
if($routeInfo['source_id']){
$data = ['source'=>9,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_PAGE){
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT){
if($routeInfo['source_id']){
$data = ['source'=>9,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
$data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_PRODUCT_CATE){
if($routeInfo['source_id']){
$data = ['source'=>2,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_BLOG){
if($routeInfo['source_id']){
$data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_BLOG_CATE){
if($routeInfo['source_id']){
$data = ['source'=>3,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_NEWS){
if($routeInfo['source_id']){
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_NEWS_CATE){
if($routeInfo['source_id']){
$data = ['source'=>4,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>0];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_MODULE){
if($routeInfo['source_id']){
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>0,'is_custom'=>1];
}
}
if($routeInfo['source'] == RouteMap::SOURCE_MODULE_CATE){
if($routeInfo['source_id']){
$data = ['source'=>7,'source_id'=>$routeInfo['source_id'],'is_list'=>1,'is_custom'=>1];
}
}
return $data;
}
/**
... ...
... ... @@ -34,6 +34,9 @@ class AyrReleaseRequest extends FormRequest
{
return [
'name.required'=>'参数错误',
'content.required'=>'内容不能为空',
'share_id.required'=>'参数错误',
'platforms.required'=>'参数错误',
];
}
}
... ...
... ... @@ -46,6 +46,7 @@ class CopyImageFileJob implements ShouldQueue
echo date('Y-m-d H:i:s') . '执行图片的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;
$amazonS3Service->syncImageFiles(getImageUrl($v['path']));
$imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
gc_collect_cycles();
}
}
... ... @@ -57,6 +58,7 @@ class CopyImageFileJob implements ShouldQueue
echo date('Y-m-d H:i:s') . '执行文件的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;
$amazonS3Service->syncImageFiles(getFileUrl($v['path']));
$fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);
gc_collect_cycles();
}
}
return true;
... ...
... ... @@ -68,6 +68,10 @@ class AmazonS3Service
{
$file_content = curl_c($files,false);
$key = str_replace_url($files);
$parsedUrl = parse_url($key);
if(isset($parsedUrl['path'])){
$key = $parsedUrl['path'];
}
try {
$result = $this->s3->putObject([
'Bucket' => $this->bucket,
... ...
... ... @@ -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://globalso-v6.s3.us-west-2.amazonaws.com'
'cdn'=>'https://v6-file.globalso.com'
],
'upload' => [
... ...