作者 zhl

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

... ... @@ -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>
... ...
... ... @@ -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;
}
}
... ...
... ... @@ -9,11 +9,8 @@
namespace App\Console\Commands;
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\Helper\Arr;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\Project;
... ... @@ -54,13 +51,14 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[627]]]);
$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']);
// $this->getProduct();
// $this->setProductKeyword();
$this->getRouteMap();
// $this->getRouteMap();
$this->getProductCategory();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ... @@ -157,6 +155,62 @@ class UpdateRoute extends Command
}
/**
* @remark :更新产品关联表
* @name :getProductCategory
* @author :lyh
* @method :post
* @time :2024/1/4 14:48
*/
public function getProductCategory(){
$product = new Product();
$num = 30;
while ($num > 0){
$list = $product->lists(['status'=>1],$num,1000);
foreach ($list['list'] as $k => $v){
if(empty($v['category_id'])){
continue;
}
$category_ids = $v['category_id'];
//产品分类关联
echo date('Y-m-d H:i:s') . '产品id--1:'.$v['id'] . PHP_EOL;
$this->saveRelated($v['id'], $category_ids);
echo date('Y-m-d H:i:s') . '产品id:'.$v['id'] . PHP_EOL;
}
$num--;
}
}
/**
* 关联产品分类
* @param $product_id
* @param $cate_ids
* @author zbj
* @date 2023/4/21
*/
public function saveRelated($product_id, $cate_ids)
{
if(!is_array($cate_ids)){
$cate_ids = array_filter(Arr::splitFilterToArray($cate_ids), 'intval');
}
//先删除
CategoryRelated::where('product_id', $product_id)->delete();
//批量保存
$data = [];
if(!empty($cate_ids)){
foreach ($cate_ids as $cate_id){
$data[] = [
'product_id' => $product_id,
'cate_id' => $cate_id,
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
];
}
CategoryRelated::insert($data);
}
return true;
}
/**
* @remark :删除路由通知C端
* @name :curlDelRoute
* @author :lyh
... ... @@ -171,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); // 排名数据-页面收录,每周一凌晨执行一次
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Aside\Com;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Com\UpdateLog;
use App\Models\Domain\DomainInfo;
use App\Models\Project\ProjectUpdateTdk;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
... ... @@ -66,7 +67,7 @@ class UpdateController extends BaseController
$project = ProjectServer::useProject($this->param['project_id']);
if(!$project){
if (!$project) {
$this->fail('项目不存在');
}
... ... @@ -86,10 +87,13 @@ class UpdateController extends BaseController
//关闭数据库
DB::disconnect('custom_mysql');
//查看项目是否已上线
$domain_info = DomainInfo::where('project_id', $this->param['project_id'])->first();
$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);
... ...
... ... @@ -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时 强制上传到本地
... ...
... ... @@ -173,6 +173,7 @@ class BaseLogic extends Logic
$data['project_id'] = $this->user['project_id'];
$str = http_build_query($data);
$url = $this->user['domain'].'api/delHtml/?'.$str;
// shell_exec($url);
curlGet($url);
return $this->success();
}
... ...
... ... @@ -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
{
... ...