|
|
@@ -2,6 +2,7 @@ package com.jzg.service.Impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
@@ -27,6 +28,8 @@ import com.jzg.utils.*;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -46,6 +49,7 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class PartnerUserServiceImpl extends ServiceImpl<PartnerUserMapper, PartnerUser> implements PartnerUserService {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(PartnerUserServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private PartnerRuleService ruleService;
|
|
|
@@ -374,49 +378,55 @@ public class PartnerUserServiceImpl extends ServiceImpl<PartnerUserMapper, Partn
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 为合伙人添加新的等级
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/4/15 10:49
|
|
|
+ */
|
|
|
@Override
|
|
|
- public HttpResult addUserIdentity(Map<String, Object> map, String token) {
|
|
|
+ public HttpResult<String> addUserIdentity(Map<String, Object> map, String token) {
|
|
|
+ log.info("为合伙人添加新的等级。 token=[{}],map=[{}]", token, JSONUtil.toJsonStr(map));
|
|
|
try {
|
|
|
- if (map.containsKey("userId")) {
|
|
|
- String userId = (String) map.get("userId");
|
|
|
- SysUserJzgInfo sysUserJzgInfo = getSysUserJzgInfo(userId);
|
|
|
- userId = sysUserJzgInfo.getId();
|
|
|
- PartnerUser partnerUsers = baseMapper.selectMaxGradeUserId(userId);
|
|
|
- if (partnerUsers == null) {
|
|
|
- return HttpResult.error("请选择用户");
|
|
|
- }
|
|
|
- if (StringUtils.equals("4", String.valueOf(partnerUsers.getGrade()))) {
|
|
|
- return HttpResult.error("请邀请团队长");
|
|
|
- }
|
|
|
- if (map.containsKey("gradeList")) {
|
|
|
- List<String> list = (ArrayList<String>) map.get("gradeList");
|
|
|
- List<String> gradeList = list.stream()
|
|
|
- .sorted(Comparator.comparingInt(Integer::parseInt))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (partnerUsers != null && CollectionUtil.isNotEmpty(gradeList)) {
|
|
|
- for (String s : gradeList) {
|
|
|
- String deptId = partnerUsers.getDeptId();
|
|
|
-// if (StringUtils.equals("4",s)){
|
|
|
-// deptId = SpringUtil.getBean(SysUserServiceImpl.class).addDeptUser(sysUser,s);
|
|
|
-// }
|
|
|
- PartnerUser partnerUser = new PartnerUser();
|
|
|
- partnerUser.setName(partnerUsers.getName());
|
|
|
- partnerUser.setMobile(partnerUsers.getMobile());
|
|
|
- partnerUser.setUserId(userId);
|
|
|
- partnerUser.setDeptId(deptId);
|
|
|
- partnerUser.setDeptName(partnerUsers.getDeptName());
|
|
|
- partnerUser.setGrade(Integer.valueOf(s));
|
|
|
- partnerUser.setReferrerId(partnerUsers.getUserId());
|
|
|
- partnerUser.setCreateTime(LocalDateTime.now());
|
|
|
- partnerUser.setStatus(partnerUsers.isStatus());
|
|
|
- baseMapper.insert(partnerUser);
|
|
|
- }
|
|
|
+ if (!map.containsKey("userId")) {
|
|
|
+ log.info("为合伙人添加新等级失败。请指定合伙人");
|
|
|
+ return HttpResult.error("为合伙人添加新等级失败。请指定合伙人");
|
|
|
+ }
|
|
|
+ String userId = (String) map.get("userId");
|
|
|
+ SysUserJzgInfo sysUserJzgInfo = getSysUserJzgInfo(userId);
|
|
|
+ userId = sysUserJzgInfo.getId();
|
|
|
+ PartnerUser partnerUsers = baseMapper.selectMaxGradeUserId(userId);
|
|
|
+ if (partnerUsers == null) {
|
|
|
+ return HttpResult.error("请选择用户");
|
|
|
+ }
|
|
|
+ if (StringUtils.equals("4", String.valueOf(partnerUsers.getGrade()))) {
|
|
|
+ return HttpResult.error("请邀请团队长");
|
|
|
+ }
|
|
|
+ if (map.containsKey("gradeList")) {
|
|
|
+ List<String> list = (ArrayList<String>) map.get("gradeList");
|
|
|
+ List<String> gradeList = list.stream()
|
|
|
+ .sorted(Comparator.comparingInt(Integer::parseInt))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(gradeList)) {
|
|
|
+ for (String s : gradeList) {
|
|
|
+ String deptId = partnerUsers.getDeptId();
|
|
|
+ PartnerUser partnerUser = new PartnerUser();
|
|
|
+ partnerUser.setName(partnerUsers.getName());
|
|
|
+ partnerUser.setMobile(partnerUsers.getMobile());
|
|
|
+ partnerUser.setUserId(userId);
|
|
|
+ partnerUser.setDeptId(deptId);
|
|
|
+ partnerUser.setDeptName(partnerUsers.getDeptName());
|
|
|
+ partnerUser.setGrade(Integer.valueOf(s));
|
|
|
+ partnerUser.setReferrerId(partnerUsers.getUserId());
|
|
|
+ partnerUser.setCreateTime(LocalDateTime.now());
|
|
|
+ partnerUser.setStatus(partnerUsers.isStatus());
|
|
|
+ baseMapper.insert(partnerUser);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("添加失败", e);
|
|
|
- return HttpResult.error();
|
|
|
+ log.error("为合伙人添加新等级失败", e);
|
|
|
+ return HttpResult.error("为合伙人添加新等级失败");
|
|
|
}
|
|
|
return HttpResult.ok("添加成功");
|
|
|
}
|
|
|
@@ -1766,6 +1776,7 @@ public class PartnerUserServiceImpl extends ServiceImpl<PartnerUserMapper, Partn
|
|
|
public SysUserJzgInfo getSysUserJzgInfo(String userId) {
|
|
|
SysUserJzgInfo sysUserJzgInfo = organizationClient.selectByUserIdInfo(userId);
|
|
|
if (Objects.isNull(sysUserJzgInfo)) {
|
|
|
+ log.info("查询用户信息异常。 根据userId[{}]找不到对应的用户",userId);
|
|
|
throw new SystemException("查询用户信息异常");
|
|
|
}
|
|
|
return sysUserJzgInfo;
|