作者 刘锟

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

... ... @@ -2,12 +2,15 @@
namespace App\Console\Commands\RankData;
use App\Helper\QuanqiusouApi;
use App\Http\Logic\Bside\RankData\RankDataLogic;
use App\Models\Domain\DomainInfo;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Utils\LogUtils;
use Illuminate\Database\Eloquent\Model;
/**
* Class GoogleRank
... ... @@ -38,6 +41,9 @@ class RankData extends BaseCommands
*/
public function do()
{
//同步api_no
$this->SyncApiNo();
//所有项目 今日是否达标 重置
Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]);
... ... @@ -62,4 +68,35 @@ class RankData extends BaseCommands
}
return !$error;
}
/**
* 同步项目api_no
* @author zbj
* @date 2023/10/16
*/
public function SyncApiNo(){
$deploy_optimizes = DeployOptimize::leftJoin('gl_project', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->whereIn('gl_project.type', [Project::TYPE_TWO,Project::TYPE_THREE])->where('gl_project_deploy_optimize.api_no', 0)
->where('gl_project_deploy_optimize.domain', '>', 0)
->get();
if(!$deploy_optimizes){
return true;
}
$api = new QuanqiusouApi();
$ai_nos = $api->getWebApiNo();
foreach ($deploy_optimizes as $deploy_optimize){
$domain = DomainInfo::where('id', $deploy_optimize['domain'])->value('domain');
if(!$domain){
continue;
}
$api_no = array_search($domain, $ai_nos);
if($api_no){
$deploy_optimize->api_no = $api_no;
$deploy_optimize->save();
}
}
}
}
... ...
... ... @@ -205,7 +205,7 @@ class SyncProject extends Command
'login_mobile'=>$param['principal_mobile']
],
'deploy_optimize' => [
'api_no' => $param['id']
'api_no' => 0
],
'project_after' => [],
'payment' => [
... ...
... ... @@ -231,5 +231,33 @@ class QuanqiusouApi
return $res;
}
/**
* 项目api_no对应关系
* @return array|false|int|mixed|null
* @author zbj
* @date 2023/10/16
*/
public function getWebApiNo(){
$key = "quanqiusou_web_api_no_" . date('Y-m-d');
$res = Cache::get($key);
if (!$res) {
$api_url = $this->url . '/api/index/weblist';
$param = [
'key' => '289c1fc81c89d79c04ed4fd72822948e',
];
try {
$res = HttpUtils::get($api_url, $param);
if($res){
$res = Arr::s2a($res);
Cache::put($key, $res, 24 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('获取项目API_NO数据失败', [], $e);
return false;
}
}
return $res;
}
}
... ...
... ... @@ -156,6 +156,8 @@ class ProjectController extends BaseController
if ($this->map['search_type'] == 'domain') {
$ids = DomainInfo::where('domain', 'like', '%'.$this->map['search'].'%')->pluck('id')->toArray();
$subQuery->whereIn('gl_project_deploy_optimize.domain', $ids);
} else if($this->map['search_type'] == 'test_domain'){
$subQuery->where('gl_project_deploy_build.test_domain','like','%'.$this->map['search'].'%');
} else {
// 搜索名称
$subQuery->orwhere('gl_project.company','like','%'.$this->map['search'].'%')
... ...
... ... @@ -2,10 +2,12 @@
namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\DescribeLogic;
use App\Http\Requests\Bside\Product\DescribeRequest;
use App\Models\Product\Describe;
use App\Rules\Ids;
use Illuminate\Http\Request;
... ... @@ -18,15 +20,14 @@ use Illuminate\Http\Request;
class DescribeController extends BaseController
{
public function index(DescribeLogic $logic)
public function index(Describe $describe)
{
$map = [];
if(!empty($this->param['search'])){
$map[] = ['title', 'like', "%{$this->param['search']}%"];
if(!empty($this->map['search'])){
$this->map['title'] = ['like',"%{$this->param['search']}%"];
unset($this->map['search']);
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'title', 'text', 'status', 'created_at'],$this->row);
return $this->success($data);
$data = $describe->lists($this->map,$this->page,$this->row, 'id', ['id', 'title', 'text', 'status', 'created_at']);
$this->response('success',Code::SUCCESS,$data);
}
public function info(Request $request, DescribeLogic $logic){
... ... @@ -39,10 +40,18 @@ class DescribeController extends BaseController
return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'text', 'created_at']));
}
public function save(DescribeRequest $request, DescribeLogic $logic)
/**
* @remark :baocun
* @name :save
* @author :lyh
* @method :post
* @time :2023/10/17 10:36
*/
public function save(DescribeRequest $request,DescribeLogic $logic)
{
$data = $logic->save($this->param);
return $this->success($data);
$request->validated();
$logic->describeSave();
return $this->success();
}
public function delete(Request $request, DescribeLogic $logic)
... ...
... ... @@ -260,7 +260,7 @@ class ImageController extends Controller
foreach ($files as $file) {
$imageModel = new ImageModel();
$hash = hash_file('md5', $file->getPathname());
$name = $files->getClientOriginalName();
$name = $file->getClientOriginalName();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
... ...
... ... @@ -139,7 +139,7 @@ class BTemplateLogic extends BaseLogic
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo !== false){
$html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$this->getProductModule().$commonInfo['footer_html'];
$commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html'];
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
... ...
... ... @@ -64,6 +64,9 @@ class CustomTemplateLogic extends BaseLogic
$id = $this->editCustomRoute($this->param['id'],$this->param['url']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
$this->fail('404页面已存在');
}
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
}
... ... @@ -84,6 +87,7 @@ class CustomTemplateLogic extends BaseLogic
*/
public function saveHtml(){
$html = $this->param['html'];
$this->saveCommonTemplate($html);
$this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
... ... @@ -98,6 +102,38 @@ class CustomTemplateLogic extends BaseLogic
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($html){
//获取设置的默认模版
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先设置模版');
}
//查看当前
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$settingInfo['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo === false){
$this->fail('请先装修首页');
}
$data = [
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
return $this->success();
}
/**
* @remark :查看路由是否更新
* @name :editProduct
* @author :lyh
... ... @@ -106,6 +142,9 @@ class CustomTemplateLogic extends BaseLogic
*/
public function editCustomRoute($id,$route){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['url'] == $this->model::NOT_FOUND_PAGE_URL && $route['url'] != '404'){
$this->fail('404页面链接不可修改');
}
if($info['url'] != $route){
//生成一条删除路由记录
$data = [
... ... @@ -129,6 +168,9 @@ class CustomTemplateLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或者已被删除');
}
if($info['url'] == $this->model::NOT_FOUND_PAGE_URL){
$this->fail('404页面不可删除');
}
try {
if($info['status'] != 2){
$this->model->edit(['status'=>2],['id'=>$this->param['id']]);
... ... @@ -170,10 +212,17 @@ class CustomTemplateLogic extends BaseLogic
* @method :post
* @time :2023/7/21 18:08
*/
public function getBodyHeaderFooter($preg_html = "<main></main>",$html_style = "<style id='globalsojs-styles'></style>"){
public function getBodyHeaderFooter($preg_html,$html_style){
if(empty($preg_html)){
$preg_html = "<main></main>";
$html_style = "<style id='globalsojs-styles'></style>";
}
//获取设置的默认模版
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先设置模版');
}
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
... ...
... ... @@ -122,11 +122,11 @@ class CategoryLogic extends BaseLogic
if($param['pid'] == $param['id']){
$this->fail('上级分类不能是本分类');
}
$info = $this->model->read(['id'=>$param['id']]);
$sub_info = $this->model->read(['pid'=>$param['id']]);
if(($info['pid'] != $param['pid']) && ($sub_info != false)){
$this->fail('当前分类拥有子分类,不允许修改上级分类');
}
// $info = $this->model->read(['id'=>$param['id']]);
// $sub_info = $this->model->read(['pid'=>$param['id']]);
// if(($info['pid'] != $param['pid']) && ($sub_info != false)){
// $this->fail('当前分类拥有子分类,不允许修改上级分类');
// }
// $productModel = new Product();
// $product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]);
// if(($product_info !== false) && ($info['pid'] != $param['pid'])){
... ...
... ... @@ -17,7 +17,26 @@ class DescribeLogic extends BaseLogic
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new Describe();
}
/**
* @remark :保存通用描述
* @name :describeSave
* @author :lyh
* @method :post
* @time :2023/10/17 10:37
*/
public function describeSave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -156,7 +156,7 @@ class RankDataLogic extends BaseLogic
$ai_projects = $this->getAiProjects()['data'] ?? [];
$flg_ai = $this->getAiFlag($ai_projects, $domain);
$ai_domain = str_replace('www.', '', $this->getAiProjects($domain)['domain'] ?? '');
$list = RankData::where('project_id', $project_id)->where('lang', $lang)->value('data');
$list = RankData::where('project_id', $project_id)->where('lang', $lang)->value('data') ?: [];
$list30 = []; //排名前三十的
$list30_0 = []; //排名前三十且近三天没有排名的
$list100 = []; //排名前100的
... ...
... ... @@ -9,4 +9,6 @@ class BCustomTemplate extends Base
protected $table = 'gl_web_custom_template';
//连接数据库
protected $connection = 'custom_mysql';
const NOT_FOUND_PAGE_URL = '404';
}
... ...
... ... @@ -9,6 +9,8 @@
namespace App\Services;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -99,25 +101,70 @@ class ProjectServer extends BaseService
* @time :2023/9/19 14:45
*/
public static function saveInitParam($project_id){
$info = DB::connection('custom_mysql')->table('gl_web_nav')->first();
if(empty($info)){
$created_at = date('Y-m-d H:i:s');
//菜单
$info = DB::connection('custom_mysql')->table('gl_web_nav')->first();
if(empty($info)) {
$data = [
['project_id'=>$project_id,'name'=>'Home','url'=>'nav-home-'.$project_id,'location'=>'header','group_id'=>1,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'Products','url'=>'nav-product'.$project_id,'location'=>'header','group_id'=>1,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'News','url'=>'nav-news'.$project_id,'location'=>'header','group_id'=>1,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'ABOUT US','url'=>'nav-about-us'.$project_id,'location'=>'footer','group_id'=>2,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'Contact Us','url'=>'nav-contact-us'.$project_id,'location'=>'footer','group_id'=>2,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'FAQ','url'=>'nav-faq'.$project_id,'location'=>'footer','group_id'=>2,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id' => $project_id, 'name' => 'Home', 'url' => 'nav-home-' . $project_id, 'location' => 'header', 'group_id' => 1, 'created_at' => $created_at, 'updated_at' => $created_at],
['project_id' => $project_id, 'name' => 'Products', 'url' => 'nav-product' . $project_id, 'location' => 'header', 'group_id' => 1, 'created_at' => $created_at, 'updated_at' => $created_at],
['project_id' => $project_id, 'name' => 'News', 'url' => 'nav-news' . $project_id, 'location' => 'header', 'group_id' => 1, 'created_at' => $created_at, 'updated_at' => $created_at],
['project_id' => $project_id, 'name' => 'ABOUT US', 'url' => 'nav-about-us' . $project_id, 'location' => 'footer', 'group_id' => 2, 'created_at' => $created_at, 'updated_at' => $created_at],
['project_id' => $project_id, 'name' => 'Contact Us', 'url' => 'nav-contact-us' . $project_id, 'location' => 'footer', 'group_id' => 2, 'created_at' => $created_at, 'updated_at' => $created_at],
['project_id' => $project_id, 'name' => 'FAQ', 'url' => 'nav-faq' . $project_id, 'location' => 'footer', 'group_id' => 2, 'created_at' => $created_at, 'updated_at' => $created_at],
];
DB::connection('custom_mysql')->table('gl_web_nav')->insert($data);
}
//菜单组
$info = DB::connection('custom_mysql')->table('gl_web_nav_group')->first();
if(empty($info)) {
$data = [
['project_id'=>$project_id,'name'=>'全局顶部菜单','created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'底部菜单','created_at'=>$created_at,'updated_at'=>$created_at],
['id' => 1, 'project_id' => $project_id, 'name' => '全局顶部菜单', 'created_at' => $created_at, 'updated_at' => $created_at],
['id' => 2, 'project_id' => $project_id, 'name' => '底部菜单', 'created_at' => $created_at, 'updated_at' => $created_at],
];
DB::connection('custom_mysql')->table('gl_web_nav_group')->insert($data);
}
//初始化单页
$info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();
if(empty($info)) {
$data = ['project_id' => $project_id, 'name' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'status' => 1, 'url' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'html' => '<main>
<section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
id="sectionIdyxqu938">
<div class="layout" data-unable="demo01-error404">
<img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" />
</div>
<style>
.section-block-error404 .layout {
height: 700px;
display: flex;
align-items: center;
justify-content: center;
}
.section-block-error404 img {
width: 400px;
}
@media only screen and (max-width:500) {
.section-block-error404 img {
max-width: 100%;
}
}
</style>
<script>
</script>
</section>
</main>', 'html_style' => '<style id="globalsojs-styles"></style>','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();
if(empty($info)) {
$data = ['project_id' => $project_id, 'source' => RouteMap::SOURCE_PAGE, 'source_id' => $id, 'route' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'created_at' => $created_at, 'updated_at' => $created_at];
DB::connection('custom_mysql')->table('gl_route_map')->insert($data);
}
}
DB::disconnect('custom_mysql');
return true;
}
... ...