作者 刘锟

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

... ... @@ -62,6 +62,7 @@ class InitProject extends Command
if(!empty($project['mobile'])){
$project_logic->createUser($project['mobile'],$project['id'],$project['lead_name']);
}
$project_logic->createdRole($project['id']);
//更改服务器状态
if(!empty($project['serve_id'])){
$project_logic->updateServe($project['serve_id']);
... ...
... ... @@ -67,6 +67,7 @@ class UpdateProgress extends Command
public function getUpdateProgress($project_id){
$info = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->first();
if(!empty($info)){
$info = (array)$info;
//超时时间
$time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60);
if($time > date("Y-m-d H:i:s")){
... ...
... ... @@ -150,6 +150,7 @@ class UpdateSeoTdk extends Command
echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
ProjectUpdateTdk::retry($task->id, $e->getMessage());
}
Cache::forget('project_deploy_optimize_info_' . $project_id);
echo date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
}
}
... ... @@ -310,6 +311,18 @@ class UpdateSeoTdk extends Command
return $prompt;
}
public function getDeployOptimize($project_id){
$cache_key = 'project_deploy_optimize_info_' . $project_id;
$info = Cache::get($cache_key);
if(!$info){
$projectOptimizeModel = new DeployOptimize();
$info = $projectOptimizeModel->read(['project_id' => $project_id], ['id', 'company_en_name', 'company_en_description', 'main_keywords']);
Cache::put($cache_key, $info, 600);
}
return $info;
}
/**
* @remark :获取公司英文名称
* @name :companyName
... ... @@ -322,8 +335,7 @@ class UpdateSeoTdk extends Command
$data = [
'product_long_description',
];
$projectOptimizeModel = new DeployOptimize();
$info = $projectOptimizeModel->read(['project_id' => $project_id], ['id', 'company_en_name', 'company_en_description']);
$info = $this->getDeployOptimize($project_id);
if (in_array($key, $data)) {
return $info['company_en_description'];
} else {
... ... @@ -341,8 +353,7 @@ class UpdateSeoTdk extends Command
public function mainKeywords($project_id, $num)
{
$str = '';
$projectOptimizeModel = new DeployOptimize();
$info = $projectOptimizeModel->read(['project_id' => $project_id], ['id', 'main_keywords']);
$info = $this->getDeployOptimize($project_id);
if (!empty($info['main_keywords'])) {
$main_keywords = explode("\r\n", $info['main_keywords']);
//随机取
... ...
<?php
namespace App\Http\Controllers\Aside;
namespace App\Http\Controllers\Aside\Collect;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\CollectLogic;
... ...
... ... @@ -11,6 +11,7 @@ use App\Http\Logic\Bside\Product\ProductLogic;
use App\Http\Requests\Bside\Product\ProductRequest;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Extend;
use App\Models\Product\ExtendInfo;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
... ... @@ -270,20 +271,56 @@ class ProductController extends BaseController
$v['is_renovation'] = $this->getProductIsRenovation($templateInfo,$v['id']);
$v['url'] = $this->user['domain'].$v['route'];
//获取当前数据扩展字段及值
$v['extend'] = $this->getExtendInfo($v['id']);
return $v;
}
/**
* @remark :获取扩展字段详情
* @name :getExtendInfo
* @author :lyh
* @method :post
* @time :2023/11/14 9:45
*/
public function getExtendInfo($product_id){
$extendModel = new Extend();
$list = $extendModel->list([],'id',['type','key','title']);
if(empty($list)){
return [];
}
$extendInfoModel = new ExtendInfo();
$v['extend'] = $extendInfoModel->list(['product_id'=>$v['id']],'created_at');
foreach ($v['extend'] as $k1=>$v1){
if($v1['type'] == 3){
$v1['values'] = getImageUrl($v1['values']);
}elseif ($v1['type'] == 4){
$v1['values'] = getFileUrl($v1['values']);
foreach ($list as $k=>$v){
$info = $extendInfoModel->read(['key'=>$v['key'],'product_id'=>$product_id]);
if($info == false){
if($v['type'] == 3 || $v['type'] == 4){
$v['values'] = [];
}else{
$v['values'] = '';
}
}else{
if($v['type'] == 3){
$arr = json_decode($info['values']);
foreach ($arr as $k1=>$v1){
$v1 = getImageUrl($v1);
$arr[$k1] = $v1;
}
$v['values'] = $arr;
}elseif($v['type'] == 4){
$arr1 = json_decode($info['values']);
foreach ($arr1 as $k1=>$v1){
$v1 = getImageUrl($v1);
$arr1[$k1] = $v1;
}
$v['values'] = $arr1;
}else{
$v['values'] = $info['values'];
}
}
$v['extend'][$k1] = $v1;
$list[$k] = $v;
}
return $v;
return $list;
}
/**
* @remark :保存产品数据
* @name :save
... ...
<?php
/**
* @remark :
* @name :BTemplateModuleProjectController.php
* @author :lyh
* @method :post
* @time :2023/11/14 14:34
*/
namespace App\Http\Controllers\Bside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic;
use App\Models\Template\BModuleProject;
class BTemplateModuleProjectController extends BaseController
{
/**
* @remark :获取私有化模块列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/11/14 14:34
*/
public function lists(BModuleProject $BModuleProject){
$list = $BModuleProject->list($this->map);
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :保存私有化左侧模块
* @name :save
* @author :lyh
* @method :post
* @time :2023/11/14 14:38
*/
public function save(BTemplateModuleProjectLogic $logic){
$this->request->validate([
'name'=>'required',
'html'=>'required',
],[
'name.required' => '模板名称不能为空',
'html.required' => 'html不能为空',
]);
$logic->moduleProjectSave();
return $this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :VisualizationController.php
* @author :lyh
* @method :post
* @time :2023/11/15 9:55
*/
namespace App\Http\Controllers\Bside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\VisualizationLogic;
use App\Models\Visualization\Visualization;
/**
* @remark :定制项目处理
* @name :VisualizationController
* @author :lyh
* @method :post
* @time :2023/11/15 9:55
*/
class VisualizationController extends BaseController
{
/**
* @remark :获取当前定制代码块详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/11/15 10:26
*/
public function info(Visualization $visualization){
//查看当前模板是否在可视化中保存
$info = $visualization->read(['source'=>$this->map['source']],['html','source','id','project_id']);
if($info === false){
$info = [];
}
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存定制项目html
* @name :save
* @author :lyh
* @method :post
* @time :2023/11/15 10:08
*/
public function save(VisualizationLogic $logic){
$this->request->validate([
'source'=>'required',
'html'=>'required',
],[
'source.required' => '类型不能为空',
'html.required' => 'html不能为空',
]);
$logic->saveVisualization();
$this->response('success');
}
/**
* @remark :可视化保存
* @name :saveHtml
* @author :lyh
* @method :post
* @time :2023/11/15 11:20
*/
public function getHtml(VisualizationLogic $logic){
$this->request->validate([
'source'=>'required',
'source_id'=>'required',
],[
'source.required' => '类型不能为空',
'source_id.required' => 'source_id不能为空',
]);
$data = $logic->getHtml();
$this->response('success',Code::SUCCESS,['html'=>$data]);
}
/**
* @remark :保存html
* @name :saveHtml
* @author :lyh
* @method :post
* @time :2023/11/15 11:44
*/
public function saveHtml(VisualizationLogic $logic){
$this->request->validate([
'source'=>'required',
'source_id'=>'required',
],[
'source.required' => '类型不能为空',
'source_id.required' => 'source_id不能为空',
]);
$logic->saveHtml();
$this->response('success');
}
}
... ...
... ... @@ -209,10 +209,21 @@ class DomainInfoLogic extends BaseLogic
$this->fail('获取项目数据失败');
}
$server_model = new ServerConfig();
$server_info = $server_model->read(['id'=>$project_info['serve_id']],'init_domain');
$server_info = $server_model->read(['id'=>$project_info['serve_id']],['init_domain', 'host']);
if($server_info === false){
$this->fail('获取服务器数据失败');
}
//域名是否都已经解析
if(!empty($info['domain']) && !$this->check_cname($info['domain'], $server_info)){
$this->fail('域名' . $info['domain'] . '未解析至目标服务器');
}
foreach ($this->param['other_domain']??[] as $other_domain){
if($other_domain && !$this->check_cname($other_domain, $server_info)){
$this->fail('域名' . $other_domain . '未解析至目标服务器');
}
}
//保存301跳转数据+其他域名
$data = [
'other_domain'=>json_encode($this->param['other_domain'] ?? []),
... ...
... ... @@ -81,6 +81,9 @@ class ProjectLogic extends BaseLogic
if(empty($info['payment']['renewal_record'])){
$info['payment']['renewal_record'] = [["amount"=> null, "remark"=> null, "expire_at"=> null]];
}
if(isset($info['is_customized']) && $info['is_customized'] == 1){
$info['is_visualization'] = json_decode($info['is_visualization']);
}
return $this->success($info);
}
... ... @@ -130,12 +133,9 @@ class ProjectLogic extends BaseLogic
//保存售后信息
$this->saveProjectAfter($this->param['project_after']);
//创建站点
$this->createSite($this->param);
// $this->createSite($this->param);
}
DB::commit();
}catch (AsideGlobalException $e){
DB::rollBack();
$this->fail($e->getMessage());
}catch (\Exception $e){
DB::rollBack();
$this->fail('请填写完整后再提交');
... ... @@ -188,6 +188,11 @@ class ProjectLogic extends BaseLogic
'upload_max_size' => $param['upload_config']['upload_max_size'] ?? 5,
];
}
if(isset($param['is_customized']) && ($param['is_customized'] == 1)){
if(!empty($param['is_visualization'])){
$param['is_visualization'] = json_encode($param['is_visualization']);
}
}
$this->model->edit($param,['id'=>$param['id']]);
Common::del_user_cache($this->model->getTable(),$param['id']);
return $this->success();
... ... @@ -400,7 +405,7 @@ class ProjectLogic extends BaseLogic
$menuModel = new ProjectMenu();
$ids = $menuModel->where(['status'=>0])->pluck('id')->toArray();
$data = [
'name'=>'超级管理员',
'name'=>'管理员',
'role_menu'=>implode(',',$ids),
'project_id'=>$project_id,
'type'=>1,
... ... @@ -524,9 +529,8 @@ class ProjectLogic extends BaseLogic
$domain_info = $domain_model->read(['id'=>$param['deploy_optimize']['domain']],'domain');
if($server_info && $domain_info){
//验证解析
if (!DomainInfoLogic::instance()->check_cname($domain_info['domain'], $server_info)) {
if (!empty($domain_info['domain']) && !DomainInfoLogic::instance()->check_cname($domain_info['domain'], $server_info)) {
throw new AsideGlobalException(Code::SYSTEM_ERROR,'域名' . $domain_info['domain'] . '未解析至目标服务器');
}
$api_url = 'http://'.$server_info['init_domain'].'/api/createSite';
... ...
<?php
/**
* @remark :
* @name :BTemplateModuleProjectLogic.php
* @author :lyh
* @method :post
* @time :2023/11/14 14:41
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Template\BModuleProject;
class BTemplateModuleProjectLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new BModuleProject();
$this->param = $this->requestAll;
}
/**
* @remark :保存私有化左侧模块
* @name :moduleProjectSave
* @author :lyh
* @method :post
* @time :2023/11/14 14:46
*/
public function moduleProjectSave(){
try {
$this->param['operator_id'] = $this->user['id'];
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}
... ...
<?php
/**
* @remark :
* @name :VisualizationLogic.php
* @author :lyh
* @method :post
* @time :2023/11/15 10:09
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Visualization\Visualization;
class VisualizationLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new Visualization();
$this->param = $this->requestAll;
}
/**
* @remark :保存定制html
* @name :saveHtml
* @author :lyh
* @method :post
* @time :2023/11/15 10:12
*/
public function saveVisualization(){
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :可视化装修获取html
* @name :getHtml
* @author :lyh
* @method :post
* @time :2023/11/15 11:30
*/
public function getHtml(){
//查询可视化是否第一次保存
$bTemplateModel = new BTemplate();
$TemplateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
]);
if($this->param['source'] == 2){
if($this->param['source_id'] == 0){$source = 3;}else{$source = 2;}
}
if($this->param['source'] == 3){
if($this->param['source_id'] == 0){$source = 5;}else{$source = 4;}
}
if($this->param['source'] == 4){
if($this->param['source_id'] == 0){$source = 7;}else{$source = 6;}
}
if($TemplateInfo === false){
$info = $this->model->read(['source'=>$source],['html','source','id','project_id']);
if($info === false){
$this->fail('请先上传定制代码块');
}
return $info['html'];
}
return $TemplateInfo['html'];
}
/**
* @remark :保存定制项目可视化
* @name :saveHtml
* @author :lyh
* @method :post
* @time :2023/11/15 11:47
*/
public function saveHtml(){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
]);
try {
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$bTemplateModel->add($this->param);
}else{
$bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
}
}catch (\Exception $e){
$this->fail('系统错误请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -38,7 +38,7 @@ class ExtendLogic extends BaseLogic
if($info !== false){
$this->fail('当前扩展名称已存在');
}
$key = trim(strtolower(preg_replace('/[\W]+/', '-', trim(Translate::tran($this->param['title'], 'en')))), '-');
$key = 'pd_extended_field_';
$this->param['key'] = $this->getKey($key);
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
... ... @@ -56,11 +56,10 @@ class ExtendLogic extends BaseLogic
* @method :post
* @time :2023/11/9 15:55
*/
public function getKey($key){
$info = $this->model->read(['key'=>$key]);
public function getKey($key,$i = 1){
$info = $this->model->read(['key'=>$key.$i]);
if($info !== false){
$key .= '-'.rand(1, 100);
return $this->getKey($key);
return $this->getKey($key,$i+1);
}
return $key;
}
... ...
... ... @@ -99,28 +99,28 @@ class ProductLogic extends BaseLogic
* @method :post
* @time :2023/11/9 15:02
*/
public function saveExtendInfo($id,$extend){
public function saveExtendInfo($product_id,$extend){
//先删除以前的数据
$extendInfoModel = new ExtendInfo();
$extendInfoModel->del(['project_id'=>$id]);
if(!empty($extend)){
foreach ($extend as $v){
unset($v['title']);
if(!empty($v['values'])){
if($v['type'] == 3 || $v['type'] || 4){
if(is_array($v['values'])){
foreach ($v['values'] as $k1=>$v1){
$v1 = str_replace_url($v1);
$v['values'][$k1] = $v1;
}
$v['values'] = json_encode($v['values']);
}
}
$v['project_id'] = $this->user['project_id'];
$v['product_id'] = $id;
$extendInfoModel->add($v);
$extendInfoModel->del(['product_id'=>$product_id]);
if(empty($extend)) {
return $this->success();
}
foreach ($extend as $k => $v){
if(empty($v['values'])){
continue;
}
unset($v['title']);
if($v['type'] == 3 || $v['type'] == 4){
foreach ($v['values'] as $k1=>$v1){
$v1 = str_replace_url($v1);
$v['values'][$k1] = $v1;
}
$v['values'] = json_encode($v['values']);
}
$v['project_id'] = $this->user['project_id'];
$v['product_id'] = $product_id;
$extendInfoModel->add($v);
}
return $this->success();
}
... ... @@ -399,12 +399,8 @@ class ProductLogic extends BaseLogic
'source_id'=>$save_id,
'template_id'=>$v['template_id'],
'section_list_id'=>$v['section_list_id'],
'head_html'=>$v['head_html'],
'main_html'=>$v['main_html'],
'footer_html'=>$v['footer_html'],
'head_css'=>$v['head_css'],
'main_css'=>$v['main_css'],
'footer_css'=>$v['footer_css'],
'created_at'=>$v['created_at'],
'updated_at'=>$v['updated_at']
];
... ...
... ... @@ -168,6 +168,9 @@ class UserLoginLogic
$info['upload_config'] = $project['upload_config'];
$info['image_max'] = $project['image_max'];
$info['configuration'] = $project['deploy_build']['configuration'];
if($info['is_customized'] == 1){
$info['is_visualization'] = json_decode($project['is_visualization']);
}
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
return $this->success($info);
... ... @@ -196,14 +199,17 @@ class UserLoginLogic
$info['is_customized'] = $project['is_customized'];
$info['is_upload_manage'] = $project['is_upload_manage'];
$info['upload_config'] = $project['upload_config'];
$info['image_max'] = $project['image_max'];
$info['configuration'] = $project['deploy_build']['configuration'];
if($info['is_customized'] == 1){
$info['is_visualization'] = json_decode($project['is_visualization']);
}
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
return $this->success($info);
}
/**
* @remark :获取项目数据详情
* @name :getProjectInfo
... ...
... ... @@ -41,6 +41,8 @@ class Category extends Base
return $ids;
}
/**
* 关联产品数量
* @param $cate_id
... ... @@ -50,7 +52,16 @@ class Category extends Base
*/
public static function getProductNum($cate_id){
$cate_ids = self::getChildIdsArr($cate_id);
$product_ids = CategoryRelated::whereIn('cate_id', $cate_ids)->groupBy('product_id')->select(['product_id'])->get();
return count($product_ids);
$str = 0;
foreach ($cate_ids as $v){
$info = self::where('pid',$v)->first();
if($info){
continue;
}else{
$count = Product::where('category_id','like','%,'.$v.',%')->count();
$str = $str+$count;
}
}
return $str;
}
}
... ...
<?php
/**
* @remark :
* @name :BModuleProject.php
* @author :lyh
* @method :post
* @time :2023/11/14 14:31
*/
namespace App\Models\Template;
use App\Models\Base;
/**
* @remark :私有化左侧模块
* @name :BModuleProject
* @author :lyh
* @method :post
* @time :2023/11/14 14:33
*/
class BModuleProject extends Base
{
protected $table = 'gl_public_template_module_project';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :TemplateProject.php
* @author :lyh
* @method :post
* @time :2023/11/15 14:38
*/
namespace App\Models\Template;
use App\Models\Base;
class TemplateProject extends Base
{
protected $table = 'gl_web_setting_template';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :Visualization.php
* @author :lyh
* @method :post
* @time :2023/11/15 10:11
*/
namespace App\Models\Visualization;
use App\Models\Base;
class Visualization extends Base
{
protected $table = 'gl_visualization_html';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -341,7 +341,7 @@ Route::group([], function () {
Route::any('get_template_list', [Aside\Template\ATemplateController::class, 'getTemplateList'])->name('admin.get_template_list');
Route::any('get_template_detail', [Aside\Template\ATemplateController::class, 'getTemplateDetail'])->name('admin.get_template_detail');
Route::any('/collect', [Aside\CollectController::class, 'index'])->name('admin.collect');
Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect');
});
... ...
... ... @@ -320,6 +320,13 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/type', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'getType'])->name('template_module_getType');
});
// 保存私有模块
Route::prefix('moduleProject')->group(function () {
//获取所有左侧模版
Route::any('/', [\App\Http\Controllers\Bside\Template\BTemplateModuleProjectController::class, 'lists'])->name('template_module_project_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateModuleProjectController::class, 'save'])->name('template_module_project_save');
});
//编辑记录
Route::prefix('log')->group(function () {
//获取所有左侧模版
... ... @@ -328,6 +335,15 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/rollbackVersion', [\App\Http\Controllers\Bside\Template\BTemplateLogController::class, 'rollbackVersion'])->name('template_log_rollbackVersion');
});
});
//定制项目上传代码块
Route::prefix('visualization')->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'info'])->name('visualization_info');
Route::any('/save', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'save'])->name('visualization_save');
Route::any('/getHtml', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'getHtml'])->name('visualization_getHtml');
Route::any('/saveHtml', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'saveHtml'])->name('visualization_saveHtml');
});
// 自定义页面,专题页
Route::prefix('custom')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'lists'])->name('custom_lists');
... ...