|
...
|
...
|
@@ -9,6 +9,7 @@ use App\Models\Product\CategoryRelated; |
|
|
|
use App\Models\Product\KeywordRelated;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\RouteMap;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -152,7 +153,98 @@ class ProductLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function setCopyProduct(){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
var_dump($info);
|
|
|
|
die();
|
|
|
|
$param = $this->setProductParams($info);
|
|
|
|
$save_id = $this->model->insertGetId($param);
|
|
|
|
//同步关联分类
|
|
|
|
CategoryRelated::saveRelated($save_id, $param['category_id']);
|
|
|
|
//同步关联关键词
|
|
|
|
KeywordRelated::saveRelated($save_id, $param['keyword_id']);
|
|
|
|
//同步可视化装修数据
|
|
|
|
$this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :同步模版数据
|
|
|
|
* @name :copyTemplate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/29 15:53
|
|
|
|
*/
|
|
|
|
public function copyTemplate($id,$project_id,$save_id){
|
|
|
|
$BTemplateModel = new BTemplate();
|
|
|
|
$list = $BTemplateModel->list(['source'=>2,'source_id'=>$id,'project_id'=>$project_id]);
|
|
|
|
if(!empty($list)){
|
|
|
|
$data = [];
|
|
|
|
foreach ($list as $k => $v){
|
|
|
|
$data[] = $this->setTemplateParams($v,$project_id,$save_id);
|
|
|
|
}
|
|
|
|
$rs = $BTemplateModel->insert($data);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :组装模版数据
|
|
|
|
* @name :setTemplateParams
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/29 15:54
|
|
|
|
*/
|
|
|
|
public function setTemplateParams($v,$project_id,$save_id){
|
|
|
|
$param = [
|
|
|
|
'html'=>$v['html'],
|
|
|
|
'project_id'=>$project_id,
|
|
|
|
'source'=>$v['source'],
|
|
|
|
'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']
|
|
|
|
];
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :组装数据
|
|
|
|
* @name :setParams
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/29 15:45
|
|
|
|
*/
|
|
|
|
public function setProductParams($info){
|
|
|
|
$param = [
|
|
|
|
'project_id'=>$info['project_id'],
|
|
|
|
'title'=>$info['title'],
|
|
|
|
'thumb'=>$info['thumb'],
|
|
|
|
'gallery'=>$info['gallery'],
|
|
|
|
'attrs'=>$info['attrs'],
|
|
|
|
'attr_id'=>$info['attr_id'],
|
|
|
|
'category_id'=>$info['category_id'],
|
|
|
|
'keyword_id'=>$info['keyword_id'],
|
|
|
|
'intro'=>$info['intro'],
|
|
|
|
'content'=>$info['content'],
|
|
|
|
'describe'=>$info['describe'],
|
|
|
|
'describe_id'=>$info['describe_id'],
|
|
|
|
'seo_mate'=>$info['seo_mate'],
|
|
|
|
'related_product_id'=>$info['related_product_id'],
|
|
|
|
'sort'=>$info['sort'],
|
|
|
|
'status'=>$info['status'],
|
|
|
|
'product_type'=>$info['product_type'],
|
|
|
|
'created_uid'=>$this->user['id'],
|
|
|
|
'icon'=>$info['icon'],
|
|
|
|
'created_at'=>date('Y-m-d H:i:s'),
|
|
|
|
'updated_at'=>date('Y-m-d H:i:s'),
|
|
|
|
];
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|