|
...
|
...
|
@@ -111,18 +111,26 @@ class ProductLogic extends BaseLogic |
|
|
|
* @time :2024/12/18 10:25
|
|
|
|
*/
|
|
|
|
public function saveDetail($product_id,$detail){
|
|
|
|
$this->delProductDetail($product_id);
|
|
|
|
if(!empty($detail)){
|
|
|
|
try {
|
|
|
|
foreach ($detail as $key =>$val){
|
|
|
|
$this->delProductDetail($product_id);
|
|
|
|
$detailModel = new Detail();
|
|
|
|
foreach ($detail as $val){
|
|
|
|
//查看当前栏目是否存在
|
|
|
|
$columnId = $this->getColumnId($product_id,$key);
|
|
|
|
foreach ($val as $v){
|
|
|
|
if(empty($key)){
|
|
|
|
continue;
|
|
|
|
if(empty($val['column_name'])){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(isset($val['column_id']) && $val['column_id'] == 1){
|
|
|
|
$column_id = 1;
|
|
|
|
}else{
|
|
|
|
$columnId = $this->getColumnId($product_id,$val['column_name']);
|
|
|
|
$column_id = $columnId['column_id'];
|
|
|
|
}
|
|
|
|
if(!empty($val['data']) && is_array($val['data'])){
|
|
|
|
foreach ($val['data'] as $item){
|
|
|
|
$save_data = $this->handleDetailParam($column_id,$product_id,$item);
|
|
|
|
$detailModel->addReturnId($save_data);
|
|
|
|
}
|
|
|
|
$save_data = $this->handleDetailParam($columnId['column_id'],$product_id,$v);
|
|
|
|
$this->model->add($save_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
...
|
...
|
@@ -156,12 +164,7 @@ class ProductLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function getColumnId($product_id,$column_name){
|
|
|
|
$columnModel = new Column();
|
|
|
|
$columnInfo = $columnModel->read(['column_name'=>strtolower($column_name),'product_id'=>$product_id]);
|
|
|
|
if($columnInfo['id'] != 1){
|
|
|
|
$column_id = $columnModel->addReturnId(['column_name'=>$column_name,'product_id'=>$product_id]);
|
|
|
|
}else{
|
|
|
|
$column_id = 1;
|
|
|
|
}
|
|
|
|
$column_id = $columnModel->addReturnId(['column_name'=>$column_name,'product_id'=>$product_id]);
|
|
|
|
return $this->success(['column_id'=>$column_id]);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -182,7 +185,7 @@ class ProductLogic extends BaseLogic |
|
|
|
'content'=>json_encode($info['content'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
|
|
|
'css'=>json_encode($info['css'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
|
|
|
];
|
|
|
|
return $this->success(['data'=>$save_data]);
|
|
|
|
return $this->success($save_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -527,6 +530,8 @@ class ProductLogic extends BaseLogic |
|
|
|
$this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
|
|
|
|
//同步扩展字段
|
|
|
|
$this->copyExtendInfo($info['id'],$save_id);
|
|
|
|
$this->copyColumn($info['id'],$save_id);
|
|
|
|
$this->copyDetail($info['id'],$save_id);
|
|
|
|
DB::commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
...
|
...
|
@@ -536,6 +541,54 @@ class ProductLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :复制栏目
|
|
|
|
* @name :copyDetail
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/12/18 15:54
|
|
|
|
*/
|
|
|
|
public function copyColumn($product_id,$new_product_id){
|
|
|
|
$columnModel = new Column();
|
|
|
|
$columnList = $columnModel->list(['product_id'=>$product_id]);
|
|
|
|
if(!empty($columnInfo)){
|
|
|
|
$data = [];
|
|
|
|
foreach ($columnList as $k => $v){
|
|
|
|
unset($v['id']);
|
|
|
|
$v['product_id'] = $new_product_id;
|
|
|
|
$v['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$v['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
$data[] = $v;
|
|
|
|
}
|
|
|
|
return $columnModel->insert($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :复制描述
|
|
|
|
* @name :copyDetail
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/12/18 16:02
|
|
|
|
*/
|
|
|
|
public function copyDetail($product_id,$new_product_id){
|
|
|
|
$detailModel = new Detail();
|
|
|
|
$detailList = $detailModel->list(['product_id'=>$product_id]);
|
|
|
|
if(!empty($columnInfo)){
|
|
|
|
$data = [];
|
|
|
|
foreach ($detailList as $k => $v){
|
|
|
|
unset($v['id']);
|
|
|
|
$v['css'] = Arr::a2s($v['css']);
|
|
|
|
$v['content'] = Arr::a2s($v['content']);
|
|
|
|
$v['product_id'] = $new_product_id;
|
|
|
|
$v['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$v['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
$data[] = $v;
|
|
|
|
}
|
|
|
|
return $detailModel->insert($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :复制项目扩展字段
|
|
|
|
* @name :copyExtendInfo
|
|
|
|
* @author :lyh
|
...
|
...
|
|