|
@@ -67,6 +67,10 @@ public class AdminUserLogic {
|
|
|
AdminDeptWebsitService adminDeptWebsitService;
|
|
|
|
|
|
@Autowired
|
|
|
+ AdminDeptService adminDeptService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
BigLogic bigLogic;
|
|
|
// @Value("${front.top.url}")
|
|
|
// private String frontTopUrl;
|
|
@@ -202,10 +206,43 @@ public class AdminUserLogic {
|
|
|
throw new RemoteServiceException("帐号已被注册");
|
|
|
}
|
|
|
//当前用户选择的部门
|
|
|
- AdminWebsit adminWebsit = adminWebsitService.getById(adminUser.getAdminWebsitId());
|
|
|
- if(adminWebsit == null){
|
|
|
- throw new RemoteServiceException("请选择部门");
|
|
|
+ if (StringUtil.isEmpty(adminUser.getAdminDeptId()) && StringUtil.isEmpty(adminUser.getAdminWebsitId()))
|
|
|
+ throw new RemoteServiceException("请选择部门/网点");
|
|
|
+
|
|
|
+ if (!StringUtil.isEmpty(adminUser.getAdminWebsitId())) {
|
|
|
+ AdminWebsit adminWebsit = adminWebsitService.getById(adminUser.getAdminWebsitId());
|
|
|
+
|
|
|
+ //非平台账号
|
|
|
+ if (!StringUtils.equals(adminWebsit.getType(), AdminWebsitTypeEnum.A.getKey())) {
|
|
|
+ adminUser.setCompanyWechatId(adminWebsit.getCompanyWechatId());
|
|
|
+ adminUser.setCompanyName(adminWebsit.getCompanyWechatName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否为入驻商户
|
|
|
+ if(addMch){
|
|
|
+ adminUser.setType(1);
|
|
|
+ }else{
|
|
|
+ if(!curAdminUser.getType().equals(AdminWebsitTypeEnum.A.getKey()) && StringUtils.equals(adminWebsit.getType(), AdminWebsitTypeEnum.A.getKey())) {
|
|
|
+ throw new RemoteServiceException("暂无权限创建当前网点的账号");
|
|
|
+ }
|
|
|
+ if(StringUtils.equals(adminWebsit.getType(), AdminWebsitTypeEnum.C.getKey())){
|
|
|
+ adminUser.setType(0);
|
|
|
+ }else if(StringUtils.equals(adminWebsit.getType(),AdminWebsitTypeEnum.B.getKey())){
|
|
|
+ adminUser.setType(1);
|
|
|
+ }else if(StringUtils.equals(adminWebsit.getType(),AdminWebsitTypeEnum.A.getKey())){
|
|
|
+ adminUser.setType(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ AdminDept adminDept = adminDeptService.getById(adminUser.getAdminDeptId());
|
|
|
+
|
|
|
+ adminUser.setCompanyWechatId(adminDept.getCompanyWechatId());
|
|
|
+ adminUser.setCompanyName(adminDept.getCompanyWechatName());
|
|
|
+
|
|
|
+ adminUser.setType(0);
|
|
|
}
|
|
|
+
|
|
|
//需要用户roleId
|
|
|
AdminRole addUserRole = null;
|
|
|
if (StringUtils.isBlank(adminUser.getRoleId()) ||
|
|
@@ -213,38 +250,43 @@ public class AdminUserLogic {
|
|
|
throw new RemoteServiceException("请为用户选择角色");
|
|
|
}
|
|
|
adminUser.setRoleName(addUserRole.getName());
|
|
|
- //非平台账号
|
|
|
- if (!StringUtils.equals(adminWebsit.getType(), AdminWebsitTypeEnum.A.getKey())) {
|
|
|
- adminUser.setCompanyWechatId(adminWebsit.getCompanyWechatId());
|
|
|
- adminUser.setCompanyName(adminWebsit.getCompanyWechatName());
|
|
|
- }
|
|
|
- //是否为入驻商户
|
|
|
- if(addMch){
|
|
|
- adminUser.setType(1);
|
|
|
- }else{
|
|
|
- if(!curAdminUser.getType().equals(AdminWebsitTypeEnum.A.getKey()) && StringUtils.equals(adminWebsit.getType(), AdminWebsitTypeEnum.A.getKey())) {
|
|
|
- throw new RemoteServiceException("暂无权限创建当前网点的账号");
|
|
|
- }
|
|
|
- if(StringUtils.equals(adminWebsit.getType(), AdminWebsitTypeEnum.C.getKey())){
|
|
|
- adminUser.setType(0);
|
|
|
- }else if(StringUtils.equals(adminWebsit.getType(),AdminWebsitTypeEnum.B.getKey())){
|
|
|
- adminUser.setType(1);
|
|
|
- }else if(StringUtils.equals(adminWebsit.getType(),AdminWebsitTypeEnum.A.getKey())){
|
|
|
- adminUser.setType(2);
|
|
|
- }
|
|
|
- }
|
|
|
adminUser.setPassword(MD5Utils.md5(adminUser.getPassword()));
|
|
|
adminUser.setCreateTime(new Date());
|
|
|
adminUserService.save(adminUser);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//部门账号(商户账号在生成商户的时候已经处理了部门)
|
|
|
if (adminUser.getType() != 2) {
|
|
|
//添加部门
|
|
|
this.addAdminUserWebsit(adminUser);
|
|
|
}
|
|
|
|
|
|
+ //添加部门
|
|
|
+ this.addAdminUserDept(adminUser);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addAdminUserDept(AdminUserAddReqBean adminUser) {
|
|
|
+
|
|
|
+ //先清除
|
|
|
+ if (StringUtils.isEmpty(adminUser.getAdminDeptId())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ adminUserDeptRelaService.lambdaUpdate().eq(AdminUserDeptRela::getAdminUserId, adminUser.getAdminUserId()).remove();
|
|
|
+
|
|
|
+ List<AdminDept> adminDepts = adminDeptService.lambdaQuery().eq(AdminDept::getAdminDeptId, adminUser.getAdminWebsitId()).list();
|
|
|
+ if (adminDepts.size() == 0) {
|
|
|
+ throw new RemoteServiceException("请选择至少1个部门");
|
|
|
+ }
|
|
|
+ log.info("【添加用户部门关系】:{}", com.alibaba.fastjson.JSONObject.toJSONString(adminUser));
|
|
|
+ for (AdminDept adminDept : adminDepts) {
|
|
|
+ AdminUserDeptRela adminUserDeptRela = new AdminUserDeptRela();
|
|
|
+ adminUserDeptRela.setAdminUserId(adminUser.getAdminUserId());
|
|
|
+ adminUserDeptRela.setAdminDeptId(adminDept.getAdminDeptId());
|
|
|
+ adminUserDeptRela.setCompanyWechatId(adminDept.getCompanyWechatId());
|
|
|
+ adminUserDeptRela.setCreateTime(new Date());
|
|
|
+ adminUserDeptRela.insert();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|