作者 lyh

gx

@@ -133,12 +133,9 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -133,12 +133,9 @@ class CustomModuleCategoryLogic extends BaseLogic
133 $id = $this->model->addReturnId($this->param); 133 $id = $this->model->addReturnId($this->param);
134 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE, 134 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE,
135 $id, $this->user['project_id']); 135 $id, $this->user['project_id']);
136 - $this->handleAddSon($id);  
137 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE,$route); 136 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE,$route);
138 $this->curlDelRoute(['new_route'=>$route]); 137 $this->curlDelRoute(['new_route'=>$route]);
139 $this->edit(['route' => $route], ['id' => $id]); 138 $this->edit(['route' => $route], ['id' => $id]);
140 - //处理上级分类商品  
141 - $this->handleAddSon($id);  
142 }catch (\Exception $e){ 139 }catch (\Exception $e){
143 $this->fail('系统错误,请联系管理员'); 140 $this->fail('系统错误,请联系管理员');
144 } 141 }
@@ -155,7 +152,6 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -155,7 +152,6 @@ class CustomModuleCategoryLogic extends BaseLogic
155 public function categoryEdit(){ 152 public function categoryEdit(){
156 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE, 153 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE,
157 $this->param['id'], $this->user['project_id']); 154 $this->param['id'], $this->user['project_id']);
158 - $this->editHandleCategory($this->param['id'],$this->param['pid']);  
159 $this->editRoute($this->param['id'],$route); 155 $this->editRoute($this->param['id'],$route);
160 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 156 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
161 if($rs === false){ 157 if($rs === false){
@@ -165,48 +161,6 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -165,48 +161,6 @@ class CustomModuleCategoryLogic extends BaseLogic
165 } 161 }
166 162
167 /** 163 /**
168 - * @remark :编辑分类,处理博客数据  
169 - * @name :editCategory  
170 - * @author :lyh  
171 - * @method :post  
172 - * @time :2023/10/20 9:32  
173 - */  
174 - public function editHandleCategory($id,$pid){  
175 - $info = $this->model->read(['id'=>$id],['id','pid']);  
176 - if($info['pid'] != $pid){  
177 - //修改勒上级,先查看上级是否拥有产品  
178 - $contentModel = new CustomModuleContent();  
179 - $contentCount = $contentModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();  
180 - if($contentCount > 0){  
181 - //随机获取最后一级id  
182 - $replacement = $this->getLastId($id);  
183 - //存在博客时,移动所有博客到当前分类最后一级  
184 - $contentModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')  
185 - ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);  
186 - $contentModel->where('category_id', 'like', '%,' . $pid . ',%')  
187 - ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);  
188 - }  
189 - }  
190 - return $this->success();  
191 - }  
192 -  
193 - /**  
194 - * @remark :随机获取当前id下最后一级的id  
195 - * @name :getLastId  
196 - * @author :lyh  
197 - * @method :post  
198 - * @time :2023/10/20 9:45  
199 - */  
200 - public function getLastId($id){  
201 - $info = $this->model->read(['pid'=>$id],['id']);  
202 - if($info !== false){  
203 - return $this->getLastId($info['id']);  
204 - }else{  
205 - return $id;  
206 - }  
207 - }  
208 -  
209 - /**  
210 * @remark :查看是否编辑路由 164 * @remark :查看是否编辑路由
211 * @name :editCategoryRoute 165 * @name :editCategoryRoute
212 * @author :lyh 166 * @author :lyh
@@ -225,46 +179,6 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -225,46 +179,6 @@ class CustomModuleCategoryLogic extends BaseLogic
225 } 179 }
226 180
227 /** 181 /**
228 - * @name :(添加分类时处理子集分类)addProcessingSon  
229 - * @author :lyh  
230 - * @method :post  
231 - * @time :2023/6/13 11:34  
232 - */  
233 - public function handleAddSon($cate_id){  
234 - if(isset($this->param['pid']) && !empty($this->param['pid'])) {  
235 - $this->param['pid'] = 0;  
236 - }  
237 - //判断为子分类时  
238 - if($this->param['pid'] != 0) {  
239 - //查看当前上级分类下是否有其他分类  
240 - $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]],['id']);  
241 - if ($cate_info === false) {  
242 - //查看当前上一级分类下是否有关联模块内容  
243 - $contentModel = new CustomModuleContent();  
244 - $news_count = $contentModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();  
245 - if ($news_count > 0) {  
246 - $replacement = $this->handleStr($cate_id);  
247 - $old = $this->handleStr($this->param['pid']);  
248 - //更新所有商品到当前分类  
249 - $contentModel->where('category_id', 'like', '%' . $old . '%')->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);  
250 - }  
251 - }  
252 - }  
253 - return $this->success();  
254 - }  
255 -  
256 - /**  
257 - * @remark :处理字符串  
258 - * @name :handleStr  
259 - * @author :lyh  
260 - * @method :post  
261 - * @time :2023/12/5 18:03  
262 - */  
263 - public function handleStr($str){  
264 - return ',' . $str . ',';  
265 - }  
266 -  
267 - /**  
268 * @remark :删除数据 182 * @remark :删除数据
269 * @name :ModuleDel 183 * @name :ModuleDel
270 * @author :lyh 184 * @author :lyh
@@ -192,7 +192,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -192,7 +192,7 @@ class CustomModuleContentLogic extends BaseLogic
192 $param['project_id'] = $this->user['project_id']; 192 $param['project_id'] = $this->user['project_id'];
193 } 193 }
194 if(isset($param['category_id']) && !empty($param['category_id'])){ 194 if(isset($param['category_id']) && !empty($param['category_id'])){
195 - $param['category_id'] = $this->getLastCategory($param['category_id']); 195 + $param['category_id'] = $this->getCategory($param['category_id']);
196 } 196 }
197 if(isset($param['image']) && !empty($param['image'])){ 197 if(isset($param['image']) && !empty($param['image'])){
198 $param['image'] = str_replace_url($param['image']); 198 $param['image'] = str_replace_url($param['image']);
@@ -219,15 +219,14 @@ class CustomModuleContentLogic extends BaseLogic @@ -219,15 +219,14 @@ class CustomModuleContentLogic extends BaseLogic
219 } 219 }
220 220
221 /** 221 /**
222 - * @remark :获取最后一级分类id 222 + * @remark :处理分类
223 * @name :getLastCategory 223 * @name :getLastCategory
224 * @author :lyh 224 * @author :lyh
225 * @method :post 225 * @method :post
226 * @time :2023/10/20 9:02 226 * @time :2023/10/20 9:02
227 */ 227 */
228 - public function getLastCategory($category){ 228 + public function getCategory($category){
229 $str = ''; 229 $str = '';
230 - $cateModel = new CustomModuleCategory();  
231 foreach ($category as $v){ 230 foreach ($category as $v){
232 $str .= $v.','; 231 $str .= $v.',';
233 } 232 }