|
@@ -111,18 +111,26 @@ class ProductLogic extends BaseLogic |
|
@@ -111,18 +111,26 @@ class ProductLogic extends BaseLogic |
|
111
|
* @time :2024/12/18 10:25
|
111
|
* @time :2024/12/18 10:25
|
|
112
|
*/
|
112
|
*/
|
|
113
|
public function saveDetail($product_id,$detail){
|
113
|
public function saveDetail($product_id,$detail){
|
|
114
|
- $this->delProductDetail($product_id);
|
|
|
|
115
|
if(!empty($detail)){
|
114
|
if(!empty($detail)){
|
|
116
|
try {
|
115
|
try {
|
|
117
|
- foreach ($detail as $key =>$val){
|
116
|
+ $this->delProductDetail($product_id);
|
|
|
|
117
|
+ $detailModel = new Detail();
|
|
|
|
118
|
+ foreach ($detail as $val){
|
|
118
|
//查看当前栏目是否存在
|
119
|
//查看当前栏目是否存在
|
|
119
|
- $columnId = $this->getColumnId($product_id,$key);
|
|
|
|
120
|
- foreach ($val as $v){
|
|
|
|
121
|
- if(empty($key)){
|
120
|
+ if(empty($val['column_name'])){
|
|
122
|
continue;
|
121
|
continue;
|
|
123
|
}
|
122
|
}
|
|
124
|
- $save_data = $this->handleDetailParam($columnId['column_id'],$product_id,$v);
|
|
|
|
125
|
- $this->model->add($save_data);
|
123
|
+ if(isset($val['column_id']) && $val['column_id'] == 1){
|
|
|
|
124
|
+ $column_id = 1;
|
|
|
|
125
|
+ }else{
|
|
|
|
126
|
+ $columnId = $this->getColumnId($product_id,$val['column_name']);
|
|
|
|
127
|
+ $column_id = $columnId['column_id'];
|
|
|
|
128
|
+ }
|
|
|
|
129
|
+ if(!empty($val['data']) && is_array($val['data'])){
|
|
|
|
130
|
+ foreach ($val['data'] as $item){
|
|
|
|
131
|
+ $save_data = $this->handleDetailParam($column_id,$product_id,$item);
|
|
|
|
132
|
+ $detailModel->addReturnId($save_data);
|
|
|
|
133
|
+ }
|
|
126
|
}
|
134
|
}
|
|
127
|
}
|
135
|
}
|
|
128
|
}catch (\Exception $e){
|
136
|
}catch (\Exception $e){
|
|
@@ -156,12 +164,7 @@ class ProductLogic extends BaseLogic |
|
@@ -156,12 +164,7 @@ class ProductLogic extends BaseLogic |
|
156
|
*/
|
164
|
*/
|
|
157
|
public function getColumnId($product_id,$column_name){
|
165
|
public function getColumnId($product_id,$column_name){
|
|
158
|
$columnModel = new Column();
|
166
|
$columnModel = new Column();
|
|
159
|
- $columnInfo = $columnModel->read(['column_name'=>strtolower($column_name),'product_id'=>$product_id]);
|
|
|
|
160
|
- if($columnInfo['id'] != 1){
|
|
|
|
161
|
$column_id = $columnModel->addReturnId(['column_name'=>$column_name,'product_id'=>$product_id]);
|
167
|
$column_id = $columnModel->addReturnId(['column_name'=>$column_name,'product_id'=>$product_id]);
|
|
162
|
- }else{
|
|
|
|
163
|
- $column_id = 1;
|
|
|
|
164
|
- }
|
|
|
|
165
|
return $this->success(['column_id'=>$column_id]);
|
168
|
return $this->success(['column_id'=>$column_id]);
|
|
166
|
}
|
169
|
}
|
|
167
|
|
170
|
|
|
@@ -182,7 +185,7 @@ class ProductLogic extends BaseLogic |
|
@@ -182,7 +185,7 @@ class ProductLogic extends BaseLogic |
|
182
|
'content'=>json_encode($info['content'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
185
|
'content'=>json_encode($info['content'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
|
183
|
'css'=>json_encode($info['css'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
186
|
'css'=>json_encode($info['css'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
|
184
|
];
|
187
|
];
|
|
185
|
- return $this->success(['data'=>$save_data]);
|
188
|
+ return $this->success($save_data);
|
|
186
|
}
|
189
|
}
|
|
187
|
|
190
|
|
|
188
|
/**
|
191
|
/**
|
|
@@ -527,6 +530,8 @@ class ProductLogic extends BaseLogic |
|
@@ -527,6 +530,8 @@ class ProductLogic extends BaseLogic |
|
527
|
$this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
|
530
|
$this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
|
|
528
|
//同步扩展字段
|
531
|
//同步扩展字段
|
|
529
|
$this->copyExtendInfo($info['id'],$save_id);
|
532
|
$this->copyExtendInfo($info['id'],$save_id);
|
|
|
|
533
|
+ $this->copyColumn($info['id'],$save_id);
|
|
|
|
534
|
+ $this->copyDetail($info['id'],$save_id);
|
|
530
|
DB::commit();
|
535
|
DB::commit();
|
|
531
|
}catch (\Exception $e){
|
536
|
}catch (\Exception $e){
|
|
532
|
DB::rollBack();
|
537
|
DB::rollBack();
|
|
@@ -536,6 +541,54 @@ class ProductLogic extends BaseLogic |
|
@@ -536,6 +541,54 @@ class ProductLogic extends BaseLogic |
|
536
|
}
|
541
|
}
|
|
537
|
|
542
|
|
|
538
|
/**
|
543
|
/**
|
|
|
|
544
|
+ * @remark :复制栏目
|
|
|
|
545
|
+ * @name :copyDetail
|
|
|
|
546
|
+ * @author :lyh
|
|
|
|
547
|
+ * @method :post
|
|
|
|
548
|
+ * @time :2024/12/18 15:54
|
|
|
|
549
|
+ */
|
|
|
|
550
|
+ public function copyColumn($product_id,$new_product_id){
|
|
|
|
551
|
+ $columnModel = new Column();
|
|
|
|
552
|
+ $columnList = $columnModel->list(['product_id'=>$product_id]);
|
|
|
|
553
|
+ if(!empty($columnInfo)){
|
|
|
|
554
|
+ $data = [];
|
|
|
|
555
|
+ foreach ($columnList as $k => $v){
|
|
|
|
556
|
+ unset($v['id']);
|
|
|
|
557
|
+ $v['product_id'] = $new_product_id;
|
|
|
|
558
|
+ $v['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
559
|
+ $v['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
560
|
+ $data[] = $v;
|
|
|
|
561
|
+ }
|
|
|
|
562
|
+ return $columnModel->insert($data);
|
|
|
|
563
|
+ }
|
|
|
|
564
|
+ }
|
|
|
|
565
|
+
|
|
|
|
566
|
+ /**
|
|
|
|
567
|
+ * @remark :复制描述
|
|
|
|
568
|
+ * @name :copyDetail
|
|
|
|
569
|
+ * @author :lyh
|
|
|
|
570
|
+ * @method :post
|
|
|
|
571
|
+ * @time :2024/12/18 16:02
|
|
|
|
572
|
+ */
|
|
|
|
573
|
+ public function copyDetail($product_id,$new_product_id){
|
|
|
|
574
|
+ $detailModel = new Detail();
|
|
|
|
575
|
+ $detailList = $detailModel->list(['product_id'=>$product_id]);
|
|
|
|
576
|
+ if(!empty($columnInfo)){
|
|
|
|
577
|
+ $data = [];
|
|
|
|
578
|
+ foreach ($detailList as $k => $v){
|
|
|
|
579
|
+ unset($v['id']);
|
|
|
|
580
|
+ $v['css'] = Arr::a2s($v['css']);
|
|
|
|
581
|
+ $v['content'] = Arr::a2s($v['content']);
|
|
|
|
582
|
+ $v['product_id'] = $new_product_id;
|
|
|
|
583
|
+ $v['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
584
|
+ $v['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
585
|
+ $data[] = $v;
|
|
|
|
586
|
+ }
|
|
|
|
587
|
+ return $detailModel->insert($data);
|
|
|
|
588
|
+ }
|
|
|
|
589
|
+ }
|
|
|
|
590
|
+
|
|
|
|
591
|
+ /**
|
|
539
|
* @remark :复制项目扩展字段
|
592
|
* @remark :复制项目扩展字段
|
|
540
|
* @name :copyExtendInfo
|
593
|
* @name :copyExtendInfo
|
|
541
|
* @author :lyh
|
594
|
* @author :lyh
|