作者 lyh

gx

... ... @@ -125,6 +125,13 @@ class ProductController extends BaseController
}
/**
* @remark :根据状态获取数量
* @name :getStatusNumber
* @author :lyh
* @method :post
* @time :2023/8/21 18:33
*/
public function getStatusNumber(ProductLogic $logic){
$data = $logic->getStatusNumber();
$this->response('success',Code::SUCCESS,$data);
... ...
... ... @@ -242,7 +242,7 @@ class BlogCategoryLogic extends BaseLogic
$replacement = ','. $this->param['pid'] . ',' . $cate_id . ',';
$old = ',' . $this->param['pid'] . ',';
//更新所有商品到当前分类
DB::table('gl_Blog')->where('category_id', 'like', '%' . $old . '%')
$blogModel->where('category_id', 'like', '%' . $old . '%')
->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
}
}
... ...
... ... @@ -243,7 +243,7 @@ class NewsCategoryLogic extends BaseLogic
$replacement = ','. $this->param['pid'] .','. $cate_id . ',';
$old = ',' . $this->param['pid'] . ',';
//更新所有商品到当前分类
DB::table('gl_news')->where('category_id', 'like', '%' . $old . '%')
$newsModel->where('category_id', 'like', '%' . $old . '%')
->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
}
}
... ...
... ... @@ -66,8 +66,8 @@ class CategoryLogic extends BaseLogic
* @time :2023/8/21 17:14
*/
public function categorySave(){
DB::beginTransaction();
try {
// DB::beginTransaction();
// try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->handleEditParam($this->param);
$id = $this->param['id'];
... ... @@ -78,11 +78,11 @@ class CategoryLogic extends BaseLogic
}
//路由映射
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
DB::commit();
} catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败');
}
// DB::commit();
// } catch (\Exception $e){
// DB::rollBack();
// $this->fail('保存失败');
// }
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]);
return $this->success();
... ... @@ -102,12 +102,28 @@ class CategoryLogic extends BaseLogic
$info = $this->model->read(['id'=>$param['id']]);
$sub_info = $this->model->read(['pid'=>$param['id']]);
if(($info['pid'] != $param['pid']) && ($sub_info != false)){
$this->fail('当前分类拥有字分类,不允许修改上级分类');
$this->fail('当前分类拥有子分类,不允许修改上级分类');
}
$productModel = new Product();
$product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]);
if($product_info !== false){
$this->fail('当前产品分类拥有产品不允许编辑上级分类');
}
return true;
}
/**
* @remark :添加时处理分类
* @name :handleAddParam
* @author :lyh
* @method :post
* @time :2023/8/21 18:34
*/
public function handleAddParam(){
}
/**
* @remark :删除
* @name :delete
* @author :lyh
... ... @@ -124,7 +140,6 @@ class CategoryLogic extends BaseLogic
if(!$info){
continue;
}
//是否有子分类
if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){
$this->fail("分类{$info['title']}存在子分类,不能删除");
... ...
... ... @@ -27,6 +27,13 @@ class ProductLogic extends BaseLogic
$this->model = new Product();
}
/**
* @remark :保存产品
* @name :productSave
* @author :lyh
* @method :post
* @time :2023/8/21 18:35
*/
public function productSave(){
$this->param = $this->handleSaveParam($this->param);
DB::beginTransaction();
... ...