作者 赵彬吉
正在显示 40 个修改的文件 包含 620 行增加231 行删除
... ... @@ -82,16 +82,17 @@ class Count extends Command
$arr['updated_at'] = date('Y-m-d H:i:s');
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain'], $v['id']);
echo date('Y-m-d H:i:s') . json_encode($arr) . '->' . PHP_EOL;
$data[] = $arr;
if($arr === false){
$data[] = $v['test_domain'];
}
DB::table('gl_count')->insert($arr);
Log::channel('day_count')->error('日期:'.$arr['created_at'].'success: ' .$v['test_domain']);
}
//判断数据是否存在
DB::table('gl_count')->insert($data);
}
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . ' error: ' . '->' . $e->getMessage() . PHP_EOL;
Log::channel('day_count')->error('day_count:->error ' . $e->getMessage());
}
echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL;
Log::channel('day_count')->error('success:end');
echo $this->error;
}
... ... @@ -127,6 +128,9 @@ class Count extends Command
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
if($inquiry_list == false){
return false;
}
if($inquiry_list['status'] == self::STATUS_ERROR){
$arr['inquiry_num'] = 0;
$countryArr = [];
... ...
... ... @@ -6,6 +6,7 @@ use App\Models\Inquiry\InquiryCount as InquiryCountModel;
use App\Models\Inquiry\InquiryInfo;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
/**
* @remark :
... ... @@ -62,20 +63,24 @@ class InquiryCount extends Command
//获取昨天的时间
$yesterday = Carbon::yesterday()->toDateString();
$inquiryInfoModel = new InquiryInfo();
foreach ($this->status as $k=>$v){
$total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count();
$untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count();
$invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count();
$data[] = [
'type'=>$k,
'day'=>$yesterday,
'total'=>$total ?? 0,
'untreated'=>$untreated ?? 0,
'invalid'=>$invalid ?? 0
];
try {
foreach ($this->status as $k=>$v){
$total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count();
$untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count();
$invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count();
$data[] = [
'type'=>$k,
'day'=>$yesterday,
'total'=>$total ?? 0,
'untreated'=>$untreated ?? 0,
'invalid'=>$invalid ?? 0
];
}
$inquiryCount = new InquiryCountModel();
$inquiryCount->insert($data);
}catch (\Exception $e){
Log::error('inquiry_count : error');
}
$inquiryCount = new InquiryCountModel();
$inquiryCount->insert($data);
return true;
}
}
... ...
... ... @@ -81,7 +81,7 @@ class DeleteBlogCategory extends Command
echo 'success:' . $item['id'] . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('项目初始化失败', $item, $e);
errorLog('delete_blog_category删除失败', $item, $e);
}
}
return true;
... ...
... ... @@ -81,7 +81,7 @@ class DeleteCustomCategory extends Command
echo 'success:' . $item['id'] . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('项目初始化失败', $item, $e);
errorLog('delete_custom_category删除失败', $item, $e);
}
}
return true;
... ...
... ... @@ -68,7 +68,7 @@ class DeleteNewsCategory extends Command
}
foreach ($list as $item){
echo 'start:' . $item['id'] . PHP_EOL;
// try {
try {
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$item['data']['project_id']]);
if($projectInfo === false){
... ... @@ -79,10 +79,10 @@ class DeleteNewsCategory extends Command
DB::disconnect('custom_mysql');
$noticeLogModel->edit(['status'=>NoticeLog::STATUS_SUCCESS],['id'=>$item['id']]);
echo 'success:' . $item['id'] . PHP_EOL;
// }catch (\Exception $e){
// echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
// errorLog('项目初始化失败', $item, $e);
// }
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('delete_news_category删除失败', $item, $e);
}
}
return true;
}
... ...
... ... @@ -82,7 +82,7 @@ class DeleteProductCategory extends Command
echo 'success:' . $item['id'] . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('项目初始化失败', $item, $e);
errorLog('delete_product_category删除失败', $item, $e);
}
}
return true;
... ...
... ... @@ -72,7 +72,6 @@ class DomainInfo extends Command
'domain_start_time' => $time['start'],
'domain_end_time' => $time['end']
];
$domainModel->edit($data, ['id' => $v['id']]);
}
}
... ...
... ... @@ -47,8 +47,6 @@ class RemainDay extends Command
$list = Project::whereIn('type', [2,3,4])->get();
foreach ($list as $item){
if($item['type'] == Project::TYPE_TWO){
//排名达标天数
// $compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0;
//获取当前项目的达标天数
$compliance_day = Project::where(['id' => $item['id']])->value('finish_remain_day') ?: 0;
$remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
... ...
... ... @@ -62,6 +62,7 @@ class ServiceCount extends Command
}
$model->edit(['count'=>$count],['id'=>$v['id']]);
}
return true;
}
}
... ...
... ... @@ -42,16 +42,16 @@ class ImportChannel extends Command
'channel'=>['like','%"user_id": "0"%'],
];
$lists = $projectModel->list($map);
// var_dump($lists);
// die();
foreach ($lists as $k => $v){
$order_id = $v['notice_order_id'];
$api = new OaGlobalsoApi();
$data = $api->order_info($order_id);
$data = $data['data'];
$channel = Channel::getProjectChannel($data['company_id'], $data['username_sales']);
$projectModel->edit(['channel'=>$channel],['id'=>$v['id']]);
if(!empty($lists)){
foreach ($lists as $k => $v){
$order_id = $v['notice_order_id'];
$api = new OaGlobalsoApi();
$data = $api->order_info($order_id);
$data = $data['data'];
$channel = Channel::getProjectChannel($data['company_id'], $data['username_sales']);
$projectModel->edit(['channel'=>$channel],['id'=>$v['id']]);
}
}
return 1;
return true;
}
}
... ...
... ... @@ -30,7 +30,7 @@ class ImportManager extends Command
*
* @var string
*/
protected $description = '导入数据';
protected $description = '导入数据(同步5.0人事信息)';
/**
* @remark :导入5.0管理员数据
* @name :handle
... ...
... ... @@ -57,13 +57,10 @@ class LastInquiry extends Command
//其他询盘的最新时间
ProjectServer::useProject($item['id']);
$other_last_time = InquiryFormData::orderBy('id', 'desc')->value('submit_at');
$last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time;
if(!$last_inquiry_time){
continue;
}
$item->last_inquiry_time = $last_inquiry_time;
$item->save();
}
... ...
... ... @@ -10,6 +10,7 @@ use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class InquiryMonthlyCount extends Command
{
... ... @@ -70,7 +71,12 @@ class InquiryMonthlyCount extends Command
$arr['project_id'] = $value['project_id'];
// 获取当前日期时间
$arr['month'] = Carbon::now()->subMonth()->format('Y-m');
DB::table('gl_month_count')->insert($arr);
try {
DB::table('gl_month_count')->insert($arr);
Log::channel('month_count')->error('success:project_id .'.$arr['project_id']);
}catch (\Exception $e){
Log::channel('month_count')->error('month_count:error ' . $e->getMessage());
}
}
return true;
}
... ...
... ... @@ -80,7 +80,6 @@ class ReplaceHtml extends Command
DB::disconnect('custom_mysql');
}
sleep(10);
return true;
}
}
... ... @@ -207,7 +206,7 @@ class ReplaceHtml extends Command
return $this->getCustomName($source,$source_id,$is_list);
}
if($source == BTemplate::SOURCE_HOME){
return ['name'=>'','route'=>''];;
return ['name'=>'','route'=>''];
}elseif ($source == BTemplate::SOURCE_PRODUCT){
return $this->getProductName($source_id,$is_list);
}elseif ($source == BTemplate::SOURCE_BLOG){
... ...
... ... @@ -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;
... ... @@ -72,34 +74,34 @@ 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'=>0],['video'=>'']);
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;
// }
//
// /**
// * @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'=>0],['video'=>'']);
// echo date('Y-m-d H:i:s') . 'end'.$rs . PHP_EOL;
// return true;
// }
// public function handle(){
// //切换数据库配置
... ...
... ... @@ -50,14 +50,19 @@ class HeaderFooter extends Command
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;
}
/**
* @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);
}
}
... ...
... ... @@ -34,44 +34,63 @@ class Temp extends Command
*/
protected $description = '临时脚本';
public function handle()
{
$domain_model = new DomainInfo();
$notify_model = new Notify();
$project_model = new Project();
$domain_list = $domain_model->list(['amp_status' => 1]);
foreach ($domain_list as $info) {
if ($info['project_id'] > 0) {
$notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
if (!$notify_info) {
$domain_array = parse_url($info['domain']);
$host = $domain_array['host'] ?? $domain_array['path'];
$host_array = explode('.', $host);
if (count($host_array) <= 2) {
array_unshift($host_array, 'm');
} else {
$host_array[0] = 'm';
}
$amp_domain = implode('.', $host_array);
$project_info = $project_model->read(['id' => $info['project_id']]);
$notify_model->add([
'project_id' => $info['project_id'],
'type' => 3,
'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
'server_id' => $project_info['serve_id'],
]);
}
}
public function handle(){
ProjectServer::useProject(1515);
$products = Product::select(['id','content'])->get();
foreach ($products as $product){
$content = $product->content;
$content = str_replace('<h1','<h2', $content);
$content = str_replace('</h1','</h2', $content);
$product->content = $content;
$product->save();
$this->output('productID:'.$product->id.',success');
}
$this->output('end');
}
// public function handle()
// {
// $domain_model = new DomainInfo();
// $notify_model = new Notify();
// $project_model = new Project();
//
// $domain_list = $domain_model->list(['amp_status' => 1]);
// foreach ($domain_list as $info) {
// if ($info['project_id'] > 0) {
// $notify_info = $notify_model->read(['project_id' => $info['project_id'], 'type' => 3]);
// if (!$notify_info) {
//
// $domain_array = parse_url($info['domain']);
// $host = $domain_array['host'] ?? $domain_array['path'];
// $host_array = explode('.', $host);
// if (count($host_array) <= 2) {
// array_unshift($host_array, 'm');
// } else {
// $host_array[0] = 'm';
// }
// $amp_domain = implode('.', $host_array);
//
// $project_info = $project_model->read(['id' => $info['project_id']]);
//
// $notify_model->add([
// 'project_id' => $info['project_id'],
// 'type' => 3,
// 'data' => json_encode(['domain' => $amp_domain, 'url' => [], 'language' => []]),
// 'server_id' => $project_info['serve_id'],
// ]);
// }
// }
// }
// }
// public function handle()
// {
// $domain_model = new DomainInfo();
// $server_model = new ServerConfig();
// $project_model = new Project();
//
... ...
... ... @@ -108,7 +108,15 @@ class KeywordVideoController extends BaseController
if($info === false){
$this->response('请先设置域名',Code::SYSTEM_ERROR);
}
$rs = $keywordModel->add($this->param);
//组装数据
$data = [
'project_id'=>$this->param['project_id'],
'number'=>$this->param['number'],
'status'=>$this->param['status'] ?? 0,
'sort'=>$this->param['sort'] ?? 0,
'keywords'=>$this->param['keywords'] ?? '',
];
$rs = $keywordModel->add($data);
if($rs === false){
$this->response('添加失败',Code::SYSTEM_ERROR);
}
... ... @@ -129,9 +137,6 @@ class KeywordVideoController extends BaseController
'id.required' => '主键标识不为空',
]);
$keywordModel = new KeywordVideoTask();
if($this->param['status'] == 0){
$this->param['num'] = $this->param['number'];
}
$rs = $keywordModel->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->response('编辑失败',Code::SYSTEM_ERROR);
... ... @@ -157,4 +162,19 @@ class KeywordVideoController extends BaseController
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :获取任务数量
* @name :taskNum
* @author :lyh
* @method :post
* @time :2024/6/13 16:16
*/
public function taskNum(){
$keywordModel = new KeywordVideoTask();
$data['total'] = $keywordModel->count();
$data['start_total'] = $keywordModel->formatQuery(['status'=>0])->count();
$data['end_total'] = $keywordModel->formatQuery(['status'=>1])->count();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -13,6 +13,7 @@ use App\Http\Controllers\Bside\BaseController;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateOldInfo;
use App\Models\Domain\DomainInfo;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\Template\BTemplate;
... ... @@ -96,17 +97,36 @@ class UpdateController extends BaseController
$this->fail('已上线项目需填写采集的测试站域名');
}
$product_cate_type = 0;//产品分类是否重采
$news_cate_type = 0;//新闻分类是否重采
if ($this->param['type'] == 1) {
$product_cate_type = 1;
$news_cate_type = 1;
$bSettingModel = new Setting();
$template_info = $bSettingModel->read(['project_id' => $this->param['project_id']]);
$template_id = $template_info ? $template_info['template_id'] : 0;//获取模版id
//产品分类重采之前,判断产品分类是否开启了可视化
$category_list = Category::where('project_id', $this->param['project_id'])->get();
if ($category_list->count() > 0) {
$bSettingModel = new Setting();
$template_info = $bSettingModel->read(['project_id' => $this->param['project_id']]);
$template_id = $template_info ? $template_info['template_id'] : 0;//获取模版id
foreach ($category_list as $category) {
if ($this->getRenovation($this->param['project_id'], BTemplate::SOURCE_PRODUCT, BTemplate::IS_LIST, $template_id, $category['id']) == 1) {
//有分类开启了可视化
$this->param['type'] = 0;
$product_cate_type = 0;
break;
}
}
}
//新闻分类重采之前,判断新闻分类是否开启了可视化
$category_news_list = NewsCategory::where('project_id', $this->param['project_id'])->get();
if ($category_news_list->count() > 0) {
foreach ($category_news_list as $category_news) {
if ($this->getRenovation($this->param['project_id'], BTemplate::SOURCE_NEWS, BTemplate::IS_LIST, $template_id, $category_news['id']) == 1) {
//有分类开启了可视化
$news_cate_type = 0;
break;
}
}
... ... @@ -143,13 +163,20 @@ class UpdateController extends BaseController
}
}
if ($this->param['type'] == 1) {
if ($product_cate_type == 1) {
//需要重新采集产品分类
DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category`");
DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category_related`");
DB::connection('custom_mysql')->statement("DELETE FROM `gl_route_map` WHERE `source` = 'product_category'");
}
if ($news_cate_type == 1) {
//需要重新采集新闻分类
DB::connection('custom_mysql')->statement("TRUNCATE `gl_news_category`");
DB::connection('custom_mysql')->statement("DELETE FROM `gl_route_map` WHERE `source` = 'news_category'");
}
} catch (\Exception $e) {
errorLog('重新采集升级项目数据', $this->param, $e);
... ... @@ -171,14 +198,19 @@ class UpdateController extends BaseController
$old_info->save();
}
if ($this->param['type'] == 1) {
//需要重新采集产品分类,只排除新闻分类
$not_api_type = ['category_news'];
if ($product_cate_type == 1 && $news_cate_type == 1) {
//需要重新采集产品分类和新闻分类
$logs = UpdateLog::where('project_id', $this->param['project_id'])->orderBy('sort', 'asc')->get();
} elseif ($product_cate_type == 1 && $news_cate_type == 0) {
//只重采产品分类
$logs = UpdateLog::where('project_id', $this->param['project_id'])->where('api_type', '!=', 'category_news')->orderBy('sort', 'asc')->get();
} elseif ($product_cate_type == 0 && $news_cate_type == 1) {
//只重采新闻分类
$logs = UpdateLog::where('project_id', $this->param['project_id'])->where('api_type', '!=', 'category')->orderBy('sort', 'asc')->get();
} else {
//无需重新采集产品分类,排除产品分类和新闻分类
$not_api_type = ['category', 'category_news'];
//分类都不重采
$logs = UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news'])->orderBy('sort', 'asc')->get();
}
$logs = UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', $not_api_type)->orderBy('sort', 'asc')->get();
foreach ($logs as $log) {
$log->status = 0;
... ...
... ... @@ -214,6 +214,9 @@ class OptimizeController extends BaseController
if(isset($this->map['title']) && !empty($this->map['title'])){
$query = $query->where('gl_project.title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['ai_video']) && !empty($this->map['ai_video'])){
$query = $query->where('gl_project_deploy_optimize.ai_video',$this->map['ai_video']);
}
if(isset($this->map['amp_status'])){
$query = $query->where('gl_domain_info.amp_status',$this->map['amp_status']);
}
... ...
... ... @@ -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);
}
... ...
... ... @@ -197,14 +197,11 @@ class ImageController extends Controller
if($image_hash !== false){
return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'], $name));
}
//保存路径
$url = $this->config['root'].$this->path;
$image_type = $files->getClientOriginalExtension();
if(strlen($image_type) > 7){
$this->response('不支持当前格式',Code::SYSTEM_ERROR);
}
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
//上传到cos
if($this->upload_location == 0){
$cosService = new CosService();
... ... @@ -290,13 +287,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;
}
... ... @@ -325,36 +318,39 @@ class ImageController extends Controller
private function multi(&$files) {
$data = [];
foreach ($files as $file) {
$imageModel = new ImageModel();
$hash = hash_file('sha256', $file->getPathname());
$name = $file->getClientOriginalName();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
$image_hash = $imageModel->read($param);
if($image_hash !== false){
$data[] = $this->responseData($image_hash['path']);
continue;
}
$image_type = $file->getClientOriginalExtension();
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
//同步数据到cos
if($this->upload_location == 0){
$cosService = new CosService();
$cosService->uploadFile($file,$this->path,$fileName);
}else{
//TODO::上传亚马逊
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($file,$this->path,$fileName);
try {
$hash = hash_file('sha256', $file->getPathname());
$imageModel = new ImageModel();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
$image_hash = $imageModel->read($param);
if($image_hash !== false){
$data[] = $this->responseData($image_hash['path'],$image_hash['name']);
continue;
}
$name = $file->getClientOriginalName();
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
$image_type = $file->getClientOriginalExtension();
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
//同步数据到cos
if($this->upload_location == 0){
$cosService = new CosService();
$cosService->uploadFile($file,$this->path,$fileName);
}else{
//TODO::上传亚马逊
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($file,$this->path,$fileName);
}
$this->synchronizationImage($fileName,$this->upload_location);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
}catch (\Exception $e){
$this->response('图片资源',Code::SUCCESS,$data);
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
$this->synchronizationImage($fileName,$this->upload_location);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
}
$this->response('图片资源',Code::SUCCESS,$data);
$this->response('图片资源',Code::SUCCESS,$data);
}
/**
... ...
... ... @@ -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
... ...
... ... @@ -131,7 +131,7 @@ class CustomTemplateLogic extends BaseLogic
if($rs === false){
$this->fail('系统错误,请联系管理');
}
$this->setTemplateLog($bSettingInfo['template_id'],$html,$this->param['id']);
$this->setTemplateLog($bSettingInfo['template_id'] ?? 0,$html,$this->param['id']);
//通知
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']);
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$info['url']]);
... ...
... ... @@ -45,8 +45,8 @@ class NewsCategoryLogic extends BaseLogic
public function newsCategorySave(){
//验证名称是否存在
$this->verifyParamName($this->param['name']);
DB::beginTransaction();
try {
// DB::beginTransaction();
// try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
... ... @@ -62,11 +62,11 @@ class NewsCategoryLogic extends BaseLogic
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('系统错误,请联系管理员');
// }
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
$this->curlDelRoute(['new_route'=>$route]);
return $this->success(['id'=>$id]);
... ...
... ... @@ -79,7 +79,7 @@ class CategoryLogic extends BaseLogic
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
$list = $this->model->list(['pid'=>$id,'status'=>1],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
... ... @@ -317,7 +317,8 @@ class CategoryLogic extends BaseLogic
*/
public function copyTemplate($id,$project_id,$save_id){
$BTemplateModel = new BTemplate();
$list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_LIST,'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]);
$list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_LIST,
'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]);
if(!empty($list)){
$data = [];
foreach ($list as $v){
... ...
... ... @@ -154,7 +154,7 @@ class KeywordLogic extends BaseLogic
}
}
}catch (\Exception $e){
return false;
$this->fail('保存失败,请联系管理员');
}
Common::del_user_cache('product_keyword',$this->user['project_id']);
NoticeLog::createLog(NoticeLog::TYPE_INIT_KEYWORD, ['project_id' => $this->user['project_id']]);
... ...
... ... @@ -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']);
... ...
... ... @@ -14,8 +14,10 @@ use App\Models\Com\UpdateLog;
use App\Models\RouteMap\RouteMap;
use App\Models\User\UserLog;
use App\Models\WebSetting\Translate as TranslateModel;
use App\Models\WebSetting\TranslateData;
use App\Models\WebSetting\WebLanguage;
use App\Helper\Translate;
use Illuminate\Support\Facades\DB;
class TranslateLogic extends BaseLogic
{
... ... @@ -36,9 +38,9 @@ class TranslateLogic extends BaseLogic
public function getTranslateList(){
$data = [];
if($this->param['url'] == 'All' || $this->param['url'] == 'other_all_text'){
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
if(!empty($info) && !empty($info['data'])){
$translateInfo = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$info = $this->model->with('translate_data')->where(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']])->first();
if(!empty($info) && !empty($info['translate_data'])){
$translateInfo = json_decode($info['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
foreach ($translateInfo as $k => $v){
$data[] = [$k=>$v];
}
... ... @@ -50,12 +52,15 @@ class TranslateLogic extends BaseLogic
// 需要校对语种
$languageInfo = $this->getLanguage($this->param['language_id']);
// 原始校对内容
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
$param = $this->getRouteSource($this->param['url']);
$param['language_id'] = $this->param['language_id'];
$param['type'] = $this->param['type'];
$info = $this->model->with('translate_data')->where($param)->first();
//获取当前URl的所有文本内容
$text_array = $this->getUrlRead($url);
// 原始校对程序
$old_key = [];//key值组成数据
$data_read = json_decode($info ? $info['data'] : '',JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$data_read = json_decode($info && $info['translate_data'] ? $info['translate_data']['data'] : '',JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if(!empty($data_read)){
foreach ($data_read as $k => $v){
$k = urldecode($k);
... ... @@ -109,10 +114,10 @@ class TranslateLogic extends BaseLogic
*/
public function getTranslateImageList(){
if($this->param['url'] == 'All'){
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
$info = $this->model->with('translate_data')->where(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']])->first();
$data = [];
if(!empty($info) && !empty($info['data'])){
$translateInfo = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if(!empty($info) && !empty($info['translate_data'])){
$translateInfo = json_decode($info['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
foreach ($translateInfo as $k => $v){
$data[] = [$k=>$v];
}
... ... @@ -120,9 +125,12 @@ class TranslateLogic extends BaseLogic
return $this->success($data);
}
$url = $this->user['domain'].(($this->param['url'] != '/') ? $this->param['url'] : '');
$info = $this->model->read(['url'=>str_replace_url($this->param['url']),'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
$param = $this->getRouteSource($this->param['url']);
$param['language_id'] = $this->param['language_id'];
$param['type'] = $this->param['type'];
$info = $this->model->with('translate_data')->where($param)->first();
$data = [];
if($info === false){
if(empty($info)){
$new_list = $this->getUrlImageRead($url);
foreach ($new_list as $v){
$data[] = [
... ... @@ -133,7 +141,7 @@ class TranslateLogic extends BaseLogic
}
$new_list = $this->getUrlImageRead($url);
$old_list = [];
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$data_read = json_decode($info && $info['translate_data'] ? $info['translate_data']['data'] : '',JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
foreach ($data_read as $k=>$v){
$old_list[] = $k;
$data[] = [
... ... @@ -258,6 +266,7 @@ class TranslateLogic extends BaseLogic
}
//解析路由
$sendData = $this->handleRoute($this->param['url']);
DB::beginTransaction();
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){
... ... @@ -273,18 +282,19 @@ class TranslateLogic extends BaseLogic
'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);
$id = $this->model->addReturnId($param);
TranslateData::insert(['trans_id'=>$id,'data'=>json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
}else{
if(!empty($data)){
$data = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$rs = $this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'project_id'=>$this->user['project_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
TranslateData::where(['trans_id'=>$info['id']])->update(['data'=>json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
}
}
//写日志
$userLogModel = new UserLog();
$userLogModel->add(['model'=>'translate/save','remark'=>json_encode($this->param,true),'type'=>0,'operator_id'=>$this->user['id'],'project_id'=>$this->user['project_id']]);
DB::commit();
}catch (\Exception $e){
DB::rollback();
$this->fail('系统错误请联系管理员');
}
$this->sendMessage($sendData);
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class Base extends Model
{
... ... @@ -94,6 +95,7 @@ class Base extends Model
* @time :2023/8/21 17:18
*/
public function add($data){
$data = $this->filterRequestData($data);
$data['created_at'] = date('Y-m-d H:i:s');
$data['updated_at'] = $data['created_at'];
return $this->insert($data);
... ... @@ -107,6 +109,7 @@ class Base extends Model
* @time :2023/8/21 17:17
*/
public function addReturnId($data){
$data = $this->filterRequestData($data);
$data['created_at'] = date('Y-m-d H:i:s');
$data['updated_at'] = $data['created_at'];
return $this->insertGetId($data);
... ... @@ -123,6 +126,7 @@ class Base extends Model
if(isset($data['id']) && !empty($data['id'])){
unset($data['id']);
}
$data = $this->filterRequestData($data);
$query = $this->formatQuery($condition);
$data['updated_at'] = date('Y-m-d H:i:s');
return $query->update($data);
... ... @@ -140,6 +144,7 @@ class Base extends Model
$query = $this->formatQuery($condition);
return $query->delete();
}
/**
* @name :参数处理查询
* @param $map = ['$k'=>['like',$v],$k1]
... ... @@ -226,8 +231,6 @@ class Base extends Model
*/
protected static function booted()
{
//保存前数据 $row->original['xx']
//保存后数据 $row->xx
static::saved(function ($row) {
//删除缓存
$row->original && static::clearCache($row);
... ... @@ -251,4 +254,21 @@ class Base extends Model
return true;
}
/**
* @remark :过滤掉请求数据中不存在于数据库表中的字段
* @name :filterRequestData
* @author :lyh
* @method :post
* @time :2024/6/14 10:49
*/
public function filterRequestData(array $data)
{
// 获取表的字段列表
$columns = Schema::connection($this->connection)->getColumnListing($this->table);
// 过滤数据
return array_filter($data, function ($key) use ($columns) {
return in_array($key, $columns);
}, ARRAY_FILTER_USE_KEY);
}
}
... ...
... ... @@ -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);
}
... ...
... ... @@ -109,6 +109,7 @@ class Project extends Base
12 => 'AI',
13 => 'AI站群',
14 => '未达标',
15 => 'AI视频'
];
}
... ...
... ... @@ -34,10 +34,6 @@ class AggregationSetting extends Base
public function getTopBannerAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
foreach ($value as $k => $v){
$v = getImageUrl($v);
$value[$k] = $v;
}
}
return $value;
}
... ... @@ -52,10 +48,6 @@ class AggregationSetting extends Base
public function getFootBannerAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
foreach ($value as $k => $v){
$v = getImageUrl($v);
$value[$k] = $v;
}
}
return $value;
}
... ...
... ... @@ -20,4 +20,15 @@ class Translate extends Base
public static $textType = 1;
public static $imageType = 2;
/**
* 校对详情数据
* @return \Illuminate\Database\Eloquent\Relations\HasOne
* @author Akun
* @date 2024/06/14 14:54
*/
public function translate_data()
{
return self::hasOne(TranslateData::class, 'trans_id', 'id');
}
}
... ...
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class TranslateData extends Base
{
protected $table = 'gl_translate_data';
//连接数据库
protected $connection = 'custom_mysql';
public $timestamps = false;
}
... ...
... ... @@ -78,6 +78,18 @@ return [
'via' => \App\Factory\LogFormatterFactory::class,
'prefix' => 'test',
],
//日记录日志
'day_count' => [
'driver' => 'custom',
'via' => \App\Factory\LogFormatterFactory::class,
'prefix' => 'day_count',
],
//月记录日志
'month_count' => [
'driver' => 'custom',
'via' => \App\Factory\LogFormatterFactory::class,
'prefix' => 'month_count',
],
'wechatside' => [
'driver' => 'custom',
'via' => \App\Factory\LogFormatterFactory::class,
... ...
... ... @@ -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');
... ... @@ -345,6 +348,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/createKeywordTask', [Aside\Com\KeywordVideoController::class, 'createKeywordTask'])->name('keyword_video_createKeywordTask');
Route::any('/edit', [Aside\Com\KeywordVideoController::class, 'edit'])->name('keyword_video_edit');
Route::any('/getVideoTaskLog', [Aside\Com\KeywordVideoController::class, 'getVideoTaskLog'])->name('keyword_video_getVideoTaskLog');
Route::any('/taskNum', [Aside\Com\KeywordVideoController::class, 'taskNum'])->name('keyword_video_taskNum');
});
// 公共主题模版
... ...