|  | @@ -3,7 +3,12 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 | 
											
												
													
														|  |  import com.alibaba.fastjson.JSON;
 |  |  import com.alibaba.fastjson.JSON;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.biz.dal.entity.SysArea;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.biz.dal.service.SysAreaService;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.common.entity.HttpResponseResult;
 | 
											
												
													
														|  | 
 |  | +import com.yonge.toolset.base.exception.BizException;
 | 
											
												
													
														|  |  import org.apache.commons.collections.CollectionUtils;
 |  |  import org.apache.commons.collections.CollectionUtils;
 | 
											
												
													
														|  | 
 |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Service;
 |  |  import org.springframework.stereotype.Service;
 | 
											
												
													
														|  |  import org.springframework.beans.BeanUtils;
 |  |  import org.springframework.beans.BeanUtils;
 | 
											
												
													
														|  |  import lombok.extern.slf4j.Slf4j;
 |  |  import lombok.extern.slf4j.Slf4j;
 | 
											
										
											
												
													
														|  | @@ -12,9 +17,7 @@ import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.mapper.TenantInfoMapper;
 |  |  import com.yonge.cooleshow.biz.dal.mapper.TenantInfoMapper;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 |  |  import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -import java.util.HashMap;
 |  | 
 | 
											
												
													
														|  | -import java.util.List;
 |  | 
 | 
											
												
													
														|  | -import java.util.Map;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import java.util.*;
 | 
											
												
													
														|  |  import java.util.stream.Collectors;
 |  |  import java.util.stream.Collectors;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
										
											
												
													
														|  | @@ -24,6 +27,13 @@ import java.util.stream.Collectors;
 | 
											
												
													
														|  |  @Slf4j
 |  |  @Slf4j
 | 
											
												
													
														|  |  @Service
 |  |  @Service
 | 
											
												
													
														|  |  public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantInfo> implements TenantInfoService {
 |  |  public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantInfo> implements TenantInfoService {
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    SysAreaService sysAreaService;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    TenantInfoMapper tenantInfoMapper;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	/**
 |  |  	/**
 | 
											
												
													
														|  |       * 查询详情
 |  |       * 查询详情
 | 
											
										
											
												
													
														|  | @@ -46,32 +56,60 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
 | 
											
												
													
														|  |       * @return IPage<TenantInfo>
 |  |       * @return IPage<TenantInfo>
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  | -    public IPage<TenantInfo> selectPage(IPage<TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query) {
 |  | 
 | 
											
												
													
														|  | -        
 |  | 
 | 
											
												
													
														|  | -        return page.setRecords(baseMapper.selectPage(page, query));
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public IPage<TenantInfoWrapper.TenantInfo> selectPage(IPage<TenantInfoWrapper.TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query) {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        //分页查询
 | 
											
												
													
														|  | 
 |  | +        List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectPage(page, query);
 | 
											
												
													
														|  | 
 |  | +        //获取省市区信息
 | 
											
												
													
														|  | 
 |  | +        List<Integer> areaCodeList = tenantInfos.stream().map(next -> {
 | 
											
												
													
														|  | 
 |  | +            Set<Integer> codes = new HashSet<>();
 | 
											
												
													
														|  | 
 |  | +            codes.add(next.getCityCode());
 | 
											
												
													
														|  | 
 |  | +            codes.add(next.getProvinceCode());
 | 
											
												
													
														|  | 
 |  | +            codes.add(next.getRegionCode());
 | 
											
												
													
														|  | 
 |  | +            return codes;
 | 
											
												
													
														|  | 
 |  | +        }).flatMap(Collection::stream).filter(Objects::nonNull).distinct().collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        Map<Integer, String> codeNameMap = new HashMap<>();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        if (!CollectionUtils.isEmpty(areaCodeList)) {
 | 
											
												
													
														|  | 
 |  | +            List<SysArea> sysAreaList = sysAreaService.queryByCodes(areaCodeList);
 | 
											
												
													
														|  | 
 |  | +            codeNameMap = sysAreaList.stream().collect(Collectors.toMap(SysArea::getCode,
 | 
											
												
													
														|  | 
 |  | +                    SysArea::getName));
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        for (TenantInfoWrapper.TenantInfo next : tenantInfos) {
 | 
											
												
													
														|  | 
 |  | +            next.setProvinceName(codeNameMap.getOrDefault(next.getProvinceCode(), ""));
 | 
											
												
													
														|  | 
 |  | +            next.setCityName(codeNameMap.getOrDefault(next.getCityCode(), ""));
 | 
											
												
													
														|  | 
 |  | +            next.setRegionName(codeNameMap.getOrDefault(next.getRegionCode(), ""));
 | 
											
												
													
														|  | 
 |  | +//            next.setSchoolName(schoolIdNameMap.getOrDefault(next.getSchoolId(), ""));
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return page.setRecords(tenantInfos);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -	
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  |       * 添加
 |  |       * 添加
 | 
											
												
													
														|  |       * @param tenantInfo TenantInfoWrapper.TenantInfo
 |  |       * @param tenantInfo TenantInfoWrapper.TenantInfo
 | 
											
												
													
														|  |       * @return Boolean
 |  |       * @return Boolean
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  | 
 |  | +    public HttpResponseResult<Boolean> add(TenantInfo tenantInfo) {
 | 
											
												
													
														|  | 
 |  | +        Boolean bool = tenantInfoMapper.insertInfo(tenantInfo);
 | 
											
												
													
														|  | 
 |  | +        return HttpResponseResult.succeed(bool);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +	
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    /*@Override
 | 
											
												
													
														|  |      public Boolean add(TenantInfoWrapper.TenantInfo tenantInfo) {    	
 |  |      public Boolean add(TenantInfoWrapper.TenantInfo tenantInfo) {    	
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  |          return this.save(JSON.parseObject(tenantInfo.jsonString(), TenantInfo.class));
 |  |          return this.save(JSON.parseObject(tenantInfo.jsonString(), TenantInfo.class));
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | 
 |  | +    }*/
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    /**
 |  | 
 | 
											
												
													
														|  | -     * 更新
 |  | 
 | 
											
												
													
														|  | -     * @param tenantInfo TenantInfoWrapper.TenantInfo
 |  | 
 | 
											
												
													
														|  | -     * @return Boolean
 |  | 
 | 
											
												
													
														|  | -     */
 |  | 
 | 
											
												
													
														|  | -    @Override
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    /*@Override
 | 
											
												
													
														|  |      public Boolean update(TenantInfoWrapper.TenantInfo tenantInfo){
 |  |      public Boolean update(TenantInfoWrapper.TenantInfo tenantInfo){
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          return this.updateById(JSON.parseObject(tenantInfo.jsonString(), TenantInfo.class));       
 |  |          return this.updateById(JSON.parseObject(tenantInfo.jsonString(), TenantInfo.class));       
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | 
 |  | +    }*/
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  |       * 机构信息
 |  |       * 机构信息
 | 
											
										
											
												
													
														|  | @@ -91,4 +129,58 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          return list.stream().collect(Collectors.toMap(TenantInfo::getId, tenantInfo -> tenantInfo));
 |  |          return list.stream().collect(Collectors.toMap(TenantInfo::getId, tenantInfo -> tenantInfo));
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    public HttpResponseResult<Boolean> submit(TenantInfoWrapper.TenantInfoQuery query) {
 | 
											
												
													
														|  | 
 |  | +        return null;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    /**
 | 
											
												
													
														|  | 
 |  | +     * 冻结
 | 
											
												
													
														|  | 
 |  | +     * @param query TenantInfoWrapper.TenantInfo
 | 
											
												
													
														|  | 
 |  | +     * @return Boolean
 | 
											
												
													
														|  | 
 |  | +     */
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    public Boolean state(TenantInfoWrapper.TenantInfoQuery query) {
 | 
											
												
													
														|  | 
 |  | +        Boolean flag;
 | 
											
												
													
														|  | 
 |  | +        Integer id = query.getId();
 | 
											
												
													
														|  | 
 |  | +        long longId = id.longValue();
 | 
											
												
													
														|  | 
 |  | +        TenantInfo info = detail(longId);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        //TenantInfo info = this.getById(id);
 | 
											
												
													
														|  | 
 |  | +        if (Objects.isNull(info)) {
 | 
											
												
													
														|  | 
 |  | +            throw new BizException("机构信息不存在");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        //获取是否冻结
 | 
											
												
													
														|  | 
 |  | +         if (query.getIfFreeze() == 1){
 | 
											
												
													
														|  | 
 |  | +             if (!info.getEnableFlag()){
 | 
											
												
													
														|  | 
 |  | +                 return false;
 | 
											
												
													
														|  | 
 |  | +             }
 | 
											
												
													
														|  | 
 |  | +             //修改机构账号冻结状态
 | 
											
												
													
														|  | 
 |  | +              flag = tenantInfoMapper.updateFlag(id);
 | 
											
												
													
														|  | 
 |  | +             //是否更改结算方式
 | 
											
												
													
														|  | 
 |  | +             if (query.getIfMethod() == 1){
 | 
											
												
													
														|  | 
 |  | +                 tenantInfoMapper.updateMethod(id);
 | 
											
												
													
														|  | 
 |  | +             }else {
 | 
											
												
													
														|  | 
 |  | +                 return true;
 | 
											
												
													
														|  | 
 |  | +             }
 | 
											
												
													
														|  | 
 |  | +         }
 | 
											
												
													
														|  | 
 |  | +         else {
 | 
											
												
													
														|  | 
 |  | +             return false;
 | 
											
												
													
														|  | 
 |  | +         }
 | 
											
												
													
														|  | 
 |  | +        return flag;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    /**
 | 
											
												
													
														|  | 
 |  | +     * 更新
 | 
											
												
													
														|  | 
 |  | +     * @param info TenantInfoWrapper.TenantInfo
 | 
											
												
													
														|  | 
 |  | +     * @return Boolean
 | 
											
												
													
														|  | 
 |  | +     */
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    public HttpResponseResult<Boolean> updateTenantInfo(TenantInfo info) {
 | 
											
												
													
														|  | 
 |  | +        Boolean bool = tenantInfoMapper.updateInfo(info);
 | 
											
												
													
														|  | 
 |  | +        return HttpResponseResult.succeed(bool);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  }
 |  |  }
 |