|
|
@@ -43,6 +43,7 @@ import com.ydtech.modules.esm.service.EsmUserReferrerService;
|
|
|
import com.ydtech.security.utils.PasswordUtils;
|
|
|
import com.ydtech.utils.StringUtils;
|
|
|
import com.ydtech.utils.idgen.IdGenerate;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
@@ -59,6 +60,7 @@ import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -68,6 +70,7 @@ import static com.ydtech.constants.RedisConstant.PHONE_VERIFICATION_CODE_KEY_TIM
|
|
|
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
|
|
|
|
|
|
@Autowired
|
|
|
@@ -118,6 +121,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
private SysDeptMapper sysDeptMapper;
|
|
|
@Resource
|
|
|
private SysPartnerService sysPartnerService;
|
|
|
+ @Resource
|
|
|
+ private SysAgencyLeaderService sysAgencyLeaderService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
|
|
@Value("${httpUrl}")
|
|
|
private String httpUrl;
|
|
|
@@ -940,8 +948,72 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult saveUserInfo1(SysUser2Vo sysUserVo, SysDeptVo sysDeptVo) {
|
|
|
+ public HttpResult saveUserInfo1(SysUser2Vo sysUserVo) {
|
|
|
+
|
|
|
+ log.info("添加团队入参:{}",sysUserVo);
|
|
|
SysUser sysUser = sysUserVo.getSysUser();
|
|
|
+ sysUser.setType(3);
|
|
|
+ sysUser.setCreateTime(new Date());
|
|
|
+ SysUserInfo sysUserInfo = new SysUserInfo();
|
|
|
+ LocalDate birthday = LocalDate.parse(sysUser.getIdentity().substring(6, 10) + "-" + sysUser.getIdentity().substring(10, 12) + "-" + sysUser.getIdentity().substring(12, 14));
|
|
|
+ sysUserInfo.setBirthday(birthday);
|
|
|
+ sysUserVo.setSysUserInfo(sysUserInfo);
|
|
|
+ // 先创建工作室下的团队
|
|
|
+ SysAgencyLeader sysAgencyLeader = sysAgencyLeaderService.getOne(new LambdaQueryWrapper<SysAgencyLeader>()
|
|
|
+ .eq(SysAgencyLeader::getUserId, sysUser.getReferrerId()));
|
|
|
+ SysDept sysDept = sysDeptService.getOne(new LambdaQueryWrapper<SysDept>().eq(SysDept::getId, sysAgencyLeader.getDeptId()));
|
|
|
+// SysDept sysDept = sysDeptList.get(0);
|
|
|
+ SysDeptVo sysDeptVo = new SysDeptVo();
|
|
|
+ sysDeptVo.setName(sysUser.getName() + "团队"); // 以人名设置工作室名称
|
|
|
+ sysDeptVo.setDeptType("D"); // 默认为子公司
|
|
|
+ sysDeptVo.setParentId(sysDept.getId());
|
|
|
+ sysDeptVo.setManagementSource(sysDept.getManagementSource()); //机构来源
|
|
|
+ sysDeptVo.setOrderNum(0);
|
|
|
+ sysDeptVo.setCreateTime(new Date());
|
|
|
+ log.info("------------------团队长添加先调添加部门-----------------------");
|
|
|
+ sysDeptService.addDept(sysDeptVo);
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isNullOrEmpty(sysUser)) {
|
|
|
+ return HttpResult.error("用户信息不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNullOrEmpty(sysDeptVo.getId())) {
|
|
|
+ return HttpResult.error("机构ID不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
|
|
|
+ throw new SystemException("角色id不能为空");
|
|
|
+ }
|
|
|
+ //获取机构层级
|
|
|
+ int deptLevel = sysUserService.getDeptLevel1(sysDeptVo.getId());
|
|
|
+ if (!StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
|
|
|
+ if (RoleConstants.R21.getCode().equals(sysUser.getRoleId())
|
|
|
+ || RoleConstants.R20.getCode().equals(sysUser.getRoleId())
|
|
|
+ || RoleConstants.R19.getCode().equals(sysUser.getRoleId())) {//19 出单员 21 团队长 20 代理人
|
|
|
+
|
|
|
+ if (deptLevel != 6) {
|
|
|
+ throw new SystemException("团队长、代理人、出单员只能归属团队中");
|
|
|
+ }
|
|
|
+ //如果为团队长,判断是否已经存在团队长,存在不允许添加 add by hxl 2024-05-07 ============begin
|
|
|
+ if (RoleConstants.R21.getCode().equals(sysUser.getRoleId())) {
|
|
|
+ int count = sysUserService.getCountByDeptAndRoleId(sysUser);
|
|
|
+ if (count > 0) {
|
|
|
+ throw new SystemException("该机构已存在团队长,不允许再添加!!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // =========================add by hxl end ====================
|
|
|
+ } else if (RoleConstants.R18.getCode().equals(sysUser.getRoleId())) { // 42 门店长
|
|
|
+ if (deptLevel != 5) {
|
|
|
+ throw new SystemException("机构管理员只能归属机构中");
|
|
|
+ }
|
|
|
+ } else if (RoleConstants.R17.getCode().equals(sysUser.getRoleId())) {
|
|
|
+ if (deptLevel != 4) {
|
|
|
+ throw new SystemException("部长只能归属于4级");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+// SysUser sysUser = sysUserVo.getSysUser();
|
|
|
// 手机号
|
|
|
List<SysUser> mobileList = lambdaQuery().eq(SysUser::getMobile, sysUser.getMobile()).list();
|
|
|
if (!mobileList.isEmpty()) {
|