|
@@ -2,6 +2,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.SysArea;
|
|
@@ -11,7 +12,6 @@ import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantStaffMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.service.SysAreaService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
|
-import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
|
|
|
import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.cooleshow.common.enums.SysUserType;
|
|
@@ -21,7 +21,6 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
|
|
@@ -88,8 +87,8 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
ArrayList<Integer> listId = new ArrayList<>();
|
|
|
for (int i = 0; i < tenantInfos.size(); i++) {
|
|
|
TenantInfoWrapper.TenantInfo info = tenantInfos.get(i);
|
|
|
- Integer id = info.getId();
|
|
|
- listId.add(i, id);
|
|
|
+ long id = info.getId();
|
|
|
+ listId.add(i,(int)id);
|
|
|
}
|
|
|
//查询对应机构的老师数量
|
|
|
List<Integer> listTeacher = new ArrayList<>();
|
|
@@ -113,29 +112,11 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
|
|
|
|
|
|
//获取省市区信息
|
|
|
- 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());
|
|
|
+ List<TenantInfoWrapper.TenantInfo> tenantList = queryArea(tenantInfos);
|
|
|
+ return page.setRecords(tenantList);
|
|
|
+ }
|
|
|
|
|
|
- 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(), ""));
|
|
|
- }
|
|
|
- return page.setRecords(tenantInfos);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 添加
|
|
@@ -156,19 +137,28 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
sysUserQueryWrapper.lambda().eq(SysUser::getPhone, tenantInfo.getPhone());
|
|
|
List<SysUser> sysUsers = sysUserMapper.selectList(sysUserQueryWrapper);
|
|
|
SysUser sysUser;
|
|
|
+ //若存在信息
|
|
|
if (!sysUsers.isEmpty()) {
|
|
|
sysUser = sysUsers.get(0);
|
|
|
TenantStaff tenantStaff = tenantStaffMapper.getByPhone(tenantInfo.getPhone());
|
|
|
if (tenantStaff != null) {
|
|
|
throw new BizException("手机号已经注册机构账号");
|
|
|
}
|
|
|
+ //获取当前账户的用户类型
|
|
|
String userType = sysUser.getUserType();
|
|
|
- String studentUserType = SysUserType.ORGANIZATION.getCode();
|
|
|
+ //设置默认机构类型
|
|
|
+ String tenantUserType = SysUserType.ORGANIZATION.getCode();
|
|
|
if (StringUtils.isEmpty(userType)) {
|
|
|
- sysUser.setUserType(studentUserType);
|
|
|
- } else if (!userType.contains(studentUserType)) {
|
|
|
- sysUser.setUserType(userType + "," + studentUserType);
|
|
|
+ sysUser.setUserType(tenantUserType);
|
|
|
+ } else if (!userType.contains(tenantUserType)) {
|
|
|
+ sysUser.setUserType(userType + "," + tenantUserType);
|
|
|
}
|
|
|
+
|
|
|
+ //更新当前账号的用户名
|
|
|
+ sysUser.setUsername(tenantInfo.getUsername());
|
|
|
+ //更新当前账号的手机号
|
|
|
+ sysUser.setPhone(tenantInfo.getPhone());
|
|
|
+
|
|
|
sysUserMapper.updateById(sysUser);
|
|
|
} else {
|
|
|
sysUser = new SysUser();
|
|
@@ -181,14 +171,16 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
sysUser.setPassword(password);
|
|
|
sysUserMapper.insert(sysUser);
|
|
|
|
|
|
- TenantStaff tenantStaff = new TenantStaff();
|
|
|
- tenantStaff.setTenantId(tenantStaff.getTenantId());
|
|
|
- tenantStaff.setUserId(sysUser.getId());
|
|
|
- tenantStaff.setAvatar(sysUser.getAvatar());
|
|
|
- tenantStaff.setNickname(tenantInfo.getUsername());
|
|
|
- tenantStaff.setStatus("ACTIVE");
|
|
|
- tenantStaffMapper.insert(tenantStaff);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ TenantStaff tenantStaff = new TenantStaff();
|
|
|
+ tenantStaff.setTenantId(tenantStaff.getTenantId());
|
|
|
+ tenantStaff.setUserId(sysUser.getId());
|
|
|
+ tenantStaff.setAvatar(sysUser.getAvatar());
|
|
|
+ tenantStaff.setNickname(tenantInfo.getUsername());
|
|
|
+ tenantStaff.setStatus("ACTIVE");
|
|
|
+ tenantStaffMapper.insert(tenantStaff);
|
|
|
return sysUser;
|
|
|
}
|
|
|
|
|
@@ -240,9 +232,8 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
@Override
|
|
|
public Boolean state(TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
Boolean flag;
|
|
|
- Integer id = query.getId();
|
|
|
- long longId = id.longValue();
|
|
|
- TenantInfo info = detail(longId);
|
|
|
+ long id = query.getId();
|
|
|
+ TenantInfo info = detail(id);
|
|
|
|
|
|
//TenantInfo info = this.getById(id);
|
|
|
if (Objects.isNull(info)) {
|
|
@@ -267,6 +258,8 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 更新
|
|
|
*
|
|
@@ -275,9 +268,124 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean updateTenantInfo(TenantInfo info) {
|
|
|
+ getOrCreateAccount(info);
|
|
|
Boolean bool = tenantInfoMapper.updateInfo(info);
|
|
|
return bool;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机构申请分页查询
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<TenantInfoWrapper.TenantInfo> applyPage(IPage<TenantInfoWrapper.TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
+ //分页查询
|
|
|
+ List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectApplyPage(page, query);
|
|
|
+ List<TenantInfoWrapper.TenantInfo> infos = queryArea(tenantInfos);
|
|
|
+ return page.setRecords(infos);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机构入驻审核历史记录查询
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<TenantInfoWrapper.TenantInfo> historyPage(IPage<TenantInfoWrapper.TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
+ long id = query.getId();
|
|
|
+ //分页查询
|
|
|
+ List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectHistoryPage(page, id);
|
|
|
+ //查询对应省市区
|
|
|
+ List<TenantInfoWrapper.TenantInfo> infos = queryArea(tenantInfos);
|
|
|
+
|
|
|
+ return page.setRecords(infos);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机构入驻审核本次提交查询
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TenantInfoWrapper.TenantInfo queryNow(TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
+ //查询本次提交记录
|
|
|
+ TenantInfoWrapper.TenantInfo info = tenantInfoMapper.queryNow(query);
|
|
|
+ Set<Integer> codes = new HashSet<>();
|
|
|
+ codes.add(info.getCityCode());
|
|
|
+ codes.add(info.getProvinceCode());
|
|
|
+ codes.add(info.getRegionCode());
|
|
|
+
|
|
|
+ //将地区码转化为对应的地名
|
|
|
+ List<Integer> areaCodeList = new ArrayList<>();
|
|
|
+ areaCodeList.addAll(codes);
|
|
|
+
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+
|
|
|
+ info.setProvinceName(codeNameMap.get(info.getProvinceCode()));
|
|
|
+ info.setCityName(codeNameMap.get(info.getCityCode()));
|
|
|
+ info.setRegionName(codeNameMap.get(info.getRegionCode()));
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean entry(TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
+ Integer pass = query.getIfPass();
|
|
|
+ //审核通过
|
|
|
+ if (pass == 1){
|
|
|
+ //查询本次提交记录,并插入审核表
|
|
|
+ TenantInfoWrapper.TenantInfo info = queryNow(query);
|
|
|
+ tenantInfoMapper.insertNow(info);
|
|
|
+ //更改当前记录的审核状态
|
|
|
+
|
|
|
+ //机构账户新增逻辑
|
|
|
+ } else {
|
|
|
+ //查询本次提交记录,并插入审核表
|
|
|
+ //更改当前记录的审核状态
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 匹配地区码与省市区
|
|
|
+ * @param tenantInfos
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<TenantInfoWrapper.TenantInfo> queryArea(List<TenantInfoWrapper.TenantInfo> tenantInfos) {
|
|
|
+ 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(), ""));
|
|
|
+ }
|
|
|
+
|
|
|
+ return tenantInfos;
|
|
|
+ }
|
|
|
+
|
|
|
}
|