作者 刘锟

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

... ... @@ -94,16 +94,16 @@ class RemainDay extends Command
}
}
$item->remain_day = ($remain_day > 0 ? $remain_day : 0);
if($item->remain_day == 0){
$item->extend_type = Project::TYPE_FIVE;
$item->site_status = Project::TYPE_ONE;//关闭站点
//TODO::未续费网站禁止登录及通知C端禁止网站
$domainModel = new DomainInfoModel();
$domainInfos = $domainModel->read(['project_id'=>$item->id]);
if($domainInfos !== false){
curl_get('https://'.$domainInfos['domain'].'/api/stop_or_start_website/');
}
}
// if($item->remain_day == 0){
// $item->extend_type = Project::TYPE_FIVE;
// $item->site_status = Project::TYPE_ONE;//关闭站点
// //TODO::未续费网站禁止登录及通知C端禁止网站
// $domainModel = new DomainInfoModel();
// $domainInfos = $domainModel->read(['project_id'=>$item->id]);
// if($domainInfos !== false){
// curl_get('https://'.$domainInfos['domain'].'/api/stop_or_start_website/');
// }
// }
$item->save();
}
}
... ...
... ... @@ -38,6 +38,7 @@ class SyncFile extends Command
}else{
$code = $this->synchronizationFile($v['path']);
}
echo date('Y-m-d H:i:s') . 'code:'. $code . PHP_EOL;
if((int)$code == 200){
echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
$errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
... ...
<?php
/**
* @remark :
* @name :HandleNewsText.php
* @author :lyh
* @method :post
* @time :2024/11/8 9:14
*/
namespace App\Console\Commands\Test;
use App\Models\News\News;
use App\Services\CosService;
use Illuminate\Console\Command;
use App\Models\Project\Project;
use App\Models\Template\BTemplateCom;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class HandleNewsText extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'news_text';
/**
* The console command description.
*
* @var string
*/
protected $description = 'news_text';
/**
* Execute the job.
*
* @return void
*/
protected $project_id = 0;
public function handle()
{
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
$data = [];
foreach ($list as $v){
$this->project_id = $v['id'];
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
DB::connection('custom_mysql')->statement('DROP TABLE IF EXISTS gl_news_copy');
DB::connection('custom_mysql')->statement('CREATE TABLE gl_news_copy LIKE gl_news');
DB::connection('custom_mysql')->statement('INSERT INTO gl_news_copy SELECT * FROM gl_news');
$newsModel = new News();
$news_list = $newsModel->list(['status'=>['!=',2]],'id',['id','text']);
if(!empty($news_list)){
foreach ($news_list as $key => $values){
echo date('Y-m-d H:i:s') . '处理的数据id:'.$values['id'] . PHP_EOL;
$text = $this->handleText($values['text']);
$newsModel->edit(['text'=>$text],['id'=>$values['id']]);
}
}
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :处理text
* @name :handleText
* @author :lyh
* @method :post
* @time :2024/11/7 17:20
*/
public function handleText($text){
$pattern = '/<img\s+[^>]*src=["\']([^"\']+)["\']/i';
$matches = [];
preg_match_all($pattern, $text, $matches);
$text = $this->saveBase64Images($matches[1],$text);
return ($text);
}
/**
* @remark :解码图片
* @name :saveBase64Images
* @author :lyh
* @method :post
* @time :2024/11/7 16:52
*/
public function saveBase64Images($imageSources,&$text)
{
foreach ($imageSources as $src) {
if (preg_match('/^data:image\/(png|jpg|jpeg|gif);base64,/', $src, $match)) {
echo date('Y-m-d H:i:s') . '当前数据包含base64图片流。' . PHP_EOL;
$imageType = $match[1]; // Image type (png, jpg, etc.)
$imageUrl = $this->manager_uploads($src,$imageType);
$text = str_replace($src, $imageUrl, $text);
}
}
return ($text);
}
/**
* @remark :自调用
* @name :manager_uploads
* @author :lyh
* @method :post
* @time :2024/11/7 11:00
*/
public function manager_uploads($files,$type = 'png'){
$this->uploads = config('upload.default_image');
$path = $this->uploads['path_b'].'/'.($this->project_id).'/image_news/'.date('Y-m');
$cosService = new CosService();
$fileName = md5(uniqid() . '_' . time() . '.' . ($this->project_id).rand(1,10000)) . '.' .$type;
return getImageUrl($cosService->uploadFile($files,$path,$fileName));
}
}
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Console\Commands\Test;
use App\Models\File\ErrorFile;
use App\Models\File\File;
use App\Models\File\Image;
use Illuminate\Console\Command;
class SyncTimeFiles extends Command
... ... @@ -32,8 +33,9 @@ class SyncTimeFiles extends Command
public function handle()
{
$fileModel = new File();
$start = '2024-08-26 00:00:00';
$end = date('Y-m-d H:i:s');
// $imagesModel = new Image();
$start = '2024-11-07 15:00:00';
$end = '2024-11-07 15:25:00';
$lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
foreach ($lists as $v){
$path = $v['path'];
... ...
... ... @@ -36,7 +36,9 @@ class SyncVideo extends Command
$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);
echo date('Y-m-d H:i:s') . ' | ' . $code . PHP_EOL;
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']]);
}
... ...
... ... @@ -17,6 +17,7 @@ use App\Models\CustomModule\CustomModuleContent;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\ProcessRecords;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
... ... @@ -55,20 +56,26 @@ class UpdateRoute extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[1653]]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
// $this->getProduct();
// $this->setProductKeyword();
// $this->getBlog();
// $this->setCustomRoute($v['id']);
$this->editProductAlt();
// $this->custom_to_blogs();
DB::disconnect('custom_mysql');
}
$recordModel = new ProcessRecords();
$lists = $recordModel->list();
foreach ($lists as $k => $v){
$date = $v['record'][0]['date'];
$recordModel->edit(['date'=>$date],['id'=>$v['id']]);
}
// $projectModel = new Project();
// $list = $projectModel->list(['delete_status'=>['=',0]]);
// $data = [];
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
//// $this->getProduct();
//// $this->setProductKeyword();
//// $this->getBlog();
//// $this->setCustomRoute($v['id']);
// $this->editProductAlt();
//// $this->custom_to_blogs();
// DB::disconnect('custom_mysql');
// }
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
... ...
... ... @@ -71,6 +71,7 @@ class ProjectController extends BaseController
$this->response('success',Code::SUCCESS,$lists);
}
/**
* 需要查询的字段
* @return array
... ... @@ -359,12 +360,20 @@ class ProjectController extends BaseController
}
if($item['type'] == Project::TYPE_ONE){//建站中
$processModel = new ProcessRecords();
$item['sign_project'] = 0;
$proInfo = $processModel->read(['project_id'=>$item['id'],'updated_at'=>['>=',time() - 3 * 12 * 3600]],['id']);
if($proInfo === false){
$item['sign_project'] = 1;
$item['sign_project'] = 1;
$count = $processModel->counts(['project_id'=>$item['id']]);
if($count < 1){
$item['sign_project'] = 0;
}else{
$proInfo = $processModel->read(['project_id'=>$item['id'],'date'=>['>=',date('Y-m-d', strtotime('-3 days'))]],['id']);
if($proInfo !== false){
$item['sign_project'] = 0;
}
}
}
if(!empty($item['extend_type'])){
$item['type'] = $item['extend_type'];
}
$manageModel = new ManageHr();
$item['channel'] = Channel::getChannelText($item['channel']['user_id'] ?? 0);
$item['build_leader'] = $manageModel->getName($item['leader_mid']);
... ... @@ -383,7 +392,6 @@ class ProjectController extends BaseController
$item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
$item['product_num'] = $data['product'] ?? 0;
$item['keyword_num'] = $data['key'] ?? 0;
$item['autologin_code'] = getAutoLoginCode($item['id']);
$item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0);
$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]);
... ...
... ... @@ -232,6 +232,7 @@ class AdsController extends BaseController
$form_id = intval($request->input('form_id'));
$country = intval($request->input('country'));
$page_size = intval($request->input('row', '20'));
$domain = trim($request->input('domain', ''));
$result = ReInquiryDetail::with('detailLog')
->when($status, function ($query, $status) {
return $query->where('status', $status);
... ... @@ -245,6 +246,9 @@ class AdsController extends BaseController
->when($country, function ($query, $country) {
return $query->where('country', 'like', '%'.$country.'%');
})
->when($domain, function ($query, $domain) {
return $query->where('re_website', 'like', '%'.$domain.'%');
})
->orderBy('id', 'desc')
->paginate($page_size);
return $this->response('success', Code::SUCCESS, $result);
... ... @@ -275,7 +279,18 @@ class AdsController extends BaseController
foreach ($result as &$item){
$item->tasks = $item->tasks; //调用访问器
$item['project_id'] = DomainInfo::where('domain', $item['domain'])->value('project_id') ?: 0;
$is_v6 = 0;
foreach ($item->tasks as $task){
if($task['is_v6']){
$is_v6 = 1;
}
}
if($is_v6){
$item['project_id'] = DomainInfo::where('domain', $item['domain'])->value('project_id') ?: 0;
}else{
$item['project_id'] = 0;
}
}
return $this->response('success', Code::SUCCESS, $result);
... ...
... ... @@ -168,7 +168,8 @@ class InquiryController extends BaseController
$data = $data['list'] ?? [];
foreach ($data as &$item){
//非正常登录的
if($this->param['login_source']??0 != 2){
if(($this->user['login_source']??0) != 2 && ($this->user['login_source']??0) != 3){
//脱敏
!empty($item['email']) && $item['email'] = email_desensitize($item['email']);
!empty($item['phone']) && $item['phone'] = substr($item['phone'], 0, -4) . '****';
... ...
... ... @@ -195,6 +195,13 @@ class ProductController extends BaseController
$this->map['title'] = str_replace('+',' ',$this->map['title']);
$query = $query->where('title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['keyword_title']) && !empty($this->map['keyword_title'])){
$keywordModel = new Keyword();
$keywordInfo = $keywordModel->read(['title'=>$this->map['keyword_title']],['id']);
if(!empty($keywordInfo)){
$query = $query->where('keyword_id','like','%,'.$keywordInfo['id'].',%');
}
}
if(isset($this->map['status'])){
if($this->map['status'] == 0){
$query = $query->whereIn('status',[0,3]);
... ...
... ... @@ -65,6 +65,7 @@ class ProcessRecordsLogic extends BaseLogic
public function recordSave(){
$info = $this->model->read(['project_id'=>$this->param['project_id']]);
$this->param['operator_id'] = $this->manager['id'];
$this->param['date'] = $this->param['record'][0]['date'] ?? null;
$this->param['record'] = json_encode($this->param['record']);
if($info === false){
$res = $this->model->add($this->param);
... ...
... ... @@ -68,19 +68,21 @@ class RenewLogic extends BaseLogic
* @time :2023/9/19 10:21
*/
public function editProjectRenew(){
//获取续费单详情
$info = $this->model->read(['id'=>$this->param['renew_id']]);
if($info === false){
$this->fail('当前续费单不存在');
}
if($info['project_id'] != 0){
$this->fail('当前续费单已关联项目,请重新选择');
if($this->param['renew_id'] != 0){
//获取续费单详情
$info = $this->model->read(['id'=>$this->param['renew_id']]);
if($info === false){
$this->fail('当前续费单不存在');
}
if($info['project_id'] != 0){
$this->fail('当前续费单已关联项目,请重新选择');
}
}
DB::beginTransaction();
try {
$this->model->edit(['project_id'=>$this->param['id'],'operator_id'=>$this->manager['id']],['id'=>$this->param['renew_id']]);
$param = $this->param;
$param['api_no'] = $info['api_no'];
$param['api_no'] = $info['api_no'] ?? 0;
$this->saveLog($param);
$this->updateProject($this->param['id'],$this->param['type']);
$this->updateProjectBuild($this->param['id'],$this->param['service_duration'],$this->param['plan']);
... ...
... ... @@ -207,6 +207,9 @@ class CustomTemplateLogic extends BaseLogic
public function handleSaveParam(){
$this->param['url'] = str_replace_url($this->param['url']);
$this->param['operator_id'] = $this->user['id'];
if(empty($this->project)){
$this->fail('登录已过期,请重新登录');
}
if(($this->project['deploy_build']['is_search'] == 0) && ($this->param['url'] == 'search')){
$this->fail('请先开启搜索页可视化');
}
... ...
... ... @@ -175,6 +175,9 @@ class BaseLogic extends Logic
$str = http_build_query($data);
$url = $this->user['domain'].'api/delHtml/?'.$str;
$serverIpModel = new ServersIp();
if(empty($this->project)){
$this->fail('登录已过期,请重新登录');
}
$serversIpInfo = $serverIpModel->read(['id'=>$this->project['serve_id']],['servers_id']);
if($serversIpInfo && ($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID)){
//自建站服务器直接返回
... ...
... ... @@ -10,6 +10,7 @@ use App\Models\News\NewsCategory;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Services\CosService;
use Illuminate\Support\Facades\DB;
use mysql_xdevapi\Exception;
... ... @@ -186,7 +187,9 @@ class NewsLogic extends BaseLogic
if(isset($param['image'])){
$param['image'] = str_replace_url($param['image'] ?? '');
}
if(isset($this->param['text'])){
$param['text'] = $this->handleText($this->param['text']);
}
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
}else{
... ... @@ -210,6 +213,53 @@ class NewsLogic extends BaseLogic
}
/**
* @remark :处理text
* @name :handleText
* @author :lyh
* @method :post
* @time :2024/11/7 17:20
*/
public function handleText($text){
$pattern = '/<img\s+[^>]*src=["\']([^"\']+)["\']/i';
$matches = [];
preg_match_all($pattern, $text, $matches);
$text = $this->saveBase64Images($matches[1],$text);
return $this->success($text);
}
/**
* @remark :解码图片
* @name :saveBase64Images
* @author :lyh
* @method :post
* @time :2024/11/7 16:52
*/
public function saveBase64Images($imageSources,&$text)
{
foreach ($imageSources as $src) {
if (preg_match('/^data:image\/(png|jpg|jpeg|gif);base64,/', $src, $match)) {
$imageType = $match[1]; // Image type (png, jpg, etc.)
$imageUrl = $this->manager_uploads($src,$imageType);
$text = str_replace($src, $imageUrl, $text);
}
}
return $this->success($text);
}
/**
* @remark :自调用
* @name :manager_uploads
* @author :lyh
* @method :post
* @time :2024/11/7 11:00
*/
public function manager_uploads($files,$type = 'png'){
$this->uploads = config('upload.default_image');
$path = $this->uploads['path_b'].'/'.($this->user['project_id']).'/image_news/'.date('Y-m');
$cosService = new CosService();
$fileName = md5(uniqid() . '_' . time() . '.' . ($this->user['project_id']).rand(1,10000)) . '.' .$type;
return getImageUrl($cosService->uploadFile($files,$path,$fileName));
}
/**
* @remark :获取分类(字符串)
* @name :getLastCategory
* @author :lyh
... ...
... ... @@ -163,48 +163,7 @@ class UserLoginLogic
if($project['site_status'] != 0){//关闭站点
$this->fail('当前网站已过期,请联系管理员及时续费。');
}
$info['title'] = $project['title'] ?? '';
$info['company'] = $project['company'] ?? '';
$info['from_order_id'] = $project['from_order_id'] ?? '';
$info['aicc'] = $project['aicc'] ?? '';
$info['hagro'] = $project['hagro'] ?? '';
$info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
$info['test_domain'] = $project['deploy_build']['test_domain'] ?? '';
$info['domain'] = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? ''));
$info['is_customized'] = $project['is_customized'];
$info['is_upload_manage'] = $project['is_upload_manage'];
$info['is_upgrade'] = $project['is_upgrade'];
$info['is_show_blog'] = $project['is_show_blog'];
$info['upload_config'] = $project['upload_config'];
$info['main_lang_id'] = $project['main_lang_id'];
$info['image_max'] = $project['image_max'];
$info['uptime_type'] = $this->getHistory($project);
$info['uptime'] = $project['uptime'];
$info['storage_type'] = $project['storage_type'];
$info['project_location'] = $project['project_location'];
$info['open_export_product'] = $project['open_export_product'];
$info['is_update_language'] = $project['is_update_language'];
$info['is_watermark'] = $project['is_watermark'];
$project['deploy_build']['configuration']['is_product'] = $project['deploy_build']['configuration']['is_news'] = $project['deploy_build']['configuration']['is_blogs'] = $project['deploy_build']['configuration']['is_module'] = "1";
$info['configuration'] = $project['deploy_build']['configuration'];
$info['file_cdn'] = $project['deploy_build']['file_cdn'];
$info['project_type'] = $project['type'];
$info['service_duration'] = $project['deploy_build']['service_duration'];
$info['remain_day'] = $project['remain_day'];
if($info['is_customized'] == 1){
$info['is_visualization'] = json_decode($project['is_visualization']);
}
$info['is_comment'] = $project['deploy_build']['is_comment'] ?? 0;
$info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority'];
$info['is_inquiry_country'] = $project['is_inquiry_country'];
$info['is_subscribe'] = $project['is_subscribe'];
//是否开通AMP
$is_amp = 0;
if(!empty($project['deploy_optimize']['domain'])){
$amp_info = (new DomainInfo())->read(['id'=>$project['deploy_optimize']['domain']],['amp_status']);
$is_amp = $amp_info ? $amp_info['amp_status'] : 0;
}
$info['is_amp'] = $is_amp;
$info = $this->handleInfo($info,$project);
$info['login_source'] = $login_source;
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
... ... @@ -212,6 +171,27 @@ class UserLoginLogic
}
/**
* @remark :组装返回数据
* @name :getProjectInfo
* @author :lyh
* @method :post
* @time :2023/8/29 15:26
*/
public function assembleParam($mobile,$project_id){
$info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','role_id','token','name','wechat','project_id']);
//获取项目详情
$project = $this->getProjectInfo($project_id);
if($project['site_status'] != 0){//关闭站点
$this->fail('当前网站已过期,请联系管理员及时续费。');
}
$info = $this->handleInfo($info,$project);
$info['login_source'] = User::LOGIN_PASSWORD_SOURCE;//账号密码登录返回
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
return $this->success($info);
}
/**
* @remark :获取问卷调查记录(阶段记录)
* @name :getHistory
* @author :lyh
... ... @@ -260,19 +240,13 @@ class UserLoginLogic
}
/**
* @remark :组装返回数据
* @name :getProjectInfo
* @remark :登录返回数据处理
* @name :handleInfo
* @author :lyh
* @method :post
* @time :2023/8/29 15:26
* @time :2024/11/5 16:51
*/
public function assembleParam($mobile,$project_id){
$info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','role_id','token','name','wechat','project_id']);
//获取项目详情
$project = $this->getProjectInfo($project_id);
if($project['site_status'] != 0){//关闭站点
$this->fail('当前网站已过期,请联系管理员及时续费。');
}
public function handleInfo($info,$project){
$info['title'] = $project['title'] ?? '';
$info['company'] = $project['company'] ?? '';
$info['from_order_id'] = $project['from_order_id'] ?? '';
... ... @@ -309,6 +283,7 @@ class UserLoginLogic
$info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority'];
$info['is_inquiry_country'] = $project['is_inquiry_country'];
$info['is_subscribe'] = $project['is_subscribe'];
$info['is_news'] = $project['is_news'] ?? 0;
//是否开通AMP
$is_amp = 0;
if(!empty($project['deploy_optimize']['domain'])){
... ... @@ -316,13 +291,9 @@ class UserLoginLogic
$is_amp = $amp_info ? $amp_info['amp_status'] : 0;
}
$info['is_amp'] = $is_amp;
$info['login_source'] = User::LOGIN_PASSWORD_SOURCE;//账号密码登录返回
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
return $this->success($info);
return $info;
}
/**
* @remark :获取项目数据详情
* @name :getProjectInfo
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models\Channel;
use App\Models\Base;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use phpDocumentor\Reflection\Types\Self_;
/**
... ... @@ -56,11 +57,16 @@ class Channel extends Base
}
public static function getChannelText($sales_id){
$user = User::where('id', $sales_id)->select(['name', 'channel_id'])->first();
if(!$user){
return $sales_id;
$channel_alias = Cache::get('channel_alias_'.$sales_id);
if(empty($channel_alias)){
$user = User::where('id', $sales_id)->select(['name', 'channel_id'])->first();
if(!$user){
return $sales_id;
}
$channel_alias = self::where('id', $user['channel_id'])->value('alias');
$channel_alias = $channel_alias . '-' . $user['name'];
Cache::put('channel_alias_'.$sales_id,$channel_alias,24 * 3600);
}
$channel_alias = self::where('id', $user['channel_id'])->value('alias');
return $channel_alias . '-' . $user['name'];
return $channel_alias;
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models\Domain;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Support\Facades\Cache;
/**
* Class DomainInfo
... ... @@ -61,11 +62,16 @@ class DomainInfo extends Base
* @time :2023/9/4 17:05
*/
public function getDomain($domain){
$info = $this->read(['id'=>$domain]);
if($info === false){
return '';
$res_domain = Cache::get('domain_'.$domain);
if(empty($res_domain)){
$info = $this->read(['id'=>$domain]);
if($info === false){
return '';
}
$res_domain = 'https://'.$info['domain'].'/';
Cache::put('domain_'.$domain,$res_domain,24 * 3600);
}
return 'https://'.$info['domain'].'/';
return $res_domain;
}
/**
... ...
... ... @@ -7,6 +7,7 @@ use App\Models\Base;
use App\Utils\LogUtils;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* Class InquiryFormData
... ... @@ -67,6 +68,8 @@ class InquiryFormData extends Base
$model->save();
if(!empty($data['name']) && !empty($data['email']) && !empty($data['message'])){
Log::channel('inquiry')->info('开始发邮件' . PHP_EOL);
unset($data['globalso-domain_host_url']);
unset($data['globalso-domain']);
unset($data['globalso-edition']);
... ... @@ -86,7 +89,7 @@ class InquiryFormData extends Base
}
if(!$has_file) {
$res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data);
LogUtils::info('询盘提交', $data, $res?: []);
Log::channel('inquiry')->info('询盘发送邮件', [$data, $res]);
}
}
return $model->id;
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Models\Manage;
use App\Models\Base;
use Illuminate\Support\Facades\Cache;
class ManageHr extends Base
{
... ... @@ -190,9 +191,13 @@ class ManageHr extends Base
public function getName($id){
$name = '';
if(!empty($id)){
$info = $this->read(['id'=>$id],['id','name']);
if($info !== false){
$name = $info['name'];
$name = Cache::get('manager_hr_'.$id);
if(empty($name)){
$info = $this->read(['id'=>$id],['id','name']);
if($info !== false){
$name = $info['name'];
Cache::put('manager_hr_'.$id,$name,24 * 3600);
}
}
}
return $name;
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Services;
use App\Exceptions\InquiryFilterException;
use App\Models\File\ImageSetting;
use App\Utils\LogUtils;
use Illuminate\Support\Str;
use Qcloud\Cos\Client;
/**
* @remark :对象存储cos
... ... @@ -34,7 +35,19 @@ class CosService
],
]);
$key = $path.'/'.$filename;
$Body = $binary ? $files : fopen($files->getRealPath(), 'r');
// 判断是否为 Base64 编码的图片流文件
if (Str::startsWith($files, 'data:image')) {
// 分离 Base64 头部和数据部分
[$meta, $base64Data] = explode(',', $files);
// 解码 Base64 数据
$Body = base64_decode($base64Data);
if ($Body === false) {
throw new \Exception("Base64 数据解码失败");
}
} else {
// 如果不是 Base64 流文件,处理为普通文件上传
$Body = $binary ? $files : fopen($files->getRealPath(), 'r');
}
$options = [
'Bucket' => $cos['bucket'],
'Key' => $key,
... ...