|
|
@@ -8,9 +8,13 @@ import com.github.microservice.auth.client.service.RoleService;
|
|
|
import com.github.microservice.auth.security.type.AuthType;
|
|
|
import com.github.microservice.core.util.bean.BeanUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
+import com.github.microservice.net.ResultMessage;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.zhongshu.card.client.model.base.ProjectOidParam;
|
|
|
import com.zhongshu.card.client.model.org.*;
|
|
|
+import com.zhongshu.card.client.model.org.orgUser.OrganizationUserAuditParam;
|
|
|
+import com.zhongshu.card.client.model.org.orgUser.OrganizationUserSearch;
|
|
|
+import com.zhongshu.card.client.model.org.orgUser.OrganizationUserSimpleModel;
|
|
|
import com.zhongshu.card.client.model.org.register.UserCountRegisterParam;
|
|
|
import com.zhongshu.card.client.model.orgModel.OrgBindUserAllParam;
|
|
|
import com.zhongshu.card.client.model.paySetting.paySetting.OrgPayShowSettingModel;
|
|
|
@@ -19,6 +23,7 @@ import com.zhongshu.card.client.model.school.ExcelUserParam;
|
|
|
import com.zhongshu.card.client.model.school.ImportResultModel;
|
|
|
import com.zhongshu.card.client.model.school.RegisterBindSchoolParam;
|
|
|
import com.zhongshu.card.client.type.*;
|
|
|
+import com.zhongshu.card.client.type.config.RegisterExamineType;
|
|
|
import com.zhongshu.card.client.type.user.OrgAddType;
|
|
|
import com.zhongshu.card.client.type.user.OrgUserState;
|
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
|
@@ -270,6 +275,19 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
return ResultContent.buildFail(passResult.getMsg());
|
|
|
}
|
|
|
|
|
|
+ // 验证角色是否合法
|
|
|
+ List<String> roleIds = projectCommonConfig.getRoleIds();
|
|
|
+ if (ObjectUtils.isEmpty(roleIds)) {
|
|
|
+ return ResultContent.buildFail("项目未配置可选择的角色");
|
|
|
+ }
|
|
|
+ String _tempRoleId = param.getRoleIds().get(0);
|
|
|
+ List<Role> visitorRoles = roleServiceImpl.getVisitorRoles(projectOid);
|
|
|
+ if (ObjectUtils.isEmpty(visitorRoles)) {
|
|
|
+ return ResultContent.buildFail("项目未配置游客角色");
|
|
|
+ }
|
|
|
+ // 是否是游客用户注册
|
|
|
+ boolean isVisitor = visitorRoles.stream().anyMatch(it -> it.getId().equals(_tempRoleId));
|
|
|
+
|
|
|
String loginName = phone;
|
|
|
UserAccount userAccount = userCountDao.findTopByLoginName(loginName);
|
|
|
if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
@@ -303,12 +321,14 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
return ResultContent.buildFail("用户不存在");
|
|
|
}
|
|
|
OrganizationUser orgUser = organizationUserDao.findTopByUserAndProjectOidOrderByCreateTimeDesc(userAccount, projectOid);
|
|
|
+ // 如果用户已存在,并且状态不为已拒绝,就代表用户已存在
|
|
|
if (ObjectUtils.isNotEmpty(orgUser) && orgUser.getOrgUserState() != OrgUserState.Refusal) {
|
|
|
return ResultContent.buildFail("用户已存在");
|
|
|
}
|
|
|
|
|
|
OrgBindUserAllParam orgBindUserAllParam = new OrgBindUserAllParam();
|
|
|
BeanUtils.copyProperties(param, orgBindUserAllParam);
|
|
|
+
|
|
|
if (ObjectUtils.isNotEmpty(orgUser)) {
|
|
|
orgBindUserAllParam.setId(orgUser.getId());
|
|
|
}
|
|
|
@@ -319,25 +339,44 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
orgBindUserAllParam.setPositionId(param.getPositionId());
|
|
|
orgBindUserAllParam.setDepartmentId(param.getDepartmentId());
|
|
|
orgBindUserAllParam.setRoleIds(param.getRoleIds());
|
|
|
- orgBindUserAllParam.setState(UserState.Normal);
|
|
|
orgBindUserAllParam.setIsAdmin(param.getIsAdmin());
|
|
|
orgBindUserAllParam.setRemark(param.getRemark());
|
|
|
orgBindUserAllParam.setProjectOid(param.getProjectOid());
|
|
|
|
|
|
// 注册方式
|
|
|
orgBindUserAllParam.setAddType(OrgAddType.Register);
|
|
|
+ // 用户审核状态
|
|
|
OrgUserState orgUserState = null;
|
|
|
+ // 用户状态
|
|
|
+ UserState state = null;
|
|
|
+ // 是否需要审核
|
|
|
+ boolean isExamine = false;
|
|
|
if (projectCommonConfig.getIsExamineRegister() != null && projectCommonConfig.getIsExamineRegister()) {
|
|
|
+ if (projectCommonConfig.getExamineType() == RegisterExamineType.All) {
|
|
|
+ isExamine = true;
|
|
|
+ } else if (projectCommonConfig.getExamineType() == RegisterExamineType.Formal) {
|
|
|
+ if (!isVisitor) {
|
|
|
+ isExamine = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ isExamine = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isExamine) {
|
|
|
// 如果需要审核
|
|
|
orgUserState = OrgUserState.Unaudited;
|
|
|
orgBindUserAllParam.setReViewTime(null);
|
|
|
orgBindUserAllParam.setReViewReMark("");
|
|
|
+ state = UserState.Locked;
|
|
|
} else {
|
|
|
orgUserState = OrgUserState.Formal;
|
|
|
orgBindUserAllParam.setReViewTime(System.currentTimeMillis());
|
|
|
orgBindUserAllParam.setReViewReMark("不需要审核");
|
|
|
+ state = UserState.Normal;
|
|
|
}
|
|
|
orgBindUserAllParam.setOrgUserState(orgUserState);
|
|
|
+ orgBindUserAllParam.setState(state);
|
|
|
|
|
|
// 绑定用户到机构
|
|
|
ResultContent<OrganizationUser> bindUserContent = orgBindUser(orgBindUserAllParam);
|
|
|
@@ -349,6 +388,34 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户审核
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent auditOrgUser(OrganizationUserAuditParam param) {
|
|
|
+ OrganizationUser organizationUser = organizationUserDao.findTopById(param.getId());
|
|
|
+ if (ObjectUtils.isEmpty(organizationUser)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
+ }
|
|
|
+ if (param.getOrgUserState() != OrgUserState.Unaudited) {
|
|
|
+ return ResultContent.buildFail("数据已审核");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, organizationUser);
|
|
|
+ if (param.getOrgUserState() == OrgUserState.Formal) {
|
|
|
+ // 同意
|
|
|
+ organizationUser.setState(UserState.Normal);
|
|
|
+ } else if (param.getOrgUserState() == OrgUserState.Refusal) {
|
|
|
+ // 拒绝
|
|
|
+ organizationUser.setState(UserState.Locked);
|
|
|
+ }
|
|
|
+ organizationUser.setReViewUserId(getCurrentUserId());
|
|
|
+ organizationUser.setReViewTime(System.currentTimeMillis());
|
|
|
+ organizationUserDao.save(organizationUser);
|
|
|
+
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 机构绑定用户 (角色、部门、职位都以新的为准)
|
|
|
* 用户基本信息已存在
|
|
|
@@ -362,9 +429,10 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
if (StringUtils.isEmpty(param.getUserId())) {
|
|
|
return ResultContent.buildFail("userId不能为空");
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(param.getOrgOid())) {
|
|
|
- return ResultContent.buildFail("orgOid不能为空");
|
|
|
- }
|
|
|
+ // 绑定的机构可以为空 02-24
|
|
|
+// if (StringUtils.isEmpty(param.getOrgOid())) {
|
|
|
+// return ResultContent.buildFail("orgOid不能为空");
|
|
|
+// }
|
|
|
|
|
|
UserAccount userAccount = userCountDao.findTopByUserId(param.getUserId());
|
|
|
if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
@@ -372,14 +440,18 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
}
|
|
|
String projectOid = param.getProjectOid();
|
|
|
boolean isUpdate = false;
|
|
|
+ String userId = userAccount.getUserId();
|
|
|
|
|
|
// 要绑定的机构 (不是项目)
|
|
|
- Organization organization = organizationDao.findTopByOid(param.getOrgOid());
|
|
|
- if (ObjectUtils.isEmpty(organization)) {
|
|
|
- return ResultContent.buildFail(String.format("机构信息不存在:%s", param.getOrgOid()));
|
|
|
+ Organization organization = null;
|
|
|
+ OidAboutInfo oidAboutInfo = null;
|
|
|
+ if (StringUtils.isNotEmpty(param.getOrgOid())) {
|
|
|
+ organization = organizationDao.findTopByOid(param.getOrgOid());
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ return ResultContent.buildFail(String.format("机构信息不存在:%s", param.getOrgOid()));
|
|
|
+ }
|
|
|
+ oidAboutInfo = organizationManagerService.getOidAboutInfo(organization.getOid());
|
|
|
}
|
|
|
- String userId = userAccount.getUserId();
|
|
|
- OidAboutInfo oidAboutInfo = organizationManagerService.getOidAboutInfo(organization.getOid());
|
|
|
|
|
|
OrganizationUser codeTemp = null;
|
|
|
if (StringUtils.isNotEmpty(param.getCode())) {
|
|
|
@@ -407,6 +479,7 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
organizationUser = new OrganizationUser();
|
|
|
initEntity(organizationUser);
|
|
|
BeanUtils.copyProperties(param, organizationUser);
|
|
|
+
|
|
|
// 在机构中的用户类型
|
|
|
organizationUser.setUserType(OrganizationUserType.Consumer);
|
|
|
} else {
|
|
|
@@ -422,26 +495,41 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
roleServiceImpl.userRemoveRole(userId, oldRoles);
|
|
|
}
|
|
|
|
|
|
- organizationUser.setOid(organization.getOid());
|
|
|
- organizationUser.setOrganization(organization);
|
|
|
- organizationUser.setUser(userAccount);
|
|
|
- organizationUser.setUserId(userAccount.getUserId());
|
|
|
- organizationUser.setCreateUserId(getCurrentUserId());
|
|
|
- organizationUser.setSex(userAccount.getSex());
|
|
|
+ if (organization != null) {
|
|
|
+ organizationUser.setOid(organization.getOid());
|
|
|
+ organizationUser.setOrganization(organization);
|
|
|
+ organizationUser.setAuthType(organization.getAuthType());
|
|
|
+ if (organization.getAuthType() == AuthType.Project || organization.getAuthType() == AuthType.Platform) {
|
|
|
+ organizationUser.setIsOrg(Boolean.FALSE);
|
|
|
+ } else {
|
|
|
+ organizationUser.setIsOrg(Boolean.TRUE);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ organizationUser.setIsOrg(Boolean.FALSE);
|
|
|
+ }
|
|
|
+ organizationUser.setProjectOid(projectOid);
|
|
|
+ if (ObjectUtils.isNotEmpty(oidAboutInfo)) {
|
|
|
+ organizationUser.setAboutOid(oidAboutInfo.getOid());
|
|
|
+ organizationUser.setAboutAuthType(oidAboutInfo.getAuthType());
|
|
|
+ }
|
|
|
|
|
|
List<Role> roles = new ArrayList<>();
|
|
|
Department department = null;
|
|
|
+ // 角色信息
|
|
|
if (ObjectUtils.isNotEmpty(param.getRoleIds())) {
|
|
|
roles = roleDao.findByIdIn(param.getRoleIds());
|
|
|
}
|
|
|
+ // 部门信息
|
|
|
if (ObjectUtils.isNotEmpty(param.getDepartmentId())) {
|
|
|
department = departmentDao.findTopById(param.getDepartmentId());
|
|
|
}
|
|
|
+ // 位置信息
|
|
|
DictInfo position = null;
|
|
|
if (StringUtils.isNotEmpty(param.getPositionId())) {
|
|
|
position = dictInfoDao.findTopById(param.getPositionId());
|
|
|
}
|
|
|
|
|
|
+ // 如果机构是平台
|
|
|
if (organization.getAuthType() == AuthType.Platform) {
|
|
|
// 判断是否是超级管理员
|
|
|
if (userAccount.getUserType() == UserType.SuperAdmin) {
|
|
|
@@ -463,23 +551,15 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
// 设置部门
|
|
|
organizationUser.setDepartment(department);
|
|
|
|
|
|
- organizationUser.setProjectOid(projectOid);
|
|
|
- organizationUser.setAboutOid(oidAboutInfo.getOid());
|
|
|
- organizationUser.setAboutAuthType(oidAboutInfo.getAuthType());
|
|
|
- organizationUser.setAuthType(organization.getAuthType());
|
|
|
- if (StringUtils.isNotEmpty(param.getProjectOid())) {
|
|
|
- organizationUser.setProjectOid(param.getProjectOid());
|
|
|
- }
|
|
|
// 用户信息
|
|
|
+ organizationUser.setUser(userAccount);
|
|
|
+ organizationUser.setUserId(userAccount.getUserId());
|
|
|
+ organizationUser.setCreateUserId(getCurrentUserId());
|
|
|
+ organizationUser.setSex(userAccount.getSex());
|
|
|
organizationUser.setPhone(userAccount.getPhone());
|
|
|
organizationUser.setName(userAccount.getName());
|
|
|
organizationUser.setCardNumber(userAccount.getCardNumber());
|
|
|
organizationUser.setOid(param.getOrgOid());
|
|
|
- if (organization.getAuthType() == AuthType.Project || organization.getAuthType() == AuthType.Platform) {
|
|
|
- organizationUser.setIsOrg(Boolean.FALSE);
|
|
|
- } else {
|
|
|
- organizationUser.setIsOrg(Boolean.TRUE);
|
|
|
- }
|
|
|
organizationUserDao.save(organizationUser);
|
|
|
|
|
|
// 发送用户信息变更事件,用以下发用户 权限关联的用户信息
|
|
|
@@ -496,6 +576,7 @@ public class OrganizationUserServiceImpl extends SuperService {
|
|
|
} else {
|
|
|
log.error("权限中心:绑定机构和用户关系出错:{}", resultContent.getMsg());
|
|
|
}
|
|
|
+ // 更新其他关联表的用户冗余信息
|
|
|
userInfoSyncService.updateProjectAboutInfoByOrgUserDataId(organizationUser.getId());
|
|
|
return ResultContent.buildSuccess(organizationUser);
|
|
|
}
|