作者 赵彬吉
... ... @@ -71,30 +71,32 @@ class RemainDay extends Command
if($item['type'] != Project::TYPE_THREE){
$item->pause_days = $item->pause_days + 1;
}
}
if(in_array($item->id,$this->projectId)){//已开始优化的时间结算
$optimizeModel = new DeployOptimize();
$opInfo = $optimizeModel->read(['project_id'=>$item->id],['start_date']);
if($opInfo === false){
continue;
}
$diff = time() - strtotime($opInfo['start_date'] ?? $item->uptime);
$remain_day = $item['deploy_build']['service_duration'] - floor($diff / (60 * 60 * 24));
}else{
if($item['type'] == Project::TYPE_TWO){
$compliance_day = ($item->finish_remain_day ?? 0);
$remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
if(in_array($item->id,$this->projectId)){//已开始优化的时间结算
$optimizeModel = new DeployOptimize();
$opInfo = $optimizeModel->read(['project_id'=>$item->id],['start_date']);
if($opInfo === false){
continue;
}
$diff = time() - strtotime($opInfo['start_date'] ?? $item->uptime);
$remain_day = $item['deploy_build']['service_duration'] - floor($diff / (60 * 60 * 24));
}else{
if($item->uptime){
$diff = time() - strtotime($item->uptime);
$item->finish_remain_day = floor($diff / (60 * 60 * 24));
$remain_day = $item['deploy_build']['service_duration'] - floor($diff / (60 * 60 * 24));
if($item['type'] == Project::TYPE_TWO){
$compliance_day = ($item->finish_remain_day ?? 0);
$remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
}else{
$remain_day = $item['deploy_build']['service_duration'];
if($item->uptime){
$diff = time() - strtotime($item->uptime);
$item->finish_remain_day = floor($diff / (60 * 60 * 24));
$remain_day = $item['deploy_build']['service_duration'] - floor($diff / (60 * 60 * 24));
}else{
$remain_day = $item['deploy_build']['service_duration'];
}
}
}
$item->remain_day = ($remain_day > 0 ? $remain_day : 0);
}
$item->remain_day = ($remain_day > 0 ? $remain_day : 0);
$item->save();
// if($item->remain_day == 0){
// $item->extend_type = Project::TYPE_FIVE;
// $item->site_status = Project::TYPE_ONE;//关闭站点
... ... @@ -105,7 +107,6 @@ class RemainDay extends Command
// curl_get('https://'.$domainInfos['domain'].'/api/stop_or_start_website/');
// }
// }
$item->save();
}
}
}
... ...
... ... @@ -34,15 +34,13 @@ class CountAllProject extends Command
public function handle(){
$countAllModel = new AllProject;
AllProject::truncate();
// $noSixData = [];
$noSixData = $this->NoSixProject();
$countAllModel->insert($noSixData);
$sixData = $this->sixProject();
$countAllModel->insert($sixData);
$data = array_merge($noSixData ?? [],$sixData ?? []);
echo 'success:' .count($data) . PHP_EOL . date('Y-m-d H:i:s');
$noSixCount = $this->NoSixProject();
echo 'success:' .$noSixCount . PHP_EOL . date('Y-m-d H:i:s');
$sixCount = $this->sixProject();
echo 'success:' .$sixCount . PHP_EOL . date('Y-m-d H:i:s');
$data = $noSixCount + $sixCount;
echo 'success:' .$data . PHP_EOL . date('Y-m-d H:i:s');
return true;
}
... ... @@ -54,16 +52,16 @@ class CountAllProject extends Command
* @time :2024/11/11 15:21
*/
public function NoSixProject(){
$res_data = [];
$count = 0;
$i = 1;
while (true) {
$url = 'https://quanqiusou.cn/extend_api/api/projects.php?page=' . $i . '&pagesize=50';
$url = 'https://quanqiusou.cn/extend_api/api/projects.php?page=' . $i . '&pagesize=500';
$result = $this->httpGetProxy($url);
// 检查结果是否成功,并且结构符合预期
if (isset($result['data']['data']) && is_array($result['data']['data'])) {
$data = $result['data']['data'];
// 如果当前页没有数据,跳出循环
if ($i == 2) {
if (empty($data)) {
break;
}
foreach ($data as $k => $v){
... ... @@ -81,7 +79,9 @@ class CountAllProject extends Command
$data[$k] = $v;
}
echo '执行页数:' . $i . PHP_EOL . date('Y-m-d H:i:s') . PHP_EOL;
$res_data = array_merge($res_data, $data);
$count = $count + count($data);
$countAllModel = new AllProject;
$countAllModel->insert($data);
$i++;
// 每次请求后增加 1 秒延迟,防止请求过于频繁
sleep(1);
... ... @@ -91,7 +91,7 @@ class CountAllProject extends Command
break;
}
}
return $res_data;
return $count;
}
public function httpGetProxy($url){
... ... @@ -115,6 +115,7 @@ class CountAllProject extends Command
}
public function sixProject(){
$count = 0;
$projectModel = new Project();
$manageModel = new ManageHr();
$i = 1;
... ... @@ -127,6 +128,7 @@ class CountAllProject extends Command
if(empty($lists) || empty($lists['list'])){
break;
}
$data = [];
echo '执行页数:' . $i . PHP_EOL . date('Y-m-d H:i:s') . PHP_EOL;
foreach ($lists['list'] as $k => $v){
$data[] = [
... ... @@ -157,9 +159,13 @@ class CountAllProject extends Command
'updated_at'=>date('Y-m-d H:i:s'),
];
}
$count = $count + count($data);
$countAllModel = new AllProject;
$countAllModel->insert($data);
sleep(1);
$i++;
}
return $data;
return $count;
}
/**
... ...
... ... @@ -57,12 +57,13 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['=',475]]);
$list = $projectModel->list(['id'=>['=',2503]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->updateProduct();
$this->getProduct();
// $this->updateProduct();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ...
... ... @@ -9,7 +9,9 @@ namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Http\Logic\Bside\User\UserLoginLogic;
use App\Models\Blog\Blog;
use App\Models\Domain\DomainInfo;
use App\Models\News\News;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
... ... @@ -283,4 +285,54 @@ class PrivateController extends BaseController
}
return $this->success($projects);
}
/**
* 获取有效时间内 新增有效URL
* 用于自动提交Google收录
* @param Request $request
* @return false|string
*/
public function projectNewUrl(Request $request)
{
$domain = trim($request->input('domain'));
$domain_parse = parse_url($domain);
$domain = $domain_parse['host'] ?? $domain;
$date = trim($request->input('date'));
if (empty($domain) || empty($date)) {
return $this->error('非法参数!');
}
$project = Project::getProjectByDomain($domain);
if (empty($project)) {
return $this->error('未找到当前域名对应的项目!');
}
ProjectServer::useProject($project->id);
$result = [];
// 查询有效时间后 有效的产品、新闻、博客、聚合页 链接
$product = Product::where(['status' => Product::STATUS_ON])->where('created_at', '>=', $date)->pluck('route');
$news = News::where(['status' => News::STATUS_ONE])->where('release_at', '>', $date)->pluck('url');
$blog = Blog::where(['status' => Blog::STATUS_ONE])->where('release_at', '>', $date)->pluck('url');
$keyword = Keyword::where('created_at', '>', $date)->pluck('route');
// 组装链接
foreach ($product as $item) {
$url = 'https://' . $domain . '/' . $item;
array_push($result, $url);
}
foreach ($keyword as $item) {
$url = 'https://' . $domain . '/' . $item;
array_push($result, $url);
}
foreach ($news as $item) {
$url = 'https://' . $domain . '/news/' . $item;
array_push($result, $url);
}
foreach ($blog as $item) {
$url = 'https://' . $domain . '/blogs/' . $item;
array_push($result, $url);
}
return $this->success($result);
}
}
... ...
<?php
/**
* @remark :
* @name :AllProjectController.php
* @author :lyh
* @method :post
* @time :2024/11/12 9:34
*/
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Project\CountAllProject;
/**
* @remark :统计所有项目(4.0,5.0,6.0)
* @name :AllProjectController
* @author :lyh
* @method :post
* @time :2024/11/12 9:34
*/
class AllProjectController extends BaseController
{
/**
* @remark :统计所有项目列表
* @name :lists
* @author :lyh
* @method :post
* @time :2024/11/12 9:35
*/
public function lists(CountAllProject $allProject){
$data = $allProject->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
<?php
/**
* @remark :
* @name :DetailController.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:55
*/
namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\DetailLogic;
use App\Models\Product\Column;
use App\Models\Product\Detail;
class DetailController extends BaseController
{
/**
* @remark :获取产品描述页所有详情
* @name :getType
* @author :lyh
* @method :post
* @time :2024/11/12 14:57
*/
public function getType(Detail $detail){
$data = [
'text_type' => $detail->text_type(),
'line_two_type' => $detail->line_two_type(),
'image_two_type' => $detail->image_two_type(),
'three_type' => $detail->three_type(),
'image_three_type' => $detail->image_three_type(),
];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取产品描述栏目
* @name :getColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:07
*/
public function getColumn(Column $column){
$data = $column->list($this->map,'id',['*'],'asc');
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存切换栏
* @name :saveColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:13
*/
public function saveColumn(DetailLogic $logic){
$this->request->validate([
'column_name'=>'required'
],[
'column_name.required' => '栏目名称不能为空'
]);
$data = $logic->saveColumn();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :saveDetail
* @author :lyh
* @method :post
* @time :2024/11/12 16:24
*/
public function saveDetail(){
$this->request->validate([
'product_id'=>'required',
'data'=>'required',
],[
'product_id.required' => '产品id不能为空',
'data.required' => 'data不能为空',
]);
}
}
... ...
... ... @@ -160,6 +160,9 @@ class FileController
$suffix = array_pop($nameArr) ?? 'jpg';
$nameStr = implode('-', $nameArr);
$enName = generateRoute(Translate::tran($nameStr, 'en'));
if(substr($enName, 0, 1) === '-'){
$enName = md5(uniqid().$project_id.rand(1,1000));
}
$fileName = $enName;
$i=1;
while($this->onlyName($enName.'.'.$suffix,$project_id)){
... ...
... ... @@ -229,9 +229,13 @@ class ImageController extends Controller
$nameArr = explode('.',$name);
$suffix = array_pop($nameArr) ?? 'jpg';
$nameStr = implode('-', $nameArr);
$enName = generateRoute(Translate::tran($nameStr, 'en'));
$tran_name = Translate::tran($nameStr, 'en');
if(is_array($tran_name)){
$tran_name = $tran_name[0];
}
$enName = generateRoute($tran_name);
if(substr($enName, 0, 1) === '-'){
$enName = $nameStr;
$enName = md5(uniqid().$project_id.rand(1,1000));;
}
$fileName = $enName;
$i=1;
... ...
<?php
/**
* @remark :
* @name :DetailLogic.php
* @author :lyh
* @method :post
* @time :2024/11/12 15:14
*/
namespace App\Http\Logic\Bside\Product;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Column;
use App\Models\Product\Detail;
class DetailLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new Detail();
}
/**
* @remark :保存栏目
* @name :saveColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:15
*/
public function saveColumn(){
$columnModel = new Column();
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$rs = $columnModel->edit(['column_name'=>$this->param['column_name']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('保存失败,请联系管理员');
}
}else{
$id = $columnModel->add($this->param);
}
return $this->success(['id'=>$id]);
}
public function saveDetail(){
foreach ($this->param['data'] as $k => $data){
$i = 1;
$save_data = [];
foreach ($data as $key => $v){
$save_data[] = [
'sort'=>$i,
'column_id'=>$v['column_id'],
'product_id'=>$this->param['product_id'],
'title'=>$v['title'] ?? '',
'content'=>json_encode($v['content'] ?? []),
'css'=>json_encode($v['css'] ?? []),
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s')
];
$i++;
}
$this->model->insert($save_data);
}
}
}
... ...
... ... @@ -560,7 +560,7 @@ class ProductLogic extends BaseLogic
'related_product_id'=>Arr::arrToSet($info['related_product_id']),
'sort'=>$info['sort'],
'status'=>0,
'route'=>$info['route'],
'route'=>$info['title'],
'product_type'=>$info['product_type'],
'created_uid'=>$this->user['id'],
'created_at'=>date('Y-m-d H:i:s'),
... ...
... ... @@ -277,6 +277,7 @@ class UserLoginLogic
$info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0;
$info['is_comment'] = $project['deploy_build']['is_comment'] ?? 0;
$info['remain_day'] = $project['remain_day'] ?? 0;
$info['type'] = $project['type'] ?? 1;
if($info['is_customized'] == 1){
$info['is_visualization'] = json_decode($project['is_visualization']);
}
... ...
... ... @@ -20,7 +20,6 @@ class Blog extends Base
if(!$value){
return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
}
return $value;
}
}
... ...
<?php
/**
* @remark :
* @name :Column.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:14
*/
namespace App\Models\Product;
use App\Models\Base;
class Column extends Base
{
//设置关联表名
protected $table = 'gl_product_column';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :Detail.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:13
*/
namespace App\Models\Product;
use App\Models\Base;
class Detail extends Base
{
//设置关联表名
protected $table = 'gl_product_detail';
//连接数据库
protected $connection = 'custom_mysql';
/**
* @remark :文本框类型
* @name :text_box
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function text_type(){
return [
1=>'富文本框',
2=>'多图模块',
3=>'单图文案',
];
}
/**
* @remark :多图框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function line_two_type(){
return [
1=>'1行',
2=>'2行',
3=>'3行',
4=>'4行',
5=>'5行',
];
}
/**
* @remark :图片框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function image_two_type(){
return [
1=>'1张图',
2=>'2张图',
3=>'3张图',
4=>'4张图',
5=>'5张图',
];
}
/**
* @remark :图片文本框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function three_type(){
return [
1=>'左图右文',
2=>'右图左文',
];
}
/**
* @remark :图片文本框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function image_three_type(){
return [
1=>'图片悬浮',
2=>'图片固定',
];
}
}
... ...
... ... @@ -136,6 +136,8 @@ class ProjectServer
self::init404Page($project_id);
//初始化模块数据
self::initModule($project_id);
//初始化切换栏
self::initColumn();
//初始化search页面
// self::initSearchPage($project_id);
DB::disconnect('custom_mysql');
... ... @@ -163,6 +165,27 @@ class ProjectServer
}
return true;
}
/**
* @remark :初始化产品切换栏
* @name :initColumn
* @author :lyh
* @method :post
* @time :2024/11/12 11:39
*/
public static function initColumn(){
$info = DB::connection('custom_mysql')->table('gl_product_column')->first();
if(empty($info)){
$data = [
'column_name'=>'Product Details',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
];
DB::connection('custom_mysql')->table('gl_product_column')->insert($data);
}
return true;
}
/**
* @remark :菜单
* @name :initGroup
... ...
... ... @@ -39,6 +39,9 @@ Route::any('valid_user', [\App\Http\Controllers\Api\PrivateController::class, 'v
Route::any('getAutoToken', [\App\Http\Controllers\Api\PrivateController::class, 'getAutoToken'])->name('api.getAutoToken');
// 特殊项目 有效产品路由
Route::any('valid_product_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProductRoute'])->name('api.valid_product_route');
// 6.0项目新增有效链接 - 提交Google
Route::any('project_new_url', [\App\Http\Controllers\Api\PrivateController::class, 'projectNewUrl'])->name('api.project_new_url');
// --------------------- 站群服务 ------------------------------------------
// 获取项目信息
... ...
... ... @@ -493,6 +493,11 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/fb_relay_detail_list', [Aside\Task\AdsController::class, 'fbRelayDetail'])->name('admin.fb_ads_relay_detail_list');
Route::any('/fb_relay_count', [Aside\Task\AdsController::class, 'fbRelayCount'])->name('admin.fb_relay_count');
});
//统计所有项目相关
Route::prefix('all_project')->group(function () {
Route::any('/', [Aside\Project\AllProjectController::class, 'lists'])->name('admin.all_project_lists');
});
});
//无需登录验证的路由组
... ...