作者 lyh

gx

... ... @@ -95,7 +95,7 @@ class ProductLogic extends BaseLogic
public function handleCategory(){
$category_ids = [];
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
$category_ids = $this->getLastCategoryArr($this->param['category_id']);
$category_ids = $this->param['category_id'];
$this->param['category_id'] = ','.implode(',',$category_ids).',';
}else{
$this->param['category_id'] = '';
... ... @@ -176,7 +176,7 @@ class ProductLogic extends BaseLogic
* @time :2023/10/26 9:49
*/
public function editList(){
$this->param['category_id'] = $this->getLastCategory($this->param['category_id']);
$this->param['category_id'] = $this->handleListCategory($this->param['category_id']);
$this->param['keyword_id'] = $this->saveKeyword($this->param['keyword_id']);
if(isset($this->param['gallery']) && !empty($this->param['gallery'])){
foreach ($this->param['gallery'] as $k => $v){
... ... @@ -186,7 +186,7 @@ class ProductLogic extends BaseLogic
$this->param['thumb'] = Arr::a2s($this->param['gallery'][0] ?? []);
$this->param['gallery'] = Arr::a2s($this->param['gallery'] ?? []);
}else{
$this->param['thumb'] = Arr::a2s([]);
unset($this->param['thumb']);
}
try {
if(isset($this->param['route']) && !empty($this->param['route'])){
... ... @@ -195,7 +195,7 @@ class ProductLogic extends BaseLogic
}
$this->model->edit($this->param,['id'=>$this->param['id']]);
}catch (\Exception $e){
$this->fail('系统错误,请连续管理员');;
$this->fail('系统错误,请连续管理员');
}
return $this->success();
}
... ... @@ -276,24 +276,20 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :获取最后一级分类id(字符串)
* @remark :列表标记处理分类(字符串)
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
public function handleListCategory($category){
$str = '';
if(isset($category) && !empty($category)){
$cateModel = new Category();
foreach ($category as $v){
$info = $cateModel->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
$str .= $v.',';
}
}
return ','.$str;
return !empty($str) ? ','.$str : '';
}
/**
... ... @@ -306,12 +302,8 @@ class ProductLogic extends BaseLogic
public function getLastCategoryArr($category){
$arr = [];
if(isset($category) && !empty($category)){
$cateModel = new Category();
foreach ($category as $v){
$info = $cateModel->read(['pid'=>$v]);
if($info === false){
$arr[] = $v;
}
$arr[] = $v;
}
}
return $arr;
... ...