|  | @@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 | 
	
	
		
			
				|  | @@ -18,6 +19,8 @@ import com.zhongzheng.common.exception.CustomException;
 | 
	
		
			
				|  |  |  import com.zhongzheng.common.utils.DateUtils;
 | 
	
		
			
				|  |  |  import com.zhongzheng.common.utils.SecurityUtils;
 | 
	
		
			
				|  |  |  import com.zhongzheng.common.utils.ServletUtils;
 | 
	
		
			
				|  |  | +import com.zhongzheng.modules.order.domain.Order;
 | 
	
		
			
				|  |  | +import com.zhongzheng.modules.order.service.IOrderService;
 | 
	
		
			
				|  |  |  import com.zhongzheng.modules.system.bo.*;
 | 
	
		
			
				|  |  |  import com.zhongzheng.modules.system.domain.SysRoleMenu;
 | 
	
		
			
				|  |  |  import com.zhongzheng.modules.system.domain.SysTenant;
 | 
	
	
		
			
				|  | @@ -27,8 +30,11 @@ import com.zhongzheng.modules.system.service.*;
 | 
	
		
			
				|  |  |  import com.zhongzheng.modules.system.vo.SysTenantAccountVo;
 | 
	
		
			
				|  |  |  import com.zhongzheng.modules.system.vo.SysTenantBankAccountVo;
 | 
	
		
			
				|  |  |  import com.zhongzheng.modules.system.vo.SysTenantVo;
 | 
	
		
			
				|  |  | +import com.zhongzheng.modules.top.goods.domain.TopOldOrder;
 | 
	
		
			
				|  |  | +import com.zhongzheng.modules.top.goods.service.ITopOldOrderService;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.RandomStringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.context.annotation.Lazy;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Propagation;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
	
		
			
				|  | @@ -71,6 +77,15 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ISysDictTypeService iSysDictTypeService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    @Lazy
 | 
	
		
			
				|  |  | +    private ITopOldOrderService topOldOrderService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    @Lazy
 | 
	
		
			
				|  |  | +    private IOrderService orderService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public SysTenantVo queryById(Long tenantId){
 | 
	
		
			
				|  |  |          SysTenant db = this.baseMapper.selectById(tenantId);
 | 
	
	
		
			
				|  | @@ -80,7 +95,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<SysTenantVo> queryList(SysTenantQueryBo bo) {
 | 
	
		
			
				|  |  |          LambdaQueryWrapper<SysTenant> lqw = Wrappers.lambdaQuery();
 | 
	
		
			
				|  |  | -        lqw.eq(bo.getStatus() != null, SysTenant::getStatus, bo.getStatus());
 | 
	
		
			
				|  |  | +        lqw.ne(SysTenant::getStatus, -1);
 | 
	
		
			
				|  |  |          lqw.like(StrUtil.isNotBlank(bo.getTenantName()), SysTenant::getTenantName, bo.getTenantName());
 | 
	
		
			
				|  |  |          return entity2Vo(this.list(lqw));
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -455,6 +470,23 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
 | 
	
		
			
				|  |  |          return updateById(tenant);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public boolean deleteTopTenant(SysTopTenantEditBo bo) {
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isEmpty(bo.getTenantIds())){
 | 
	
		
			
				|  |  | +            throw new CustomException("参数错误");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for (Long tenantId : bo.getTenantIds()) {
 | 
	
		
			
				|  |  | +            int count = topOldOrderService.count(new LambdaQueryWrapper<TopOldOrder>().eq(TopOldOrder::getTenantId, tenantId));
 | 
	
		
			
				|  |  | +            int num = orderService.count(new LambdaQueryWrapper<Order>().eq(Order::getTenantId, tenantId));
 | 
	
		
			
				|  |  | +            if (count > 0 || num > 0){
 | 
	
		
			
				|  |  | +                throw new CustomException("机构已有订单信息,请勿删除!");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return update(new LambdaUpdateWrapper<SysTenant>()
 | 
	
		
			
				|  |  | +        .in(SysTenant::getTenantId,bo.getTenantIds())
 | 
	
		
			
				|  |  | +        .set(SysTenant::getStatus,-1));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private void initRoles(Long newTenantId,Long tenantId) {
 | 
	
		
			
				|  |  |          List<String> roleKey = new ArrayList<>();
 | 
	
		
			
				|  |  |          roleKey.add("seller");
 |