Parcourir la source

用户编辑手机号修改

master
niohe·erbao il y a 1 an
Parent
révision
6015dc6c90
1 fichiers modifiés avec 38 ajouts et 16 suppressions
  1. +38
    -16
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java

+ 38
- 16
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java Voir le fichier

@@ -74,6 +74,7 @@ public class UserInfoManage {

LambdaQueryWrapper<DingEmployeeInfo> wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(DingEmployeeInfo::getStatus, "A")
.eq(StringUtils.isNotBlank(orgCode), DingEmployeeInfo::getOrganizationCode, orgCode)
.like(StringUtils.isNotBlank(phoneNo), DingEmployeeInfo::getBindUserMobile, phoneNo)
.like(StringUtils.isNotBlank(name), DingEmployeeInfo::getEmployeeName, name)
@@ -91,7 +92,7 @@ public class UserInfoManage {
Map<String, UserInfo> employeeCodeAvailableMap = new HashMap<>(16);
if (CollUtil.isNotEmpty(employeeCodeList)) {
employeeCodeAvailableMap = iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class)
.in(UserInfo::getEmployeeCode, employeeCodeList))
.in(UserInfo::getEmployeeCode, employeeCodeList))
.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode, Function.identity()));
}
List<String> orgCodeList = records.stream()
@@ -168,7 +169,7 @@ public class UserInfoManage {

// TODO 这里过滤的非浙政钉用户的专家 后续需要增加补充逻辑
return iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class)
.in(UserInfo::getId, compliantUserIdList))
.in(UserInfo::getId, compliantUserIdList))
.stream().map(UserInfo::getEmployeeCode)
.filter(StringUtils::isNotBlank).collect(Collectors.toList());

@@ -256,23 +257,11 @@ public class UserInfoManage {

@Transactional(rollbackFor = Exception.class)
public void userInfoDetailEdit(ReqUserDetailEditPO reqUserDetailEditPO) {
String employeeCode = reqUserDetailEditPO.getEmployeeCode();
Long userId = generateUserId(reqUserDetailEditPO.getEmployeeCode());
UserInfo userInfo = iUserInfoService.getById(userId);
// 绑定用户手机号
bandUserMobile(userInfo, reqUserDetailEditPO);

String mobile = userInfo.getMobile();
if (StringUtils.isBlank(mobile)) {
String phoneNo = reqUserDetailEditPO.getPhoneNo();
userInfo.setMobile(phoneNo);
// 更新浙政钉相关数据
if (StringUtils.isNotBlank(phoneNo)) {
iDingEmployeeInfoService
.update(Wrappers.lambdaUpdate(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode)
.set(DingEmployeeInfo::getBindUserMobile, phoneNo));
}
}
userInfo.setAvailable(reqUserDetailEditPO.getStatus());
userInfo.setUpdateOn(LocalDateTime.now());
userInfo.setUpdateBy(LoginUserUtil.getUserId());
@@ -291,6 +280,39 @@ public class UserInfoManage {
}
}

/**
* 绑定用户手机号
*
* @param userInfo
* @param reqUserDetailEditPO
*/
@Transactional(rollbackFor = Exception.class)
public void bandUserMobile(UserInfo userInfo, ReqUserDetailEditPO reqUserDetailEditPO) {
String employeeCode = reqUserDetailEditPO.getEmployeeCode();
String mobile = userInfo.getMobile();
Long userId = userInfo.getId();
if (StringUtils.isBlank(mobile)) {
// 校验手机号是否重复
UserInfo repeatMobileUserInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getMobile, mobile).ne(UserInfo::getId, userId));
if (Objects.nonNull(repeatMobileUserInfo)) {
throw new BizException("该手机号码已被绑定,请问重复绑定");
}

String phoneNo = reqUserDetailEditPO.getPhoneNo();
userInfo.setMobile(phoneNo);
// 更新浙政钉相关数据
if (StringUtils.isNotBlank(phoneNo)) {
iDingEmployeeInfoService
.update(Wrappers.lambdaUpdate(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode)
.set(DingEmployeeInfo::getBindUserMobile, phoneNo));
}
}

}

@Transactional(rollbackFor = Exception.class)
public Long generateUserId(String employeeCode) {
UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)


Chargement…
Annuler
Enregistrer