From 221c873ee48ed5f44680578d32b0bbf19fd9e4c1 Mon Sep 17 00:00:00 2001
From: weimingfei <fei_gaming@sina.com>
Date: 星期六, 18 十月 2025 15:23:59 +0800
Subject: [PATCH] 钥匙柜

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
index 5bb5632..b89b1b5 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
@@ -3,6 +3,8 @@
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
+import com.doumee.dao.business.JkLineMapper;
+import com.doumee.dao.business.model.JkLine;
 import com.doumee.service.business.third.model.LoginUserInfo;
 import com.doumee.service.business.third.model.PageData;
 import com.doumee.service.business.third.model.PageWrap;
@@ -44,6 +46,8 @@
     private SystemDictDataBiz systemDictDataBiz;
     @Autowired
     private CategoryMapper categoryMapper;
+    @Autowired
+    private JkLineMapper jkLineMapper;
 
     @Override
     @Transactional(rollbackFor = {Exception.class, BindException.class})
@@ -81,6 +85,17 @@
 
     @Override
     public void deleteById(Integer id) {
+        Category c = categoryMapper.selectById(id);
+        if(c == null||Constants.equalsInteger(c.getIsdeleted(),Constants.ONE)){
+            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        if(Constants.equalsInteger(c.getType(),Constants.FOUR)){
+            //濡傛灉鏄柊绾胯矾锛屾鏌ユ槸鍚︽湁瀛愮嚎璺紝鏈夊垯涓嶅厑璁稿垹闄�
+            if(jkLineMapper.selectCount(new MPJLambdaWrapper<JkLine>().eq(JkLine::getIsdeleted,Constants.ZERO)
+                    .eq(JkLine::getCategoryId,id)) >0){
+                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓荤嚎璺��"+c.getName()+"銆戜笅宸插瓨鍦ㄥ瓙绾胯矾锛屼笉鍏佽鍒犻櫎锛�");
+            }
+        }
         categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE)
                 .eq(Category::getId,id)
         );
@@ -97,7 +112,20 @@
         if (CollectionUtils.isEmpty(ids)) {
             return;
         }
-        categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE)
+        for(Integer id :ids){
+            Category c = categoryMapper.selectById(id);
+            if(c == null ||Constants.equalsInteger(c.getIsdeleted(),Constants.ONE)){
+                continue;
+            }
+            if(Constants.equalsInteger(c.getType(),Constants.FOUR)){
+                //濡傛灉鏄柊绾胯矾锛屾鏌ユ槸鍚︽湁瀛愮嚎璺紝鏈夊垯涓嶅厑璁稿垹闄�
+                if(jkLineMapper.selectCount(new MPJLambdaWrapper<JkLine>().eq(JkLine::getIsdeleted,Constants.ZERO)
+                        .eq(JkLine::getCategoryId,id)) >0){
+                    throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓荤嚎璺��"+c.getName()+"銆戜笅宸插瓨鍦ㄥ瓙绾胯矾锛屼笉鍏佽鍒犻櫎锛�");
+                }
+            }
+        }
+       categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE)
                 .in(Category::getId,ids)
         );
     }
@@ -167,7 +195,7 @@
             //濡傛灉鏄富绾胯矾锛屾煡璇㈢嚎璺暟鍜屽鎴锋暟
             queryWrapper.select( "(select count(1) from jk_line b where b.isdeleted=0 and b.CATEGORY_ID = t.id)",Category::getLineNum);
             queryWrapper.select( "(select count(1) from jk_customer b left join jk_line c on b.line_id=c.id where c.isdeleted=0 and b.isdeleted=0 and c.CATEGORY_ID = t.id)",Category::getCustomerNum);
-            queryWrapper.select( "(select count(1) from jk_customer b left join jk_line c on b.line_id=c.id where c.isdeleted=0 and b.isdeleted=0 and c.CATEGORY_ID = t.id b.DISTANCE_STATUS = 1)",Category::getCustomerDoneNum);
+            queryWrapper.select( "(select count(1) from jk_customer b left join jk_line c on b.line_id=c.id where c.isdeleted=0 and b.isdeleted=0 and c.CATEGORY_ID = t.id and b.DISTANCE_STATUS = 1)",Category::getCustomerDoneNum);
         }
         queryWrapper.eq(Category::getIsdeleted,Constants.ZERO)
                 .eq(Objects.nonNull(pageWrap.getModel().getType()),Category::getType,pageWrap.getModel().getType())

--
Gitblit v1.9.3