作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

... ... @@ -7,6 +7,7 @@ use App\Models\ProjectAssociation\ProjectAssociation;
use App\Services\CosService;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class GeneratePdfData extends Command
{
... ... @@ -66,15 +67,22 @@ class GeneratePdfData extends Command
sleep(60);
return 0;
}
$pdfFile = new PdfFile();
$bool = $pdfFile->saveData(['pid' => $list->id]);
if (!$bool) {
$this->error('生成v6绑定的aicc用户的pdf备用数据添加失败');
return 0;
DB::beginTransaction();
try {
$pdfFile = new PdfFile();
$bool = $pdfFile->saveData(['pid' => $list->id]);
if (!$bool) {
$this->error('生成v6绑定的aicc用户的pdf备用数据添加失败');
return 0;
}
$list->m_status = $month;
$list->save();
DB::commit();
$this->info('生成v6绑定的aicc用户的pdf备用数据添加成功 - ' . $list->id);
} catch (\Exception $exception) {
DB::rollBack();
$this->error('生成v6绑定的aicc用户的pdf备用数据添加失败 - ' . $list->id);
}
$list->m_status = $month;
$list->save();
$this->info('生成v6绑定的aicc用户的pdf备用数据添加成功');
return 0;
}
}
... ...
... ... @@ -5,9 +5,11 @@ namespace App\Console\Commands\GeneratePDF;
use App\Models\File\PdfFile;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Services\CosService;
use App\Services\ProjectServer;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Console\Command;
use Illuminate\Http\File;
use Illuminate\Support\Facades\DB;
class ProjectFilePDF extends Command
{
... ... @@ -48,7 +50,6 @@ class ProjectFilePDF extends Command
public function handle()
{
// 开始时间
$startTime = microtime(true);
... ... @@ -105,8 +106,14 @@ class ProjectFilePDF extends Command
$friend_id = $isExists->friend_id;
// todo 根据项目查询数据
$project_data = [];
$html = $this->html($project_data);
$filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
//获取当前数据详情
$res = ProjectServer::useProject($project_id);
if ($res) {
$project_data = [];
}
DB::disconnect('custom_mysql');
$html = $this->html($project_data);
$filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
if ($count == 2) {
$list->is_pdf = PdfFile::GENERATE_OTHER_PDF;
... ... @@ -169,7 +176,14 @@ class ProjectFilePDF extends Command
*/
protected function html($item)
{
$font_path = storage_path('fonts\msyh.ttf');
return '<html><head><title>Laravel</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'/><style>body{ font-family: \'msyh\'; } @font-face { font-family: \'msyh\'; font-style: normal; font-weight: normal; src: url(' . $font_path . ') format(\'truetype\'); }</style></head><body><div class=\'container\'><div class=\'content\'><p style=\'font-family: msyh, DejaVu Sans,sans-serif;\'>献给母亲的爱</p><div style=\'font-family: msyh, DejaVu Sans,sans-serif;\' class=\'title\'>Laravel 5中文测试sdsd</div><div class=\'title\'>测试三askjdhfkjasdhf</div></div></div></body></html>';
$html = @file_get_contents(dirname(__FILE__) . '/pdf_template.html');
if (empty($html)) {
return '';
}
$rep = [
'ENTRY_NAME' => '测试项目',
'NUMBER' => 1000,
];
return str_replace(array_keys($rep), array_values($rep), $html);
}
}
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>网站数据</title>
<style>
@font-face {
font-family: 'msyh';
font-style: normal;
font-weight: normal;
src: url(../../../../storage/fonts/msyh.ttf) format('truetype');
}
body {
font-family: 'msyh';
}
</style>
</head>
<body>
项目名称:ENTRY_NAME<br>
数量:NUMBER
</body>
</html>
... ...
... ... @@ -55,7 +55,7 @@ class InitProject extends Command
$project = Project::find($item['data']['project_id']);
$project_logic = new ProjectLogic();
//初始化数据库
if(!empty($project['mysql_id'])){
if(!empty($project['mysql_id']) && ($project['type'] == 1)){
$project_logic->initializationMysql($project['id']);
}
//初始账号
... ...
... ... @@ -7,6 +7,7 @@ use App\Helper\SemrushApi;
use App\Models\Domain\DomainInfo;
use App\Models\RankData\ExternalLinks as ExternalLinksModel;
use App\Models\Project\DeployOptimize;
use App\Utils\HttpUtils;
use App\Utils\LogUtils;
/**
... ... @@ -40,9 +41,12 @@ class ExternalLinks extends BaseCommands
$error = 0;
$semrushApi = new SemrushApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
$list = DeployOptimize::where('api_no', '>', 0)->select('domain', 'api_no', 'project_id')->get()->toArray();
LogUtils::info('start rank_data_external_links:' . count($list));
foreach ($list as $project_id => $domain) {
foreach ($list as $item) {
$project_id = $item['project_id'];
$api_no = $item['api_no'];
$domain = $item['domain'];
if(!$domain){
continue;
}
... ... @@ -54,15 +58,26 @@ class ExternalLinks extends BaseCommands
$model = new ExternalLinksModel();
}
//外链数据
$domain = (new DomainInfo())->getDomain($domain);
$res = $semrushApi->backlinks_overview($domain);
if (!$res) {
$error++;
continue;
//5.0
try {
$data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
$data = Arr::s2a($data);
}catch (\Exception $e){
$data = [];
}
$data = $this->_data($project_id, $res['total']);
if(!$data){
//外链数据
$domain = (new DomainInfo())->getDomain($domain);
$res = $semrushApi->backlinks_overview($domain);
if (!$res) {
$error++;
continue;
}
$data = $this->_data($project_id, $res['total']);
}
$model->project_id = $project_id;
$model->total = $data['total'];
... ...
... ... @@ -2,10 +2,12 @@
namespace App\Console\Commands\RankData;
use App\Helper\Arr;
use App\Helper\SemrushApi;
use App\Models\Domain\DomainInfo;
use App\Models\RankData\RecommDomain as RecommDomainModel;
use App\Models\Project\DeployOptimize;
use App\Utils\HttpUtils;
use App\Utils\LogUtils;
/**
... ... @@ -39,9 +41,12 @@ class RecommDomain extends BaseCommands
$error = 0;
$semrushApi = new SemrushApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
$list = DeployOptimize::where('api_no', '>', 0)->select('domain', 'api_no', 'project_id')->get()->toArray();
LogUtils::info('start rank_data_recomm_domain:' . count($list));
foreach ($list as $project_id => $domain) {
foreach ($list as $item) {
$project_id = $item['project_id'];
$api_no = $item['api_no'];
$domain = $item['domain'];
if(!$domain){
continue;
}
... ... @@ -53,9 +58,20 @@ class RecommDomain extends BaseCommands
$model = new RecommDomainModel();
}
//外链引荐域名
$domain = (new DomainInfo())->getDomain($domain);
$data = $semrushApi->backlinks_refdomains($domain);
//5.0
try {
$data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
$data = Arr::s2a($data)['list'];
}catch (\Exception $e){
$data = [];
}
if(!$data){
//外链引荐域名
$domain = (new DomainInfo())->getDomain($domain);
$data = $semrushApi->backlinks_refdomains($domain);
}
if (!$data) {
$error++;
continue;
... ...
... ... @@ -138,7 +138,7 @@ class HtmlCollect extends Command
}
$update_log = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('project_id', 'asc')->first();
$update_log = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('updated_at', 'asc')->first();
if (!$update_log) {
return false;
}
... ...
... ... @@ -292,7 +292,7 @@ class ProjectUpdate extends Command
'route' => $route
]);
$this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list);
CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
} else {
$id = $product['id'];
$model->edit([
... ... @@ -418,7 +418,7 @@ class ProjectUpdate extends Command
]);
$this->set_map($route, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);
CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $link_type, $language_list, $page_list);
CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
} else {
$id = $news['id'];
$model->edit([
... ... @@ -483,7 +483,7 @@ class ProjectUpdate extends Command
]);
$this->set_map($route, RouteMap::SOURCE_PAGE, $id, $project_id);
CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $link_type, $language_list, $page_list);
CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
} else {
$id = $custom['id'];
$model->edit([
... ... @@ -527,7 +527,7 @@ class ProjectUpdate extends Command
return $task_id;
}
$task_list = UpdateLog::where('status', UpdateLog::STATUS_UN)->orderBy('sort', 'asc')->orderBy('project_id', 'asc')->limit(20)->get();
$task_list = UpdateLog::where('status', UpdateLog::STATUS_UN)->orderBy('sort', 'asc')->orderBy('updated_at', 'asc')->limit(20)->get();
if ($task_list->count() == 0) {
return false;
}
... ... @@ -689,8 +689,6 @@ class ProjectUpdate extends Command
$host = $arr['host'] ?? '';
$path = $arr['path'] ?? '';
$url_complete = ($scheme ?: 'https') . '://' . $domain . $path;
if (
(empty($scheme) || $scheme == 'https' || $scheme == 'http')
&& (empty($host) || (strpos($web_url_domain, $host) !== false) || (strpos($home_url, $host) !== false))
... ... @@ -698,6 +696,10 @@ class ProjectUpdate extends Command
) {
$source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first();
if (!$source) {
if (empty($scheme) && empty($host) && substr($path, 0, 1) != '/') {
$path = '/' . $path;
}
$url_complete = ($scheme ?: 'https') . '://' . $domain . $path;
$new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete);
if ($new_url) {
... ... @@ -717,7 +719,7 @@ class ProjectUpdate extends Command
return getImageUrl($source['target']);
}
} else {
return $url_complete;
return ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path;
}
}
... ...
... ... @@ -12,6 +12,8 @@ namespace App\Console\Commands;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
... ... @@ -57,31 +59,85 @@ class UpdateMainHtml extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['type'=>['!=',0]]);
$list = $projectModel->list(['id'=>99]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->initModule($v['id']);
$this->editRoute();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
public function initModule($project_id){
$moduleModel = new CustomModule();
$info = $moduleModel->read(['route'=>'video']);
if($info === false){
$info = $moduleModel->read(['name'=>'视频模块']);
if($info === false){
$data = [
'name'=>'视频模块',
'project_id'=>$project_id,
'route'=>'video',
];
$moduleModel->add($data);
}
/**
* @remark :所有博客数据添加到自定义模块
* @name :setBlogCustom
* @author :lyh
* @method :post
* @time :2024/1/5 10:21
*/
public function setBlogCustom(){
$data = [];
$blogCategoryModel = new BlogCategory();
$list = $blogCategoryModel->list(['status'=>0]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . '博客分类id:'.$v['id'] . PHP_EOL;
$data[] = [
'name'=>$v['name'],
'route'=>$v['alias'],
'project_id'=>99,
'operator_id'=>366,
'seo_title'=>$v['seo_title'],
'seo_keywords'=>$v['seo_keywords'],
'seo_description'=>$v['seo_des'],
'created_at'=>$v['created_at'],
'updated_at'=>$v['updated_at'],
'module_id'=>7
];
}
$cate = new CustomModuleCategory();
$cate->insert($data);
}
/**
* @remark :所有博客数据添加到自定义模块
* @name :setBlogCustom
* @author :lyh
* @method :post
* @time :2024/1/5 10:21
*/
public function setBlogCustomContent(){
$data = [];
$blogModel = new Blog();
$list = $blogModel->list(['status'=>1]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . '博客分类id:'.$v['id'] . PHP_EOL;
$data[] = [
'name'=>$v['name'],
'content'=>$v['text'],
'remark'=>$v['remark'],
'route'=>$v['url'],
'image'=>$v['image'],
'project_id'=>99,
'operator_id'=>366,
'seo_title'=>$v['seo_title'],
'seo_keywords'=>$v['seo_keywords'],
'seo_description'=>$v['seo_description'],
'created_at'=>$v['created_at'],
'updated_at'=>$v['updated_at'],
'module_id'=>7,
'category_id'=>$v['category_id']
];
}
$content = new CustomModuleContent();
$content->insert($data);
return true;
}
public function editRoute(){
$routeMap = new RouteMap();
$routeMap->edit(['source'=>RouteMap::SOURCE_MODULE,'blog'=>''],['source'=>'blog']);
$routeMap->edit(['source'=>RouteMap::SOURCE_MODULE_CATE,'blog'=>''],['source'=>'blog_category']);
return true;
}
}
... ...
... ... @@ -10,11 +10,6 @@
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
... ... @@ -56,7 +51,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[475]]]);
$list = $projectModel->list(['id'=>475]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
... ... @@ -168,7 +163,7 @@ class UpdateRoute extends Command
*/
public function getProductCategory(){
$product = new Product();
$num = 35;
$num = 30;
while ($num > 0){
$list = $product->lists(['status'=>1],$num,1000);
foreach ($list['list'] as $k => $v){
... ... @@ -230,5 +225,4 @@ class UpdateRoute extends Command
return true;
}
}
... ...
... ... @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel
// $schedule->command('inspire')->hourly();
$schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
$schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
$schedule->command('rank_data')->dailyAt('07:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
$schedule->command('rank_data_speed')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
$schedule->command('rank_data_external_links')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
$schedule->command('rank_data_indexed_pages')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次
... ...
... ... @@ -103,7 +103,7 @@ class QuanqiusouApi
Cache::put($key, $res, 2 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('获取谷歌排名数据失败', $api_no, $e);
errorLog('获取谷歌排名数据失败', [$api_no], $e);
return false;
}
}
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/1/4
* Time: 16:25
*/
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
/**
* Class BaseController
* @package App\Http\Controllers\Api
*/
class BaseController extends Controller
{
/**
* @param array $data
* @param string $message
* @param int $status
* @return false|string
*/
protected function success($data = [], $message = 'success', $status = 200)
{
$array = compact('status', 'message', 'data');
return json_encode($array, JSON_UNESCAPED_UNICODE);
}
/**
* @param string $message
* @param int $status
* @param array $data
* @return false|string
*/
protected function error($message = 'error', $status = 400, $data = [])
{
$array = compact('status', 'message', 'data');
return json_encode($array, JSON_UNESCAPED_UNICODE);
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/01/04
* Time: 16:08
*/
namespace App\Http\Controllers\Api;
use App\Models\Visit\SyncSubmitTask;
use App\Models\Visit\Visit;
use Illuminate\Http\Request;
/**
* Class NoticeController
* @package App\Http\Controllers\Api
*/
class NoticeController extends BaseController
{
/**
* 网站引流
* FIXME 当前接口给内部引流用, 使用简易接口, 后期需要添加完整校验机制以及多数据接口
* @param Request $request
* @return false|string
*/
public function trafficVisit(Request $request)
{
$ip = $request->input('ip');
$url = $request->input('url');
$device_port = intval($request->input('device_port'));
$referrer_url = $request->input('referrer_url');
$user_agent = $request->input('user_agent');
// 数据占时不入库, 些日志分析数据
file_put_contents(storage_path('logs/trafficVisit.log'), var_export($request->all(), true) . PHP_EOL, FILE_APPEND);
// return $this->success([]);
if (empty($ip))
return $this->error('IP不能为空');
if (empty($url))
return $this->error('访问链接不能为空');
if (empty($user_agent))
return $this->error('请求头信息user_agent不能为空');
$url_array = parse_url($url);
$array = [
'ip' => $ip,
'domain' => $url_array['host'] ?? '',
'referer' => $referrer_url,
'user_agent' => $user_agent,
'data' => [
'url' => $url,
'domain' => empty($url_array['host']) ? '' : $url_array['scheme'] . '://' . $url_array['host'],
'device_port' => in_array($device_port, array_keys(Visit::deviceMap())) ? $device_port : Visit::DEVICE_PC,
'referrer_url' => $referrer_url
]
];
SyncSubmitTask::createTask($array, SyncSubmitTask::TYPE_VISIT);
return $this->success([]);
}
}
... ...
... ... @@ -12,6 +12,8 @@ namespace App\Http\Controllers\Aside\Com;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateOldInfo;
use App\Models\Domain\DomainInfo;
use App\Models\Project\ProjectUpdateTdk;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
... ... @@ -66,7 +68,7 @@ class UpdateController extends BaseController
$project = ProjectServer::useProject($this->param['project_id']);
if(!$project){
if (!$project) {
$this->fail('项目不存在');
}
... ... @@ -74,9 +76,26 @@ class UpdateController extends BaseController
$this->fail('非升级无法进行采集操作');
}
$test_domain = $this->param['test_domain'] ?? '';
if ($test_domain) {
$test_domain_arr = parse_url($test_domain);
$test_domain = $test_domain_arr['host'] ?? '';
}
//查看项目是否已上线
$domain_info = DomainInfo::where('project_id', $this->param['project_id'])->first();
if ($domain_info && !$test_domain) {
$this->fail('已上线项目需填写采集的测试站域名');
}
try {
DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
if ($domain_info) {
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = ''");
} else {
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
}
} catch (\Exception $e) {
errorLog('重新采集升级项目数据', $this->param, $e);
... ... @@ -87,9 +106,9 @@ class UpdateController extends BaseController
DB::disconnect('custom_mysql');
$update = ['collect_status' => 0];
// if ($this->param['type'] == 2) {
// $update['status'] = 0;
// }
if ($this->param['type'] == 2 && !$domain_info) {
$update['status'] = 0;
}
UpdateLog::where('project_id', $this->param['project_id'])->whereIn('api_type', ['post', 'page', 'news', 'blog'])->update($update);
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Aside\Optimize;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Optimize\OptimizeLogic;
use App\Http\Logic\Aside\Project\ProjectLogic;
... ... @@ -47,6 +48,7 @@ class OptimizeController extends BaseController
$data = $rankDataModel->read(['project_id'=>$v['id'],'lang'=>''],['first_page_num','indexed_pages_num']);
$v['first_page_num'] = $data['first_page_num'] ?? 0;
$v['indexed_pages_num'] = $data['indexed_pages_num'] ?? 0;
$v['g'] = $this->getGNum($v['id']);
$v = $this->handleParam($v);
$lists['list'][$k] = $v;
}
... ... @@ -55,6 +57,27 @@ class OptimizeController extends BaseController
}
/**
* @remark :统计数量
* @name :getGNum
* @author :lyh
* @method :post
* @time :2024/1/6 11:12
*/
public function getGNum($project_id){
$num = 0;
$list = RankData::where('project_id', $project_id)->where('lang', '')->value('data') ?: [];
if(!empty($list)){
foreach ($list as $v) {
$last = Arr::last($v);
if(isset($last['g']) && ($last['g'] == 1)){
$num = $num+1;
}
}
}
return $num;
}
/**
* @remark :参数处理
* @name :handleParam
* @author :lyh
... ...
... ... @@ -212,8 +212,8 @@ class ProofreadingController extends BaseController
$data[] = $trimmedString;
}
$data = array_values($data);
$uniqueArray = array_unique($data);
$data = array_values($uniqueArray);
// $uniqueArray = array_unique($data);
// $data = array_values($uniqueArray);
return $data;
}
... ...
... ... @@ -85,7 +85,6 @@ class FileController
'file.required'=>'必须填写',
]);
$files = $this->request->file('file');
if (empty($files)) {
$this->response('没有上传的文件!');
}
... ... @@ -306,6 +305,7 @@ class FileController
public function setUrl(){
//A端上传
if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('进入222', true) . PHP_EOL, FILE_APPEND);
$this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
}else{
//B端上传,upload_method 为 1时 强制上传到本地
... ...
... ... @@ -264,12 +264,36 @@ class InitHtmlLogic extends BaseLogic
if($info === false){
$html = '';
}else{
$type = $this->getCustomizedType($this->param['type'],$is_list);
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type]);
if($commonInfo !== false){
$info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);
}
$html = $info['main_html'];
}
//更新头部底部
return $this->success(['html'=>$html]);
}
/**
* @remark :返回整个html截取代码
* @name :handleAllHtml
* @author :lyh
* @method :post
* @time :2023/12/13 15:39
*/
public function handleAllHtml($commonInfo,$html){
if(!empty($commonInfo)){
$html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
$html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
}
return $html;
}
/**
* @remark :保存定制html
* @name :saveHtml
* @author :lyh
... ... @@ -292,6 +316,8 @@ class InitHtmlLogic extends BaseLogic
}else{
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
}
//更新头部底部
$this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list);
}catch (\Exception $exception){
$this->fail('保存失败,请联系开发人员');
}
... ... @@ -299,6 +325,68 @@ class InitHtmlLogic extends BaseLogic
}
/**
* @remark :定制代码更新头部信息
* @name :saveCustomizeCommon
* @author :lyh
* @method :post
* @time :2024/1/6 10:29
*/
public function saveCustomizeCommon($html,$source,$is_list){
$type = $this->getCustomizedType($source,$is_list);
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],
];
$templateCommonModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
return $this->success();
}
/**
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
*/
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 :getInitModuleMain
* @author :lyh
... ...
... ... @@ -371,7 +371,7 @@ class RankDataLogic extends BaseLogic
if (!$model || $model->updated_date != date('Y-m-d') || $force) {
$res = $api->getGoogleRank($api_no, 0, 7, $force);
if (!$res) {
throw new \Exception('接口数据获取失败');
throw new \Exception("接口数据获取失败,api_no:{$api_no}");
}
//收录数
$indexed_pages_num = $site_res[$api_no] ?? 0;
... ... @@ -384,7 +384,7 @@ class RankDataLogic extends BaseLogic
if (!$model || $model->updated_date != date('Y-m-d') || $force) {
$res = $api->getGoogleRank($api_no, 1, 7, $force);
if (!$res) {
throw new \Exception('接口数据获取失败');
throw new \Exception("接口数据获取失败,api_no:{$api_no},lang");
}
$data = [];
//不同的小语种取出来
... ...
... ... @@ -17,7 +17,7 @@ class CollectTask extends Base
const STATUS_COM = 2;
const STATUS_FAIL = 3;
public static function _insert($url, $project_id, $source, $source_id, $link_type = 0, $language_list = [], $page_list = [])
public static function _insert($url, $project_id, $source, $source_id, $domain, $link_type = 0, $language_list = [], $page_list = [])
{
if (!$url) {
return;
... ... @@ -36,19 +36,19 @@ class CollectTask extends Base
$data = [];
$now = date('Y-m-d H:i:s');
if (!$task) {
$data[] = [
$data[] = [
'project_id' => $project_id,
'source' => $source,
'source_id' => $source_id,
'domain' => $url_arr['host'],
'route' => $url_arr['path'],
'domain' => $url_arr['host'] ?? $domain,
'route' => substr($url_arr['path'], 0, 1) == '/' ? $url_arr['path'] : '/' . $url_arr['path'],
'language' => '',
'created_at' => $now,
'updated_at' => $now,
];
if ($link_type > 0 && $language_list && in_array($url_arr['path'], $page_list)) {
$domain_arr = explode('.', $url_arr['host']);
$domain_arr = explode('.', $url_arr['host'] ?? $domain);
foreach ($language_list as $v_lan) {
if ($link_type == 1) {
//二级域名
... ... @@ -56,7 +56,7 @@ class CollectTask extends Base
$new_domain = implode('.', $domain_arr);
} else {
//二级目录
$new_domain = $url_arr['host'] . '/' . $v_lan;
$new_domain = $url_arr['host'] ?? $domain . '/' . $v_lan;
}
$data[] = [
... ...
... ... @@ -7,7 +7,70 @@ use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\Product\Product
*
* @method static get()
* @property int $id
* @property int $project_id
* @property string $title
* @property string $thumb 封面
* @property mixed|null $gallery 图集
* @property mixed|null $attrs 属性参数
* @property string|null $attr_id 通用参数
* @property string|null $category_id 分类 多个,号隔开
* @property string|null $keyword_id 关键词标签 多个,号隔开
* @property string|null $intro 简介
* @property string|null $content 详情
* @property mixed|null $describe 描述
* @property string $describe_id 通用描述
* @property mixed|null $seo_mate seo tdk
* @property string $related_product_id 相关产品 多个,号隔开
* @property int $sort 排序
* @property int $status 状态 0草稿 1已上架 2已下架
* @property int $created_uid 创建者
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property string|null $route 路由
* @property mixed|null $icon 图标
* @property string|null $product_type 产品类型:1,一般产品;2:推荐产品(recommend);3:热销产品(hot)
* @property int $is_upgrade 0:6.0 1:4.0,5.0升级
* @property string|null $send_time 发布时间
* @property int|null $six_read 1:导入数据可按6.0显示
* @method \Illuminate\Database\Eloquent\Builder|Product newModelQuery()
* @method \Illuminate\Database\Eloquent\Builder|Product newQuery()
* @method \Illuminate\Database\Eloquent\Builder|Product onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Product query()
* @method \Illuminate\Database\Eloquent\Builder|Product whereAttrId($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereAttrs($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereCategoryId($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereContent($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereCreatedAt($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereCreatedUid($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereDeletedAt($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereDescribe($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereDescribeId($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereGallery($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereIcon($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereId($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereIntro($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereIsUpgrade($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereKeywordId($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereProductType($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereProjectId($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereRelatedProductId($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereRoute($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereSendTime($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereSeoMate($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereSixRead($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereSort($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereStatus($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereThumb($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereTitle($value)
* @method \Illuminate\Database\Eloquent\Builder|Product whereUpdatedAt($value)
* @method \Illuminate\Database\Eloquent\Builder|Product withTrashed()
* @method \Illuminate\Database\Eloquent\Builder|Product withoutTrashed()
* @mixin \Eloquent
*/
class Product extends Base
{
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/1/5
* Time: 14:16
*/
namespace App\Models\Visit;
use App\Models\Base;
/**
* Class SyncSubmitTask
* @package App\Models\Visit
*/
class SyncSubmitTask extends Base
{
/**
* 表名
* @var string
*/
protected $table = 'gl_sync_submit_task';
const TYPE_INQUIRY = 'inquiry';
const TYPE_VISIT = 'visit';
/**
* @param $data
* @param string $type
* @return mixed
*/
public static function createTask($data, $type = self::TYPE_VISIT)
{
$task = new self();
$task->data = json_encode($data);
$task->type = $type;
$task->save();
return $task->id;
}
}
\ No newline at end of file
... ...
... ... @@ -20,10 +20,13 @@ class Visit extends Base
protected $connection = 'custom_mysql';
protected $appends = ['device_text'];
const DEVICE_PC = 1;
const DEVICE_MOBILE = 2;
public static function deviceMap(){
return [
1 => 'PC',
2 => '移动端'
self::DEVICE_PC => 'PC',
self::DEVICE_MOBILE => '移动端'
];
}
... ...
... ... @@ -105,7 +105,7 @@ class ProjectServer
$created_at = date('Y-m-d H:i:s');
self::initGroup($project_id,$created_at);
//初始化单页
self::init404Page($project_id);
self::init404Page($project_id,$created_at);
//初始化模块数据
self::initModule($project_id);
DB::disconnect('custom_mysql');
... ... @@ -172,7 +172,7 @@ class ProjectServer
* @method :post
* @time :2023/12/29 9:32
*/
public function init404Page($project_id){
public function init404Page($project_id,$created_at){
$info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();
if(empty($info)) {
$main_404_html = '<main>
... ... @@ -208,7 +208,10 @@ class ProjectServer
'status' => 1,
'url' => BCustomTemplate::NOT_FOUND_PAGE_URL,
'html' => $main_404_html,
'html_style' => '<style id="globalsojs-styles"></style>','title' => '404-Page not found', 'description' => 'Sorry. The page has either moved or cannot be found.', 'created_at' => $created_at, 'updated_at' => $created_at];
'html_style' => '<style id="globalsojs-styles"></style>',
'title' => '404-Page not found',
'description' => 'Sorry. The page has either moved or cannot be found.',
'created_at' => $created_at, 'updated_at' => $created_at];
$id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data);
//路由
$info = DB::connection('custom_mysql')->table('gl_route_map')->first();
... ...
... ... @@ -17,3 +17,5 @@ use Illuminate\Support\Facades\Route;
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit');
\ No newline at end of file
... ...
... ... @@ -357,7 +357,7 @@ Route::middleware(['aloginauth'])->group(function () {
//无需登录验证的路由组
Route::group([], function () {
Route::any('/login', [Aside\LoginController::class, 'login'])->name('admin.login.white');
Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class, 'index'])->name('admin.image_show');
// Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class, 'index'])->name('admin.image_show');
Route::any('/file/{hash}', [\App\Http\Controllers\File\FileController::class, 'index'])->name('admin.file_show');
Route::any('/download_files', [\App\Http\Controllers\File\FileController::class, 'downLoad'])->name('admin.files_downLoad');//导出文件
Route::any('/download_images', [\App\Http\Controllers\File\ImageController::class, 'downLoad'])->name('admin.images_downLoad');//导出图片
... ...