|
|
|
<?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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|