作者 刘锟

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

... ... @@ -78,10 +78,10 @@ class DeleteBlogCategory extends Command
$this->updateCategory();
DB::disconnect('custom_mysql');
$noticeLogModel->edit(['status'=>NoticeLog::STATUS_SUCCESS],['id'=>$item['id']]);
echo 'success:' . $item['id'] . PHP_EOL;
echo 'success:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('delete_blog_category删除失败', $item, $e);
echo 'error:' . $item['id'] . $e->getMessage() . '执行时间:'.date('Y-m-d H:i:s') . PHP_EOL;
errorLog('delete_blog_category删除失败'.date('Y-m-d H:i:s'), $item, $e);
}
}
return true;
... ...
... ... @@ -78,9 +78,9 @@ class DeleteCustomCategory extends Command
$this->updateCategory();
DB::disconnect('custom_mysql');
$noticeLogModel->edit(['status'=>NoticeLog::STATUS_SUCCESS],['id'=>$item['id']]);
echo 'success:' . $item['id'] . PHP_EOL;
echo 'success:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
echo 'error:' . $item['id'] . $e->getMessage() . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
errorLog('delete_custom_category删除失败', $item, $e);
}
}
... ...
... ... @@ -78,9 +78,9 @@ class DeleteNewsCategory extends Command
$this->updateCategory();
DB::disconnect('custom_mysql');
$noticeLogModel->edit(['status'=>NoticeLog::STATUS_SUCCESS],['id'=>$item['id']]);
echo 'success:' . $item['id'] . PHP_EOL;
echo 'success:' . $item['id'] . '执行时间:'.date('Y-m-d H:i:s') . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
echo 'error:' . $item['id'] . $e->getMessage() . '执行时间:'.date('Y-m-d H:i:s') . PHP_EOL;
errorLog('delete_news_category删除失败', $item, $e);
}
}
... ...
... ... @@ -79,10 +79,10 @@ class DeleteProductCategory extends Command
$this->updateCategory();
DB::disconnect('custom_mysql');
$noticeLogModel->edit(['status'=>NoticeLog::STATUS_SUCCESS],['id'=>$item['id']]);
echo 'success:' . $item['id'] . PHP_EOL;
echo 'success:' . $item['id'] . '执行时间:'.date('Y-m-d H:i:s') . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('delete_product_category删除失败', $item, $e);
errorLog('delete_product_category删除失败'.',执行时间:'.date('Y-m-d H:i:s'), $item, $e);
}
}
return true;
... ...
... ... @@ -61,6 +61,7 @@ class RemainDay extends Command
{
$list = Project::whereIn('type', [Project::TYPE_TWO,Project::TYPE_THREE,Project::TYPE_FOUR])->get();
foreach ($list as $item){
echo '项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
if(in_array($item->id,$this->ceaseProjectId)){//暂停的项目
if(($item['type'] == Project::TYPE_TWO) && ($item->is_remain_today == 1)){
$item->pause_days = $item->pause_days + 1;
... ...
... ... @@ -79,7 +79,7 @@ class InitKeyword extends Command
ProjectServer::useProject($notice['data']['project_id']);
$keyword = Keyword::whereNull('route')->get();
foreach ($keyword as $val) {
$this->output(' keywordID: ' . $val->id . ', title: ' . $val->title);
$this->output(' keywordID: ' . $val->id . ', title: ' . $val->title . '时间:'. date('Y-m-d H:i:s'));
try {
if(contains_russian($val['title'])){
$title = Translate::tran($val['title'], 'en');
... ... @@ -90,7 +90,7 @@ class InitKeyword extends Command
$val->route = $route;
$val->save();
} catch (\Exception $e) {
$this->output(' keywordID: ' . $val->id . ', title: ' . $val->title . ', error: ' . $e->getMessage());
$this->output(' keywordID: ' . $val->id . ', title: ' . $val->title . ', error: ' . $e->getMessage() . '执行时间:'.date('Y-m-d H:i:s'));
}
}
... ...
... ... @@ -63,9 +63,9 @@ class InitProject extends Command
$project_logic->createdRole($project['id']);
$item->status = NoticeLog::STATUS_SUCCESS;
$item->save();
echo 'success:' . $item['id'] . PHP_EOL;
echo 'success:' . $item['id'] . PHP_EOL . date('Y-m-d H:i:s');
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL . date('Y-m-d H:i:s');
errorLog('项目初始化失败', $item, $e);
$this->retry($item, $e->getMessage());
}
... ...
... ... @@ -96,9 +96,9 @@ class SyncProject extends Command
}
$item->status = NoticeLog::STATUS_SUCCESS;
$item->save();
echo 'success:' . $item['id'] . PHP_EOL;
echo 'success:' . $item['id'] . '执行时间:' . date('Y-m-d H:i:s') . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() .' line ' . $e->getLine() . PHP_EOL;
echo 'error:' . $item['id'] . $e->getMessage() .' line ' . $e->getLine() . '执行时间:' . PHP_EOL;
errorLog('项目同步失败', $item, $e);
$this->retry($item, $e->getMessage());
}
... ...
... ... @@ -13,7 +13,6 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
/**
*
* Class SyncSubmitTask
... ... @@ -30,6 +29,7 @@ class SyncSubmitTaskDistribution extends Command
public function handle()
{
while (true) {
try {
$len = Redis::llen('sync_submit_task');
if (!$len) {
$max_id = SyncSubmitTaskModel::orderBy('id', 'desc')->value('id');
... ... @@ -41,8 +41,12 @@ class SyncSubmitTaskDistribution extends Command
$task->status = 3;
$task->save();
Redis::lpush('sync_submit_task', $task->id);
$this->output('分发:' . $task->id);
}
}
}
}catch (\Exception $e){
$this->output('异常:' . $e->getMessage());
}
}
}
... ...
<?php
/**
* @remark :
* @name :SyncTimeFiles.php
* @author :lyh
* @method :post
* @time :2024/8/14 14:23
*/
namespace App\Console\Commands\Sync;
use App\Models\File\ErrorFile;
use App\Models\File\File;
use Illuminate\Console\Command;
class SyncTimeMinuteFile extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_minute_file';
/**
* The console command description.
*
* @var string
*/
protected $description = '按时间同步图片与文件(每分钟执行前面10分钟的数据)';
public function handle()
{
$dir = '/www/wwwroot/cos';
// 获取当前时间的 Unix 时间戳
$currentTime = time();
// 获取当前时间前10分钟的 Unix 时间戳
$time10MinutesAgo = $currentTime - 10 * 60;
// 将 Unix 时间戳格式化为标准的日期时间格式
$start = date('Y-m-d H:i:s', $time10MinutesAgo);
$end = date('Y-m-d H:i:s');
$fileModel = new File();
$lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
if(empty($lists)){
echo date('Y-m-d H:i:s') . ' | 无数据:' . PHP_EOL;
return true;
}
foreach ($lists as $v){
$path = $v['path'];
if (file_exists($dir.$path)) {
echo date('Y-m-d H:i:s') . ' | file_ok:' . $dir.$path . PHP_EOL;
continue;
}
$this->param['name'] = basename($path);
$this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
if(200 != (int)$code){
echo date('Y-m-d H:i:s') . ' | 错误状态:' . $code . PHP_EOL;
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}
echo date('Y-m-d H:i:s') . ' | ok:' . $code . PHP_EOL;
}
return true;
}
/**
* @remark :获取图片文件链接
* @name :getUrl
* @author :lyh
* @method :post
* @time :2024/5/22 11:53
*/
public function getUrl($path,$storage_type,$location){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = $this->getUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
return '';
}
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
return $path;
}
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
}
}
... ...
... ... @@ -32,7 +32,7 @@ class SyncTimeFiles extends Command
public function handle()
{
$fileModel = new File();
$start = '2024-08-10 00:00:00';
$start = '2024-08-26 00:00:00';
$end = date('Y-m-d H:i:s');
$lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
foreach ($lists as $v){
... ...
... ... @@ -266,6 +266,11 @@ class CustomModuleContentController extends BaseController
* @time :2024/4/28 16:31
*/
public function copyModuleContent(CustomModuleContentLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$data = $logic->copyModuleContentInfo();
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -192,7 +192,7 @@ class ExtensionModuleController extends BaseController
];
$moduleValueModel->addReturnId($data);
}else{
$moduleValueModel->edit(['value'=>$v['value']],['id'=>$info['id']]);
$moduleValueModel->edit(['value'=>$v['value'] ?? ''],['id'=>$info['id']]);
}
}
$this->response('success',Code::SUCCESS,['uuid'=>$this->param['uuid']]);
... ... @@ -349,4 +349,6 @@ class ExtensionModuleController extends BaseController
$moduleValueModel->del(['module_id'=>$this->param['module_id'],'uuid'=>$this->param['uuid']]);
$this->response('success');
}
}
... ...
... ... @@ -703,4 +703,22 @@ class ProductController extends BaseController
}
$this->response('success',Code::SUCCESS,['id'=>$id]);
}
/**
* @remark :删除
* @name :delProductType
* @author :lyh
* @method :post
* @time :2024/8/27 9:44
*/
public function delProductType(){
$this->request->validate([
'name'=>'required',
],[
'name.required' => 'id不为空',
]);
$typeModel = new ProductType();
$typeModel->del(['project_id'=>$this->user['project_id'],'name'=>$this->param['name']]);
$this->response('success');
}
}
... ...
... ... @@ -146,15 +146,7 @@ class FileController
* @time :2024/4/8 11:10
*/
public function synchronizationFile($fileName,$location){
//同步到大文件
$file_path = $this->getUrl($this->path.'/'.$fileName, 0,$location);
$headers = get_headers($file_path, 1);
if (strpos($headers[0], '200') === false) {
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}else{
SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
}
return true;
}
... ...
... ... @@ -207,8 +207,9 @@ class ImageController extends Controller
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
//上传到cos
if($this->upload_location == 0){
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
$cosService = new CosService();
$cosService->uploadFile($files,$this->path,$fileName);
$cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions);
}else{
//TODO::上传亚马逊
$amazonS3Service = new AmazonS3Service();
... ... @@ -231,6 +232,9 @@ class ImageController extends Controller
$suffix = array_pop($nameArr) ?? 'jpg';
$nameStr = implode('-', $nameArr);
$enName = generateRoute(Translate::tran($nameStr, 'en'));
if(substr($enName, 0, 1) === '-'){
$enName = $nameStr;
}
$fileName = $enName;
$i=1;
while($this->onlyName($enName.'.'.$suffix,$project_id)){
... ... @@ -342,7 +346,7 @@ class ImageController extends Controller
if($this->upload_location == 0){
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
$cosService = new CosService();
$cosService->uploadFile($file,$this->path,$fileName,$watermarkOptions);
$cosService->uploadFile($file,$this->path,$fileName,false,$watermarkOptions);
}else{
//TODO::上传亚马逊
$amazonS3Service = new AmazonS3Service();
... ... @@ -365,37 +369,44 @@ class ImageController extends Controller
* @time :2024/8/24 11:03
*/
public function getProjectConfig($project_id = 0){
$str = '';
$imageSettingModel = new ImageSetting();
$settingInfo = $imageSettingModel->read(['project_id'=>$project_id]);
if($settingInfo !== false){
if($settingInfo['status'] == 1 && !empty($settingInfo['image_data'])){
$image_data = json_decode($settingInfo['image_data'],true);
foreach ($image_data as $k => $v){
$arr = implode('/',$v);
if ($arr[0] == 'image') {
$arr[1] = urlSafeBase64Encode($arr[1]);
if (str_starts_with($v, "image/")) {
$v = 'image/'.urlSafeBase64Encode(substr($v, strlen("image/")));
}
$image_data[$k] = $v;
}
$str = 'watermark/1/'.implode('/',$image_data);
return $str;
}
if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){
$str_data = json_decode($settingInfo['str_data'],true);
foreach ($str_data as $k => $v){
$arr = implode('/',$v);
$arr = explode('/',$v);
if ($arr[0] == 'text') {
$arr[1] = urlSafeBase64Encode($arr[1]);
$v = implode('/',$arr);
}
if ($arr[0] == 'font') {
$arr[1] = urlSafeBase64Encode($arr[1]);
$v = implode('/',$arr);
}
if ($arr[0] == 'fill') {
$arr[1] = urlSafeBase64Encode($arr[1]);
$v = implode('/',$arr);
}
$str_data[$k] = $arr;
$str_data[$k] = $v;
}
$str = 'watermark/2/'.implode('/',$str_data);
return $str;
}
}
return null;
return $str;
}
/**
... ... @@ -726,10 +737,10 @@ class ImageController extends Controller
if($info === false){
$this->response('请先设置水印',Code::SYSTEM_ERROR);
}
if($info['status'] == 1 && !empty($info['image_data'])){
if($info['status'] == 1 && empty($info['image_data'])){
$this->response('请先设置水印',Code::SYSTEM_ERROR);
}
if($info['status'] == 2 && !empty($info['str_data'])){
if($info['status'] == 2 && empty($info['str_data'])){
$this->response('请先设置水印',Code::SYSTEM_ERROR);
}
$imageSetting->edit(['status'=>$this->param['status']],['project_id'=>$this->cache['project_id']]);
... ... @@ -753,7 +764,9 @@ class ImageController extends Controller
if(!empty($info['str_data'])){
$info['str_data'] = json_decode($info['str_data'],true);
}
$info['domain'] = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';
}
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -9,6 +9,7 @@ use App\Models\CustomModule\CustomModuleCategory;
use App\Models\IsCom\ProjectComConfig;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\ProductType;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
... ... @@ -777,6 +778,15 @@ class BTemplateLogic extends BaseLogic
$productCategory = $this->getCategoryList((new Category()),1);
$newCategory = $this->getCategoryList((new NewsCategory()));
$blogCategory = $this->getCategoryList((new BlogCategory()));
$productTypeModel = new ProductType();
$productTypeList = $productTypeModel->list(['project_id'=>$this->user['project_id']],'id',['id','name']);
if(!empty($productTypeList)){
foreach ($productTypeList as $item){
$items['id'] = 'product_type_'.$item['id'];
$items['title'] = $item['name'];
$data["products"]["category"][] =$items;
}
}
if (!empty($productCategory)){
foreach ($productCategory as $item){$data["products"]["category"][] =$item;}
}
... ... @@ -831,6 +841,15 @@ class BTemplateLogic extends BaseLogic
foreach ($data as $key => $values){
switch ($values['name']){
case '产品':
$productTypeModel = new ProductType();
$productTypeList = $productTypeModel->list(['project_id'=>$this->user['project_id']],'id',['id','name']);
if(!empty($productTypeList)){
foreach ($productTypeList as $item){
$items['id'] = 'product_type_'.$item['id'];
$items['title'] = $item['name'];
$values['category'][] = $items;
}
}
$productCategory = $this->getCategoryList((new Category()),1,['id','title','pid']);
if(!empty($productCategory)){
foreach ($productCategory as $item){
... ...
... ... @@ -23,7 +23,7 @@ class CosService
* @method :post
* @time :2023/7/19 15:28
*/
public function uploadFile(&$files,$path,$filename, $binary = false,$watermarkOptions = null)
public function uploadFile(&$files,$path,$filename, $binary = false,$watermarkOptions = '')
{
$cos = config('filesystems.disks.cos');
$cosClient = new Client([
... ... @@ -42,18 +42,17 @@ class CosService
];
//水印
if ($watermarkOptions) {
$options['Pic-Operations'] = json_encode([
$options['PicOperations'] = json_encode([
'is_pic_info' => 1,
'rules' => [
[
'fileid' => $filename, // 使用相同的文件名保存
'rule' => 'watermark/1/'.implode('/',$watermarkOptions),
'fileid' => $key, // 使用相同的文件名保存
'rule' => $watermarkOptions,
]
]
]);
], true);
}
// 上传文件
$cosClient->putObject($options);
$res = $cosClient->putObject($options);
return $key;
}
... ... @@ -189,7 +188,7 @@ class CosService
if($is_image){
$param = [
'image/'.urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片
'gravity/'.($data['gravity'] ?? 'SouthEast'),
'gravity/'.($data['gravity'] ?? 'southeast'),
'dx/'.($data['dx'] ?? 0),
'dy/'. ($data['dy'] ?? 0),
'batch/'.($data['batch'] ?? 0),//平铺水印功能
... ... @@ -200,7 +199,7 @@ class CosService
}else{
$param = [
'text/'.urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称
'gravity/'.($data['gravity'] ?? 'SouthEast'),
'gravity/'.($data['gravity'] ?? 'southeast'),
'dx/'.($data['dx'] ?? 10),
'dy/'. ($data['dy'] ?? 10),
'font/'.urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体
... ...
... ... @@ -259,6 +259,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/delProductKeyword', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delProductKeyword'])->name('product_delProductKeyword');
Route::any('/getProductType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getProductType'])->name('product_getProductType');
Route::any('/saveType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'saveType'])->name('product_saveType');
Route::any('/delProductType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delProductType'])->name('product_delProductType');
//产品分类
Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category');
Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info');
... ...