作者 赵彬吉
正在显示 35 个修改的文件 包含 358 行增加138 行删除
... ... @@ -50,11 +50,11 @@ class Count extends Command
try {
if(!empty($list)){
$list = $list->toArray();
$data = [];
$yesterday = Carbon::yesterday()->toDateString();
$domainInfo = new DomainInfo();
foreach ($list as $v){
$v = (array)$v;
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
if($v['type'] == Project::TYPE_ZERO){
continue;
}
... ... @@ -76,7 +76,7 @@ class Count extends Command
//服务达标天数
$arr['compliance_day'] = $v['finish_remain_day'];
//剩余服务时常
$arr['service_day'] = $v['remain_day'] - 1;
$arr['service_day'] = ($v['remain_day'] - 1) < 0 ? 0: $v['remain_day'] - 1;
//项目id
$arr['project_id'] = $v['project_id'];
$arr['created_at'] = date('Y-m-d H:i:s');
... ... @@ -84,9 +84,16 @@ class Count extends Command
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain'], $v['id']);
if($arr === false){
$data[] = $v['test_domain'];
continue;
}
//查询当天数据是否存在 存在则更新
$countModel = new \App\Models\HomeCount\Count();
$info = $countModel->read(['date'=>$arr['date'],'project_id'=>$v['id']]);
if($info === false){
DB::table('gl_count')->insert($arr);
}else{
$countModel->edit($arr,['id'=>$info['id']]);
}
DB::table('gl_count')->insert($arr);
Log::channel('day_count')->error('日期:'.$arr['created_at'].'success: ' .$v['test_domain']);
}
}
... ...
<?php
/**
* @remark :
* @name :UpgradeProjectCount.php
* @name :CountProject.php
* @author :lyh
* @method :post
* @time :2024/1/8 9:03
... ... @@ -18,15 +18,16 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Models\HomeCount\Count;
class UpgradeCount extends Command
class CountAll extends Command
{
const STATUS_ERROR = 400;
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'upgrade_counts';
protected $signature = 'count_all';
/**
* The console command description.
... ... @@ -37,7 +38,7 @@ class UpgradeCount extends Command
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]);
$list = $projectModel->list(['delete_status'=>0]);
foreach ($list as $v) {
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
... ...
<?php
/**
* @remark :
* @name :UpgradeProjectCount.php
* @name :CountProject.php
* @author :lyh
* @method :post
* @time :2024/1/8 9:03
... ... @@ -20,7 +20,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Models\HomeCount\Count;
class UpgradeProjectCount extends Command
class CountProject extends Command
{
const STATUS_ERROR = 400;
public $error = 0;
... ... @@ -29,7 +29,7 @@ class UpgradeProjectCount extends Command
*
* @var string
*/
protected $signature = 'upgrade_count {project_id}';
protected $signature = 'count_project {project_id}';
/**
* The console command description.
... ... @@ -61,10 +61,10 @@ class UpgradeProjectCount extends Command
$optimizeInfo = $projectOptimizeModel->read(['project_id'=>$project_id]);
$domain = '';
if(!empty($optimizeInfo['domain'])){
$domainInfo = new DomainInfo();
$info = $domainInfo->read(['id'=>$optimizeInfo['domain']]);
if($info !== false){
$domain = $info['domain'];
$domainInfoModel = new DomainInfo();
$domainInfo = $domainInfoModel->read(['id'=>$optimizeInfo['domain']]);
if($domainInfo !== false){
$domain = $domainInfo['domain'];
}
}
if(empty($domain)){
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Console\Commands\Domain;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\ServersIp;
use App\Models\Project\CountryCustom;
use App\Models\Project\Project;
use Illuminate\Console\Command;
... ... @@ -98,13 +99,18 @@ class DomainInfo extends Command
$ssl['to'] && $data['certificate_end_time'] = $ssl['to'];
$project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']);
if ($v['type'] == 1 && $ssl['to'] < $end_day && $project_info && $project_info['serve_id'] != ServerConfig::SELF_SITE_ID) {
//非自建站项目,申请免费证书
$this->updatePrivate($v);
if ($v['type'] == 1 && $ssl['to'] < $end_day && $project_info) {
$serverIpModel = new ServersIp();
$servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id']);
if ($servers_ip_info && $servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID) {
//非自建站项目,申请免费证书
$this->updatePrivate($v);
$ssl_new = $this->updateDomainSsl($v['domain']);
$ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];
$ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];
}
$ssl_new = $this->updateDomainSsl($v['domain']);
$ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];
$ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];
}
$domainModel->edit($data, ['id' => $v['id']]);
... ... @@ -142,13 +148,17 @@ class DomainInfo extends Command
$ssl['to'] && $data['amp_certificate_end_time'] = $ssl['to'];
$project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']);
if ($v['amp_type'] == 1 && $ssl['to'] < $end_day && $project_info && $project_info['serve_id'] != ServerConfig::SELF_SITE_ID) {
//非自建站项目,申请免费证书
$this->updateAmpPrivate($v['domain']);
if ($v['amp_type'] == 1 && $ssl['to'] < $end_day && $project_info) {
$serverIpModel = new ServersIp();
$servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id']);
if ($servers_ip_info && $servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID) {
//非自建站项目,申请免费证书
$this->updateAmpPrivate($v['domain']);
$ssl_new = $this->updateDomainSsl($v['domain']);
$ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];
$ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];
$ssl_new = $this->updateDomainSsl($v['domain']);
$ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];
$ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];
}
}
$domainModel->edit($data, ['id' => $v['id']]);
... ...
<?php
/**
* @remark :
* @name :UpgradeProjectCount.php
* @name :CountProject.php
* @author :lyh
* @method :post
* @time :2024/1/8 9:03
... ... @@ -21,14 +21,14 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Models\HomeCount\Count;
class UpgradeCount extends Command
class MonthAllCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'upgrade_month_counts';
protected $signature = 'month_all';
/**
* The console command description.
... ... @@ -39,7 +39,7 @@ class UpgradeCount extends Command
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]);
$list = $projectModel->list(['delete_status'=>0]);
foreach ($list as $v) {
if($v['is_upgrade'] == 1){
$oldModel = new UpdateOldInfo();
... ... @@ -77,9 +77,7 @@ class UpgradeCount extends Command
->groupBy('month')->get()->toArray();
foreach ($list as $k=>$v){
$v = (array)$v;
if($v['month'] == date('Y-m')){
continue;
}
$arr = [];
$monthCountModel = new MonthCount();
$info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
// 获取当月开始时间
... ... @@ -88,7 +86,7 @@ class UpgradeCount extends Command
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = $this->inquiry($url,$v['month']);
// $arr['month_total'] = 0;
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
$arr['month_total'] = $res['data']['count'];
... ...
<?php
/**
* @remark :
* @name :UpgradeProjectCount.php
* @name :CountProject.php
* @author :lyh
* @method :post
* @time :2024/1/8 9:03
... ... @@ -99,6 +99,7 @@ class MonthCount extends Command
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
$arr = [];
$v = ['month'=>date('Y-m')];
$monthCountModel = new MonthCountModel();
$info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
... ... @@ -108,7 +109,7 @@ class MonthCount extends Command
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = $this->inquiry($url,$v['month']);
// $arr['month_total'] = 0;
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
$arr['month_total'] = $res['data']['count'];
... ...
<?php
/**
* @remark :
* @name :UpgradeProjectCount.php
* @name :CountProject.php
* @author :lyh
* @method :post
* @time :2024/1/8 9:03
... ... @@ -21,14 +21,14 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Models\HomeCount\Count;
class UpgradeProjectCount extends Command
class MonthProjectCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'upgrade_month_count {project_id}';
protected $signature = 'month_project {project_id}';
/**
* The console command description.
... ... @@ -65,10 +65,8 @@ class UpgradeProjectCount extends Command
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
->groupBy('month')->get()->toArray();
foreach ($list as $k=>$v){
$arr = [];
$v = (array)$v;
// if($v['month'] == date('Y-m')){
// continue;
// }
$monthCountModel = new MonthCount();
$info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
// 获取当月开始时间
... ... @@ -77,7 +75,7 @@ class UpgradeProjectCount extends Command
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = $this->inquiry($url,$v['month']);
// $arr['month_total'] = 0;
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
$arr['month_total'] = $res['data']['count'];
... ...
... ... @@ -13,6 +13,7 @@ use App\Models\Com\KeywordVideoTaskLog;
use App\Models\Domain\DomainInfo;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* @remark :通知C端生成界面
... ... @@ -65,6 +66,7 @@ class Notice extends Command
}
foreach ($domainList as $v1){
//TODO::通知C端
@file_put_contents(storage_path('logs/notice_c'.'.log'), var_export($v1['domain'], true) . PHP_EOL, FILE_APPEND);
$this->curlDelRoute($v1['domain'],$v1['project_id']);
}
return true;
... ...
... ... @@ -54,12 +54,13 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[1085]]]);
$list = $projectModel->list(['id'=>['in',[664]]]);
$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->getProduct();
$this->setProductKeyword();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ... @@ -106,19 +107,8 @@ class UpdateRoute extends Command
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['route'])){
// $tag = "-tag";
// if ((substr($v['route'], -strlen($tag)) === $tag)) {
// echo date('Y-m-d H:i:s') . '拼接 :'.$v['id'] . PHP_EOL;
// $route = Translate::tran($v['route'], 'en').$tag;
// // 如果不是以 '-tag' 结尾,则拼接上 '-tag'
// $route = trim($v['route'],'-tag');
// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }else{
// $route = Translate::tran($v['title'], 'en').$tag;
// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }
echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;
continue;
}else{
echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;
$route = Translate::tran($v['title'], 'en');
... ... @@ -128,7 +118,6 @@ class UpdateRoute extends Command
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
}
}
echo date('Y-m-d H:i:s') . 'end :' . PHP_EOL;
}
}
}
... ... @@ -224,7 +213,7 @@ class UpdateRoute extends Command
public function getProduct(){
$productModel = new Product();
$lists = $productModel->list(['status'=>1]);
$lists = $productModel->list(['status'=>1,'id'=>['<=',501]]);
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['route'])){
... ... @@ -240,9 +229,10 @@ class UpdateRoute extends Command
// $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
// $productModel->edit(['route'=>$route],['id'=>$v['id']]);
}
continue;
}else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
// $v['title'] = Translate::tran($v['title'], 'en');
$v['title'] = Translate::tran($v['title'], 'en');
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
$productModel->edit(['route'=>$route],['id'=>$v['id']]);
}
... ...
... ... @@ -92,8 +92,6 @@ class HtmlCollect extends Command
try {
$html = curl_c('https://' . $collect_info->domain . $collect_info->route, false);
if (strlen($html) < 4) {
$collect_info->status = CollectTask::STATUS_FAIL;
$collect_info->save();
if ($html == 404) {
//原数据页面404,需要将6.0数据存入草稿箱
... ... @@ -124,6 +122,8 @@ class HtmlCollect extends Command
$status_draft = BCustomTemplate::STATUS_DRAFT;
}
$model->edit(['status' => $status_draft], ['project_id' => $project_id, 'id' => $collect_info->source_id, 'six_read' => 1]);
CollectTask::where('source', $collect_info->source)->where('source_id', $collect_info->source_id)->delete();
}
echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: ' . $html . PHP_EOL;
... ... @@ -347,6 +347,14 @@ class HtmlCollect extends Command
$source[] = $check_vv2;
}
}
preg_match_all('/<iframe\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video_3);
$video_3 = $result_video_3[2] ?? [];
foreach ($video_3 as $vv3) {
$check_vv3 = $this->url_check($vv3, $project_id, $domain, $web_url_domain, $home_url);
if ($check_vv3 && (!in_array($check_vv3, $source))) {
$source[] = $check_vv3;
}
}
//css
preg_match_all('/<link\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_css);
... ...
<?php
/**
* @remark :
* @name :UpdateKeyword.php
* @author :lyh
* @method :post
* @time :2024/7/3 9:23
*/
namespace App\Console\Commands\Update;
use App\Models\Domain\DomainInfo;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordPage;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class UpdateKeyword extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_keyword_content';
/**
* The console command description.
*
* @var string
*/
protected $description = '批量更新关键词内容';
public function handle(){
while (true){
$keywordPageModel = new KeywordPage();
$lists = $keywordPageModel->list(['status'=>0]);
if(empty($lists)){
sleep(100);
continue;
}
$domainModel = new DomainInfo();
foreach ($lists as $v){
ProjectServer::useProject($v['project_id']);
$this->saveKeywordContent($v);
DB::disconnect('custom_mysql');
//获取当前项目的域名
$domainInfo = $domainModel->read(['project_id'=>$v['project_id']]);
if($domainInfo !== false){
$this->curlDelRoute($domainInfo['domain'],$v['project_id']);
}
$keywordPageModel->edit(['status'=>1],['id'=>$v['id']]);
}
sleep(10);
}
}
/**
* @remark :更新关键词内容
* @name :saveKeywordContent
* @author :lyh
* @method :post
* @time :2024/7/3 10:25
*/
public function saveKeywordContent($info){
$keywordModel = new Keyword();
$updateObject = json_decode($info['update_object'],true);
$text = json_decode($info['text'],true);
if(empty($text)){
return false;
}
$number = count($text);
$randomNumber = rand(0, $number - 1);
if($updateObject['type'] == 0){//更新所有关键字
$keywordModel->edit(['keyword_content'=>$text[$randomNumber]],['status'=>1]);
}else{
//按传递的关键字更新
if(!empty($updateObject['keyword'])){
$updateObject['keyword'] = (array)$updateObject['keyword'];
$keywordModel->edit(['keyword_content'=>$text[$randomNumber]],['title'=>['in',$updateObject['keyword']]]);
}
//按给定的数量更新
if(!empty($updateObject['number']) && ($updateObject['number'] != 0)){
$keywordIdArr = $keywordModel->where("status",1)->inRandomOrder()->take($updateObject['number'])->pluck('id')->toArray();
$keywordModel->edit(['keyword_content'=>$text[$randomNumber]],['id'=>['in',$keywordIdArr]]);
}
}
return true;
}
/**
* @remark :删除路由通知C端
* @name :curlDelRoute
* @author :lyh
* @method :post
* @time :2023/11/30 14:43
*/
public function curlDelRoute($domain,$project_id){
if (strpos($domain, 'https://') === false) {
$domain = 'https://' . $domain . '/';
}
$url = $domain.'api/update_page/?project_id='.$project_id.'&route=4';
shell_exec('curl -k "'.$url.'"');
return true;
}
}
... ...
... ... @@ -48,6 +48,8 @@ class Kernel extends ConsoleKernel
$schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
$schedule->command('update_keyword_route')->dailyAt('01:00')->withoutOverlapping(1); //升级项目--清除路由相同的关键字
$schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
$schedule->command('update_keyword_content')->hourly()->withoutOverlapping(1);
// 每日推送视频任务
$schedule->command('video_task')->hourly()->withoutOverlapping(1);
// 每日推送已完成视频任务项目生成对应界面
... ...
... ... @@ -23,8 +23,7 @@ define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/');
if (!function_exists('generateRoute')) {
function generateRoute($string)
{
//TODO::html结尾,htm结尾,只处理.htm前面的内容
return trim(strtolower(preg_replace('/[^\w.]+/', '-', trim($string))), '-');
return str_replace(".", "", trim(strtolower(preg_replace('/[^\w.]+/', '-', trim($string))), '-'));
}
}
... ...
... ... @@ -28,6 +28,7 @@ class ServersController extends BaseController
if(isset($this->map['server_name']) && !empty($this->map['server_name'])){
$this->map['server_name'] = ['like','%'.$this->map['server_name'].'%'];
}
$this->map['status'] = 0;
$serversModel = new ServersModel();
$lists = $serversModel->list($this->map);
$this->response('success',Code::SUCCESS,$lists);
... ...
... ... @@ -101,15 +101,17 @@ class ServersIpController extends BaseController
* @time :2024/6/24 16:24
*/
public function save(ServersIpLogic $serversIpLogic){
$this->request->validate([
'ip'=>'required',
'servers_id'=>'required',
'domain'=>'required'
],[
'ip.required' => 'ip不能为空',
'servers_id.required' => '服务器servers_id不能为空',
'domain.required' => 'cname域名不能为空',
]);
if(!isset($this->param['id'])){
$this->request->validate([
'ip'=>'required',
'servers_id'=>'required',
'domain'=>'required'
],[
'ip.required' => 'ip不能为空',
'servers_id.required' => '服务器servers_id不能为空',
'domain.required' => 'cname域名不能为空',
]);
}
$data = $serversIpLogic->saveServersIp();
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -42,7 +42,7 @@ class AutoTaskController extends BaseController
$where['status'] = $status - 1;
$result = Notify::select(['id','project_id', 'type', 'data', 'status', 'route', 'num', 'updated_at', 'created_at'])
->where('id', '>', 84000) // 查询有效数据
->where('server_id', '<>', 9) // 过滤测试环境数据
->where('server_id', '<>', 7) // 过滤测试环境数据
->where('server_id', '>', 0) // 过滤测试环境数据
->where($where)
->orderBy('id', 'desc')
... ... @@ -99,4 +99,4 @@ class AutoTaskController extends BaseController
];
return $this->response('success', Code::SUCCESS, $result);
}
}
\ No newline at end of file
}
... ...
... ... @@ -121,4 +121,21 @@ class ATemplateModuleController extends BaseController
$list = $project->list($this->map,'id',['id','title']);
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :修改审核状态
* @name :auditingStatus
* @author :lyh
* @method :post
* @time :2024/5/23 16:42
*/
public function auditingStatus(ATemplateModuleLogic $ATemplateModuleLogic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$data = $ATemplateModuleLogic->auditingStatus();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -139,9 +139,12 @@ class CategoryController extends BaseController
*/
public function sort(CategoryLogic $logic){
$this->request->validate([
'id'=>['required'],
'id'=>'required',
'sort'=>'numeric|min:0',
],[
'id.required' => 'ID不能为空',
'sort.numeric' => 'sort位数字',
'sort.min' => 'sort最小值为0',
]);
$logic->categorySort();
$this->response('success');
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Logic\Bside\Product\KeywordLogic;
use App\Http\Requests\Bside\Product\KeywordRequest;
use App\Models\Com\NoticeLog;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordPage;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
... ... @@ -242,6 +243,21 @@ class KeywordController extends BaseController
* @time :2024/7/2 10:14
*/
public function batchUpdateKeyword(){
$noticeLogModel = new NoticeLog();
$this->request->validate([
'text'=>'required|array',
'update_object'=>'required|array',
'update_method'=>'required'
],[
'text.required' => '文件内容不能为空',
'update_object.required' => '更新对象不为空',
'update_object.array' => '更新对象为数组',
'update_method.required' => '请求方式不为空'
]);
$keywordPageModel = new KeywordPage();
$this->param['text'] = json_encode($this->param['text']);
$this->param['update_object'] = json_encode($this->param['update_object']);
$this->param['project_id'] = $this->user['project_id'];
$id = $keywordPageModel->addReturnId($this->param);
$this->response('success',Code::SUCCESS,['id'=>$id]);
}
}
... ...
... ... @@ -49,9 +49,11 @@ class ServersIpLogic extends BaseLogic
*/
public function saveServersIp(){
//验证域名是否唯一
$info = $this->model->read(['domain'=>$this->param['domain']]);
if($info !== false){
$this->fail('当前初始域名已存在');
if(!isset($this->param['id'])){
$info = $this->model->read(['domain'=>$this->param['domain']]);
if($info !== false){
$this->fail('当前初始域名已存在');
}
}
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
... ...
... ... @@ -268,10 +268,10 @@ class DomainInfoLogic extends BaseLogic
$serverModel = new Servers();
$serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']);
$server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']];
if($project_info['serve_id'] == 9){
if($serversIpInfo['servers_id'] == 7){
$this->fail('请切换服务器,生成站点不能使用测试服务器');
}
if($project_info['serve_id'] == ServerConfig::SELF_SITE_ID){
if($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID){
$this->model->edit(['amp_status' => $this->param['amp_status'] ?? 0,],['id'=>$this->param['id']]);
$this->fail('自建站服务器无法生成站点');
}
... ... @@ -391,6 +391,12 @@ class DomainInfoLogic extends BaseLogic
$serverModel = new Servers();
$serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']);
$server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']];
if($serversIpInfo['servers_id'] == 7){
$this->fail('请切换服务器,生成站点不能使用测试服务器');
}
if($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID){
$this->fail('自建站服务器无法生成站点');
}
//域名是否都已经解析
if(strpos($this->param['custom_domain'],'//') === false){
$this->param['custom_domain'] = '//'.$this->param['custom_domain'];
... ...
... ... @@ -148,7 +148,7 @@ class ProjectLogic extends BaseLogic
//初始化项目
$this->createProjectData($this->param);
//双向绑定服务器,需放到保存项目的上方
$this->setServers($this->param['serve_id'],$this->param['id']);
$this->setServers($this->param['serve_id'] ?? 0,$this->param['id']);
//保存项目信息
$this->saveProject($this->param);
//保存建站部署信息
... ... @@ -192,6 +192,9 @@ class ProjectLogic extends BaseLogic
$serversModel->where(['id'=>$oldServerIpInfo['servers_id']])->decrement('being_number',1);
}
}
if(empty($servers_id)){
return $this->success();
}
$serversIpInfo = $serversIpModel->read(['id'=>$servers_id]);
$serversInfo = $serversModel->read(['id'=>$serversIpInfo['servers_id']]);
if($serversIpInfo['total'] >= $serversInfo['ip_total']){
... ...
... ... @@ -124,11 +124,11 @@ class ATemplateLogic extends BaseLogic
if(!empty($info['image'])){
$info['image_link'] = getImageUrl($info['image']);
}
if(!empty($info['design_manager'])){
$info['design_manager'] = (new Manage())->getName($info['design_manager']);
if(!empty($info['design_msg'])){
$info['design_msg'] = json_decode($info['design_msg']);
}
if(!empty($info['front_manager'])){
$info['front_manager'] = (new Manage())->getName($info['front_manager']);
if(!empty($info['front_msg'])){
$info['front_msg'] = json_decode($info['front_msg']);
}
return $this->success($info);
}
... ... @@ -261,15 +261,11 @@ class ATemplateLogic extends BaseLogic
*/
public function auditingStatus(){
//获取当前数据详情
$info = $this->model->read(['id'=>$this->param['id']]);
if(isset($this->param['front_status']) && $this->param['front_status'] == 1){
if($info['design_status'] == 0){
$this->fail('请先提交设计审核');
}
$this->param['design_manager'] = $this->manager['id'];
$this->param['test_model'] = 0;
}else{
$this->param['front_manager'] = $this->manager['id'];
if(isset($this->param['design_msg']) && !empty($this->param['design_msg'])){
$this->param['design_msg'] = json_encode($this->param['design_msg']);
}
if(isset($this->param['front_msg']) && !empty($this->param['front_msg'])){
$this->param['front_msg'] = json_encode($this->param['front_msg']);
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
... ...
... ... @@ -100,4 +100,19 @@ class ATemplateModuleLogic extends BaseLogic
return $this->success();
}
/**
* @remark :修改状态
* @name :auditingStatus
* @author :lyh
* @method :post
* @time :2024/5/23 16:44
*/
public function auditingStatus(){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('修改失败,请联系管理员');
}
return $this->success(['id'=>$this->param['id']]);
}
}
... ...
... ... @@ -68,7 +68,7 @@ class UserLogic extends BaseLogic
$this->param = $this->editPassword($this->param);
$rs = $this->model->edit($this->param, ['id' => $this->param['id']]);
} else {
$this->param['password'] = base64_encode(md5($this->param['password']));
$this->param['password'] = base64_encode(md5($this->param['password'] ?? '123456'));
$rs = $this->model->add($this->param);
}
if ($rs === false) {
... ...
... ... @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Logic;
use App\Models\Com\UpdateNotify;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\ServersIp;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteDelete;
use App\Models\Service\Service;
... ... @@ -175,11 +176,13 @@ class BaseLogic extends Logic
$data['project_id'] = $this->user['project_id'];
$str = http_build_query($data);
$url = $this->user['domain'].'api/delHtml/?'.$str;
if(isset($this->project['serve_id']) && ($this->project['serve_id'] == ServerConfig::SELF_SITE_ID)){
$serverIpModel = new ServersIp();
$serversIpInfo = $serverIpModel->read(['id'=>$this->project['serve_id']],['servers_id']);
if($serversIpInfo && ($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID)){
//自建站服务器直接返回
return $this->success();
}
if(isset($this->project['serve_id']) && ($this->project['serve_id'] != 1)){//TODO::当前项目通知不过 ,跳过自动更新
if($serversIpInfo && ($serversIpInfo['servers_id'] != 1)){//TODO::当前项目通知不过 ,跳过自动更新
exec('curl -k "'.$url.'" > /dev/null 2>&1 &');
}else{
shell_exec('curl -k "'.$url.'"');
... ...
... ... @@ -203,7 +203,7 @@ class BlogLogic extends BaseLogic
public function getCategory($category){
$str = '';
foreach ($category as $v){
$str .= $v.',';
$str .= $v.',';
}
return !empty(trim($str,',')) ? ','.$str.',' : '';
}
... ...
... ... @@ -59,32 +59,23 @@ class NewsLogic extends BaseLogic
*/
public function newsSave()
{
//拼接参数
// DB::beginTransaction();
// try {
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
$id = $this->param['id'];
$is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
$six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
if($is_upgrade == 0 || $six_read == 1) {
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
}
//是否更新路由
$route = $this->param['url'];
$this->edit($this->param, ['id' => $id]);
} else {
$this->param['sort'] = $this->setNewsSort();
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
$this->edit(['url' => $route], ['id' => $id]);
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
$id = $this->param['id'];
$is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
$six_read = $this->param['six_read'] ?? 0;//是否按6.0显示
if($is_upgrade == 0 || $six_read == 1) {
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
}
// //更新路由
// DB::commit();
// } catch (\Exception $e) {
// DB::rollBack();
// $this->fail('系统错误,请联系管理员');
// }
//是否更新路由
$route = $this->param['url'];
$this->edit($this->param, ['id' => $id]);
} else {
$this->param['sort'] = $this->setNewsSort();
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
$this->edit(['url' => $route], ['id' => $id]);
}
$this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
$this->curlDelRoute(['new_route'=>$route]);
return $this->success(['id'=>$id]);
... ... @@ -223,10 +214,10 @@ class NewsLogic extends BaseLogic
*/
public function getCategory($category){
$str = '';
if(is_array($category) && $category){
$str = ','.implode(',',$category).',';
foreach ($category as $v){
$str .= $v.',';
}
return $str;
return !empty(trim($str,',')) ? ','.$str.',' : '';
}
/**
... ...
... ... @@ -20,6 +20,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class CopyProjectJob implements ShouldQueue
... ... @@ -52,6 +53,7 @@ class CopyProjectJob implements ShouldQueue
$projectModel = new Project();
DB::beginTransaction();
try {
$this->output('CopyProjectJob start, project_id: ' . $this->param['project_id']);
//复制初始项目
$data = $projectModel::where('id', $this->param['project_id'])->first();
$data = $data->getAttributes();
... ... @@ -61,6 +63,7 @@ class CopyProjectJob implements ShouldQueue
$data['finish_remain_day'] = 0;
$data['title'] = $data['title'].'-copy';
$data['delete_status'] = 1;
$data['uptime'] = null;
unset($data['id']);
$project_id = $projectModel->insertGetId($data);
$hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890');
... ... @@ -95,7 +98,6 @@ class CopyProjectJob implements ShouldQueue
unset($optimizeData['id'],$optimizeData['domain']);
$optimizeData['project_id'] = $project_id;
$optimizeData['api_no'] = 0;
$optimizeData['minor_languages'] = json_encode([]);
$optimizeModel->insert($optimizeData);
}
//复制付费表
... ... @@ -128,6 +130,7 @@ class CopyProjectJob implements ShouldQueue
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->output('CopyProjectJob error, error message: ' . $e->getMessage());
$this->fail('error');
}
if($type != 0){
... ... @@ -135,6 +138,7 @@ class CopyProjectJob implements ShouldQueue
}
//修改项目状态
$projectModel->edit(['delete_status'=>0],['id'=>$project_id]);
$this->output('CopyProjectJob end, old project_id: ' . $this->param['project_id'] . ', new project_id: ' . $project_id);
return true;
}
... ... @@ -170,7 +174,7 @@ class CopyProjectJob implements ShouldQueue
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)->truncate(); // 清空目标表数据
DB::connection('custom_mysql')->table($table)->insertUsing(
[], // 列名数组,留空表示插入所有列
function ($query) use ($table,$project_id) {
... ... @@ -184,4 +188,17 @@ class CopyProjectJob implements ShouldQueue
}
return true;
}
/**
* @param $message
* @return bool
*/
public function output($message)
{
$date = date('Y-m-d H:i:s');
$output = $date . ', ' . $message . PHP_EOL;
echo $output;
Log::info($output);
return true;
}
}
... ...
... ... @@ -15,7 +15,6 @@ use App\Utils\EncryptUtils;
class Servers extends Base
{
protected $table = 'gl_servers';
const SELF_SITE_ID = 8;//自建站服务器ID
/**
* @remark :获取数据用户名解密
... ...
<?php
/**
* @remark :
* @name :KeywordPage.php
* @author :lyh
* @method :post
* @time :2024/7/2 15:26
*/
namespace App\Models\Product;
use App\Models\Base;
class KeywordPage extends Base
{
protected $table = 'gl_product_keyword_page';
}
... ...
... ... @@ -55,10 +55,9 @@ class RouteMap extends Base
public static function generateRoute($title, $source, $source_id, $project_id){
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
$title = Translate::tran($title, 'en');
}else{
if(contains_russian($title)){
$title = Translate::tran($title, 'en');
}
}
if(contains_russian($title)){
$title = Translate::tran($title, 'en');
}
$i=1;
$sign = generateRoute($title);
... ...
... ... @@ -79,6 +79,12 @@ return [
'prefix' => 'test',
],
//日记录日志
'copy_project' => [
'driver' => 'custom',
'via' => \App\Factory\LogFormatterFactory::class,
'prefix' => 'copy_project',
],
//日记录日志
'day_count' => [
'driver' => 'custom',
'via' => \App\Factory\LogFormatterFactory::class,
... ...
... ... @@ -373,6 +373,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/status', [Aside\Template\ATemplateModuleController::class, 'status'])->name('admin.ATemplateModule_status');
Route::any('/del', [Aside\Template\ATemplateModuleController::class, 'del'])->name('admin.ATemplateModule_del');
Route::any('/type', [Aside\Template\ATemplateModuleController::class, 'getType'])->name('admin.ATemplateModule_getType');
Route::any('/auditingStatus', [Aside\Template\ATemplateModuleController::class, 'auditingStatus'])->name('admin.ATemplateModule_auditingStatus');
Route::any('/getProjectList', [Aside\Template\ATemplateModuleController::class, 'getProjectList'])->name('admin.ATemplateModule_getProjectList');
});
//设置类型
... ...
... ... @@ -271,6 +271,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/batchUpdateKeyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchUpdateKeyword'])->name('product_keyword_batchUpdateKeyword');
Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
//产品参数
... ...