作者 lyh

gx

@@ -152,18 +152,16 @@ class NewsLogic extends BaseLogic @@ -152,18 +152,16 @@ class NewsLogic extends BaseLogic
152 * @method 152 * @method
153 */ 153 */
154 public function newsDel(){ 154 public function newsDel(){
155 - $ids = $this->param['id'];  
156 DB::beginTransaction(); 155 DB::beginTransaction();
157 try { 156 try {
158 - $this->param['id'] = ['in',$this->param['id']];  
159 - $this->model->del($this->param);  
160 - foreach ($ids as $id){ 157 + foreach ($this->param['id'] as $id){
161 $this->delRoute($id); 158 $this->delRoute($id);
  159 + $this->model->del(['id'=>$id]);
162 } 160 }
163 DB::commit(); 161 DB::commit();
164 }catch (Exception $e){ 162 }catch (Exception $e){
165 DB::rollBack(); 163 DB::rollBack();
166 - $this->fail('当前数据不存在'); 164 + $this->fail('error');
167 } 165 }
168 return $this->success(); 166 return $this->success();
169 } 167 }
@@ -124,8 +124,8 @@ class ProductLogic extends BaseLogic @@ -124,8 +124,8 @@ class ProductLogic extends BaseLogic
124 * @time :2023/8/21 17:11 124 * @time :2023/8/21 17:11
125 */ 125 */
126 public function productDelete(){ 126 public function productDelete(){
127 -// DB::beginTransaction();  
128 -// try { 127 + DB::beginTransaction();
  128 + try {
129 foreach ($this->param['ids'] as $k => $id) { 129 foreach ($this->param['ids'] as $k => $id) {
130 $info = $this->model->read(['id'=>$id]); 130 $info = $this->model->read(['id'=>$id]);
131 if($info['status'] == Product::STATUS_RECYCLE){ 131 if($info['status'] == Product::STATUS_RECYCLE){
@@ -138,12 +138,11 @@ class ProductLogic extends BaseLogic @@ -138,12 +138,11 @@ class ProductLogic extends BaseLogic
138 $this->model->edit(['status'=>Product::STATUS_RECYCLE],['id'=>$id]); 138 $this->model->edit(['status'=>Product::STATUS_RECYCLE],['id'=>$id]);
139 } 139 }
140 } 140 }
141 -// DB::commit();  
142 -// }catch (\Exception $e){  
143 -// DB::rollBack();  
144 -// $this->fail('删除失败');  
145 -// }  
146 - 141 + DB::commit();
  142 + }catch (\Exception $e){
  143 + DB::rollBack();
  144 + $this->fail('删除失败');
  145 + }
147 return $this->success(); 146 return $this->success();
148 } 147 }
149 148