作者 刘锟

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

正在显示 41 个修改的文件 包含 611 行增加501 行删除
... ... @@ -101,6 +101,7 @@ class VideoTask extends Command
continue;
}
$keywordInfo = $this->getKeywordImage($val->id,$task_project->project_id,$domainInfo['domain']);
if(!empty($keywordInfo['product_list'])){
$array = [
'project_id' => $task_project->project_id,
'keyword_id' => $val->id,
... ... @@ -115,6 +116,7 @@ class VideoTask extends Command
KeywordVideoTaskLog::insert($array);
$sub_task_num--;
}
}
$task_project->status = KeywordVideoTask::STATUS_CLOSE;
$task_project->save();
}
... ... @@ -209,7 +211,6 @@ class VideoTask extends Command
}
}
}
//TODO::所有产品
$thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);
$keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();
... ... @@ -238,7 +239,7 @@ class VideoTask extends Command
$productIds[] = $item->id;
}
if (count($productIds)<7){
$product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$array_count = count($product_all_id);
if ($array_count > 0) {
... ... @@ -250,7 +251,7 @@ class VideoTask extends Command
$products = $productsQuery;
}
}else{
$product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$array_count = count($product_all_id);
if ($array_count > 0)
... ... @@ -273,7 +274,7 @@ class VideoTask extends Command
if (strpos(','.$keyword_id.',', ','.$productKeyword->id.',') === false) {
//不包含
$productModel = new Product();
$keyword_id = $keyword_id . $productKeyword->id.',';
$keyword_id = ','.$keyword_id.',' . $productKeyword->id.',';
$productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]);
}
$data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
... ...
<?php
/**
* @remark :
* @name :SyncFile.php
* @author :lyh
* @method :post
* @time :2024/4/17 10:05
*/
namespace App\Console\Commands\SyncFile;
use App\Models\File\ErrorFile;
use Illuminate\Console\Command;
class SyncFile extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_file';
/**
* The console command description.
*
* @var string
*/
protected $description = '同步图片与文件';
public function handle(){
$errorFileModel = new ErrorFile();
$lists = $errorFileModel->list(['status'=>0]);//未同步成功的图片及文件
foreach ($lists as $k => $v){
$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;
$errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
}
}
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);
}
}
... ...
... ... @@ -11,6 +11,7 @@ use App\Helper\Common;
use App\Models\Blog\Blog;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\File\File;
use App\Models\File\Image;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Dept;
... ... @@ -47,381 +48,7 @@ class Demo extends Command
*/
protected $description = 'demo';
/**
* Create a new command instance.
*
* @return void
*/
// public function __construct()
// {
// parent::__construct();
// }
public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if ($data)
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
'Expect:',
'Content-type: application/json',
'Accept: application/json',
], $header)
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [$code, $response];
}
/**
* @return bool
*/
// public function handle()
// {
// return $this->domain();
// $result = app(SyncService::class)->projectAcceptAddress(1);
// dd($result);
// $data = [
// 'key' => 'productkey_keyword',
// 'keywords' => 'apple watch'
// ];
// $result = Common::send_openai_msg('v2/openai_chat', $data);
// dd();
// $string = 'demo.globalso.site/';
// $domain_array = parse_url($string);
// $domain = $domain_array['host'] ?? $domain_array['path'];
// dd($domain);
// $data = [];
// dd(isset($data['a']['b']));
// $url = 'https://demo.globalso.site/';
// $action = 'api/updateHtmlNotify/';
// $data = [
// 'project_id' => 1,
// 'type' => 1,
// 'route' => 1
// ];;
// $method = 'GET';
// $result = $this->curlRequest($url . $action, $data, $method);
// dd($result);
//
// $context = stream_context_create([
// 'ssl' => [
// 'capture_peer_cert' => true,
// 'capture_peer_cert_chain' => false,
// ],
// ]);
//
// $stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
//
// if(!$stream) {
// die("Failed to connect: $errno - $errstr");
// }
//
// $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
//
// if(!$remote_cert) {
// die("Failed to retrieve certificate");
// }
//
// $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
// $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
//
// fclose($stream);
//
// echo "Certificate Valid From: $valid_from<br>";
// echo "Certificate Valid To: $valid_to<br>";
//
// dd('end');
// $dept_array = [
// '品牌部',
// '综合部',
// '渠道部',
// '广告推广部',
// 'AICC运营部',
// '黑格运营部',
// '直营运营部',
// '直营销售部',
// '深圳跨境部',
// '外贸部',
// '研发部',
// '技术部',
// '售后部',
// ];
// foreach ($dept_array as $v) {
// $dept = Dept::where(['title' => $v])->first();
// if (FALSE == empty($dept))
// continue;
// $dept = new Dept();
// $dept->title = $v;
// $dept->save();
// }
//// dd('dept end');
// $dept_map = Dept::pluck('title', 'id')->toArray();
// $belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
//// dd($belonging_map);
//
// $filename = storage_path('logs/oa_hr.txt');
// $string = file_get_contents($filename);
// $data = explode("\r\n", $string);
// $data = array_filter($data);
// $dept = '';
// foreach ($data as $k=>$v) {
//// var_dump($v) . PHP_EOL;
// if ($k == 1)
// continue;
// $tmp = explode("\t", $v);
// if (count($tmp) == 3) {
// $dept = $tmp[0] ? : $dept;
// $position = $tmp[1];
// $name = $tmp[2];
// } else if (count($tmp) == 2) {
// $position = $tmp[0];
// $name = $tmp[1];
// } else {
// Log::info($v . PHP_EOL);
// continue;
// }
//
//
//// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
//// continue;
//
// $dept_id = array_search($dept, $dept_map);
// $belonging_id = 17;
// if (FALSE !== strpos($dept,'技术部')) {
// $belonging_string = str_replace('技术部', '', $dept);
// if ($belonging_string) {
// $belonging_string = $belonging_string . '组';
// $belonging_id = array_search($belonging_string, $belonging_map);
// }
//
// $dept_tmp = '技术部';
// $dept_id = array_search($dept_tmp, $dept_map);
// }
// if (FALSE !== strpos($dept,'售后')) {
// $belonging_string = str_replace('售后', '', $dept);
// if ($belonging_string)
// $belonging_id = array_search($belonging_string, $belonging_map);
// $dept_tmp = '售后部';
// $dept_id = array_search($dept_tmp, $dept_map);
// }
//
// $position_log = EntryPosition::where(['name' => $position])->first();
// if (empty($position_log)) {
// $position_log = new EntryPosition();
// $position_log->name = $position;
// $position_log->save();
// }
// $position_id = $position_log->id;
//
// $hr = ManageHr::where(['name' => $name])->first();
// if (empty($hr)) {
// Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
// continue;
// }
//
// $hr->belong_group = $belonging_id;
// $hr->dept_id = $dept_id;
// $hr->entry_position = $position_id;
// $hr->save();
// echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
//
// }
// dd('end');
// exit;
//
// if (($handle = fopen($filename, 'r')) !== false) {
// while (($data = fgetcsv($handle, 1000, ',')) !== false) {
// // 处理每行数据
// Log::info(var_export($data, true));
// }
// fclose($handle);
// }
// exit;
//
// $group = BelongingGroup::get();
// dd($group->toArray());
// $domain = parse_url('https//:dev.golbalso.site/');
// dd($domain);
// echo time() . PHP_EOL;
// $blogModel = new Image();
// $list = $blogModel->list();
// echo time() . PHP_EOL;
// dd(count($list));
//
// return;
// preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'
//@include("asdf")@include("")@include("asdtrw2erf")
// ',$include);
//
// print_r($include);
// }
public function handle(){
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['project_id'=>45]);
if($domainInfo === false){
dd('11111');
}
$bg = '';
$logo = '';
$dom = file_get_html('https://'.$domainInfo['domain'].'/');
$logoDom = $dom->find('.logo', 0)->find("img",0);
if($logoDom != null){
$logo = $logoDom->src;
}
$elements = $dom->find('.section-banner-wrap-block');
if (count($elements) >= 2) {
foreach ($elements as $v){
$image = $v->find('img', 0);
if($image != null){
break;
}
}
} else {
$image = $elements->find('img', 0);
}
if($image != null){
$bg = $image->src;
}
if($image != null){
$bg = $image->src;
}
// return $logo;
dd(['logo'=>$logo ?? '','bg'=>$bg ?? '']);
// $projectModel = new Project();
// $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
// foreach ($list as $v1){
// ProjectServer::useProject($v1['id']);
// echo date('Y-m-d H:i:s') . '项目id:'.$v1['id'] . PHP_EOL;
// $navGroupModel = new BNavGroup();
// $groupList = $navGroupModel->list(['sort_list'=>['!=','']]);
// if(empty($groupList)){
// continue;
// }
// foreach ($groupList as $k=>$v){
// if(!empty($v['sort_list'])){
// $sort_list = json_decode($v['sort_list']);
// $sort = 0;
// $this->subSort($sort_list,$sort);
// }
// }
// DB::disconnect('custom_mysql');
// }
return true;
}
/**
* @remark :处理子集排序
* @name :subSort
* @author :lyh
* @method :post
* @time :2024/2/29 15:30
*/
public function subSort($subList,&$sort,$pid = 0){
$navModel = new BNav();
foreach ($subList as $k => $v){
$v = (array)$v;
$sort = $sort+1;
$navModel->edit(['sort'=>$sort],['id'=>$v['id']]);
if(!empty($v['sub'])){
$this->subSort($v['sub'],$sort,$v['id']);
}
}
return true;
}
// public function handle(){
// $projectModel = new DeployOptimize();
// $list = $projectModel->list(['project_id'=>['<',187]]);
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'end'.json_encode($v) . PHP_EOL;
// $data = [];
// if(!empty($v['minor_languages']) && is_array($v['minor_languages'])){
// foreach ($v['minor_languages'] as $k1=> $v1){
// if(!empty($v1['tl']) && !empty($v1['type'])){
// $data[] = [
// 'language'=>$v1['tl'],
// 'type'=>$v1['type'],
// 'keywords'=>$v1['keywords'],
// 'service_day'=>$v1['service_day'],
// 'project_id'=>$v['project_id'],
// 'created_at'=>date('Y-m-d H:i:s'),
// 'updated_at'=>date('Y-m-d H:i:s')
// ];
// }
// }
// }
// $languageModel = new MinorLanguages();
// $languageModel->insert($data);
// }
//
// }
public function printMessage()
{
$client = new Client();
$headers = [
'Accept-Language' => 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
'Cache-Control' => 'no-cache',
'Content-Type' => 'application/json',
'DNT' => '1',
'Origin' => 'http://openai.waimaoq.com',
'Pragma' => 'no-cache',
'Proxy-Connection' => 'keep-alive',
'Referer' => 'http://openai.waimaoq.com/docs',
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
'accept' => 'application/json',
'Access-Control-Allow-Origin' => '*'
];
$body = '{
"prompt": "Human: 我需要一篇100字的英文原创博客并包含标题,内容结合:“cnc machine”。AI:"
}';
$response = $client->post('http://openai.waimaoq.com/v1/openai_chat_stream', [
'stream' => true,
'headers' => $headers,
'body' => $body
]);
// 获取响应流对象
$stream = $response->getBody();
// 设置输出缓冲区
ob_start();
// 读取流中的数据并输出到页面
while (!$stream->eof()) {
echo $stream->read(4);
ob_flush();
flush();
}
dd(1);
}
/**
* @remark :获取域名
* @name :domain
* @author :lyh
* @method :post
* @time :2023/11/29 18:47
*/
public function domain(){
$domainModel = new DomainInfo();
$lists = $domainModel->list();
foreach ($lists as $k => $v){
if($v['project_id'] != 0){
echo date('Y-m-d H:i:s') . ' start: ' . $v['project_id'] . PHP_EOL;
$domain = 'https://'.$v['domain'].'/';
$url = $domain.'/api/update_robots/?project_id='.$v['project_id'];
http_get($url);
echo date('Y-m-d H:i:s') . ' end: ' . $v['project_id'] . PHP_EOL;
}
}
return true;
}
}
... ...
<?php
/**
* @remark :
* @name :EditVideoMp4.php
* @author :lyh
* @method :post
* @time :2024/4/16 9:44
*/
namespace App\Console\Commands\Test;
use App\Models\Project\Project;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class EditVideoMp4 extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'edit_video';
/**
* The console command description.
*
* @var string
*/
protected $description = 'edit_mp4';
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0,'type'=>['!=',0],'id'=>['<=',82]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->copyTable();
$this->getHtml();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :获取需要替换的html
* @name :getHtml
* @author :lyh
* @method :post
* @time :2024/4/16 10:17
*/
public function getHtml(){
$templateModel = new BTemplate();
$templateList = $templateModel->list();
if(!empty($templateList)){
foreach ($templateList as $v1){
$this->getVideoSrc($v1['id'],$v1['main_html'],'main_html',$templateModel);
}
}
return true;
}
/**
* @remark :获取video的src
* @name :getVideoSrc
* @author :lyh
* @method :post
* @time :2024/4/16 9:46
*/
public function getVideoSrc($id,$html,$filed,$model){
$pattern = '/<video.*?src="([^"]+)"[^>]*>/i';
preg_match_all($pattern, $html, $matches);
$srcLinks = $matches[1];
if(!empty($srcLinks)){
foreach ($srcLinks as $link) {
$newLink = str_replace('ecdn6.globalso.com','v6-file.globalso.com', $link);
$html = str_replace($link, $newLink, $html);
}
$model->edit([$filed=>$html],['id'=>$id]);
}
return true;
}
/**
* @remark :复制表
* @name :copyTable
* @author :lyh
* @method :post
* @time :2024/4/16 9:51
*/
public function copyTable(){
// 原始表名和新表名
$originalTableName = "gl_web_template";
$newTableName = "gl_web_template_c";
// 检查原始表是否存在
DB::connection('custom_mysql')->select("SHOW TABLES LIKE '{$originalTableName}'");
DB::connection('custom_mysql')->statement("CREATE TABLE {$newTableName} LIKE {$originalTableName}");
DB::connection('custom_mysql')->statement("INSERT INTO {$newTableName} SELECT * FROM {$originalTableName}");
}
}
... ...
... ... @@ -165,6 +165,8 @@ class WebTraffic extends Command
try {
$type = $this->argument('type');
Log::channel('traffic')->info('开始运行:' . $type);
$this->sleep($type);
$page = 1;
... ...
... ... @@ -164,6 +164,8 @@ class WebTrafficSpecial extends Command
*/
public function handle()
{
Log::channel('traffic')->info('开始运行特殊引流' );
try {
$this->sleep();
... ...
... ... @@ -29,12 +29,12 @@ class Kernel extends ConsoleKernel
$schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
$schedule->command('web_traffic_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
$schedule->command('web_traffic_russia_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
$schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
$schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
$schedule->command('web_traffic_russia 1')->everyThirtyMinutes(); // 俄语站引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic_russia 2')->cron('*/18 * * * *'); // 俄语站引流 4-8个月的项目,18分钟一次
$schedule->command('web_traffic_russia 3')->cron('*/12 * * * *'); // 俄语站引流 大于9个月的项目,12分钟一次
// $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
// $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
// $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
// $schedule->command('web_traffic_russia 1')->everyThirtyMinutes(); // 俄语站引流 1-3个月的项目,半小时一次
// $schedule->command('web_traffic_russia 2')->cron('*/18 * * * *'); // 俄语站引流 4-8个月的项目,18分钟一次
// $schedule->command('web_traffic_russia 3')->cron('*/12 * * * *'); // 俄语站引流 大于9个月的项目,12分钟一次
$schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
$schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
$schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
... ...
... ... @@ -53,7 +53,7 @@ if (!function_exists('http_post')) {
* @param type $url
* @param type $post_data
*/
function http_post($url, $post_data, $header = [])
function http_post($url, $post_data, $header = [],$is_json = true)
{
if (empty($header)) {
$header = array(
... ... @@ -78,8 +78,11 @@ if (!function_exists('http_post')) {
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($error_message, true) . PHP_EOL, FILE_APPEND);
}
curl_close($ch);
if($is_json){
return json_decode($res, true);
}
return trim($res);
}
}
... ... @@ -594,12 +597,12 @@ if (!function_exists('getFileUrl')) {
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
// $file_type = pathinfo($path, PATHINFO_EXTENSION);
// $fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
// if(in_array(strtolower($file_type),$fileTypeArr)){
// $cdn2 = config('filesystems.disks.cos')['cdn2'];
// return $cdn2.$path;
// }
$file_type = pathinfo($path, PATHINFO_EXTENSION);
$fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
if(in_array(strtolower($file_type),$fileTypeArr)){
$cdn2 = config('filesystems.disks.cos')['cdn2'];
return $cdn2.$path;
}
if($location == 0){
//v6-file.globalso.com
$cos = config('filesystems.disks.cos');
... ...
... ... @@ -59,8 +59,8 @@ class KeywordVideoController extends BaseController
* @time :2023/8/18 10:58
*/
public function searchParam(&$query){
if(isset($this->map['project_name']) && is_array($this->map['project_name'])){
$query->where('gl_project.title','like','%'.$this->map['project_name'].'%');
if(isset($this->map['title']) && is_array($this->map['title'])){
$query->where('gl_project.title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['status'])){
$query->where('gl_keyword_video_task.status',$this->map['status']);
... ...
... ... @@ -138,6 +138,7 @@ class OptimizeController extends BaseController
}
$item['product_num'] = $data['product'] ?? 0;
$item['keyword_num'] = $item['key'] ?? 0;
$item['inquiry_num'] = $data['inquiry'] ?? 0;
$item['autologin_code'] = getAutoLoginCode($item['id']);
return $item;
}
... ...
... ... @@ -86,6 +86,7 @@ class ProjectController extends BaseController
'gl_project.channel AS channel',
'gl_project.company AS company',
'gl_project.type AS type',
'gl_project.uptime AS uptime',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.created_at AS created_at',
'gl_project.cooperate_date AS cooperate_date',
... ...
... ... @@ -13,9 +13,12 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\HomeCount\Count;
use App\Models\HomeCount\MonthCount;
use App\Models\Inquiry\InquiryIP;
use App\Models\Inquiry\InquirySet;
use App\Models\News\News;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Visit\Visit;
use Carbon\Carbon;
class MonthReportController extends BaseController
... ... @@ -82,6 +85,9 @@ class MonthReportController extends BaseController
$info['news_num_last_7'] = $newsModel->formatQuery(
['status'=>0,'created_at'=>['between',[now()->subDays(7)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]]
])->count();
$info['service_duration'] = $this->user['service_duration'];//服务天数
$info['ip_total'] = (new Visit())->count();//ip总数
$info['remain_day'] = $this->user['remain_day'];//剩余服务天数
$info['speed'] = round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2);
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -41,6 +41,9 @@ class BaseController extends Controller
$this->uid = $info['id'];
//参数处理
$this->getParam();
if(!empty($this->user)){
$this->project = Cache::get('user-'.$this->user['project_id']);
}
//日志记录
$this->set_user_log();
}
... ...
... ... @@ -17,6 +17,7 @@ use App\Helper\Translate;
use App\Helper\Wechat;
use App\Http\Logic\Bside\User\UserLoginLogic;
use App\Models\Domain\DomainInfo;
use App\Models\File\ErrorFile;
use App\Models\Project\Project;
use App\Models\Service\Service;
use App\Models\Sms\SmsLog;
... ... @@ -24,6 +25,7 @@ use App\Models\User\DeptUser;
use App\Models\User\ProjectRole;
use App\Models\User\User;
use App\Utils\EncryptUtils;
use http\Client\Response;
use Illuminate\Support\Facades\Cache;
use Mrgoon\AliSms\AliSms;
... ...
... ... @@ -54,15 +54,22 @@ class DescribeController extends BaseController
$this->response('success');
}
public function delete(Request $request, DescribeLogic $logic)
/**
* @remark :删除数据
* @name :delete
* @author :lyh
* @method :post
* @time :2024/4/12 16:59
*/
public function delete(DescribeLogic $logic)
{
$request->validate([
'ids'=>['required', new Ids()]
$this->request->validate([
'ids'=>'required'
],[
'ids.required' => 'ID不能为空'
]);
$data = $logic->delete($this->param['ids']);
$this->response('success',Code::SUCCESS,$data);
$logic->describeDel();
$this->response('success');
}
}
... ...
... ... @@ -173,4 +173,32 @@ class KeywordController extends BaseController
$this->response('success');
}
/**
* @remark :批量清除关键词相关内容
* @name :batchKeywordFiled
* @author :lyh
* @method :post
* @time :2024/4/22 10:27
*/
public function batchKeywordFiled(){
$param = [];
if(isset($this->param['keyword'])){
$param['seo_keywords'] = null;
}
if(isset($this->param['description'])){
$param['seo_description'] = null;
}
if(isset($this->param['title'])){
$param['keyword_title'] = null;
}
if(isset($this->param['content'])){
$param['keyword_content'] = null;
}
$keywordModel = new Keyword();
$rs = $keywordModel->edit($param,['id'=>['!=',0]]);
if($rs === false){
$this->fail('保存失败,请联系管理员');
}
$this->response('success');
}
}
... ...
... ... @@ -85,8 +85,8 @@ class TranslateController extends BaseController
'url.required' => 'url不能为空',
'alias.required' => 'url不能为空',
]);
$logic->translateSave();
$this->response('success');
$rs = $logic->translateSave();
$this->response('success',Code::SUCCESS,$rs);
}
/**
... ...
... ... @@ -33,9 +33,8 @@ class BTemplateLogController extends BaseController
* @time :2023/8/23 11:05
*/
public function lists(BTemplateLog $bTemplateLog){
unset($this->map['template_id']);
// unset($this->map['template_id']);
$this->map['project_id'] = $this->user['project_id'];
$this->map['source'] = 1;
$this->map['is_custom'] = 0;
$lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']);
if(!empty($lists['list'])){
... ...
... ... @@ -6,6 +6,8 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\CustomTemplateLogic;
use App\Http\Requests\Bside\Template\CustomTemplateRequest;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateLog;
/**
* @remark :自定义模块
... ... @@ -107,4 +109,40 @@ class CustomTemplateController extends BaseController
$customTemplateLogic->saveHtml();
$this->response('success');
}
/**
* @remark :获取自定义界面的保存记录
* @name :getCustomTemplateLog
* @author :lyh
* @method :post
* @time :2024/4/23 11:07
*/
public function getCustomTemplateLog(BTemplateLog $bTemplateLog){
$this->request->validate([
'source_id'=>['required'],
],[
'source_id.required' => 'ID不能为空',
]);
$this->map['source'] = 9;
$this->map['is_custom'] = 0;
$lists = $bTemplateLog->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :还原单页面记录
* @name :rollbackVersion
* @author :lyh
* @method :post
* @time :2024/4/23 13:58
*/
public function rollbackVersion(CustomTemplateLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '模版ID不能为空',
]);
$logic->saveRollbackVersion();
$this->response('success');
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\File;
use App\Enums\Common\Code;
use App\Models\File\ErrorFile;
use App\Models\File\File;
use App\Models\Project\Project;
use App\Services\AmazonS3Service;
... ... @@ -130,7 +131,7 @@ class FileController
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
$this->synchronizationFile($files->getClientOriginalExtension(),$fileName);
$this->synchronizationFile($fileName);
$this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
... ... @@ -141,11 +142,16 @@ class FileController
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationFile($file_type,$fileName){
public function synchronizationFile($fileName){
//同步到大文件
$file_path = getFileUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
$file_path = config('filesystems.disks.cos')['cdn1'].$this->path.'/'.$fileName;
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
shell_exec($cmd);
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->path.'/'.$fileName]);
}
return true;
}
/**
... ... @@ -262,7 +268,7 @@ class FileController
$mime = $file->getMimeType();
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
$data[] = $this->responseData($this->path.'/'.$fileName, $name);
$this->synchronizationFile($file_type,$fileName);
$this->synchronizationFile($fileName);
}
$this->response('资源',Code::SUCCESS,$data);
}
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\File;
use App\Enums\Common\Code;
use App\Http\Controllers\Controller;
use App\Http\Controllers\type;
use App\Models\File\ErrorFile;
use App\Models\File\Image as ImageModel;
use App\Models\Project\Project;
use App\Services\AmazonS3Service;
... ... @@ -225,7 +226,12 @@ class ImageController extends Controller
//同步到大文件
$file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
shell_exec($cmd);
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->path.'/'.$fileName]);
}
return true;
}
/**
... ...
... ... @@ -307,13 +307,11 @@ class DomainInfoLogic extends BaseLogic
//主站生成证书
EditDomainBt::dispatch($this->param['id']);
// $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? [],$this->param['is_https'] ?? 0);
//amp站生成证书
if($data['amp_status']){
EditAmpDomainBt::dispatch($this->param['id']);
// $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);
}
return $this->success();
}
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Logic\Aside\Project;
use App\Console\Commands\Languages;
use App\Enums\Common\Code;
use App\Events\CopyImageFile;
use App\Events\CopyProject;
... ... @@ -16,9 +17,16 @@ use App\Models\Project\InquiryFilterConfig;
use App\Models\Project\MinorLanguages;
use App\Models\Project\ProjectRenew;
use App\Models\Project\WebTrafficConfig;
use App\Models\RankData\ExternalLinks;
use App\Models\RankData\IndexedPages;
use App\Models\RankData\RankData;
use App\Models\RankData\RankWeek;
use App\Models\RankData\RecommDomain;
use App\Models\RankData\Speed;
use App\Models\Template\Setting;
use App\Models\User\ProjectMenu;
use App\Models\User\ProjectRole;
use App\Models\WebSetting\WebLanguage;
use App\Services\SyncService;
use App\Utils\HttpUtils;
use App\Utils\LogUtils;
... ... @@ -156,9 +164,8 @@ class ProjectLogic extends BaseLogic
$this->saveProjectDeployOptimize($this->param['deploy_optimize']);
//保存售后信息
$this->saveProjectAfter($this->param['project_after']);
$this->saveMinorLanguages($this->param['minor_language'] ?? []);
$this->saveMinorLanguages($this->param['deploy_optimize']['minor_languages'] ?? []);
$this->syncImageFile($this->param['project_location'],$this->param['id']);
//创建站点
(new SyncService())->projectAcceptAddress($this->param['id']);
}
DB::commit();
... ... @@ -288,13 +295,24 @@ class ProjectLogic extends BaseLogic
//更改域名
$this->editDomainStatus($deploy_optimize['domain'],$deploy_optimize['project_id']);
}
$deploy_optimize['minor_languages'] = Arr::a2s( []);
$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');
if($api_no != $deploy_optimize['api_no']){
NoticeLog::createLog(NoticeLog::TYPE_RANK_DATA, ['api_no' => $deploy_optimize['api_no']]);
if($deploy_optimize['api_no']){
NoticeLog::createLog(NoticeLog::TYPE_RANK_DATA, ['api_no' => $deploy_optimize['api_no'] ?: 0]);
}else{
//清空已有排名数据
RankData::where('project_id', $deploy_optimize['project_id'])->delete();
ExternalLinks::where('project_id', $deploy_optimize['project_id'])->delete();
IndexedPages::where('project_id', $deploy_optimize['project_id'])->delete();
RecommDomain::where('project_id', $deploy_optimize['project_id'])->delete();
Speed::where('project_id', $deploy_optimize['project_id'])->delete();
RankWeek::where('project_id', $deploy_optimize['project_id'])->delete();
}
}
$deployOptimizeModel->edit($deploy_optimize,['id'=>$deploy_optimize['id']]);
return $this->success();
... ... @@ -327,12 +345,24 @@ class ProjectLogic extends BaseLogic
$languageModel = new MinorLanguages();
$languageModel->del(['project_id'=>$this->param['id']]);
if(!empty($minor_language)){
$webLanguageModel = new WebLanguage();
$result = [];
foreach ($minor_language as $k => $v){
if(!empty($v['language'])){
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$v['project_id'] = $this->param['id'];
$data[] = $v;
if(!empty($v['lang'])){
$zh = $webLanguageModel->read(['short'=>$v['lang']],['chinese']);
if(empty($zh)){
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;
}
}
if(!empty($data)){
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Project\PageSetting;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
... ... @@ -39,38 +40,76 @@ class BTemplateLogLogic extends BaseLogic
$this->fail('error');
}
$bTemplateModel = new BTemplate();
if($info['template_id'] == 0){//定制项目
//TODO::还原头部+底部
$bTemplateModel->edit(['html'=>$info['text']],['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
return $this->success();
}
//演示项目,不允许其他号码编辑
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
}
//获取当前项目的模版
if($info['template_id'] == 0) {//todo::定制项目
return $this->rollBackCustomized($info);
}
//TODO::非定制项目,获取当前项目的模版
return $this->rollBackNoCustomized($info);
}
/**
* @remark :定制页面还原
* @name :rollBackCustomized
* @author :lyh
* @method :post
* @time :2024/4/23 14:36
*/
public function rollBackCustomized($info){
$bTemplateModel = new BTemplate();
$condition = ['template_id'=>0,'source'=>$info['source'],'source_id'=>$info['source_id'],
'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
//TODO::还原头部+底部
$bTemplateModel->edit(['html'=>$info['text']],$condition);
$commonData = [
'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'],
'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']
];
$type = $this->getCustomizedType($info['source'],$info['is_list']);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);
return $this->success();
}
/**
* @remark :非定制界面还原
* @name :rollBackNoCustomized
* @author :lyh
* @method :post
* @time :2024/4/23 14:38
*/
public function rollBackNoCustomized($info){
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先选择模版');
}
$bTemplateModel = new BTemplate();
try {
//切换模版
if($info['template_id'] != $settingInfo['template_id']){
$bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]);
}
try {
$data = $this->setParam($info);
$bTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$commonData = $this->setCommonParam($info);
$data = ['main_html'=>$info['main_html'], 'main_css'=>$info['main_css']];
$condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id'],
'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
$bTemplateModel->edit($data,$condition);
//还原头部+底部
$commonData = [
'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']
];
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);
//更新所有界面的other
$type = $this->getType($info['source'],$info['is_list'],$info['is_custom']);
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);
if(!empty($info['other'])){
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
}else{
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$type]);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
... ... @@ -79,35 +118,67 @@ class BTemplateLogLogic extends BaseLogic
}
/**
* @remark :设置回滚参数
* @name :setParam
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/8/23 14:18
* @time :2023/11/16 11:20
*/
public function setParam($info){
$data = [
'main_html'=>$info['main_html'],
'main_css'=>$info['main_css'],
];
return $this->success($data);
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_PRODUCT_LIST;
}else{
$type = BTemplate::TYPE_PRODUCT_DETAIL;
}
}
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
}
/**
* @remark :设置回滚公共参数参数
* @name :setParam
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/8/23 14:18
* @time :2023/10/21 17:29
*/
public function setCommonParam($info){
$data = [
'head_html'=>$info['head_html'],
'head_css'=>$info['head_css'],
'footer_html'=>$info['footer_html'],
'footer_css'=>$info['footer_css']
];
return $this->success($data);
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo === false) {
return $this->success($type);
}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
}
return $this->success($type);
}
/**
... ...
... ... @@ -417,7 +417,7 @@ class BTemplateLogic extends BaseLogic
}
//更新头部信息
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
return $this->success();
... ... @@ -607,6 +607,7 @@ class BTemplateLogic extends BaseLogic
$param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
return $this->success($param);
}
/**
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
... ... @@ -646,7 +647,7 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/8/23 11:16
*/
public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){
public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom = 0,$is_list = 0,$type = 0){
if($is_custom != BTemplate::IS_NO_CUSTOM){
return true;
}
... ... @@ -657,6 +658,7 @@ class BTemplateLogic extends BaseLogic
'text'=>$html,
'type'=>$type,
'is_custom'=>$is_custom,
'is_list'=>$is_list,
'source'=>$source,
'source_id'=>$source_id,
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
... ...
... ... @@ -113,7 +113,7 @@ class CustomTemplateLogic extends BaseLogic
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$this->setTemplateLog($bSettingInfo['template_id'],$html,$this->param['id']);
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
$rs = $this->model->edit($this->param,['id'=>$this->param['id'],'project_id'=>$this->user['project_id']]);
if($rs === false){
$this->fail('系统错误,请联系管理');
}
... ... @@ -364,4 +364,37 @@ class CustomTemplateLogic extends BaseLogic
}
return $this->success($data);
}
/**
* @remark :单页面还原
* @name :saveRollbackVersion
* @author :lyh
* @method :post
* @time :2024/4/23 14:00
*/
public function saveRollbackVersion(){
//获取当前数据记录详情
$log = new BTemplateLog();
$logInfo = $log->read(['id'=>$this->param['id']]);
if($logInfo === false){
$this->fail('未获取到当前记录');
}
//获取当前数据详情
$info = $this->model->read(['id'=>$logInfo['source_id']],['is_visualization']);
if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){
//还原头部底部
$type = $this->getType();
//还原头部+底部
$commonData = [
'head_html'=>$logInfo['head_html'],
'head_css'=>$logInfo['head_css'],
'footer_html'=>$logInfo['footer_html'],
'footer_css'=>$logInfo['footer_css']
];
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$logInfo['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);
}
$this->model->edit(['html'=>$logInfo['main_html'],'html_style'=>$logInfo['main_css']],['id'=>$logInfo['source_id']]);
return $this->success();
}
}
... ...
... ... @@ -39,4 +39,23 @@ class DescribeLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :删除数据
* @name :del
* @author :lyh
* @method :post
* @time :2024/4/12 16:57
*/
public function describeDel(){
if(is_array($this->param['ids'])){
$rs = $this->model->del(['id'=>['in',$this->param['ids']]]);
}else{
$rs = $this->model->del(['id'=>$this->param['ids']]);
}
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -273,22 +273,29 @@ class ProductLogic extends BaseLogic
*/
public function handleSaveParam(&$param){
//产品图
if(isset($param['gallery'])){
if(isset($param['gallery']) && !empty($param['gallery'])){
foreach ($param['gallery'] as $k => $v){
$v['url'] = str_replace_url($v['url']);
$param['gallery'][$k] = $v;
}
$param['thumb'] = Arr::a2s($param['gallery'][0] ?? []);
$param['gallery'] = Arr::a2s($param['gallery'] ?? []);
}else{
$param['thumb'] = Arr::a2s([]);
$param['gallery'] = Arr::a2s([]);
}
if(isset($param['files'])){
if(isset($param['files']) && !empty($param['files'])){
$param['files']['url'] = str_replace_url($param['files']['url'] ?? '');
$param['files'] = Arr::a2s($param['files'] ?? []);
}else{
$param['files'] = Arr::a2s([]);
}
if(isset($param['video'])){
$param['video']['url'] = str_replace_url($param['video']['url']);
$param['video']['video_image'] = str_replace_url($param['video']['video_image']);
$param['video'] = Arr::a2s($param['video'] ?? []);
}else{
$param['video'] = Arr::a2s([]);
}
if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
$param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).',';
... ... @@ -304,6 +311,8 @@ class ProductLogic extends BaseLogic
$param['icon'][$k1] = str_replace_url($v1);
}
$param['icon'] = Arr::a2s($param['icon'] ?? []);
}else{
$param['icon'] = Arr::a2s([]);
}
$param['created_uid'] = $this->user['id'];
return $param;
... ...
... ... @@ -77,8 +77,8 @@ class RankDataLogic extends BaseLogic
'keyword_num' => $project['deploy_build']['keyword_num'],
'compliance_day' => $project['finish_remain_day'] ?? 0,
'remain_day' => $project['deploy_build']['service_duration'] - ($project['finish_remain_day'] ?? 0),
'g_top_plan' => $project['deploy_optimize']['g_top_plan'] ?? [],
];
//小语种列表
$quanqiusou_api = new QuanqiusouApi();
$lang_data = $quanqiusou_api->getLangRankData($api_no);
... ... @@ -92,10 +92,11 @@ class RankDataLogic extends BaseLogic
$data['langs'][$lang['language'] ?? ''] = [
'lang_text' => $lang['language'],
'keyword_num' => $lang['keywords'] ?? 0,
'reach_day' => $lang_data[$lang['language']]['dabiao_day'] ?? 0,
'home_cnt' => $lang_data[$lang['language']]['home_cnt'] ?? 0,
'reach_day' => $lang_data[$lang['lang']]['dabiao_day'] ?? 0,
'home_cnt' => $lang_data[$lang['lang']]['home_cnt'] ?? 0,
'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day,
'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
'service_day' => $lang['service_day'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
];
}
}
... ... @@ -424,8 +425,10 @@ class RankDataLogic extends BaseLogic
*/
public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){
$without_project_ids = []; //不用处理排名的项目
$without_extension_project_ids = [658]; //是否达标只统计主词的
$first_num = $first_page_num = $first_three_pages_num = $first_five_pages_num = $first_ten_pages_num = 0;
$first_page_without_extension_num = 0; //不算扩展词在首页的数量
foreach ($data as &$ranks){
ksort($ranks);
... ... @@ -446,6 +449,7 @@ class RankDataLogic extends BaseLogic
//排名第一页
if($last['position'] > 0 && $last['position'] <= 10){
$first_page_num ++;
$last['g'] == 1 && $first_page_without_extension_num++;
}
//排名前三页
if($last['position'] > 0 && $last['position'] <= 30){
... ... @@ -460,8 +464,6 @@ class RankDataLogic extends BaseLogic
$first_ten_pages_num ++;
}
}
$where = [
'project_id' => $project_id,
'lang' => $lang
... ... @@ -470,28 +472,29 @@ class RankDataLogic extends BaseLogic
if(!$model){
$model = new RankData();
}
//关键词达标天数
//保证关键词数
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
$type = Project::where('id', $project_id)->value('type');
$model->is_compliance = 0;
if ($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num) {
Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num);
//是否达标
$is_compliance = $first_page_num >= $keyword_num;
if(in_array($project_id, $without_extension_project_ids)){
$is_compliance = $first_page_without_extension_num >= $keyword_num;
}
if ($keyword_num && $type == Project::TYPE_TWO && $is_compliance) {
Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num . ' - ' . $first_page_without_extension_num);
//项目表更新
if (($model->updated_date != date('Y-m-d') || empty($model->is_compliance)) && !$lang) {
$compliance_day = Project::where(['id' => $project_id])->value('finish_remain_day') ?: 0;
Project::where('id', $project_id)->update(['is_remain_today' => 1, 'finish_remain_day' => $compliance_day + 1]);
Log::channel('rank_data')->info('项目' . $project_id . '达标天数+1:'. ($compliance_day + 1));
}
$model->compliance_day = $model->compliance_day + 1;
$model->is_compliance = 1;
} else {
Log::channel('rank_data')->info('项目' . $project_id . ':关键词未达标'. $keyword_num .' - ' . $first_page_num);
}
$model->project_id = $project_id;
$model->first_num = $first_num;
$model->first_page_num = $first_page_num;
... ...
... ... @@ -54,16 +54,20 @@ class TranslateLogic extends BaseLogic
$text_array = $this->getUrlRead($url);
// 原始校对程序
$old_key = [];//key值组成数据
if($info !== false){
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$data_read = json_decode($info ? $info['data'] : '',JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if(!empty($data_read)){
foreach ($data_read as $k => $v){
$k = urldecode($k);
$old_key[] = $k;
$data[] = [$k => $v];
}
}
$arr2 = [];
foreach ($text_array as $val) {
if (FALSE == in_array($val, $old_key)){
if($val == ' '){
continue;
}
if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){
$arr2[] = $val;
}
}
... ... @@ -251,7 +255,7 @@ class TranslateLogic extends BaseLogic
}
$this->param['data'] = $data;
}
try {
// 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){
$param = [
... ... @@ -262,21 +266,21 @@ class TranslateLogic extends BaseLogic
'alias'=>$this->param['alias'],
];
$param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$this->model->add($param);
$rs = $this->model->add($param);
}else{
if(!empty($data)){
$data = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$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']]);
$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']]);
}
}
//写日志
$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']]);
}catch (\Exception $e){
$this->fail('系统错误请联系管理员');
}
// }catch (\Exception $e){
// $this->fail('系统错误请联系管理员');
// }
$this->handleRoute($this->param['url']);
return $this->success();
return $this->success($rs);
}
/**
... ...
... ... @@ -56,8 +56,6 @@ class UserLoginLogic
}
$projectModel = new Project();
$project_list = $projectModel->list(['id'=>['in',$projectArr],'delete_status'=>0],'id',['id','title']);
//登录选择项目的有效时间
Cache::add('login-project-'.$this->param['mobile'],1,300);
return $this->success($project_list);
}
... ... @@ -69,9 +67,6 @@ class UserLoginLogic
* @time :2023/6/17 16:43
*/
public function projectLogin(){
if(!Cache::get('login-project-'.$this->param['mobile'])){
$this->fail('当前用户选择项目有限时间已过期');
}
//获取项目详情
$info = $this->assembleParam($this->param['mobile'],$this->param['project_id']);
if(isset($info['token']) && !empty($info['token'])){
... ... @@ -178,10 +173,12 @@ class UserLoginLogic
$info['is_update_language'] = $project['is_update_language'];
$info['configuration'] = $project['deploy_build']['configuration'];
$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_visualization_authority'] = $project['deploy_build']['is_visualization_authority'];
//是否开通AMP
$is_amp = 0;
if(!empty($project['deploy_optimize']['domain'])){
... ... @@ -277,10 +274,12 @@ class UserLoginLogic
$info['project_type'] = $project['type'];
$info['storage_type'] = $project['storage_type'];
$info['project_location'] = $project['project_location'];
$info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0;
$info['remain_day'] = $project['remain_day'] ?? 0;
if($info['is_customized'] == 1){
$info['is_visualization'] = json_decode($project['is_visualization']);
}
$info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority'];
//是否开通AMP
$is_amp = 0;
if(!empty($project['deploy_optimize']['domain'])){
... ...
... ... @@ -58,6 +58,7 @@ class CopyProjectJob implements ShouldQueue
$type = $data['type'];
$data['type'] = 0;
$data['status'] = 0;
$data['finish_remain_day'] = 0;
$data['title'] = $data['title'].'-copy';
unset($data['id']);
$project_id = $projectModel->insertGetId($data);
... ... @@ -82,6 +83,8 @@ class CopyProjectJob implements ShouldQueue
$optimizeData = $optimizeData->getAttributes();
unset($optimizeData['id'],$optimizeData['domain']);
$optimizeData['project_id'] = $project_id;
$optimizeData['api_no'] = 0;
$optimizeData['minor_languages'] = json_encode([]);
$optimizeModel->insert($optimizeData);
}
//复制付费表
... ... @@ -160,6 +163,9 @@ class CopyProjectJob implements ShouldQueue
$sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']);
}
if($table == 'gl_customer_visit' || $table == 'gl_customer_visit_item' || $table == 'gl_inquiry_other' || $table == 'gl_inquiry_form_data' || $table == 'gl_inquiry_form'){
continue;
}
// DB::connection('custom_mysql')->table($table)->truncate(); // 清空目标表数据
DB::connection('custom_mysql')->table($table)->insertUsing(
[], // 列名数组,留空表示插入所有列
... ...
... ... @@ -44,21 +44,18 @@ class EditCustomDomainBt implements ShouldQueue
if ($domain_info === false) {
return $this->output($domain_info['custom_domain'] . ':获取域名数据失败');
}
//获取项目数据
$project_model = new Project();
$project_info = $project_model->read(['id' => $domain_info['project_id']], 'serve_id');
if ($project_info === false) {
return $this->output($domain_info['custom_domain'] . ':获取项目数据失败');
}
//获取服务器数据
$server_model = new ServerConfig();
$server_info = $server_model->read(['id' => $project_info['serve_id']], ['init_domain', 'host']);
if ($server_info === false) {
return $this->output($domain_info['custom_domain'] . ':获取服务器数据失败');
}
//编辑站点
if ($domain_info['type'] == 2) {
$api_url = 'http://' . $server_info['init_domain'] . '/api/setSsl';
... ...
... ... @@ -10,9 +10,11 @@
namespace App\Models\ASide;
use App\Helper\AyrShare as AyrShareHelper;
use App\Helper\FormGlobalsoApi;
use App\Models\AyrShare\AyrShare as AyrShareModel;
use App\Models\Base;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class APublicModel extends Base
... ... @@ -30,6 +32,8 @@ class APublicModel extends Base
*/
public static function getNumByProjectId($project_id){
ProjectServer::useProject($project_id);
$data = Cache::get('product_blog_news_'.$project_id);
if(!$data){
$productNumber = DB::connection('custom_mysql')->table('gl_product')
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
$blogNumber = DB::connection('custom_mysql')->table('gl_blog')
... ... @@ -38,8 +42,16 @@ class APublicModel extends Base
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
$keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword')
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
//获取项目的询盘数量
$inquiryNumber = 0;
$countInfo = DB::table('gl_count')->where('project_id', $project_id)->orderBy('id', 'desc')->first();
if(!empty($countInfo)){
$inquiryNumber = $countInfo->inquiry_num ?? 0;
}
$data = ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber];
Cache::add('product_blog_news_'.$project_id,$data,30 * 60);
}
DB::disconnect('custom_mysql');
return ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber];
return $data;
}
}
... ...
<?php
/**
* @remark :
* @name :ErrorFile.php
* @author :lyh
* @method :post
* @time :2024/4/16 17:00
*/
namespace App\Models\File;
use App\Models\Base;
class ErrorFile extends Base
{
protected $table = 'gl_error_file';
}
... ...
... ... @@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class Keyword extends Base
{
use SoftDeletes;
// use SoftDeletes;
//设置关联表名
protected $table = 'gl_product_keyword';
... ...
... ... @@ -19,7 +19,9 @@ class DeployOptimize extends Base
public function getMinorLanguagesAttribute($value){
return Arr::s2a($value);
}
public function getGTopPlanAttribute($value){
return Arr::s2a($value);
}
public static function clearCache($row){
$cache_key = 'project_' . $row->original['domain'];
Cache::forget($cache_key);
... ...
... ... @@ -9,6 +9,7 @@ use App\Models\Devops\ServerConfig;
use App\Models\Optimize\Process;
use App\Services\Facades\Upload;
use Illuminate\Support\Facades\Cache;
use App\Models\Domain\DomainInfo as DomainInfoModel;
class Project extends Base
{
... ... @@ -354,6 +355,9 @@ class Project extends Base
$project_id = DeployBuild::where('test_domain', 'https://' . $domain . '/')->value('project_id');
//是否正式域名
if (!$project_id) {
$domainModel = new DomainInfoModel();
$project_id = $domainModel->formatQuery(['domain'=>$domain,'status'=>1])->value('project_id');
if (empty($project_id)) {
//是否小语种域名或amp站域名
$domainPrefix = explode(".",$domain);
if (!empty($domainPrefix)){
... ... @@ -366,7 +370,8 @@ class Project extends Base
}
}
}
$project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id');
$project_id = $domainModel->formatQuery(['domain'=>$domain,'status'=>1])->value('project_id');
}
}
$project = self::find($project_id ?: 0);
if($project){
... ...
... ... @@ -40,12 +40,10 @@ class ProjectServer
config(['database.connections.custom_mysql.database' => $project->databaseName()]);
config(['database.connections.custom_mysql.username' => $project->mysqlConfig->user]);
config(['database.connections.custom_mysql.password' => $project->mysqlConfig->password]);
//清除现有的数据库连接配置
DB::purge('custom_mysql');
//重连
DB::connection('custom_mysql')->reconnect();
// 设置 redis 配置
return $project;
}
... ... @@ -172,7 +170,7 @@ class ProjectServer
* @method :post
* @time :2023/12/29 9:32
*/
public function init404Page($project_id){
public static function init404Page($project_id){
$time = date('Y-m-d H:i:s');
$info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();
if(empty($info)) {
... ...
... ... @@ -204,6 +204,11 @@ class SyncSubmitTaskService
}
$config = InquiryFilterConfig::getCacheInfoByProjectId($project_id);
//没配置 则默认开启且使用全局
if($config){
$config['is_global_rule'] = 1;
$config['status'] = 1;
}
//是否开启过滤
if($config && $config['status']){
//是否包含全局规则(就是project_id=1的配置)
... ... @@ -262,7 +267,7 @@ class SyncSubmitTaskService
//过滤邮箱
if($config['filter_emails'] && !empty($data['data']['email'])){
foreach ($config['filter_emails'] as $filter_email){
if($data['data']['email'] == $filter_email){
if(Str::contains($data['data']['email'], $filter_email)){
throw new InquiryFilterException( '过滤邮箱:' . $filter_email);
}
}
... ... @@ -270,7 +275,7 @@ class SyncSubmitTaskService
//过滤电话
if($config['filter_mobiles'] && !empty($data['data']['phone'])){
foreach ($config['filter_mobiles'] as $filter_mobile){
if($data['data']['phone'] == $filter_mobile){
if(Str::contains($data['data']['phone'], $filter_mobile)){
throw new InquiryFilterException( '过滤电话:' . $filter_mobile);
}
}
... ... @@ -278,7 +283,7 @@ class SyncSubmitTaskService
//过滤姓名
if($config['filter_names'] && !empty($data['data']['name'])){
foreach ($config['filter_names'] as $filter_name){
if($data['data']['name'] == $filter_name){
if( Str::contains($data['data']['name'], $filter_name)){
throw new InquiryFilterException( '过滤姓名:' . $filter_name);
}
}
... ...
... ... @@ -258,7 +258,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
//产品参数
Route::get('attr', [\App\Http\Controllers\Bside\Product\AttrController::class, 'index'])->name('product_attr');
Route::get('attr/info', [\App\Http\Controllers\Bside\Product\AttrController::class, 'info'])->name('product_attr_info');
... ... @@ -396,6 +396,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/saveHtml', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'saveHtml'])->name('custom_saveHtml');
Route::any('/statusNum', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'statusNumber'])->name('custom_statusNum');
Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del');
Route::any('/rollbackVersion', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'rollbackVersion'])->name('custom_rollbackVersion');
Route::any('/getCustomTemplateLog', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'getCustomTemplateLog'])->name('custom_getCustomTemplateLog');
});
// 菜单组
Route::prefix('nav_group')->group(function () {
... ...