作者 刘锟

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

正在显示 42 个修改的文件 包含 361 行增加230 行删除
... ... @@ -42,7 +42,7 @@ class Count extends Command
public function handle()
{
$list = DB::table('gl_project')->where('gl_project.extend_type','=',0)
->where('gl_project.type','!=',0)
->where('gl_project.type','!=',0)->where('gl_project.delete_status',0)
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->select($this->selectParam())->get();
... ...
... ... @@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 632;
$project_id = 769;
ProjectServer::useProject($project_id);
$this->count($project_id);
DB::disconnect('custom_mysql');
... ...
... ... @@ -38,7 +38,7 @@ class InquiryMonthlyCount extends Command
*/
public function handle(){
$list = DB::table('gl_project')->where('gl_project.extend_type','=',0)
->where('gl_project.type','!=',0)
->where('gl_project.type','!=',0)->where('gl_project.delete_status',0)
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->select($this->selectParam())->get()->toArray();
... ...
... ... @@ -36,7 +36,7 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 632;
$project_id = 769;
$oldModel = new UpdateOldInfo();
$info = $oldModel->read(['project_id'=>$project_id]);
$url = $info['old_domain_online'];
... ...
... ... @@ -59,17 +59,40 @@ class UpdateMainHtml extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>223]);
$list = $projectModel->list(['is_upgrade'=>0,'type'=>['!=',0]]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->setBlogCustomContent();
$this->getVideoModule($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :查看项目是否有video模块
* @name :getVideoModule
* @author :lyh
* @method :post
* @time :2024/1/29 11:29
*/
public function getVideoModule($project_id){
$customModel = new CustomModule();
$info = $customModel->read(['name'=>'视频模块']);
if($info === false){
echo date('Y-m-d H:i:s') . '添加,项目id:'.$project_id . PHP_EOL;
//执行添加
$data = [
'name'=>'视频模块',
'project_id'=>$project_id,
'route'=>'video',
];
$customModel->add($data);
}
return true;
}
/**
* @remark :所有博客数据添加到自定义模块
* @name :setBlogCustom
* @author :lyh
... ...
... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>0]);
$list = $projectModel->list(['id'=>206]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ... @@ -114,23 +114,25 @@ class UpdateRoute extends Command
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['route'])){
$tag = "-tag";
if ((substr($v['route'], -strlen($tag)) === $tag)) {
echo date('Y-m-d H:i:s') . '拼接 :'.$v['id'] . PHP_EOL;
// $route = Translate::tran($v['route'], 'en').$tag;
// 如果不是以 '-tag' 结尾,则拼接上 '-tag'
$route = trim($v['route'],'-tag');
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// $tag = "-tag";
// if ((substr($v['route'], -strlen($tag)) === $tag)) {
// echo date('Y-m-d H:i:s') . '拼接 :'.$v['id'] . PHP_EOL;
//// $route = Translate::tran($v['route'], 'en').$tag;
// // 如果不是以 '-tag' 结尾,则拼接上 '-tag'
// $route = trim($v['route'],'-tag');
// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }else{
// $route = Translate::tran($v['title'], 'en').$tag;
// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
}
// }else{
// echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
// $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }
}else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$route = Translate::tran($v['title'], 'en');
echo date('Y-m-d H:i:s') . 'route :'.$route . PHP_EOL;
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
}
echo date('Y-m-d H:i:s') . 'end :' . PHP_EOL;
}
... ...
... ... @@ -282,7 +282,9 @@ class WebTraffic extends Command
ProjectServer::useProject($project_id);
//已发布产品分类页面
$data['urls_cats'] = DB::connection('custom_mysql')->table('gl_product_category')
->where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)->pluck('route','id')->toArray();
->where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)
->whereNull('deleted_at')
->pluck('route','id')->toArray();
//已发布单页面
$data['urls_page'] = [];
... ... @@ -291,7 +293,9 @@ class WebTraffic extends Command
//已发布产品详情页
$data['urls_details'] = DB::connection('custom_mysql')->table('gl_product')
->where('project_id', $project_id)->where('status', Product::STATUS_ON)->pluck('route', 'id')->toArray();
->where('project_id', $project_id)->where('status', Product::STATUS_ON)
->whereNull('deleted_at')
->pluck('route', 'id')->toArray();
$data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']);
if(empty($data['urls_cats'])){
... ...
<?php
/**
* @remark :
* @name :CopyProject.php
* @author :lyh
* @method :post
* @time :2024/1/9 16:01
*/
namespace App\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class CopyProject
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $data;
/**
* 监听更新HTML静态页
*/
public function __construct($data)
{
$this->data = $data;
}
}
<?php
use App\Models\File\Image;
use App\Models\File\File;
use App\Models\File\File as FileModel;
use App\Models\RouteMap\RouteMap;
use App\Services\CosService;
use App\Utils\EncryptUtils;
... ... @@ -10,7 +10,6 @@ use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Redis;
use App\Models\User\User;
define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/');
/**
... ... @@ -77,7 +76,6 @@ if (!function_exists('http_post')) {
if (curl_errno($ch)) {
$error_message = curl_error($ch);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($error_message, true) . PHP_EOL, FILE_APPEND);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($res, true) . PHP_EOL, FILE_APPEND);
}
curl_close($ch);
return json_decode($res, true);
... ... @@ -457,11 +455,11 @@ if (!function_exists('getImageUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getImageUrl($path,$storage_type = 0){
function getImageUrl($path,$storage_type = 0,$location = 0){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = getImageUrl($v,$storage_type);
$url[] = getImageUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
... ... @@ -473,12 +471,7 @@ if (!function_exists('getImageUrl')) {
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
$imageModel = new Image();
$imageInfo = $imageModel->read(['path'=>$path],'is_cos');
if($imageInfo === false){
return '';
}
if($imageInfo['is_cos'] == 1){
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
... ... @@ -500,11 +493,11 @@ if (!function_exists('getFileUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getFileUrl($path,$storage_type = 0){
function getFileUrl($path,$storage_type = 0,$location = 0){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = getFileUrl($v,$storage_type);
$url[] = getFileUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
... ... @@ -516,12 +509,7 @@ if (!function_exists('getFileUrl')) {
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
$fileModel = new File();
$fileInfo = $fileModel->read(['path'=>$path],'is_cos');
if($fileInfo === false){
return '';
}
if($fileInfo['is_cos'] == 1){
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
... ...
... ... @@ -217,7 +217,10 @@ class OptimizeController extends BaseController
$query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']);
}
if(isset($this->map['special'])){
$query = $query->where('gl_project_deploy_optimize.special','like','%'.$this->map['special'].'%');
$query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]);
}
if(isset($this->map['is_remain_today'])){
$query = $query->where('gl_project.is_remain_today',$this->map['is_remain_today']);
}
if(isset($this->map['manager_mid']) && !empty($this->map['manager_mid'])){
$query = $query->where('gl_project_deploy_build.manager_mid','like','%'.$this->map['manager_mid'].'%');
... ...
... ... @@ -26,7 +26,7 @@ class ATemplateController extends BaseController
*/
public function lists(ATemplateLogic $aTemplateLogic){
$filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
$this->map['project_id'] = 0;
$this->map['test_model'] = 0;
$lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
... ...
... ... @@ -25,8 +25,10 @@ class ATemplateModuleController extends BaseController
* @time :2023/6/28 16:54
*/
public function lists(ATemplateModuleLogic $ATemplateModuleLogic){
if(!isset($this->map['test_model'])){
$this->map['test_model'] = 0;
if(isset($this->map['type']) && ($this->map['type'] == 99)){
$this->map['type'] = 99;
}else{
$this->map['project_id'] = 0;
}
$lists = $ATemplateModuleLogic->aTemplateModuleLists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
... ...
... ... @@ -38,7 +38,7 @@ class BlogController extends BaseController
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
... ...
... ... @@ -37,7 +37,7 @@ class CustomModuleContentController extends BaseController
$data = $this->getAllCategoryName();
foreach ($lists['list'] as $k=>$v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['operator_name'] = (new User())->getName($v['operator_id']);
$lists['list'][$k] = $v;
}
... ...
... ... @@ -35,6 +35,7 @@ class NavController extends BaseController
if(!empty($lists)){
foreach ($lists as $v){
$v = (array)$v;
$v = $this->handleReturnInfo($v);
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $lists);
$data[] = $v;
... ... @@ -52,6 +53,23 @@ class NavController extends BaseController
}
/**
* @remark :单独处理图片文件
* @name :HandleReturnInfo
* @author :lyh
* @method :post
* @time :2024/1/26 9:44
*/
public function handleReturnInfo($param){
if(isset($param['image']) && !empty($param['image'])){
$param['image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']);
}
if(isset($param['remark_image']) && !empty($param['remark_image'])){
$param['remark_image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']);
}
return $this->success($param);
}
/**
* @remark :根据固定的数组排序
* @name :findDetailsInList
* @author :lyh
... ...
... ... @@ -41,7 +41,7 @@ class NewsController extends BaseController
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
... ... @@ -299,4 +299,21 @@ class NewsController extends BaseController
$logic->batchSetCategory();
$this->response('success');
}
/**
* @remark :Ai发布新闻
* @name :sendAiNews
* @author :lyh
* @method :post
* @time :2024/1/26 15:33
*/
public function sendAiNews(){
$this->request->validate([
'keyword'=>'required',
],[
'keyword.required' => 'keyword不能为空',
]);
$data = http_get('http://gnews.globalso.com/gnews_news.php?keyword='.$this->param['keyword']);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -41,7 +41,7 @@ class CategoryController extends BaseController
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'].'/';
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
$list[$k] = $v;
}
... ...
... ... @@ -43,6 +43,7 @@ class KeywordController extends BaseController
}else{
$v['tdk'] = 0;
}
$v = $this->handleReturnInfo($v);
$v['url'] = $this->user['domain'] . $v['route'].'/';
}
}
... ... @@ -50,6 +51,23 @@ class KeywordController extends BaseController
}
/**
* @remark :单独处理图片文件
* @name :HandleReturnInfo
* @author :lyh
* @method :post
* @time :2024/1/26 9:44
*/
public function handleReturnInfo($param){
if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){
$param['keyword_top_banner'] = getImageUrl($param['keyword_top_banner'],$this->user['storage_type'],$this->user['project_location']);
}
if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){
$param['keyword_foot_banner'] = getImageUrl($param['keyword_foot_banner'],$this->user['storage_type'],$this->user['project_location']);
}
return $this->success($param);
}
/**
* @remark :搜索
* @name :searchParam
* @author :lyh
... ... @@ -82,6 +100,9 @@ class KeywordController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getKeywordInfo();
if($data !== false){
$data = $this->handleReturnInfo($data);
}
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -43,7 +43,7 @@ class ProductController extends BaseController
*/
public function index(Product $product)
{
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb' ,'product_type' , 'route' ,
'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at','six_read'];
$this->order = 'sort';
$query = $product->orderBy($this->order ,'desc')->orderBy('id','desc');
... ... @@ -78,25 +78,25 @@ class ProductController extends BaseController
public function getHandleFileImage($v){
//ToDo::处理图片及文件
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['storage_type'] ?? 0);
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['gallery'])){
foreach ($v['gallery'] as $gallery_k => $gallery_v){
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['storage_type'] ?? 0);
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['gallery'][$gallery_k] = $gallery_v;
}
}
if(!empty($v['icon'])){
foreach ($v['icon'] as $icon_k => $icon_v){
$icon_v = getImageUrl($icon_v,$this->user['storage_type'] ?? 0);
$icon_v = getImageUrl($icon_v,$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['icon'][$icon_k] = $icon_v;
}
}
if(!empty($v['video']) && !empty($v['video']['url'])){
$v['video']['url'] = getImageUrl($v['video']['url'],$this->user['storage_type'] ?? 0);
$v['video']['url'] = getImageUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['files']) && !empty($v['files']['url'])){
$v['files']['url'] = getImageUrl($v['files']['url'],$this->user['storage_type'] ?? 0);
$v['files']['url'] = getImageUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
return $this->success($v);
}
... ... @@ -330,7 +330,7 @@ class ProductController extends BaseController
$arr = json_decode($info['values']);
foreach ($arr as $k1=>$v1){
$v1 = (array)$v1;
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type']);
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
$arr[$k1] = $v1;
}
$v['values'] = $arr;
... ... @@ -339,9 +339,9 @@ class ProductController extends BaseController
foreach ($arr1 as $k1=>$v1){
$v1 = (array)$v1;
if(isset($v1['url'])){
$v1['url'] = getFileUrl($v1['url'],$this->user['storage_type']);
$v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
}else{
$v1 = getFileUrl($v1,$this->user['storage_type']);
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']);
}
$arr1[$k1] = $v1;
}
... ...
... ... @@ -25,7 +25,7 @@ class WebSettingImageController extends BaseController
public function lists(WebSettingImage $webSettingImage){
$list = $webSettingImage->list([],'id',['id','image','type']);
foreach ($list as $k=>$v){
$v['image'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$list[$k] = $v;
}
$this->response('success',Code::SUCCESS,$list);
... ...
... ... @@ -22,7 +22,7 @@ class WebSettingServiceController extends BaseController
$lists = $webSettingServiceLogic->setting_service_list();
foreach ($lists as $k => $v){
if($v['type'] == self::TYPE_CODE){
$v['values_link'] = getImageUrl($v['values']);
$v['values_link'] = getImageUrl($v['values'],$this->user['storage_type'],$this->user['project_location']);
$lists[$k] = $v;
}
}
... ...
... ... @@ -22,7 +22,7 @@ class BTemplateController extends BaseController
$lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => &$v){
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$lists['list'][$k] = $v;
}
}
... ...
... ... @@ -363,7 +363,7 @@ class ImageController extends Controller
$lists = $imageModel->lists($this->map,$this->page,$this->row);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image_link'] = getImageUrl($v['path'],$this->cache['storage_type'] ?? 0);
$v['image_link'] = getImageUrl($v['path'],$this->cache['storage_type'] ?? 0,$this->cache['project_location']);
$lists['list'][$k] = $v;
}
}
... ... @@ -429,7 +429,7 @@ class ImageController extends Controller
public function responseData($path = '', $name = ''){
$data = [
'image'=>$path,
'image_link'=>getImageUrl($path,$this->cache['storage_type'] ?? 0),
'image_link'=>getImageUrl($path,$this->cache['storage_type'] ?? 0,$this->cache['project_location'] ?? 0),
'name'=>$name,
'image_download'=>url('a/download_images?path='.$path)
];
... ...
... ... @@ -3,8 +3,11 @@
namespace App\Http\Logic\Aside\Project;
use App\Enums\Common\Code;
use App\Events\CopyImageFile;
use App\Events\CopyProject;
use App\Exceptions\AsideGlobalException;
use App\Jobs\CopyImageFileJob;
use App\Jobs\CopyProjectJob;
use App\Models\Com\NoticeLog;
use App\Models\Com\UpdateLog;
use App\Models\Devops\ServerConfig;
... ... @@ -149,7 +152,7 @@ class ProjectLogic extends BaseLogic
//保存询盘过滤配置
// $this->param['inquiry_filter_config']['project_id'] = $this->param['id'];
// $this->saveInquiryFilterConfig($this->param['inquiry_filter_config']);
$this->syncImageFile($this->param['project_location'],$this->param['id']);
//创建站点
// $this->createSite($this->param);
}
... ... @@ -162,6 +165,13 @@ class ProjectLogic extends BaseLogic
return $this->success();
}
public function syncImageFile($location,$project_id){
if($location == 1){
CopyImageFileJob::dispatch(['project_id'=>$project_id]);
}
return $this->success();
}
/**
* @remark :保存项目
* @name :setExtendType
... ... @@ -330,7 +340,7 @@ class ProjectLogic extends BaseLogic
$config['filter_mobiles'] = Arr::a2s(!empty($config['filter_mobiles']) ? $config['filter_mobiles'] : []);
$config['filter_names'] = Arr::a2s(!empty($config['filter_names']) ? $config['filter_names'] : []);
$config['black_ips'] = $config['black_ips'] ?? '';
$model = InquiryFilterConfig::where('project_id', $config['project_id'])->first();
if(!$model){
$model = new InquiryFilterConfig();
... ... @@ -603,7 +613,7 @@ class ProjectLogic extends BaseLogic
* @time :2023/11/8 14:23
*/
public function copyProject(){
CopyProject::dispatch(['project_id'=>$this->param['project_id']]);
CopyProjectJob::dispatch(['project_id'=>$this->param['project_id']]);
return $this->success();
}
... ...
... ... @@ -64,12 +64,12 @@ class AyrReleaseLogic extends BaseLogic
$imageModel = new Image();
$list = $imageModel->list(['path'=>['in',$images]],'id');
foreach ($list as $v1){
$arr[] = getImageUrl($v1['path']);
$arr[] = getImageUrl($v1['path'],$this->user['storage_type'],$this->user['project_location']);
}
}else{
$fileModel = new File();
$info = $fileModel->read(['path'=>$v]);
$arr[] = getFileUrl($info['path']);
$arr[] = getFileUrl($info['path'],$this->user['storage_type'],$this->user['project_location']);
}
}
return $this->success($arr);
... ...
... ... @@ -101,7 +101,7 @@ class BlogLogic extends BaseLogic
//获取标签名称
$blogLabelLogic = new BlogLabelLogic();
$info['label_name'] = $blogLabelLogic->getLabelName($info['label_id']);
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type']);
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
return $this->success($info);
}
... ...
... ... @@ -82,7 +82,7 @@ class CustomModuleCategoryLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
$info['image'] = getImageUrl($info['image']);
$info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
return $this->success($info);
}
... ...
... ... @@ -39,7 +39,7 @@ class CustomModuleContentLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
$info['image'] = getImageUrl($info['image'],$this->user['storage_type']);
$info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
$info['extend'] = $this->getExtendInfo($info['module_id'],$info['id']);
return $this->success($info);
}
... ... @@ -86,14 +86,14 @@ class CustomModuleContentLogic extends BaseLogic
$arr = json_decode($info['values']);
foreach ($arr as $k1=>$v1){
$v1 = (array)$v1;
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type']);
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
$arr[$k1] = $v1;
}
$v['values'] = $arr;
}elseif($v['type'] == 4){
$arr1 = json_decode($info['values']);
foreach ($arr1 as $k1=>$v1){
$v1 = getFileUrl($v1,$this->user['storage_type']);
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']);
$arr1[$k1] = $v1;
}
$v['values'] = $arr1;
... ...
... ... @@ -97,7 +97,7 @@ class InquiryLogic extends BaseLogic
foreach ($data['list'] as &$v){
foreach ($v['data'] as &$field){
if(is_array($field) && !empty($field['path'])){
$field['path'] = getImageUrl($field['path']);
$field['path'] = getImageUrl($field['path'],$this->user['storage_type'],$this->user['project_location']);
}
}
$v = array_merge($v, $v['data']);
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Logic\Bside\News;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\News\News;
use App\Models\News\NewsCategory;
... ... @@ -147,7 +148,7 @@ class NewsLogic extends BaseLogic
$this->fail('error');
}
$info['category_id'] = explode(',',trim($info['category_id'],','));
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type']);
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
return $this->success($info);
}
... ... @@ -181,6 +182,9 @@ class NewsLogic extends BaseLogic
*/
public function paramProcessing($param)
{
if(isset($param['image'])){
$param['image'] = str_replace_url($param['image'] ?? '');
}
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
... ...
... ... @@ -32,7 +32,7 @@ class CategoryLogic extends BaseLogic
foreach ($data as &$v){
$v['url'] = $this->user['domain'] . $v['route'] ;
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
}
if(!$map){
$data = Arr::listToTree($data);
... ... @@ -100,8 +100,8 @@ class CategoryLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或者已被删除');
}
$info['image_link'] = getImageUrl($info['image']);
$info['describe_image'] = !empty($info['describe_image']) ? getImageUrl(json_decode($info['describe_image'])) : [];
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
$info['describe_image'] = !empty($info['describe_image']) ? getImageUrl(json_decode($info['describe_image']),$this->user['storage_type'],$this->user['project_location']) : [];
return $this->success($info);
}
... ...
... ... @@ -40,8 +40,10 @@ class KeywordLogic extends BaseLogic
public function getKeywordInfo()
{
$info = $this->model->read($this->param);
$info['url'] = $this->user['domain'] . $info['route'];
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
if($info !== false){
$info['url'] = $this->user['domain'] . $info['route'];
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
}
return $this->success($info);
}
... ... @@ -103,30 +105,20 @@ class KeywordLogic extends BaseLogic
* @time :2023/10/23 14:47
*/
public function handleSaveParam($param){
if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){
$param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner']);
}else{
unset($param['keyword_top_banner']);
if(isset($param['keyword_top_banner'])){
$param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner'] ?? []);
}
if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){
$param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner']);
}else{
unset($param['keyword_foot_banner']);
if(isset($param['keyword_foot_banner'])){
$param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner'] ?? []);
}
if(isset($param['keyword_video']) && !empty($param['keyword_video'])){
$param['keyword_video'] = Arr::a2s($param['keyword_video']);
}else{
unset($param['keyword_video']);
if(isset($param['keyword_video'])){
$param['keyword_video'] = Arr::a2s($param['keyword_video'] ?? []);
}
if(!empty($param['related_news_ids'])){
$param['related_news_ids'] = Arr::arrToSet($param['related_news_ids']);
}else{
unset($param['related_news_ids']);
$param['related_news_ids'] = Arr::arrToSet($param['related_news_ids'] ?? []);
}
if(!empty($param['related_blog_ids'])){
$param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids']);
}else{
unset($param['related_blog_ids']);
$param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids'] ?? []);
}
return $param;
}
... ...
... ... @@ -24,11 +24,10 @@ class TranslateLogic extends BaseLogic
}
/**
* @remark :
* @name :getTranslateList
* @author :lyh
* @method :post
* @time :2024/1/12 9:43
* 获取翻译校对文案
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
*/
public function getTranslateList(){
$data = [];
... ... @@ -42,44 +41,46 @@ class TranslateLogic extends BaseLogic
}
return $this->success($data);
}
$url = $this->user['domain'].(($this->param['url'] != '/') ? $this->param['url'] : '');
// 需要校对路由
$url = $this->user['domain'] . (($this->param['url'] != '/') ? $this->param['url'] : '');
// 需要校对语种
$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']]);
//获取当前URl的所有文本内容
$new_key = $this->getUrlRead($url);
if($info === false){
$translate_list = Translate::tran($new_key, $languageInfo['short']);
if(empty($translate_list)){
$this->fail('翻译失败,请联系管理员');
}
foreach ($new_key as $k=>$v){
$data[] = [
trim($v)=>$translate_list[$k],
];
}
return $this->success($data);
}
$text_array = $this->getUrlRead($url);
// 原始校对程序
$old_key = [];//key值组成数据
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE);
foreach ($data_read as $k => $v){
$old_key[] = $k;
$data[] = [$k => $v];
if($info !== false){
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE);
foreach ($data_read as $k => $v){
$old_key[] = $k;
$data[] = [$k => $v];
}
}
$arr2 = array_values(array_diff($new_key, $old_key));
$arr2 = array_values(array_diff($text_array, $old_key));
if(!empty($arr2)){
$i = 0;
TranslateText:
$translate_list = Translate::tran($arr2, $languageInfo['short']);
if(empty($translate_list)){
if ($i < 3) {
$i++;
goto TranslateText;
}
$this->fail('翻译失败,请稍后重试!');
}
if(count($arr2) == 1){
$data[] = [
$arr2[0]=>$translate_list
];
}else{
if(!empty($translate_list)){
foreach ($arr2 as $k => $v){
$data[] = [
trim($v)=>$translate_list[$k]
];
}
foreach ($arr2 as $k => $v){
$data[] = [
trim($v)=>$translate_list[$k]
];
}
}
}
return $this->success($data);
... ... @@ -153,11 +154,9 @@ class TranslateLogic extends BaseLogic
}
/**
* @remark :获取Url内容
* @name :getUrlRead
* @author :lyh
* @method :post
* @time :2023/11/22 10:02
* 获取url HTML需要翻译的文本
* @param $url
* @return array
*/
public function getUrlRead($url){
$dom = file_get_html($url);
... ... @@ -184,10 +183,9 @@ class TranslateLogic extends BaseLogic
}
$need_tran[] = htmlspecialchars_decode(html_entity_decode($string));
}
$need_tran[] = $description->attr['content'];
$need_tran[] = $keywords->attr['content'];
$need_tran[] = $description ? $description->attr['content'] : '';
$need_tran[] = $keywords ? $keywords->attr['content'] : '';
return $need_tran;
return $data;
}
... ...
... ... @@ -28,11 +28,11 @@ class WebSettingAmpLogic extends BaseLogic
return $this->success();
}
//log图处理
$info['top_logo'] = getImageUrl($info['top_logo'], $this->user['storage_type'] ?? 0);
$info['top_logo'] = getImageUrl($info['top_logo'],$this->user['storage_type'],$this->user['project_location']);
//banner处理
if (!empty($info['index_banner'])) {
foreach ($info['index_banner'] as &$v) {
$v = getImageUrl($v, $this->user['storage_type'] ?? 0);
$v = getImageUrl($v,$this->user['storage_type'],$this->user['project_location']);
}
}
return $this->success($info);
... ...
<?php
namespace App\Jobs;
use App\Events\CopyImageFile;
use App\Models\File\File as FileModel;
use App\Models\File\Image as ImageModel;
use App\Services\AmazonS3Service;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class CopyImageFileJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3; // 可配置任务重试次数
protected $param;
/**
* Create a new job instance.
*
* @param CopyImageFile $event
* @return void
*/
public function __construct($data)
{
$this->param = $data;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$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']]);
}
}
$fileModel = new FileModel();
$fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos']);
if(!empty($fileList)){
$amazonS3Service = new AmazonS3Service();
foreach ($fileList as $k => $v){
$amazonS3Service->syncImageFiles(getImageUrl($v['path']));
$fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);
}
}
return true;
}
}
... ...
<?php
namespace App\Listeners;
namespace App\Jobs;
use App\Events\CopyProject;
use App\Events\UpdateHtml;
... ... @@ -14,37 +14,52 @@ use App\Models\Template\Setting;
use App\Models\User\User as UserModel;
use App\Services\ProjectServer;
use Hashids\Hashids;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CopyProjectListener implements ShouldQueue
class CopyProjectJob implements ShouldQueue
{
public function __construct()
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3; // 可配置任务重试次数
protected $param;
/**
* Create a new job instance.
*
* @param CopyImageFile $event
* @return void
*/
public function __construct($data)
{
//
$this->param = $data;
}
/**
* Handle the event.
*
* @param UpdateHtml $event
* @return void
*/
public function handle(CopyProject $event)
public function handle()
{
$this->param = $event->data;
$this->model = new Project();
$projectModel = new Project();
DB::beginTransaction();
try {
//复制初始项目
$data = $this->model::where('id', $this->param['project_id'])->first();
$data = $projectModel::where('id', $this->param['project_id'])->first();
$data = $data->getAttributes();
$type = $data['type'];
$data['type'] = 0;
$data['title'] = $data['title'].'-copy';
unset($data['id']);
$project_id = $this->model->insertGetId($data);
$project_id = $projectModel->insertGetId($data);
//复制部署表
$buildModel = new DeployBuild();
$buildData = $buildModel::where('project_id', $this->param['project_id'])->first();
... ...
... ... @@ -65,31 +65,31 @@ class BNav extends Base
return static::where(['pid'=>$id,'project_id'=>$project_id])->limit(1)->count();
}
/**
* @remark :获取图片
* @name :getImageAttribute
* @author :lyh
* @method :post
* @time :2023/9/18 16:20
*/
public function getImageAttribute($value)
{
$value = getImageUrl($value);
return $value;
}
/**
* @remark :获取图片
* @name :getImageAttribute
* @author :lyh
* @method :post
* @time :2023/9/18 16:20
*/
public function getRemarkImageAttribute($value)
{
$value = getImageUrl($value);
return $value;
}
// /**
// * @remark :获取图片
// * @name :getImageAttribute
// * @author :lyh
// * @method :post
// * @time :2023/9/18 16:20
// */
// public function getImageAttribute($value)
// {
// $value = getImageUrl($value);
// return $value;
// }
//
// /**
// * @remark :获取图片
// * @name :getImageAttribute
// * @author :lyh
// * @method :post
// * @time :2023/9/18 16:20
// */
// public function getRemarkImageAttribute($value)
// {
// $value = getImageUrl($value);
// return $value;
// }
/**
* 是否支持一键导入
... ...
... ... @@ -13,35 +13,8 @@ class Keyword extends Base
//设置关联表名
protected $table = 'gl_product_keyword';
// protected $appends = ['route'];
//连接数据库
protected $connection = 'custom_mysql';
// public function getRouteAttribute(){
// return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id);
// }
/**
* @remark :图
* @name :getKeywordTopBannerAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getKeywordTopBannerAttribute($value){
return getImageUrl($value);
}
/**
* @remark :图
* @name :getKeywordTopBannerAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getKeywordFootBannerAttribute($value){
return getImageUrl($value);
}
/**
* @remark :视频
... ...
... ... @@ -2,12 +2,13 @@
namespace App\Providers;
use App\Events\CopyImageFile;
use App\Events\CopyProject;
use App\Listeners\CopyImageFileListener;
use App\Listeners\CopyProjectListener;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
... ... @@ -24,7 +25,6 @@ class EventServiceProvider extends ServiceProvider
'Illuminate\Database\Events\QueryExecuted' => [
'App\Listeners\QueryListener',
],
CopyProject::class => [CopyProjectListener::class],
];
/**
... ...
... ... @@ -51,11 +51,35 @@ class AmazonS3Service
'SourceFile' => $body,
// 'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改
]);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('ok:'.$result['ObjectURL'], true) . PHP_EOL, FILE_APPEND);
return $result['ObjectURL'];
} catch (S3Exception $e) {
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('失败'.$e->getMessage(), true) . PHP_EOL, FILE_APPEND);
return false;
}
}
/**
* @remark :同步图片文件到亚马逊
* @name :uploadImage
* @author :lyh
* @method :post
* @time :2024/1/23 9:20
*/
public function syncImageFiles($files)
{
$file_content = curl_c($files,false);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($file_content, true) . PHP_EOL, FILE_APPEND);
$key = str_replace_url($files);
try {
$result = $this->s3->putObject([
'Bucket' => $this->bucket,
'Key' => ltrim($key,'/'),
'Body' => $file_content,
]);
// unlink($location);
return $result['ObjectURL'];
} catch (AwsException $e) {
return '上传文件到S3时发生错误:' . $e->getMessage();
}
}
}
... ...
... ... @@ -13,7 +13,7 @@ return [
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
'default' => env('QUEUE_CONNECTION', 'redis'),
/*
|--------------------------------------------------------------------------
... ...
... ... @@ -75,6 +75,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/del', [\App\Http\Controllers\Bside\News\NewsController::class, 'del'])->name('news_del');
Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_status');
Route::any('/sort', [\App\Http\Controllers\Bside\News\NewsController::class, 'sort'])->name('news_sort');
Route::any('/sendAiNews', [\App\Http\Controllers\Bside\News\NewsController::class, 'sendAiNews'])->name('news_sendAiNews');
Route::any('/allSort', [\App\Http\Controllers\Bside\News\NewsController::class, 'allSort'])->name('news_allSort');
Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\News\NewsController::class, 'batchSetCategory'])->name('news_batchSetCategory');
Route::any('/statusNum', [\App\Http\Controllers\Bside\News\NewsController::class, 'getStatusNumber'])->name('news_statusNum');
... ...