|
...
|
...
|
@@ -36,6 +36,7 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
$v['category_name'] = trim($str,',');
|
|
|
|
return $this->success($v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :详情
|
|
|
|
* @return array
|
|
...
|
...
|
@@ -76,13 +77,15 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
if ($cate_info === false) {
|
|
|
|
//查看当前上一级分类下是否有新闻
|
|
|
|
$newsModel = new NewsModel();
|
|
|
|
$news_info = $newsModel->read(['category_id' => ['like', ',' . $this->param['pid'] . ',']]);
|
|
|
|
if ($news_info !== false) {
|
|
|
|
$replacement = ',' . $cate_id . ',';
|
|
|
|
$news_count = $newsModel->formatQuery(['category_id' => ['like', ',' . $this->param['pid'] . ',']])->count();
|
|
|
|
if ($news_count > 0) {
|
|
|
|
$replacement = ','. $this->param['pid'] .','. $cate_id . ',';
|
|
|
|
$old = ',' . $this->param['pid'] . ',';
|
|
|
|
//更新所有商品到当前分类
|
|
|
|
DB::table('gl_news')->where('category_id', 'like', '%' . $old . '%')
|
|
|
|
->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
|
|
|
|
//更新计数
|
|
|
|
$this->set_num($this->model,$cate_id,'add',$news_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
...
|
...
|
|