作者 lyh

gx脚本更新路由

@@ -159,10 +159,14 @@ class ProductLogic extends BaseLogic @@ -159,10 +159,14 @@ class ProductLogic extends BaseLogic
159 public function getColumnId($product_id,$column_name){ 159 public function getColumnId($product_id,$column_name){
160 $columnModel = new Column(); 160 $columnModel = new Column();
161 $columnInfo = $columnModel->read(['column_name'=>strtolower($column_name),'product_id'=>$product_id]); 161 $columnInfo = $columnModel->read(['column_name'=>strtolower($column_name),'product_id'=>$product_id]);
162 - if($columnInfo === false || $columnInfo['id'] != 1){ 162 + if($columnInfo === false){
163 $column_id = $columnModel->addReturnId(['column_name'=>$column_name,'product_id'=>$product_id]); 163 $column_id = $columnModel->addReturnId(['column_name'=>$column_name,'product_id'=>$product_id]);
164 }else{ 164 }else{
165 - $column_id = 1; 165 + if($columnInfo['id'] != 1){
  166 + $column_id = $columnModel->addReturnId(['column_name'=>$column_name,'product_id'=>$product_id]);
  167 + }else{
  168 + $column_id = 1;
  169 + }
166 } 170 }
167 return $this->success(['column_id'=>$column_id]); 171 return $this->success(['column_id'=>$column_id]);
168 } 172 }
@@ -537,8 +541,43 @@ class ProductLogic extends BaseLogic @@ -537,8 +541,43 @@ class ProductLogic extends BaseLogic
537 return $this->success(['id'=>$save_id]); 541 return $this->success(['id'=>$save_id]);
538 } 542 }
539 543
540 - public function copyDetail(){ 544 + /**
  545 + * @remark :复制描述
  546 + * @name :copyDetail
  547 + * @author :lyh
  548 + * @method :post
  549 + * @time :2024/12/18 15:54
  550 + */
  551 + public function copyColumn($product_id,$new_product_id){
  552 + $columnModel = new Column();
  553 + $columnList = $columnModel->list(['product_id'=>$product_id]);
  554 + if(!empty($columnInfo)){
  555 + $data = [];
  556 + foreach ($columnList as $k => $v){
  557 + unset($v['id']);
  558 + $v['product_id'] = $new_product_id;
  559 + $v['created_at'] = date('Y-m-d H:i:s');
  560 + $v['updated_at'] = date('Y-m-d H:i:s');
  561 + $data[] = $v;
  562 + }
  563 + return $columnModel->insert($data);
  564 + }
  565 + }
541 566
  567 + public function copyDetail($product_id,$new_product_id){
  568 + $detailModel = new Detail();
  569 + $detailList = $detailModel->list(['product_id'=>$product_id]);
  570 + if(!empty($columnInfo)){
  571 + $data = [];
  572 + foreach ($detailList as $k => $v){
  573 + unset($v['id']);
  574 + $v['product_id'] = $new_product_id;
  575 + $v['created_at'] = date('Y-m-d H:i:s');
  576 + $v['updated_at'] = date('Y-m-d H:i:s');
  577 + $data[] = $v;
  578 + }
  579 + return $detailModel->insert($data);
  580 + }
542 } 581 }
543 582
544 /** 583 /**