作者 lyh

gx

@@ -125,6 +125,13 @@ class ProductController extends BaseController @@ -125,6 +125,13 @@ class ProductController extends BaseController
125 } 125 }
126 126
127 127
  128 + /**
  129 + * @remark :根据状态获取数量
  130 + * @name :getStatusNumber
  131 + * @author :lyh
  132 + * @method :post
  133 + * @time :2023/8/21 18:33
  134 + */
128 public function getStatusNumber(ProductLogic $logic){ 135 public function getStatusNumber(ProductLogic $logic){
129 $data = $logic->getStatusNumber(); 136 $data = $logic->getStatusNumber();
130 $this->response('success',Code::SUCCESS,$data); 137 $this->response('success',Code::SUCCESS,$data);
@@ -242,7 +242,7 @@ class BlogCategoryLogic extends BaseLogic @@ -242,7 +242,7 @@ class BlogCategoryLogic extends BaseLogic
242 $replacement = ','. $this->param['pid'] . ',' . $cate_id . ','; 242 $replacement = ','. $this->param['pid'] . ',' . $cate_id . ',';
243 $old = ',' . $this->param['pid'] . ','; 243 $old = ',' . $this->param['pid'] . ',';
244 //更新所有商品到当前分类 244 //更新所有商品到当前分类
245 - DB::table('gl_Blog')->where('category_id', 'like', '%' . $old . '%') 245 + $blogModel->where('category_id', 'like', '%' . $old . '%')
246 ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); 246 ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
247 } 247 }
248 } 248 }
@@ -243,7 +243,7 @@ class NewsCategoryLogic extends BaseLogic @@ -243,7 +243,7 @@ class NewsCategoryLogic extends BaseLogic
243 $replacement = ','. $this->param['pid'] .','. $cate_id . ','; 243 $replacement = ','. $this->param['pid'] .','. $cate_id . ',';
244 $old = ',' . $this->param['pid'] . ','; 244 $old = ',' . $this->param['pid'] . ',';
245 //更新所有商品到当前分类 245 //更新所有商品到当前分类
246 - DB::table('gl_news')->where('category_id', 'like', '%' . $old . '%') 246 + $newsModel->where('category_id', 'like', '%' . $old . '%')
247 ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); 247 ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
248 } 248 }
249 } 249 }
@@ -66,8 +66,8 @@ class CategoryLogic extends BaseLogic @@ -66,8 +66,8 @@ class CategoryLogic extends BaseLogic
66 * @time :2023/8/21 17:14 66 * @time :2023/8/21 17:14
67 */ 67 */
68 public function categorySave(){ 68 public function categorySave(){
69 - DB::beginTransaction();  
70 - try { 69 +// DB::beginTransaction();
  70 +// try {
71 if(isset($this->param['id']) && !empty($this->param['id'])){ 71 if(isset($this->param['id']) && !empty($this->param['id'])){
72 $this->handleEditParam($this->param); 72 $this->handleEditParam($this->param);
73 $id = $this->param['id']; 73 $id = $this->param['id'];
@@ -78,11 +78,11 @@ class CategoryLogic extends BaseLogic @@ -78,11 +78,11 @@ class CategoryLogic extends BaseLogic
78 } 78 }
79 //路由映射 79 //路由映射
80 $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); 80 $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
81 - DB::commit();  
82 - } catch (\Exception $e){  
83 - DB::rollBack();  
84 - $this->fail('保存失败');  
85 - } 81 +// DB::commit();
  82 +// } catch (\Exception $e){
  83 +// DB::rollBack();
  84 +// $this->fail('保存失败');
  85 +// }
86 //通知更新 86 //通知更新
87 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]); 87 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]);
88 return $this->success(); 88 return $this->success();
@@ -102,12 +102,28 @@ class CategoryLogic extends BaseLogic @@ -102,12 +102,28 @@ class CategoryLogic extends BaseLogic
102 $info = $this->model->read(['id'=>$param['id']]); 102 $info = $this->model->read(['id'=>$param['id']]);
103 $sub_info = $this->model->read(['pid'=>$param['id']]); 103 $sub_info = $this->model->read(['pid'=>$param['id']]);
104 if(($info['pid'] != $param['pid']) && ($sub_info != false)){ 104 if(($info['pid'] != $param['pid']) && ($sub_info != false)){
105 - $this->fail('当前分类拥有字分类,不允许修改上级分类'); 105 + $this->fail('当前分类拥有子分类,不允许修改上级分类');
  106 + }
  107 + $productModel = new Product();
  108 + $product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]);
  109 + if($product_info !== false){
  110 + $this->fail('当前产品分类拥有产品不允许编辑上级分类');
106 } 111 }
107 return true; 112 return true;
108 } 113 }
109 114
110 /** 115 /**
  116 + * @remark :添加时处理分类
  117 + * @name :handleAddParam
  118 + * @author :lyh
  119 + * @method :post
  120 + * @time :2023/8/21 18:34
  121 + */
  122 + public function handleAddParam(){
  123 +
  124 + }
  125 +
  126 + /**
111 * @remark :删除 127 * @remark :删除
112 * @name :delete 128 * @name :delete
113 * @author :lyh 129 * @author :lyh
@@ -124,7 +140,6 @@ class CategoryLogic extends BaseLogic @@ -124,7 +140,6 @@ class CategoryLogic extends BaseLogic
124 if(!$info){ 140 if(!$info){
125 continue; 141 continue;
126 } 142 }
127 -  
128 //是否有子分类 143 //是否有子分类
129 if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){ 144 if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){
130 $this->fail("分类{$info['title']}存在子分类,不能删除"); 145 $this->fail("分类{$info['title']}存在子分类,不能删除");
@@ -27,6 +27,13 @@ class ProductLogic extends BaseLogic @@ -27,6 +27,13 @@ class ProductLogic extends BaseLogic
27 $this->model = new Product(); 27 $this->model = new Product();
28 } 28 }
29 29
  30 + /**
  31 + * @remark :保存产品
  32 + * @name :productSave
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2023/8/21 18:35
  36 + */
30 public function productSave(){ 37 public function productSave(){
31 $this->param = $this->handleSaveParam($this->param); 38 $this->param = $this->handleSaveParam($this->param);
32 DB::beginTransaction(); 39 DB::beginTransaction();