作者 lyh

gx

@@ -75,12 +75,8 @@ class ProductLogic extends BaseLogic @@ -75,12 +75,8 @@ class ProductLogic extends BaseLogic
75 * @time :2023/10/26 9:49 75 * @time :2023/10/26 9:49
76 */ 76 */
77 public function editList(){ 77 public function editList(){
78 - if(isset($this->param['category_id']) && !empty($this->param['category_id'])){  
79 - $this->param['category_id'] = $this->getLastCategory($this->param['category_id']);  
80 - }  
81 - if(isset($this->param['keyword_id']) && !empty($this->param['keyword_id'])){  
82 - $this->param['keyword_id'] = ','.implode(',',$this->saveKeyword($this->param['keyword_id'])).',';  
83 - } 78 + $this->param['category_id'] = $this->getLastCategory($this->param['category_id']);
  79 + $this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']);
84 $this->model->edit($this->param,['id'=>$this->param['id']]); 80 $this->model->edit($this->param,['id'=>$this->param['id']]);
85 return $this->success(); 81 return $this->success();
86 } 82 }
@@ -93,8 +89,9 @@ class ProductLogic extends BaseLogic @@ -93,8 +89,9 @@ class ProductLogic extends BaseLogic
93 * @time :2023/10/26 9:51 89 * @time :2023/10/26 9:51
94 */ 90 */
95 public function saveKeyword($keyword){ 91 public function saveKeyword($keyword){
96 - $arr = []; 92 + $str = '';
97 if(!empty($keyword) && is_array($keyword)){ 93 if(!empty($keyword) && is_array($keyword)){
  94 + $arr = [];
98 $keywordModel = new Keyword(); 95 $keywordModel = new Keyword();
99 foreach ($keyword as $v){ 96 foreach ($keyword as $v){
100 //查询当前关键字是否存在 97 //查询当前关键字是否存在
@@ -114,8 +111,9 @@ class ProductLogic extends BaseLogic @@ -114,8 +111,9 @@ class ProductLogic extends BaseLogic
114 $arr[] = $info['id']; 111 $arr[] = $info['id'];
115 } 112 }
116 } 113 }
  114 + $str = ','.implode(',',$arr).',';
117 } 115 }
118 - return $arr; 116 + return $str;
119 } 117 }
120 118
121 /** 119 /**
@@ -137,9 +135,7 @@ class ProductLogic extends BaseLogic @@ -137,9 +135,7 @@ class ProductLogic extends BaseLogic
137 } 135 }
138 $param['attrs'] = Arr::a2s($param['attrs'] ?? ''); 136 $param['attrs'] = Arr::a2s($param['attrs'] ?? '');
139 $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); 137 $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? '');
140 - if(isset($param['category_id']) && !empty($param['category_id'])){  
141 - $param['category_id'] = $this->getLastCategory($param['category_id']);  
142 - } 138 + $param['category_id'] = $this->getLastCategory($param['category_id']);
143 if(isset($param['keyword_id']) && !empty($param['keyword_id'])){ 139 if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
144 $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).','; 140 $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).',';
145 } 141 }
@@ -166,11 +162,13 @@ class ProductLogic extends BaseLogic @@ -166,11 +162,13 @@ class ProductLogic extends BaseLogic
166 */ 162 */
167 public function getLastCategory($category){ 163 public function getLastCategory($category){
168 $str = ''; 164 $str = '';
169 - $cateModel = new Category();  
170 - foreach ($category as $v){  
171 - $info = $cateModel->read(['pid'=>$v]);  
172 - if($info === false){  
173 - $str .= $v.','; 165 + if(isset($category) && !empty($category)){
  166 + $cateModel = new Category();
  167 + foreach ($category as $v){
  168 + $info = $cateModel->read(['pid'=>$v]);
  169 + if($info === false){
  170 + $str .= $v.',';
  171 + }
174 } 172 }
175 } 173 }
176 return ','.$str; 174 return ','.$str;