作者 刘锟

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

... ... @@ -14,6 +14,8 @@ use App\Models\File\File as FileModel;
use App\Models\File\Image;
use App\Models\File\Image as ImageModel;
use App\Models\Product\Keyword;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
use App\Models\Project\Project;
use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
... ... @@ -138,14 +140,4 @@ class Demo extends Command
// }
// return true;
// }
public function handle(){
$keywordModel = new KeywordVideoTask();
$lists = $keywordModel->list(['keywords'=>['!=',null]]);
foreach ($lists as $v){
$keywords = str_replace(["\r\n", "\r", "\n"], ',', $v['keywords']);
$keywordModel->edit(['keywords'=>$keywords],['id'=>$v['id']]);
}
return true;
}
}
... ...
... ... @@ -56,6 +56,13 @@ class HeaderFooter extends Command
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :头部底部分开脚本
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2024/6/17 14:46
*/
public function saveTemplateCom($project_id){
//获取当前项目选择的模版
$settingModel = new Setting();
... ...
<?php
/**
* @remark :
* @name :ProductFileUpload.php
* @author :lyh
* @method :post
* @time :2024/6/18 15:43
*/
namespace App\Console\Commands\Test;
use App\Models\File\File;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class ProductFileUpload extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'files_upload {project_id}';
/**
* The console command description.
*
* @var string
*/
protected $description = '重新上传文件获取文件后缀';
/**
* @remark :
* @name :handle
* @author :lyh
* @method :post
* @time :2024/6/18 15:46
*/
public function handle(){
$project_id = $this->argument('project_id');
ProjectServer::useProject($project_id);
$productModel = new Product();
$lists = $productModel->list(['status'=>1,'id'=>['<=',106]]);
foreach ($lists as $k => $v){
if(!empty($v['files']) && !empty($v['files']['url'])){
$url = str_replace_url($v['files']['url']);
//获取当前图片的原名称
$files = new File();
$fileInfo = $files->read(['path'=>$url,'project_id'=>$project_id]);
if($fileInfo === false){
continue;
}
$newName = $fileInfo['name'];
$code = $this->synchronizationFile($url,$newName);
if((int)$code == 200){
echo date('Y-m-d H:i:s') . '编辑的path为:'. $url .',主键id:'. $v['id'] . PHP_EOL;
$v['files']['url'] = preg_replace('#/[^/]*$#', '/', $url).$newName;
$productModel->edit(['files'=>json_encode($v['files'])],['id'=>$v['id']]);
}
}
}
DB::disconnect('custom_mysql');
}
/**
* @remark :指定同步文件到獨立177服務器
* @name :synchronizationFile
* @author :lyh
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationFile($path_name,$newName){
//同步到大文件
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
echo date('Y-m-d H:i:s') . '编辑的path为:'. $file_path. PHP_EOL;
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" -F "file_name='.$newName.'" https://v6-file.globalso.com/fileUploads.php';
return shell_exec($cmd);
}
}
... ...
<?php
/**
* @remark :
* @name :SyncProjectFile.php
* @author :lyh
* @method :post
* @time :2024/6/18 14:53
*/
namespace App\Console\Commands\Test;
use App\Models\File\ErrorFile;
use App\Models\File\File;
use Illuminate\Console\Command;
class SyncProjectFile extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_project_file {project_id}';
/**
* The console command description.
*
* @var string
*/
protected $description = '同步图片与文件';
public function handle(){
$project_id = $this->argument('project_id');
$fileModel = new File();
$lists = $fileModel->list(['project_id'=>$project_id]);//未同步成功的图片及文件
foreach ($lists as $k => $v){
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;
}
}
echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
return true;
}
/**
* @remark :指定同步文件到獨立177服務器
* @name :synchronizationFile
* @author :lyh
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationFile($path_name){
//同步到大文件
$file_path = config('filesystems.disks.cos')['cdn1'].$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);
}
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);
}
}
... ...
... ... @@ -105,6 +105,7 @@ class ProjectController extends BaseController
'gl_project_deploy_build.tech_mid AS tech_mid',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_build.plan AS plan',
'gl_project_deploy_build.is_participle AS is_participle',
'gl_project_deploy_optimize.dept_id AS optimize_dept_id',
'gl_project_deploy_optimize.manager_mid AS optimize_manager_mid',
'gl_project_deploy_optimize.optimist_mid AS optimize_optimist_mid',
... ... @@ -367,7 +368,6 @@ class ProjectController extends BaseController
$item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN);
$item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]);
$item['collect_time'] = $item['is_upgrade'] ? UpdateLog::getProjectUpdate($item['id']) : '';
return $item;
}
... ... @@ -389,6 +389,23 @@ class ProjectController extends BaseController
}
/**
* @remark :逻辑删除
* @name :deleteMinorLanguages
* @author :lyh
* @method :post
* @time :2024/6/18 11:53
*/
public function deleteMinorLanguages(ProjectLogic $logic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->deleteMinorLanguages();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
... ... @@ -1007,4 +1024,23 @@ class ProjectController extends BaseController
$this->response('success');
}
/**
* @remark :开启与关闭分词搜索
* @name :setIsParticiple
* @author :lyh
* @method :post
* @time :2024/6/19 10:07
*/
public function setIsParticiple(){
$this->request->validate([
'project_id'=>'required',
'is_participle'=>'required'
],[
'project_id.required' => '项目id不能为空',
'is_participle.required' => '项目id不能为空',
]);
$deployBuildModel = new DeployBuild();
$deployBuildModel->edit(['is_participle'=>$this->param['is_participle']],['project_id'=>$this->param['project_id']]);
$this->response('success');
}
}
... ...
... ... @@ -343,11 +343,11 @@ class FileController
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$fileUrl = getFileUrl($info['path'],$info['is_cos']);
// $fileName = basename($fileUrl); // 要保存的文件名
// 设置响应头
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . !empty($info['name']) ? $info['name'] : '未命名'.basename($info['path']) . '"');
$name = !empty($info['name']) ? $info['name'] : '未命名'.basename($info['path']);
header('Content-Disposition: attachment; filename="'.$name.'"');
// 下载文件
readfile($fileUrl);
}
... ...
... ... @@ -290,13 +290,9 @@ class ImageController extends Controller
'name'=>$name,
'en_name'=>$fileName
];
$imageModel = new ImageModel();
$info = $imageModel->read(['hash'=>$hash,'project_id'=>$this->cache['project_id'] ?? 0]);
if($info === false){
$rs = $imageModel->add($data);
if ($rs === false) {
return $this->response('添加失败', Code::USER_ERROR);
}
$rs = $imageModel->add($data);
if ($rs === false) {
return $this->response('添加失败', Code::USER_ERROR);
}
return true;
}
... ... @@ -335,7 +331,7 @@ class ImageController extends Controller
}
$image_hash = $imageModel->read($param);
if($image_hash !== false){
$data[] = $this->responseData($image_hash['path']);
$data[] = $this->responseData($image_hash['path'],$image_hash['name']);
continue;
}
$image_type = $file->getClientOriginalExtension();
... ...
... ... @@ -77,7 +77,6 @@ class ProjectLogic extends BaseLogic
public function getProjectInfo($id){
$info = $this->model->with(['payment', 'deploy_build', 'deploy_optimize', 'online_check', 'project_after','inquiry_filter_config','web_traffic_config'])->where(['id'=>$id])->first()->toArray();
$info['online_check']['name'] = (new Manage())->getName($info['online_check']['created_manage_id'] ?? 0);
$info['deploy_optimize']['minor_keywords'] = !empty($info['deploy_optimize']['minor_keywords']) ? json_decode($info['deploy_optimize']['minor_keywords']) : [];
$info['init_domain'] = $this->getInitDomain($info['serve_id'])['domain'];
if($info['extend_type'] != 0){
$info['type'] = $info['extend_type'];
... ... @@ -99,12 +98,27 @@ class ProjectLogic extends BaseLogic
if(isset($info['deploy_build']['other_project']) && !empty($info['deploy_build']['other_project'])){
$info['deploy_build']['other_project']= json_decode($info['deploy_build']['other_project']);
}
//获取小语种
$info['minor_languages'] = $this->getProjectMinorLanguages($id);
//升级项目采集完成时间
$info['collect_time'] = $info['is_upgrade'] ? UpdateLog::getProjectUpdate($id) : '';
return $this->success($info);
}
/**
* @remark :获取当前项目的小语种配置
* @name :getProjectMinorLanguages
* @author :lyh
* @method :post
* @time :2024/6/18 11:05
*/
public function getProjectMinorLanguages($project_id){
$projectMinorLanguagesModel = new MinorLanguages();
$lists = $projectMinorLanguagesModel->list(['project_id'=>$project_id,'is_delete'=>0]);
return $this->success($lists);
}
/**
* @remark :获取初始域名
* @name :getInitDomain
* @author :lyh
... ... @@ -149,8 +163,11 @@ class ProjectLogic extends BaseLogic
$this->saveProjectDeployOptimize($this->param['deploy_optimize']);
//保存售后信息
$this->saveProjectAfter($this->param['project_after']);
$this->saveMinorLanguages($this->param['deploy_optimize']['minor_languages'] ?? []);
//单独保存小语种配置
$this->saveMinorLanguages($this->param['minor_languages'] ?? [],$this->param['id']);
//同步图片文件
$this->syncImageFile($this->param['project_location'],$this->param['id']);
//同步信息表
(new SyncService())->projectAcceptAddress($this->param['id']);
}
// DB::commit();
... ... @@ -161,6 +178,13 @@ class ProjectLogic extends BaseLogic
return $this->success();
}
/**
* @remark :危险项目同步图片与文件
* @name :syncImageFile
* @author :lyh
* @method :post
* @time :2024/6/18 10:51
*/
public function syncImageFile($location,$project_id){
if($location == 1){
CopyImageFileJob::dispatch(['project_id'=>$project_id]);
... ... @@ -176,6 +200,8 @@ class ProjectLogic extends BaseLogic
* @time :2023/8/30 12:14
*/
public function saveProject($param){
// unset($param['payment'],$param['deploy_build'],$param['deploy_optimize'],
// $param['online_check'],$param['project_after'],$param['inquiry_filter_config'],$param['minor_languages']);
if((($param['type'] == Project::TYPE_TWO) || ($param['type'] == Project::TYPE_THREE)) && empty($param['uptime'])){
$param['uptime'] = date('Y-m-d H:i:s');
}
... ... @@ -207,8 +233,6 @@ class ProjectLogic extends BaseLogic
}
$param['remain_day'] = $param['deploy_build']['service_duration'] - $param['finish_remain_day'];
$param['remain_day'] = ($param['remain_day'] > 0) ? $param['remain_day'] : 0;
unset($param['payment'],$param['deploy_build'],$param['deploy_optimize'],
$param['online_check'],$param['project_after'],$param['inquiry_filter_config'],$param['minor_language']);
//文件上传默认值
if($param['is_upload_manage']){
$param['upload_config'] = [
... ... @@ -278,9 +302,7 @@ class ProjectLogic extends BaseLogic
//更改域名
$this->editDomainStatus($deploy_optimize['domain'],$deploy_optimize['project_id']);
}
$deploy_optimize['minor_languages'] = Arr::a2s($deploy_optimize['minor_languages'] ?? []);
$deploy_optimize['g_top_plan'] = Arr::a2s($deploy_optimize['g_top_plan'] ?? []);
$deploy_optimize['minor_keywords'] = Arr::a2s(!empty($deploy_optimize['minor_keywords']) ? $deploy_optimize['minor_keywords'] : []);
$deploy_optimize['special'] = !empty($deploy_optimize['special']) ? ','.trim($deploy_optimize['special'],',').',' : '';
//是否更新了api_no
$api_no = DeployOptimize::where('id', $deploy_optimize['id'])->value('api_no');
... ... @@ -324,30 +346,41 @@ class ProjectLogic extends BaseLogic
* @method :post
* @time :2023/8/30 13:57
*/
protected function saveMinorLanguages($minor_language){
protected function saveMinorLanguages($minor_language,$project_id){
$data = [];
//查询数据是否存在
$languageModel = new MinorLanguages();
$languageModel->del(['project_id'=>$this->param['id']]);
if(!empty($minor_language)){
$webLanguageModel = new WebLanguage();
$result = [];
foreach ($minor_language as $k => $v){
foreach ($minor_language as $v){
if(!empty($v['lang'])){
$zh = $webLanguageModel->read(['short'=>$v['lang']],['chinese']);
if(empty($zh)){
if($zh === false){
continue;
}
//获取小语种达标天数
$result['language'] = $zh['chinese'];
$result['lang'] = $v['lang'];
$result['created_at'] = date('Y-m-d H:i:s');
$result['updated_at'] = date('Y-m-d H:i:s');
$result['project_id'] = $this->param['id'];
$result['service_day'] = $v['service_day'];
$result['type'] = $v['type'];
$result['keywords'] = $v['keywords'];
$data[] = $result;
$info = $languageModel->read(['lang'=>$v['lang'],'project_id'=>$project_id]);
if($info === false){
//获取小语种达标天数
$result['language'] = $zh['chinese'];
$result['lang'] = $v['lang'];
$result['created_at'] = date('Y-m-d H:i:s');
$result['updated_at'] = date('Y-m-d H:i:s');
$result['project_id'] = $project_id;
$result['service_day'] = $v['service_day'] ?? 50;
$result['type'] = $v['type'] ?? 0;
$result['keywords'] = $v['keywords'] ?? 50;
$result['minor_keywords'] = $v['minor_keywords'] ?? '';
$data[] = $result;
}else{
$editParam = [
'service_day'=>$v['service_day'],
'type'=>$v['type'],
'keywords'=>$v['keywords'],
'minor_keywords'=>$v['minor_keywords'] ?? '',
'is_delete'=>0
];
$languageModel->edit($editParam,['id'=>$info['id']]);
}
}
}
if(!empty($data)){
... ... @@ -358,6 +391,18 @@ class ProjectLogic extends BaseLogic
}
/**
* @remark :删除小语种(主键id)
* @name :deleteMinorLanguages
* @author :lyh
* @method :post
* @time :2024/6/18 11:32
*/
public function deleteMinorLanguages(){
$languageModel = new MinorLanguages();
return $languageModel->edit(['is_delete'=>1],['id'=>$this->param['id']]);
}
/**
* @remark :创建初始数据
* @name :createProjectData
* @author :lyh
... ...
... ... @@ -284,11 +284,11 @@ class ProductLogic extends BaseLogic
$param['thumb'] = Arr::a2s([]);
$param['gallery'] = Arr::a2s([]);
}
if(isset($param['files']) && !empty($param['files'])){
if(isset($param['files'])){
$param['files']['url'] = str_replace_url($param['files']['url'] ?? '');
$param['files'] = Arr::a2s($param['files'] ?? []);
}else{
$param['files'] = Arr::a2s([]);
$param['files'] = null;
}
if(isset($param['video'])){
$param['video']['url'] = str_replace_url($param['video']['url']);
... ...
... ... @@ -95,7 +95,7 @@ class Base extends Model
* @time :2023/8/21 17:18
*/
public function add($data){
$data = $this->filterRequestData($data,$this->table);
$data = $this->filterRequestData($data);
$data['created_at'] = date('Y-m-d H:i:s');
$data['updated_at'] = $data['created_at'];
return $this->insert($data);
... ... @@ -109,7 +109,7 @@ class Base extends Model
* @time :2023/8/21 17:17
*/
public function addReturnId($data){
$data = $this->filterRequestData($data,$this->table);
$data = $this->filterRequestData($data);
$data['created_at'] = date('Y-m-d H:i:s');
$data['updated_at'] = $data['created_at'];
return $this->insertGetId($data);
... ... @@ -126,7 +126,7 @@ class Base extends Model
if(isset($data['id']) && !empty($data['id'])){
unset($data['id']);
}
$data = $this->filterRequestData($data,$this->table);
$data = $this->filterRequestData($data);
$query = $this->formatQuery($condition);
$data['updated_at'] = date('Y-m-d H:i:s');
return $query->update($data);
... ... @@ -261,10 +261,10 @@ class Base extends Model
* @method :post
* @time :2024/6/14 10:49
*/
public function filterRequestData(array $data, $table)
public function filterRequestData(array $data)
{
// 获取表的字段列表
$columns = Schema::connection($this->connection)->getColumnListing($table);
$columns = Schema::connection($this->connection)->getColumnListing($this->table);
// 过滤数据
return array_filter($data, function ($key) use ($columns) {
return in_array($key, $columns);
... ...
... ... @@ -12,13 +12,13 @@ class DeployOptimize extends Base
protected $table = 'gl_project_deploy_optimize';
public function setMinorLanguagesAttribute($value){
$this->attributes['minor_languages'] = Arr::a2s($value);
}
public function getMinorLanguagesAttribute($value){
return Arr::s2a($value);
}
// public function setMinorLanguagesAttribute($value){
// $this->attributes['minor_languages'] = Arr::a2s($value);
// }
//
// public function getMinorLanguagesAttribute($value){
// return Arr::s2a($value);
// }
public function getGTopPlanAttribute($value){
return Arr::s2a($value);
}
... ...
... ... @@ -162,6 +162,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::get('/', [Aside\Project\ProjectController::class, 'lists'])->name('admin.project');
Route::get('/info', [Aside\Project\ProjectController::class, 'info'])->name('admin.project_info');
Route::post('/save', [Aside\Project\ProjectController::class, 'save'])->name('admin.project_save');
Route::any('/deleteMinorLanguages', [Aside\Project\ProjectController::class, 'deleteMinorLanguages'])->name('admin.project_deleteMinorLanguages');
Route::any('/inquiry_set', [Aside\Project\ProjectController::class, 'inquiry_set'])->name('admin.project_inquiry_set');
Route::any('/get_process_records', [Aside\Project\ProjectController::class, 'get_process_records'])->name('admin.project_get_process_records');
Route::any('/save_process_records', [Aside\Project\ProjectController::class, 'save_process_records'])->name('admin.project_save_process_records');
... ... @@ -188,6 +189,8 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/saveInquiryFilterConfig', [Aside\Project\ProjectController::class, 'saveInquiryFilterConfig'])->name('admin.project_inquiry_filter_config_save');//保存询盘过滤配置
Route::any('/saveWebTrafficConfig', [Aside\Project\ProjectController::class, 'saveWebTrafficConfig'])->name('admin.project_web_traffic_config_save');//保存引流配置
Route::any('/updateProjectManager', [Aside\Project\ProjectController::class, 'updateProjectManager'])->name('admin.project_updateProjectManager');//更改项目人员配置
Route::any('/setIsParticiple', [Aside\Project\ProjectController::class, 'setIsParticiple'])->name('admin.project_setIsParticiple');//开启/关闭分词
//获取关键词前缀和后缀
Route::prefix('keyword')->group(function () {
Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix');
... ...