作者 lyh

gx

@@ -110,7 +110,7 @@ class DetailController extends BaseController @@ -110,7 +110,7 @@ class DetailController extends BaseController
110 'product_id.required' => '产品id不能为空', 110 'product_id.required' => '产品id不能为空',
111 'data.required' => 'data不能为空', 111 'data.required' => 'data不能为空',
112 ]); 112 ]);
113 - $data = $logic->saveDetail(); 113 + $data = $logic->saveDetail($this->param['product_id'],$this->param['data']);
114 $this->response('success',Code::SUCCESS,$data); 114 $this->response('success',Code::SUCCESS,$data);
115 } 115 }
116 116
@@ -50,15 +50,15 @@ class DetailLogic extends BaseLogic @@ -50,15 +50,15 @@ class DetailLogic extends BaseLogic
50 * @method :post 50 * @method :post
51 * @time :2024/11/13 9:30 51 * @time :2024/11/13 9:30
52 */ 52 */
53 - public function saveDetail(){  
54 - if(!empty($this->param['data'])){ 53 + public function saveDetail($product_id,$data){
  54 + if(!empty($data)){
55 try { 55 try {
56 - foreach ($this->param['data'] as $data){  
57 - foreach ($data as $v){ 56 + foreach ($data as $val){
  57 + foreach ($val as $v){
58 $save_data = [ 58 $save_data = [
59 'sort'=>$v['sort'], 59 'sort'=>$v['sort'],
60 'column_id'=>$v['column_id'], 60 'column_id'=>$v['column_id'],
61 - 'product_id'=>$this->param['product_id'], 61 + 'product_id'=>$product_id,
62 'text_type'=>$v['text_type'], 62 'text_type'=>$v['text_type'],
63 'title'=>$v['title'] ?? '', 63 'title'=>$v['title'] ?? '',
64 'content'=>json_encode($v['content'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), 64 'content'=>json_encode($v['content'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
@@ -75,6 +75,6 @@ class DetailLogic extends BaseLogic @@ -75,6 +75,6 @@ class DetailLogic extends BaseLogic
75 $this->fail('保存失败,请联系管理员.错误:'.$e->getMessage()); 75 $this->fail('保存失败,请联系管理员.错误:'.$e->getMessage());
76 } 76 }
77 } 77 }
78 - return $this->success(['product_id'=>$this->param['product_id']]); 78 + return $this->success(['product_id'=>$product_id]);
79 } 79 }
80 } 80 }
@@ -67,6 +67,9 @@ class ProductLogic extends BaseLogic @@ -67,6 +67,9 @@ class ProductLogic extends BaseLogic
67 //产品分类关联 67 //产品分类关联
68 CategoryRelated::saveRelated($id, $category_ids); 68 CategoryRelated::saveRelated($id, $category_ids);
69 KeywordRelated::saveRelated($id,$category_ids); 69 KeywordRelated::saveRelated($id,$category_ids);
  70 + //更新产品新描述
  71 + $detailLogic = new DetailLogic();
  72 + $detailLogic->saveDetail($id,$this->param['data'] ?? []);
70 //保存扩展字段 73 //保存扩展字段
71 $this->saveExtendInfo($id,$extend); 74 $this->saveExtendInfo($id,$extend);
72 }catch (\Exception $e){ 75 }catch (\Exception $e){