作者 lyh

gx

@@ -95,7 +95,7 @@ class ProductLogic extends BaseLogic @@ -95,7 +95,7 @@ class ProductLogic extends BaseLogic
95 public function handleCategory(){ 95 public function handleCategory(){
96 $category_ids = []; 96 $category_ids = [];
97 if(isset($this->param['category_id']) && !empty($this->param['category_id'])) { 97 if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
98 - $category_ids = $this->getLastCategoryArr($this->param['category_id']); 98 + $category_ids = $this->param['category_id'];
99 $this->param['category_id'] = ','.implode(',',$category_ids).','; 99 $this->param['category_id'] = ','.implode(',',$category_ids).',';
100 }else{ 100 }else{
101 $this->param['category_id'] = ''; 101 $this->param['category_id'] = '';
@@ -176,7 +176,7 @@ class ProductLogic extends BaseLogic @@ -176,7 +176,7 @@ class ProductLogic extends BaseLogic
176 * @time :2023/10/26 9:49 176 * @time :2023/10/26 9:49
177 */ 177 */
178 public function editList(){ 178 public function editList(){
179 - $this->param['category_id'] = $this->getLastCategory($this->param['category_id']); 179 + $this->param['category_id'] = $this->handleListCategory($this->param['category_id']);
180 $this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']); 180 $this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']);
181 if(isset($this->param['gallery']) && !empty($this->param['gallery'])){ 181 if(isset($this->param['gallery']) && !empty($this->param['gallery'])){
182 foreach ($this->param['gallery'] as $k => $v){ 182 foreach ($this->param['gallery'] as $k => $v){
@@ -186,7 +186,7 @@ class ProductLogic extends BaseLogic @@ -186,7 +186,7 @@ class ProductLogic extends BaseLogic
186 $this->param['thumb'] = Arr::a2s($this->param['gallery'][0] ?? []); 186 $this->param['thumb'] = Arr::a2s($this->param['gallery'][0] ?? []);
187 $this->param['gallery'] = Arr::a2s($this->param['gallery'] ?? []); 187 $this->param['gallery'] = Arr::a2s($this->param['gallery'] ?? []);
188 }else{ 188 }else{
189 - $this->param['thumb'] = Arr::a2s([]); 189 + unset($this->param['thumb']);
190 } 190 }
191 try { 191 try {
192 if(isset($this->param['route']) && !empty($this->param['route'])){ 192 if(isset($this->param['route']) && !empty($this->param['route'])){
@@ -195,7 +195,7 @@ class ProductLogic extends BaseLogic @@ -195,7 +195,7 @@ class ProductLogic extends BaseLogic
195 } 195 }
196 $this->model->edit($this->param,['id'=>$this->param['id']]); 196 $this->model->edit($this->param,['id'=>$this->param['id']]);
197 }catch (\Exception $e){ 197 }catch (\Exception $e){
198 - $this->fail('系统错误,请连续管理员');; 198 + $this->fail('系统错误,请连续管理员');
199 } 199 }
200 return $this->success(); 200 return $this->success();
201 } 201 }
@@ -276,24 +276,20 @@ class ProductLogic extends BaseLogic @@ -276,24 +276,20 @@ class ProductLogic extends BaseLogic
276 } 276 }
277 277
278 /** 278 /**
279 - * @remark :获取最后一级分类id(字符串) 279 + * @remark :列表标记处理分类(字符串)
280 * @name :getLastCategory 280 * @name :getLastCategory
281 * @author :lyh 281 * @author :lyh
282 * @method :post 282 * @method :post
283 * @time :2023/10/20 9:02 283 * @time :2023/10/20 9:02
284 */ 284 */
285 - public function getLastCategory($category){ 285 + public function handleListCategory($category){
286 $str = ''; 286 $str = '';
287 if(isset($category) && !empty($category)){ 287 if(isset($category) && !empty($category)){
288 - $cateModel = new Category();  
289 foreach ($category as $v){ 288 foreach ($category as $v){
290 - $info = $cateModel->read(['pid'=>$v]);  
291 - if($info === false){  
292 $str .= $v.','; 289 $str .= $v.',';
293 } 290 }
294 } 291 }
295 - }  
296 - return ','.$str; 292 + return !empty($str) ? ','.$str : '';
297 } 293 }
298 294
299 /** 295 /**
@@ -306,14 +302,10 @@ class ProductLogic extends BaseLogic @@ -306,14 +302,10 @@ class ProductLogic extends BaseLogic
306 public function getLastCategoryArr($category){ 302 public function getLastCategoryArr($category){
307 $arr = []; 303 $arr = [];
308 if(isset($category) && !empty($category)){ 304 if(isset($category) && !empty($category)){
309 - $cateModel = new Category();  
310 foreach ($category as $v){ 305 foreach ($category as $v){
311 - $info = $cateModel->read(['pid'=>$v]);  
312 - if($info === false){  
313 $arr[] = $v; 306 $arr[] = $v;
314 } 307 }
315 } 308 }
316 - }  
317 return $arr; 309 return $arr;
318 } 310 }
319 311